Class MockHelper
java.lang.Object
org.apache.sling.testing.resourceresolver.MockHelper
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
Modifier and TypeMethodDescriptionvoid
add()
Finish building and add all resources to the resource tree.void
commit()
Finish building, add all resources to the resource tree and commit changes.static @NotNull MockHelper
create
(@NotNull org.apache.sling.api.resource.ResourceResolver resolver) Create a new helper@NotNull MockHelper
Add a property to the current resource@NotNull MockHelper
Add a new resource.
-
Method Details
-
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
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
-