Class ContentBuilder
java.lang.Object
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
FieldsModifier and TypeFieldDescriptionprotected final org.apache.sling.api.resource.ResourceResolver
Resource resolver -
Constructor Summary
ConstructorsConstructorDescriptionContentBuilder
(@NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver) -
Method Summary
Modifier and TypeMethodDescriptionprotected final @NotNull org.apache.sling.api.resource.Resource
ensureResourceExists
(@NotNull String path) Ensure that a resource exists at the given path.final @NotNull org.apache.sling.api.resource.Resource
Create resource.final @NotNull org.apache.sling.api.resource.Resource
Create resource.final @NotNull org.apache.sling.api.resource.Resource
Create resource.final @NotNull org.apache.sling.api.resource.Resource
Create child resource below the given parent resource.final @NotNull org.apache.sling.api.resource.Resource
resource
(@NotNull org.apache.sling.api.resource.Resource resource, @NotNull String name, @NotNull Object @NotNull ... properties) Create child resource below the given parent resource.final @NotNull org.apache.sling.api.resource.Resource
resource
(@NotNull org.apache.sling.api.resource.Resource resource, @NotNull String name, @NotNull Map<String, Object> properties) Create child resource below the given parent resource.
-
Field Details
-
resourceResolver
protected final org.apache.sling.api.resource.ResourceResolver resourceResolverResource resolver
-
-
Constructor Details
-
ContentBuilder
public ContentBuilder(@NotNull @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver) - Parameters:
resourceResolver
- Resource resolver
-
-
Method Details
-
resource
@NotNull public final @NotNull org.apache.sling.api.resource.Resource resource(@NotNull @NotNull String path) Create resource. If parent resource(s) do not exist they are created automatically usingnt:unstructured
nodes.- Parameters:
path
- Page path- Returns:
- Resource object
-
resource
@NotNull public final @NotNull org.apache.sling.api.resource.Resource resource(@NotNull @NotNull String path, @NotNull @NotNull Map<String, Object> properties) Create resource. If parent resource(s) do not exist they are created automatically usingnt:unstructured
nodes.- Parameters:
path
- Page pathproperties
- Properties for resource.- Returns:
- Resource object
-
resource
@NotNull public final @NotNull org.apache.sling.api.resource.Resource resource(@NotNull @NotNull String path, @NotNull @NotNull Object @NotNull ... properties) Create resource. If parent resource(s) do not exist they are created automatically usingnt:unstructured
nodes.- Parameters:
path
- Page pathproperties
- Properties for resource.- Returns:
- Resource object
-
resource
@NotNull public final @NotNull org.apache.sling.api.resource.Resource resource(@NotNull @NotNull org.apache.sling.api.resource.Resource resource, @NotNull @NotNull String name) Create child resource below the given parent resource.- Parameters:
resource
- Parent resourcename
- Child resource name- Returns:
- Resource object
-
resource
@NotNull public final @NotNull org.apache.sling.api.resource.Resource resource(@NotNull @NotNull org.apache.sling.api.resource.Resource resource, @NotNull @NotNull String name, @NotNull @NotNull Map<String, Object> properties) Create child resource below the given parent resource.- Parameters:
resource
- Parent resourcename
- Child resource nameproperties
- Properties for resource.- Returns:
- Resource object
-
resource
@NotNull public final @NotNull org.apache.sling.api.resource.Resource resource(@NotNull @NotNull org.apache.sling.api.resource.Resource resource, @NotNull @NotNull String name, @NotNull @NotNull Object @NotNull ... properties) Create child resource below the given parent resource.- Parameters:
resource
- Parent resourcename
- Child resource nameproperties
- Properties for resource.- Returns:
- Resource object
-
ensureResourceExists
@NotNull protected final @NotNull org.apache.sling.api.resource.Resource ensureResourceExists(@NotNull @NotNull String path) Ensure that a resource exists at the given path. If not, it is created usingnt:unstructured
node type.- Parameters:
path
- Resource path- Returns:
- Resource at path (existing or newly created)
-