Class MockHelper
- java.lang.Object
-
- org.apache.sling.testing.resourceresolver.MockHelper
-
public class MockHelper extends Object
Helper class to create resources: MockHelper.create(resolver).resource("/libs").p("prop", "value") .resource("sub").p("sub", "hello") .resource(".sameLevel") .resource("/apps").p("foo", "baa").commit()
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd()Finish building and add all resources to the resource tree.voidcommit()Finish building, add all resources to the resource tree and commit changes.static @NotNull MockHelpercreate(@NotNull org.apache.sling.api.resource.ResourceResolver resolver)Create a new helper@NotNull MockHelperp(@NotNull String name, @Nullable Object value)Add a property to the current resource@NotNull MockHelperresource(@NotNull String path)Add a new resource.
-
-
-
Method Detail
-
create
@NotNull public static @NotNull MockHelper create(@NotNull @NotNull org.apache.sling.api.resource.ResourceResolver resolver)
Create a new helper- Parameters:
resolver- Resource resolver- Returns:
- this
-
resource
@NotNull public @NotNull MockHelper resource(@NotNull @NotNull String path)
Add a new resource. If the path is relative, this resource is added as a child to the previous resource. If the path is relative and starts with a dot, this resource is added as a peer to the previous resource.- Parameters:
path- Resource path- Returns:
- this
-
p
@NotNull public @NotNull MockHelper p(@NotNull @NotNull String name, @Nullable @Nullable Object value)
Add a property to the current resource- Parameters:
name- Property namevalue- Property value- Returns:
- this
-
add
public void add() throws org.apache.sling.api.resource.PersistenceExceptionFinish building and add all resources to the resource tree.- Throws:
org.apache.sling.api.resource.PersistenceException- Persistence exception
-
commit
public void commit() throws org.apache.sling.api.resource.PersistenceExceptionFinish building, add all resources to the resource tree and commit changes.- Throws:
org.apache.sling.api.resource.PersistenceException- Persistence exception
-
-