### Question:
PendingRequestResource implements CollectionResourceProvider { @Override public Promise<QueryResponse, ResourceException> queryCollection(Context context, QueryRequest request, QueryResourceHandler handler) { if (request.getQueryFilter() == null) { return new NotSupportedException("Only query filter is supported.").asPromise(); } try { List<ResourceResponse> values = new ArrayList<>(); for (UmaPendingRequest pendingRequest : queryResourceOwnerPendingRequests(context)) { if (request.getQueryFilter().accept(QUERY_VISITOR, pendingRequest.asJson())) { values.add(newResourceResponse(pendingRequest.getId(), null, pendingRequest.asJson())); } } QueryResponsePresentation.enableDeprecatedRemainingQueryResponse(request); return QueryResponsePresentation.perform(handler, request, values); } catch (ResourceException e) { return e.asPromise(); } } @Inject  PendingRequestResource(PendingRequestsService service,
            ContextHelper contextHelper); @Override Promise<ActionResponse, ResourceException> actionCollection(Context context, ActionRequest request); @Override Promise<ActionResponse, ResourceException> actionInstance(Context context, String resourceId,
            ActionRequest request); @Override Promise<QueryResponse, ResourceException> queryCollection(Context context, QueryRequest request,
            QueryResourceHandler handler); @Override Promise<ResourceResponse, ResourceException> readInstance(Context context, String resourceId,
            ReadRequest request); @Override Promise<ResourceResponse, ResourceException> createInstance(Context context, CreateRequest request); @Override Promise<ResourceResponse, ResourceException> deleteInstance(Context context, String resourceId,
            DeleteRequest request); @Override Promise<ResourceResponse, ResourceException> patchInstance(Context context, String resourceId,
            PatchRequest request); @Override Promise<ResourceResponse, ResourceException> updateInstance(Context context, String resourceId,
            UpdateRequest request);  }### Answer:
@Test public void shouldQueryPendingRequests() throws Exception { Context context = mockContext("REALM"); QueryRequest request = Requests.newQueryRequest("").setQueryFilter(QueryFilter.<JsonPointer>alwaysTrue()); QueryResourceHandler handler = mock(QueryResourceHandler.class); given(handler.handleResource(any(ResourceResponse.class))).willReturn(true); mockPendingRequestsForUser("alice", "REALM", 2); Promise<QueryResponse, ResourceException> promise = resource.queryCollection(context, request, handler); verify(handler, times(2)).handleResource(any(ResourceResponse.class)); assertThat(promise).succeeded(); }