Package io.wcm.testing.mock.aem.builder
Class ContentBuilder
java.lang.Object
org.apache.sling.testing.mock.sling.builder.ContentBuilder
io.wcm.testing.mock.aem.builder.ContentBuilder
@ProviderType
public final class ContentBuilder
extends org.apache.sling.testing.mock.sling.builder.ContentBuilder
Helper class for building test content in the resource hierarchy with as less boilerplate code as possible.
-
Field Summary
Fields inherited from class org.apache.sling.testing.mock.sling.builder.ContentBuilder
resourceResolver -
Constructor Summary
ConstructorsConstructorDescriptionContentBuilder(@NotNull AemContextImpl context) ContentBuilder(@NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver) -
Method Summary
Modifier and TypeMethodDescriptioncom.day.cq.dam.api.AssetCreate DAM asset with a generated dummy image.com.day.cq.dam.api.Assetasset(@NotNull String path, long width, long height, @NotNull String mimeType, @NotNull Object @NotNull ... metadata) Create DAM asset with a generated dummy image.com.day.cq.dam.api.Assetasset(@NotNull String path, long width, long height, @NotNull String mimeType, @Nullable Map<String, Object> metadata) Create DAM asset with a generated dummy image.com.day.cq.dam.api.Assetasset(@NotNull String path, @NotNull InputStream inputStream, @NotNull String mimeType) Create DAM asset.com.day.cq.dam.api.Assetasset(@NotNull String path, @NotNull InputStream inputStream, @NotNull String mimeType, @NotNull Object @NotNull ... metadata) Create DAM asset.com.day.cq.dam.api.Assetasset(@NotNull String path, @NotNull InputStream inputStream, @NotNull String mimeType, @Nullable Map<String, Object> metadata) Create DAM asset.com.day.cq.dam.api.AssetCreate DAM asset.com.day.cq.dam.api.Assetasset(@NotNull String path, @NotNull String classpathResource, @NotNull String mimeType, @NotNull Object @NotNull ... metadata) Create DAM asset.com.day.cq.dam.api.Assetasset(@NotNull String path, @NotNull String classpathResource, @NotNull String mimeType, @Nullable Map<String, Object> metadata) Create DAM asset.com.day.cq.dam.api.RenditionassetRendition(@NotNull com.day.cq.dam.api.Asset asset, @NotNull String name, long width, long height, @NotNull String mimeType) Adds a rendition with a generated dummy image to DAM asset.com.day.cq.dam.api.RenditionassetRendition(@NotNull com.day.cq.dam.api.Asset asset, @NotNull String name, @NotNull String classpathResource, @NotNull String mimeType) Adds a rendition to DAM asset.com.day.cq.dam.api.RenditionassetRendition(@NotNull com.day.cq.dam.api.Asset asset, String name, @NotNull InputStream inputStream, @NotNull String mimeType) Adds a rendition to DAM asset.com.day.cq.dam.api.RenditionassetRenditionWebEnabled(@NotNull com.day.cq.dam.api.Asset asset) Adds a web-enabled rendition to DAM asset.com.day.cq.dam.api.RenditionassetRenditionWebEnabled(@NotNull com.day.cq.dam.api.Asset asset, long maxWidth, long maxHeight) Adds a web-enabled rendition to DAM asset.com.adobe.cq.dam.cfm.ContentFragmentcontentFragmentStructured(@NotNull String path, @NotNull Object @NotNull ... data) Create DAM content fragment.com.adobe.cq.dam.cfm.ContentFragmentcontentFragmentStructured(@NotNull String path, @Nullable Map<String, Object> data) Create DAM content fragment.com.adobe.cq.dam.cfm.ContentFragmentcontentFragmentText(@NotNull String path, @NotNull String text, @NotNull String mimeType) Create DAM content fragment.static @NotNull InputStreamcreateDummyImage(long width, long height, String mimeType) Create dummy imagecom.day.cq.wcm.api.PageCreate content page.com.day.cq.wcm.api.PageCreate content page.com.day.cq.wcm.api.Pagepage(@NotNull com.day.cq.wcm.api.Page parentPage, @NotNull String name, @Nullable String template, @NotNull Object @NotNull ... pageProperties) Create content page.com.day.cq.wcm.api.Pagepage(@NotNull com.day.cq.wcm.api.Page parentPage, @NotNull String name, @Nullable String template, @NotNull String title) Create content page.com.day.cq.wcm.api.Pagepage(@NotNull com.day.cq.wcm.api.Page parentPage, @NotNull String name, @Nullable String template, @NotNull Map<String, Object> pageProperties) Create content page.com.day.cq.wcm.api.PageCreate content page.com.day.cq.wcm.api.PageCreate content page.com.day.cq.wcm.api.PageCreate content page.com.day.cq.wcm.api.PageCreate content page.com.day.cq.wcm.api.PageCreate content page.@NotNull org.apache.sling.api.resource.ResourceCreate child resource below the page'sjcr:contentresource.@NotNull org.apache.sling.api.resource.Resourceresource(@NotNull com.day.cq.wcm.api.Page page, @NotNull String name, @NotNull Object @NotNull ... properties) Create child resource below the page'sjcr:contentresource.@NotNull org.apache.sling.api.resource.Resourceresource(@NotNull com.day.cq.wcm.api.Page page, @NotNull String name, @NotNull Map<String, Object> properties) Create child resource below the page'sjcr:contentresource.com.day.cq.tagging.TagAdds a tag definition.Methods inherited from class org.apache.sling.testing.mock.sling.builder.ContentBuilder
ensureResourceExists, resource, resource, resource, resource, resource, resource
-
Constructor Details
-
ContentBuilder
public ContentBuilder(@NotNull @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver) - Parameters:
resourceResolver- Resource resolver
-
ContentBuilder
- Parameters:
context- Context
-
-
Method Details
-
page
Create content page. If parent resource(s) do not exist they are created automatically usingnt:unstructurednodes.- Parameters:
path- Page path- Returns:
- Page object
-
page
public com.day.cq.wcm.api.Page page(@NotNull @NotNull String path, @Nullable @Nullable String template) Create content page. If parent resource(s) do not exist they are created automatically usingnt:unstructurednodes.- Parameters:
path- Page pathtemplate- Template- Returns:
- Page object
-
page
public com.day.cq.wcm.api.Page page(@NotNull @NotNull String path, @Nullable @Nullable String template, @NotNull @NotNull String title) Create content page. If parent resource(s) do not exist they are created automatically usingnt:unstructurednodes.- Parameters:
path- Page pathtemplate- Templatetitle- Page title- Returns:
- Page object
-
page
public com.day.cq.wcm.api.Page page(@NotNull @NotNull String path, @Nullable @Nullable String template, @NotNull @NotNull Map<String, Object> pageProperties) Create content page. If parent resource(s) do not exist they are created automatically usingnt:unstructurednodes.- Parameters:
path- Page pathtemplate- TemplatepageProperties- Properties forjcr:contentnode.- Returns:
- Page object
-
page
public com.day.cq.wcm.api.Page page(@NotNull @NotNull String path, @Nullable @Nullable String template, @NotNull @NotNull Object @NotNull ... pageProperties) Create content page. If parent resource(s) do not exist they are created automatically usingnt:unstructurednodes.- Parameters:
path- Page pathtemplate- TemplatepageProperties- Properties forjcr:contentnode.- Returns:
- Page object
-
page
public com.day.cq.wcm.api.Page page(@NotNull @NotNull com.day.cq.wcm.api.Page parentPage, @NotNull @NotNull String name) Create content page. If parent resource(s) do not exist they are created automatically usingnt:unstructurednodes.- Parameters:
parentPage- Parent page of the newp agename- Child page name- Returns:
- Page object
-
page
public com.day.cq.wcm.api.Page page(@NotNull @NotNull com.day.cq.wcm.api.Page parentPage, @NotNull @NotNull String name, @Nullable @Nullable String template) Create content page. If parent resource(s) do not exist they are created automatically usingnt:unstructurednodes.- Parameters:
parentPage- Parent page of the newp agename- Child page nametemplate- Template- Returns:
- Page object
-
page
public com.day.cq.wcm.api.Page page(@NotNull @NotNull com.day.cq.wcm.api.Page parentPage, @NotNull @NotNull String name, @Nullable @Nullable String template, @NotNull @NotNull String title) Create content page. If parent resource(s) do not exist they are created automatically usingnt:unstructurednodes.- Parameters:
parentPage- Parent page of the newp agename- Child page nametemplate- Templatetitle- Page title- Returns:
- Page object
-
page
public com.day.cq.wcm.api.Page page(@NotNull @NotNull com.day.cq.wcm.api.Page parentPage, @NotNull @NotNull String name, @Nullable @Nullable String template, @NotNull @NotNull Map<String, Object> pageProperties) Create content page. If parent resource(s) do not exist they are created automatically usingnt:unstructurednodes.- Parameters:
parentPage- Parent page of the newp agename- Child page nametemplate- TemplatepageProperties- Properties forjcr:contentnode.- Returns:
- Page object
-
page
public com.day.cq.wcm.api.Page page(@NotNull @NotNull com.day.cq.wcm.api.Page parentPage, @NotNull @NotNull String name, @Nullable @Nullable String template, @NotNull @NotNull Object @NotNull ... pageProperties) Create content page. If parent resource(s) do not exist they are created automatically usingnt:unstructurednodes.- Parameters:
parentPage- Parent page of the newp agename- Child page nametemplate- TemplatepageProperties- Properties forjcr:contentnode.- Returns:
- Page object
-
asset
public com.day.cq.dam.api.Asset asset(@NotNull @NotNull String path, @NotNull @NotNull String classpathResource, @NotNull @NotNull String mimeType) Create DAM asset.- Parameters:
path- Asset pathclasspathResource- Classpath resource URL for binary file.mimeType- Mime type- Returns:
- Asset
-
asset
public com.day.cq.dam.api.Asset asset(@NotNull @NotNull String path, @NotNull @NotNull String classpathResource, @NotNull @NotNull String mimeType, @Nullable @Nullable Map<String, Object> metadata) Create DAM asset.- Parameters:
path- Asset pathclasspathResource- Classpath resource URL for binary file.mimeType- Mime typemetadata- Asset metadata properties- Returns:
- Asset
-
asset
public com.day.cq.dam.api.Asset asset(@NotNull @NotNull String path, @NotNull @NotNull String classpathResource, @NotNull @NotNull String mimeType, @NotNull @NotNull Object @NotNull ... metadata) Create DAM asset.- Parameters:
path- Asset pathclasspathResource- Classpath resource URL for binary file.mimeType- Mime typemetadata- Asset metadata properties- Returns:
- Asset
-
asset
public com.day.cq.dam.api.Asset asset(@NotNull @NotNull String path, long width, long height, @NotNull @NotNull String mimeType) Create DAM asset with a generated dummy image. The image is empty.- Parameters:
path- Asset pathwidth- Dummy image widthheight- Dummy image heightmimeType- Mime type- Returns:
- Asset
-
asset
public com.day.cq.dam.api.Asset asset(@NotNull @NotNull String path, long width, long height, @NotNull @NotNull String mimeType, @Nullable @Nullable Map<String, Object> metadata) Create DAM asset with a generated dummy image. The image is empty.- Parameters:
path- Asset pathwidth- Dummy image widthheight- Dummy image heightmimeType- Mime typemetadata- Asset metadata properties- Returns:
- Asset
-
asset
public com.day.cq.dam.api.Asset asset(@NotNull @NotNull String path, long width, long height, @NotNull @NotNull String mimeType, @NotNull @NotNull Object @NotNull ... metadata) Create DAM asset with a generated dummy image. The image is empty.- Parameters:
path- Asset pathwidth- Dummy image widthheight- Dummy image heightmimeType- Mime typemetadata- Asset metadata properties- Returns:
- Asset
-
asset
public com.day.cq.dam.api.Asset asset(@NotNull @NotNull String path, @NotNull @NotNull InputStream inputStream, @NotNull @NotNull String mimeType) Create DAM asset.- Parameters:
path- Asset pathinputStream- Binary data for original renditionmimeType- Mime type- Returns:
- Asset
-
asset
public com.day.cq.dam.api.Asset asset(@NotNull @NotNull String path, @NotNull @NotNull InputStream inputStream, @NotNull @NotNull String mimeType, @Nullable @Nullable Map<String, Object> metadata) Create DAM asset.- Parameters:
path- Asset pathinputStream- Binary data for original renditionmimeType- Mime typemetadata- Asset metadata properties- Returns:
- Asset
-
asset
public com.day.cq.dam.api.Asset asset(@NotNull @NotNull String path, @NotNull @NotNull InputStream inputStream, @NotNull @NotNull String mimeType, @NotNull @NotNull Object @NotNull ... metadata) Create DAM asset.- Parameters:
path- Asset pathinputStream- Binary data for original renditionmimeType- Mime typemetadata- Asset metadata properties- Returns:
- Asset
-
createDummyImage
@NotNull public static @NotNull InputStream createDummyImage(long width, long height, String mimeType) Create dummy image- Parameters:
width- Widthheight- heightmimeType- Mime type- Returns:
- Input stream
-
assetRendition
public com.day.cq.dam.api.Rendition assetRendition(@NotNull @NotNull com.day.cq.dam.api.Asset asset, @NotNull @NotNull String name, @NotNull @NotNull String classpathResource, @NotNull @NotNull String mimeType) Adds a rendition to DAM asset.- Parameters:
asset- DAM assetname- Rendition nameclasspathResource- Classpath resource URL for binary file.mimeType- Mime type- Returns:
- Rendition
-
assetRendition
public com.day.cq.dam.api.Rendition assetRendition(@NotNull @NotNull com.day.cq.dam.api.Asset asset, @NotNull @NotNull String name, long width, long height, @NotNull @NotNull String mimeType) Adds a rendition with a generated dummy image to DAM asset. The image is empty.- Parameters:
asset- DAM assetname- Rendition namewidth- Dummy image widthheight- Dummy image heightmimeType- Mime type- Returns:
- Rendition
-
assetRendition
public com.day.cq.dam.api.Rendition assetRendition(@NotNull @NotNull com.day.cq.dam.api.Asset asset, String name, @NotNull @NotNull InputStream inputStream, @NotNull @NotNull String mimeType) Adds a rendition to DAM asset.- Parameters:
asset- DAM assetname- Rendition nameinputStream- Binary data for original renditionmimeType- Mime type- Returns:
- Rendition
-
assetRenditionWebEnabled
public com.day.cq.dam.api.Rendition assetRenditionWebEnabled(@NotNull @NotNull com.day.cq.dam.api.Asset asset) Adds a web-enabled rendition to DAM asset. The rendition has max a width/height of 1280px, but is never bigger then the original rendition.- Parameters:
asset- DAM asset- Returns:
- Rendition
-
assetRenditionWebEnabled
public com.day.cq.dam.api.Rendition assetRenditionWebEnabled(@NotNull @NotNull com.day.cq.dam.api.Asset asset, long maxWidth, long maxHeight) Adds a web-enabled rendition to DAM asset. The rendition has max the given width/height, but is never bigger then the original rendition.- Parameters:
asset- DAM assetmaxWidth- Max. widthmaxHeight- Max. width- Returns:
- Rendition
-
contentFragmentStructured
public com.adobe.cq.dam.cfm.ContentFragment contentFragmentStructured(@NotNull @NotNull String path, @Nullable @Nullable Map<String, Object> data) Create DAM content fragment.- Parameters:
path- Content fragment asset pathdata- Content fragment structured data- Returns:
- Content fragment
-
contentFragmentStructured
public com.adobe.cq.dam.cfm.ContentFragment contentFragmentStructured(@NotNull @NotNull String path, @NotNull @NotNull Object @NotNull ... data) Create DAM content fragment.- Parameters:
path- Content fragment asset pathdata- Content fragment structured data- Returns:
- Content fragment
-
contentFragmentText
public com.adobe.cq.dam.cfm.ContentFragment contentFragmentText(@NotNull @NotNull String path, @NotNull @NotNull String text, @NotNull @NotNull String mimeType) Create DAM content fragment.- Parameters:
path- Content fragment asset pathtext- Text valuemimeType- Mime type of the value- Returns:
- Content fragment
-
tag
Adds a tag definition.- Parameters:
tagId- Tag ID. May include namespace (separated by ":"). May include nested levels (separated by "/").- Returns:
- Tag
-
resource
@NotNull public @NotNull org.apache.sling.api.resource.Resource resource(@NotNull @NotNull com.day.cq.wcm.api.Page page, @NotNull @NotNull String name) Create child resource below the page'sjcr:contentresource. If parent resource(s) do not exist they are created automatically usingnt:unstructurednodes.- Parameters:
page- Page to create resource inname- Child resource name- Returns:
- Resource object
-
resource
@NotNull public @NotNull org.apache.sling.api.resource.Resource resource(@NotNull @NotNull com.day.cq.wcm.api.Page page, @NotNull @NotNull String name, @NotNull @NotNull Map<String, Object> properties) Create child resource below the page'sjcr:contentresource. If parent resource(s) do not exist they are created automatically usingnt:unstructurednodes.- Parameters:
page- Page to create resource inname- Child resource nameproperties- Properties for resource.- Returns:
- Resource object
-
resource
@NotNull public @NotNull org.apache.sling.api.resource.Resource resource(@NotNull @NotNull com.day.cq.wcm.api.Page page, @NotNull @NotNull String name, @NotNull @NotNull Object @NotNull ... properties) Create child resource below the page'sjcr:contentresource. If parent resource(s) do not exist they are created automatically usingnt:unstructurednodes.- Parameters:
page- Page to create resource inname- Child resource nameproperties- Properties for resource.- Returns:
- Resource object
-