### Question:
PolicyResourceDelegate { public Promise<Pair<QueryResponse, List<ResourceResponse>>, ResourceException> queryPolicies(Context context, QueryRequest request) { final List<ResourceResponse> resources = new ArrayList<>(); return policyResource.handleQuery(context, request, new QueryResourceHandler() { @Override public boolean handleResource(ResourceResponse resource) { resources.add(resource); return true; } }) .thenAsync(new AsyncFunction<QueryResponse, Pair<QueryResponse, List<ResourceResponse>>, ResourceException>() { @Override public Promise<Pair<QueryResponse, List<ResourceResponse>>, ResourceException> apply(QueryResponse response) { return newResultPromise(Pair.of(response, resources)); } }); } @Inject  PolicyResourceDelegate(@Named(UMA_BACKEND_POLICY_RESOURCE_HANDLER) RequestHandler policyResource); Promise<List<ResourceResponse>, ResourceException> createPolicies(Context context,
            Set<JsonValue> policies); Promise<List<ResourceResponse>, ResourceException> updatePolicies(Context context,
            Set<JsonValue> policies); Promise<Pair<QueryResponse, List<ResourceResponse>>, ResourceException> queryPolicies(Context context,
            QueryRequest request); Promise<QueryResponse, ResourceException> queryPolicies(Context context,
            QueryRequest request, QueryResourceHandler resultHandler); Promise<List<ResourceResponse>, ResourceException> deletePolicies(Context context,
            Collection<String> policyIds);  }### Answer:
@Test public void shouldQueryPolicies() throws ResourceException { Context context = mock(Context.class); QueryRequest request = mock(QueryRequest.class); QueryResourceHandler handler = mock(QueryResourceHandler.class); delegate.queryPolicies(context, request, handler); verify(policyResource).handleQuery(context, request, handler); }
@Test public void shouldQueryPoliciesWithHandler() throws ResourceException { Context context = mock(Context.class); QueryRequest request = mock(QueryRequest.class); QueryResourceHandler handler = mock(QueryResourceHandler.class); delegate.queryPolicies(context, request, handler); verify(policyResource).handleQuery(context, request, handler); }