Package org.apache.sling.testing.resourceresolver

# Class MockFindQueryResources

java.lang.Object
org.apache.sling.testing.resourceresolver.MockFindQueryResources

public final class MockFindQueryResources extends Object
Allows to provide mocked search result for queries via `ResourceResolver`. This works if `MockResourceResolver` is used directly or indirectly via `MockResourceProvider`.

## Method Summary

Modifier and Type
Method
Description
`static void`
`addFindResourceHandler(@NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @NotNull MockFindResourcesHandler handler)`
Adds a handler that can provide a mocked find resources result.
`static void`
`addQueryResourceHandler(@NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @NotNull MockQueryResourceHandler handler)`
Adds a handler that can provide a mocked query resources result.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### addFindResourceHandler

public static void addFindResourceHandler(@NotNull @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @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 calling `ResourceResolver.findResources(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:
  `resourceResolver` - Resource resolver
  `handler` - Handler
Throws:
  `IllegalStateException` - If the given resource resolver is not based on resourceresolver-mock

### addQueryResourceHandler

public static void addQueryResourceHandler(@NotNull @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @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 calling `ResourceResolver.queryResources(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:
  `resourceResolver` - Resource resolver
  `handler` - Handler
Throws:
  `IllegalStateException` - If the given resource resolver is not based on resourceresolver-mock