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
-
-
Constructor Summary
Constructors Constructor Description MockResourceResolver(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
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addChanged(String path, Map<String,Object> props)
void
addFindResourceHandler(@NotNull MockFindResourcesHandler handler)
Adds a handler that can provide a mocked find resources result.void
addQueryResourceHandler(@NotNull MockQueryResourceHandler handler)
Adds a handler that can provide a mocked query resources result.@NotNull org.apache.sling.api.resource.ResourceResolver
clone(Map<String,Object> authenticationInfo)
void
close()
void
commit()
org.apache.sling.api.resource.Resource
copy(String srcAbsPath, String destAbsPath)
@NotNull org.apache.sling.api.resource.Resource
create(@NotNull org.apache.sling.api.resource.Resource parent, @NotNull String name, Map<String,Object> properties)
void
delete(@NotNull org.apache.sling.api.resource.Resource resource)
@NotNull Iterator<org.apache.sling.api.resource.Resource>
findResources(@NotNull String query, String language)
Object
getAttribute(@NotNull String name)
@NotNull Iterator<String>
getAttributeNames()
@NotNull Iterable<org.apache.sling.api.resource.Resource>
getChildren(@NotNull org.apache.sling.api.resource.Resource parent)
org.apache.sling.api.resource.Resource
getParent(@NotNull org.apache.sling.api.resource.Resource child)
String
getParentResourceType(String resourceType)
String
getParentResourceType(org.apache.sling.api.resource.Resource resource)
@NotNull Map<String,Object>
getPropertyMap()
org.apache.sling.api.resource.Resource
getResource(@NotNull String path)
org.apache.sling.api.resource.Resource
getResource(org.apache.sling.api.resource.Resource base, @NotNull String path)
String @NotNull []
getSearchPath()
String
getUserID()
boolean
hasChanges()
boolean
hasChildren(@NotNull org.apache.sling.api.resource.Resource resource)
boolean
isLive()
boolean
isResourceType(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
map(@NotNull String resourcePath)
String
map(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull String resourcePath)
org.apache.sling.api.resource.Resource
move(String srcAbsPath, String destAbsPath)
boolean
orderBefore(@NotNull org.apache.sling.api.resource.Resource parent, @NotNull String name, @Nullable String followingSiblingName)
@NotNull Iterator<Map<String,Object>>
queryResources(@NotNull String query, String language)
void
refresh()
@NotNull org.apache.sling.api.resource.Resource
resolve(@NotNull String absPath)
@NotNull org.apache.sling.api.resource.Resource
resolve(@NotNull javax.servlet.http.HttpServletRequest request)
Deprecated.@NotNull org.apache.sling.api.resource.Resource
resolve(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull String absPath)
void
revert()
-
Methods inherited from class org.apache.sling.api.adapter.SlingAdaptable
adaptTo, setAdapterManager, unsetAdapterManager
-
-
-
-
Constructor Detail
-
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 Detail
-
resolve
@NotNull public @NotNull org.apache.sling.api.resource.Resource resolve(@NotNull @NotNull javax.servlet.http.HttpServletRequest request, @NotNull @NotNull String absPath)
- Specified by:
resolve
in interfaceorg.apache.sling.api.resource.ResourceResolver
-
resolve
@NotNull public @NotNull org.apache.sling.api.resource.Resource resolve(@NotNull @NotNull String absPath)
- Specified by:
resolve
in interfaceorg.apache.sling.api.resource.ResourceResolver
-
map
@NotNull public @NotNull String map(@NotNull @NotNull String resourcePath)
- Specified by:
map
in interfaceorg.apache.sling.api.resource.ResourceResolver
-
map
public String map(@NotNull @NotNull javax.servlet.http.HttpServletRequest request, @NotNull @NotNull String resourcePath)
- Specified by:
map
in interfaceorg.apache.sling.api.resource.ResourceResolver
-
getResource
public org.apache.sling.api.resource.Resource getResource(@NotNull @NotNull String path)
- Specified by:
getResource
in 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:
getResource
in interfaceorg.apache.sling.api.resource.ResourceResolver
-
getSearchPath
public String @NotNull [] getSearchPath()
- Specified by:
getSearchPath
in 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:
listChildren
in 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:
getChildren
in interfaceorg.apache.sling.api.resource.ResourceResolver
-
isLive
public boolean isLive()
- Specified by:
isLive
in interfaceorg.apache.sling.api.resource.ResourceResolver
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceorg.apache.sling.api.resource.ResourceResolver
-
getUserID
public String getUserID()
- Specified by:
getUserID
in interfaceorg.apache.sling.api.resource.ResourceResolver
-
getAttributeNames
@NotNull public @NotNull Iterator<String> getAttributeNames()
- Specified by:
getAttributeNames
in interfaceorg.apache.sling.api.resource.ResourceResolver
-
getAttribute
public Object getAttribute(@NotNull @NotNull String name)
- Specified by:
getAttribute
in 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:
delete
in 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:
create
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Throws:
org.apache.sling.api.resource.PersistenceException
-
revert
public void revert()
- Specified by:
revert
in interfaceorg.apache.sling.api.resource.ResourceResolver
-
commit
public void commit() throws org.apache.sling.api.resource.PersistenceException
- Specified by:
commit
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Throws:
org.apache.sling.api.resource.PersistenceException
-
hasChanges
public boolean hasChanges()
- Specified by:
hasChanges
in interfaceorg.apache.sling.api.resource.ResourceResolver
-
isResourceType
public boolean isResourceType(org.apache.sling.api.resource.Resource resource, String resourceType)
- Specified by:
isResourceType
in interfaceorg.apache.sling.api.resource.ResourceResolver
-
refresh
public void refresh()
- Specified by:
refresh
in interfaceorg.apache.sling.api.resource.ResourceResolver
-
getParentResourceType
public String getParentResourceType(org.apache.sling.api.resource.Resource resource)
- Specified by:
getParentResourceType
in interfaceorg.apache.sling.api.resource.ResourceResolver
-
getParentResourceType
public String getParentResourceType(String resourceType)
- Specified by:
getParentResourceType
in interfaceorg.apache.sling.api.resource.ResourceResolver
-
hasChildren
public boolean hasChildren(@NotNull @NotNull org.apache.sling.api.resource.Resource resource)
- Specified by:
hasChildren
in 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:
getParent
in 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:
findResources
in interfaceorg.apache.sling.api.resource.ResourceResolver
-
addFindResourceHandler
public void addFindResourceHandler(@NotNull @NotNull MockFindResourcesHandler handler)
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:
queryResources
in interfaceorg.apache.sling.api.resource.ResourceResolver
-
addQueryResourceHandler
public void addQueryResourceHandler(@NotNull @NotNull MockQueryResourceHandler handler)
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
-
resolve
@Deprecated @NotNull public @NotNull org.apache.sling.api.resource.Resource resolve(@NotNull @NotNull javax.servlet.http.HttpServletRequest request)
Deprecated.- Specified by:
resolve
in 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:
clone
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Throws:
org.apache.sling.api.resource.LoginException
-
copy
public org.apache.sling.api.resource.Resource copy(String srcAbsPath, String destAbsPath) throws org.apache.sling.api.resource.PersistenceException
- Specified by:
copy
in 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:
move
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Throws:
org.apache.sling.api.resource.PersistenceException
-
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
- Throws:
UnsupportedOperationException
org.apache.sling.api.resource.PersistenceException
IllegalArgumentException
-
-