Class MockResourceResolver
java.lang.Object
org.apache.sling.api.adapter.SlingAdaptable
org.apache.sling.testing.resourceresolver.MockResourceResolver
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.sling.api.adapter.Adaptable,org.apache.sling.api.resource.ResourceResolver
public class MockResourceResolver
extends org.apache.sling.api.adapter.SlingAdaptable
implements org.apache.sling.api.resource.ResourceResolver
-
Field Summary
Fields inherited from interface org.apache.sling.api.resource.ResourceResolver
PROPERTY_RESOURCE_SUPER_TYPE, PROPERTY_RESOURCE_TYPE, REQUEST_ATTR_WORKSPACE_INFO, USER_IMPERSONATOR -
Constructor Summary
ConstructorsConstructorDescriptionMockResourceResolver(MockResourceResolverFactoryOptions options, MockResourceResolverFactory factory, Map<String, Map<String, Object>> resources) MockResourceResolver(MockResourceResolverFactoryOptions options, MockResourceResolverFactory factory, Map<String, Map<String, Object>> resources, Map<String, Object> attributes) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChanged(String path, Map<String, Object> props) voidaddFindResourceHandler(@NotNull MockFindResourcesHandler handler) Deprecated.voidaddQueryResourceHandler(@NotNull MockQueryResourceHandler handler) Deprecated.@NotNull org.apache.sling.api.resource.ResourceResolvervoidclose()voidcommit()org.apache.sling.api.resource.Resource@NotNull org.apache.sling.api.resource.Resourcecreate(@NotNull org.apache.sling.api.resource.Resource parent, @NotNull String name, Map<String, Object> properties) voiddelete(@NotNull org.apache.sling.api.resource.Resource resource) @NotNull Iterator<org.apache.sling.api.resource.Resource>findResources(@NotNull String query, String language) getAttribute(@NotNull String name) @NotNull Iterable<org.apache.sling.api.resource.Resource>getChildren(@NotNull org.apache.sling.api.resource.Resource parent) org.apache.sling.api.resource.ResourcegetParent(@NotNull org.apache.sling.api.resource.Resource child) getParentResourceType(String resourceType) getParentResourceType(org.apache.sling.api.resource.Resource resource) org.apache.sling.api.resource.ResourcegetResource(@NotNull String path) org.apache.sling.api.resource.ResourcegetResource(org.apache.sling.api.resource.Resource base, @NotNull String path) @NotNull String[]booleanbooleanhasChildren(@NotNull org.apache.sling.api.resource.Resource resource) booleanisLive()booleanisResourceType(org.apache.sling.api.resource.Resource resource, String resourceType) @NotNull Iterator<org.apache.sling.api.resource.Resource>listChildren(@NotNull org.apache.sling.api.resource.Resource parent) @NotNull String@NotNull StringDeprecated.org.apache.sling.api.resource.ResourcebooleanorderBefore(@NotNull org.apache.sling.api.resource.Resource parent, @NotNull String name, @Nullable String followingSiblingName) queryResources(@NotNull String query, String language) voidrefresh()@NotNull org.apache.sling.api.resource.Resource@NotNull org.apache.sling.api.resource.Resource@NotNull org.apache.sling.api.resource.Resourceresolve(javax.servlet.http.HttpServletRequest request) Deprecated.as of ResourceResolver 2.0.4, useresolve(HttpServletRequest, String)instead.@NotNull org.apache.sling.api.resource.ResourceDeprecated.voidrevert()Methods inherited from class org.apache.sling.api.adapter.SlingAdaptable
adaptTo, setAdapterManager, unsetAdapterManagerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.sling.api.adapter.Adaptable
adaptTo
-
Constructor Details
-
MockResourceResolver
public MockResourceResolver(MockResourceResolverFactoryOptions options, MockResourceResolverFactory factory, Map<String, Map<String, Object>> resources) -
MockResourceResolver
public MockResourceResolver(MockResourceResolverFactoryOptions options, MockResourceResolverFactory factory, Map<String, Map<String, Object>> resources, Map<String, Object> attributes)
-
-
Method Details
-
resolve
@Deprecated(since="2.5.0") @NotNull public @NotNull org.apache.sling.api.resource.Resource resolve(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull @NotNull String absPath) Deprecated.- Specified by:
resolvein interfaceorg.apache.sling.api.resource.ResourceResolver
-
resolve
@NotNull public @NotNull org.apache.sling.api.resource.Resource resolve(@NotNull @NotNull jakarta.servlet.http.HttpServletRequest request, @NotNull @NotNull String absPath) - Specified by:
resolvein interfaceorg.apache.sling.api.resource.ResourceResolver
-
resolve
@NotNull public @NotNull org.apache.sling.api.resource.Resource resolve(@NotNull @NotNull String absPath) - Specified by:
resolvein interfaceorg.apache.sling.api.resource.ResourceResolver
-
map
- Specified by:
mapin interfaceorg.apache.sling.api.resource.ResourceResolver
-
map
@Deprecated(since="2.5.0") public String map(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull @NotNull String resourcePath) Deprecated.- Specified by:
mapin interfaceorg.apache.sling.api.resource.ResourceResolver
-
map
@NotNull public @NotNull String map(@NotNull @NotNull jakarta.servlet.http.HttpServletRequest request, @NotNull @NotNull String resourcePath) - Specified by:
mapin interfaceorg.apache.sling.api.resource.ResourceResolver
-
getResource
- Specified by:
getResourcein interfaceorg.apache.sling.api.resource.ResourceResolver
-
getResource
public org.apache.sling.api.resource.Resource getResource(org.apache.sling.api.resource.Resource base, @NotNull @NotNull String path) - Specified by:
getResourcein interfaceorg.apache.sling.api.resource.ResourceResolver
-
getSearchPath
- Specified by:
getSearchPathin interfaceorg.apache.sling.api.resource.ResourceResolver
-
listChildren
@NotNull public @NotNull Iterator<org.apache.sling.api.resource.Resource> listChildren(@NotNull @NotNull org.apache.sling.api.resource.Resource parent) - Specified by:
listChildrenin interfaceorg.apache.sling.api.resource.ResourceResolver
-
getChildren
@NotNull public @NotNull Iterable<org.apache.sling.api.resource.Resource> getChildren(@NotNull @NotNull org.apache.sling.api.resource.Resource parent) - Specified by:
getChildrenin interfaceorg.apache.sling.api.resource.ResourceResolver
-
isLive
public boolean isLive()- Specified by:
isLivein interfaceorg.apache.sling.api.resource.ResourceResolver
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceorg.apache.sling.api.resource.ResourceResolver
-
getUserID
- Specified by:
getUserIDin interfaceorg.apache.sling.api.resource.ResourceResolver
-
getAttributeNames
- Specified by:
getAttributeNamesin interfaceorg.apache.sling.api.resource.ResourceResolver
-
getAttribute
- Specified by:
getAttributein interfaceorg.apache.sling.api.resource.ResourceResolver
-
delete
public void delete(@NotNull @NotNull org.apache.sling.api.resource.Resource resource) throws org.apache.sling.api.resource.PersistenceException - Specified by:
deletein interfaceorg.apache.sling.api.resource.ResourceResolver- Throws:
org.apache.sling.api.resource.PersistenceException
-
create
@NotNull public @NotNull org.apache.sling.api.resource.Resource create(@NotNull @NotNull org.apache.sling.api.resource.Resource parent, @NotNull @NotNull String name, Map<String, Object> properties) throws org.apache.sling.api.resource.PersistenceException- Specified by:
createin interfaceorg.apache.sling.api.resource.ResourceResolver- Throws:
org.apache.sling.api.resource.PersistenceException
-
revert
public void revert()- Specified by:
revertin interfaceorg.apache.sling.api.resource.ResourceResolver
-
commit
public void commit() throws org.apache.sling.api.resource.PersistenceException- Specified by:
commitin interfaceorg.apache.sling.api.resource.ResourceResolver- Throws:
org.apache.sling.api.resource.PersistenceException
-
hasChanges
public boolean hasChanges()- Specified by:
hasChangesin interfaceorg.apache.sling.api.resource.ResourceResolver
-
isResourceType
- Specified by:
isResourceTypein interfaceorg.apache.sling.api.resource.ResourceResolver
-
refresh
public void refresh()- Specified by:
refreshin interfaceorg.apache.sling.api.resource.ResourceResolver
-
addChanged
-
getParentResourceType
- Specified by:
getParentResourceTypein interfaceorg.apache.sling.api.resource.ResourceResolver
-
getParentResourceType
- Specified by:
getParentResourceTypein interfaceorg.apache.sling.api.resource.ResourceResolver
-
hasChildren
public boolean hasChildren(@NotNull @NotNull org.apache.sling.api.resource.Resource resource) - Specified by:
hasChildrenin interfaceorg.apache.sling.api.resource.ResourceResolver
-
getParent
public org.apache.sling.api.resource.Resource getParent(@NotNull @NotNull org.apache.sling.api.resource.Resource child) - Specified by:
getParentin interfaceorg.apache.sling.api.resource.ResourceResolver
-
findResources
@NotNull public @NotNull Iterator<org.apache.sling.api.resource.Resource> findResources(@NotNull @NotNull String query, String language) - Specified by:
findResourcesin interfaceorg.apache.sling.api.resource.ResourceResolver
-
addFindResourceHandler
Deprecated.Adds a handler that can provide a mocked find resources result. You can add multiple handlers which are called in the order they were added when callingfindResources(String, String). The result of the first handler that returns a non-null result is used. If no handler delivers a result, an empty result is returned.- Parameters:
handler- Handler
-
queryResources
@NotNull public @NotNull Iterator<Map<String,Object>> queryResources(@NotNull @NotNull String query, String language) - Specified by:
queryResourcesin interfaceorg.apache.sling.api.resource.ResourceResolver
-
copy
public org.apache.sling.api.resource.Resource copy(String srcAbsPath, String destAbsPath) throws org.apache.sling.api.resource.PersistenceException - Specified by:
copyin interfaceorg.apache.sling.api.resource.ResourceResolver- Throws:
org.apache.sling.api.resource.PersistenceException
-
move
public org.apache.sling.api.resource.Resource move(String srcAbsPath, String destAbsPath) throws org.apache.sling.api.resource.PersistenceException - Specified by:
movein interfaceorg.apache.sling.api.resource.ResourceResolver- Throws:
org.apache.sling.api.resource.PersistenceException
-
addQueryResourceHandler
Deprecated.Adds a handler that can provide a mocked query resources result. You can add multiple handlers which are called in the order they were added when callingqueryResources(String, String). The result of the first handler that returns a non-null result is used. If no handler delivers a result, an empty result is returned.- Parameters:
handler- Handler
-
getPropertyMap
- Specified by:
getPropertyMapin interfaceorg.apache.sling.api.resource.ResourceResolver
-
resolve
@Deprecated(since="1.1") @NotNull public @NotNull org.apache.sling.api.resource.Resource resolve(@NotNull javax.servlet.http.HttpServletRequest request) Deprecated.as of ResourceResolver 2.0.4, useresolve(HttpServletRequest, String)instead.- Specified by:
resolvein interfaceorg.apache.sling.api.resource.ResourceResolver
-
clone
@NotNull public @NotNull org.apache.sling.api.resource.ResourceResolver clone(Map<String, Object> authenticationInfo) throws org.apache.sling.api.resource.LoginException- Specified by:
clonein interfaceorg.apache.sling.api.resource.ResourceResolver- Throws:
org.apache.sling.api.resource.LoginException
-
orderBefore
public boolean orderBefore(@NotNull @NotNull org.apache.sling.api.resource.Resource parent, @NotNull @NotNull String name, @Nullable @Nullable String followingSiblingName) throws UnsupportedOperationException, org.apache.sling.api.resource.PersistenceException, IllegalArgumentException - Specified by:
orderBeforein interfaceorg.apache.sling.api.resource.ResourceResolver- Throws:
UnsupportedOperationExceptionorg.apache.sling.api.resource.PersistenceExceptionIllegalArgumentException
-
MockFindQueryResources.addFindResourceHandler(ResourceResolver, MockFindResourcesHandler)