Class ContentBuilder
- java.lang.Object
-
- org.apache.sling.testing.mock.sling.builder.ContentBuilder
-
public class ContentBuilder extends Object
Helper class for building test content in the resource hierarchy with as less boilerplate code as possible.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.sling.api.resource.ResourceResolver
resourceResolver
-
Constructor Summary
Constructors Constructor Description ContentBuilder(@NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected @NotNull org.apache.sling.api.resource.Resource
ensureResourceExists(@NotNull String path)
Ensure that a resource exists at the given path.@NotNull org.apache.sling.api.resource.Resource
resource(@NotNull String path)
Create resource.@NotNull org.apache.sling.api.resource.Resource
resource(@NotNull String path, @NotNull Object @NotNull ... properties)
Create resource.@NotNull org.apache.sling.api.resource.Resource
resource(@NotNull String path, @NotNull Map<String,Object> properties)
Create resource.@NotNull org.apache.sling.api.resource.Resource
resource(@NotNull org.apache.sling.api.resource.Resource resource, @NotNull String name)
Create child resource below the given parent resource.@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.@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.
-
-
-
Method Detail
-
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)
-
-