### Question:
UmaPolicyResource implements CollectionResourceProvider { @Override public Promise<ResourceResponse, ResourceException> deleteInstance(Context context, final String resourceId, DeleteRequest request) { return umaPolicyService.deletePolicy(context, resourceId) .thenAsync(new AsyncFunction<Void, ResourceResponse, ResourceException>() { @Override public Promise<ResourceResponse, ResourceException> apply(Void value) throws ResourceException { return newResultPromise(newResourceResponse(resourceId, "0", json(object()))); } }); } @Inject  UmaPolicyResource(UmaPolicyService umaPolicyService); @Override Promise<ResourceResponse, ResourceException> createInstance(Context context, CreateRequest request); @Override Promise<ResourceResponse, ResourceException> readInstance(Context context, final String resourceId,
            ReadRequest request); @Override Promise<ResourceResponse, ResourceException> updateInstance(Context context, String resourceId,
            UpdateRequest request); @Override Promise<ResourceResponse, ResourceException> deleteInstance(Context context, final String resourceId,
            DeleteRequest request); @Override Promise<ResourceResponse, ResourceException> patchInstance(Context context, String resourceId,
            PatchRequest request); @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, final QueryRequest request,
            final QueryResourceHandler handler);  }### Answer:
@Test @SuppressWarnings("unchecked") public void shouldSuccessfullyDeletePolicy() { Context context = mock(Context.class); DeleteRequest request = Requests.newDeleteRequest("/policies"); Promise<Void, ResourceException> promise = Promises.newResultPromise(null); given(policyService.deletePolicy(context, "RESOURCE_SET_UID")).willReturn(promise); Promise<ResourceResponse, ResourceException> result = policyResource.deleteInstance(context, "RESOURCE_SET_UID", request); assertThat(result).succeeded().withId().isEqualTo("RESOURCE_SET_UID"); assertThat(result).succeeded().withRevision().isEqualTo("0"); assertThat(result).succeeded().withContent().isEmpty(); }
@Test @SuppressWarnings("unchecked") public void shouldHandledFailedDeletePolicy() { Context context = mock(Context.class); DeleteRequest request = Requests.newDeleteRequest("/policies"); ResourceException resourceException = mock(ResourceException.class); Promise<Void, ResourceException> promise = Promises.newExceptionPromise(resourceException); given(policyService.deletePolicy(context, "RESOURCE_SET_UID")).willReturn(promise); Promise<ResourceResponse, ResourceException> result = policyResource.deleteInstance(context, "RESOURCE_SET_UID", request); assertThat(result).failedWithResourceException().isEqualTo(resourceException); }