### Question:
DecisionCombinersResource implements CollectionResourceProvider { @Override public Promise<ResourceResponse, ResourceException> readInstance(Context context, String resourceId, ReadRequest request) { final Class<? extends EntitlementCombiner> combinerClass = entitlementRegistry.getCombinerType(resourceId); final String principalName = PrincipalRestUtils.getPrincipalNameFromServerContext(context); if (combinerClass == null) { if (debug.errorEnabled()) { debug.error("DecisionCombinersResource :: READ by " + principalName + ": Requested combiner short name not found: " + resourceId); } return new NotFoundException().asPromise(); } final JsonValue json = jsonify(resourceId); final ResourceResponse resource = newResourceResponse(resourceId, String.valueOf(currentTimeMillis()), json); return newResultPromise(resource); } @Inject  DecisionCombinersResource(@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<QueryResponse, ResourceException> queryCollection(Context context, QueryRequest request,
            QueryResourceHandler handler); @Override Promise<ResourceResponse, ResourceException> readInstance(Context context, String resourceId,
            ReadRequest request); @Override Promise<ResourceResponse, ResourceException> updateInstance(Context context, String resourceId,
            UpdateRequest request);  }### Answer:
@Test (expectedExceptions = NotFoundException.class) public void shouldThrowErrorWthInvalidCondition() throws JsonMappingException, ResourceException { SubjectContext mockSubjectContext = mock(SubjectContext.class); RealmContext realmContext = new RealmContext(mockSubjectContext); Context mockServerContext = ClientContext.newInternalClientContext(realmContext); Subject mockSubject = new Subject(); given(mockSubjectContext.getCallerSubject()).willReturn(mockSubject); ReadRequest mockRequest = mock(ReadRequest.class); JsonSchema mockSchema = mock(JsonSchema.class); given(mockMapper.generateJsonSchema((Class<?>) any(Class.class))).willReturn(mockSchema); Promise<ResourceResponse, ResourceException> result = testResource.readInstance(mockServerContext, "invalidCondition", mockRequest); result.getOrThrowUninterruptibly(); }
@Test public void testSuccessfulJsonificationAndReadAndNamePropertyRemoved() throws JsonMappingException, ResourceException { SubjectContext mockSubjectContext = mock(SubjectContext.class); RealmContext realmContext = new RealmContext(mockSubjectContext); Context mockServerContext = ClientContext.newInternalClientContext(realmContext); Subject mockSubject = new Subject(); given(mockSubjectContext.getCallerSubject()).willReturn(mockSubject); ReadRequest mockRequest = mock(ReadRequest.class); JsonSchema mockSchema = mock(JsonSchema.class); given(mockMapper.generateJsonSchema((Class<?>) any(Class.class))).willReturn(mockSchema); Promise<ResourceResponse, ResourceException> result = testResource.readInstance(mockServerContext, TEST_COMBINER, mockRequest); Map resultMap = result.getOrThrowUninterruptibly().getContent().asMap(); assertThat(resultMap.containsKey("title")).isTrue(); assertThat(resultMap.get("title")).isEqualTo(TEST_COMBINER); }