### Question:
ConditionTypesResource implements CollectionResourceProvider { @Override public Promise<QueryResponse, ResourceException> queryCollection(Context context, QueryRequest request, QueryResourceHandler handler) { final Set<String> conditionTypeNames = new TreeSet<>(); List<ResourceResponse> conditionTypes = new ArrayList<>(); final String principalName = PrincipalRestUtils.getPrincipalNameFromServerContext(context); conditionTypeNames.addAll(entitlementRegistry.getConditionsShortNames()); for (String conditionTypeName : conditionTypeNames) { final Class<? extends EntitlementCondition> conditionClass = entitlementRegistry.getConditionType(conditionTypeName); if (conditionClass == null) { if (debug.warningEnabled()) { debug.warning("ConditionTypesResource :: QUERY by " + principalName + ": Requested condition short name not found: " + conditionTypeName); } continue; } final JsonValue json = jsonify(conditionClass, conditionTypeName, LogicalCondition.class.isAssignableFrom(conditionClass)); if (json != null) { conditionTypes.add(newResourceResponse(json.get(JSON_OBJ_TITLE).asString(), null, json)); } } QueryResponsePresentation.enableDeprecatedRemainingQueryResponse(request); return QueryResponsePresentation.perform(handler, request, conditionTypes); } @Inject  ConditionTypesResource(@Named("frRest") Debug debug, EntitlementRegistry entitlementRegistry); @Override Promise<ActionResponse, ResourceException> actionCollection(Context context, ActionRequest request); @Override Promise<ActionResponse, ResourceException> actionInstance(Context context, String resourceId,
            ActionRequest 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); @Override Promise<QueryResponse, ResourceException> queryCollection(Context context, QueryRequest request,
            QueryResourceHandler handler); @Override Promise<ResourceResponse, ResourceException> readInstance(Context context, String resourceId,
            ReadRequest request);  }### Answer:
@Test public void testSuccessfulJsonificationAndQuery() throws JsonMappingException { SubjectContext mockSubjectContext = mock(SubjectContext.class); RealmContext realmContext = new RealmContext(mockSubjectContext); Context mockServerContext = ClientContext.newInternalClientContext(realmContext); QueryResourceHandler mockHandler = mock(QueryResourceHandler.class); Subject mockSubject = new Subject(); given(mockSubjectContext.getCallerSubject()).willReturn(mockSubject); QueryRequest mockRequest = mock(QueryRequest.class); JsonSchema mockSchema = mock(JsonSchema.class); given(mockRequest.getPageSize()).willReturn(2); given(mockHandler.handleResource(any(ResourceResponse.class))).willReturn(true); given(mockMapper.generateJsonSchema((Class<?>) any(Class.class))).willReturn(mockSchema); testResource.queryCollection(mockServerContext, mockRequest, mockHandler); verify(mockHandler, times(2)).handleResource(any(ResourceResponse.class)); }