use of org.forgerock.json.resource.DeleteRequest in project OpenAM by OpenRock.
the class PolicyV1FilterTest method forwardOnDelete.
/**
* Verify that delete requests are forwarded on.
*/
@Test
public void forwardOnDelete() {
// Given
DeleteRequest deleteRequest = mock(DeleteRequest.class);
// When
filter.filterDelete(context, deleteRequest, requestHandler);
// Then
verify(requestHandler).handleDelete(context, deleteRequest);
}
use of org.forgerock.json.resource.DeleteRequest in project OpenAM by OpenRock.
the class PolicyResourceTest method shouldDeletePoliciesFromStore.
@Test
public void shouldDeletePoliciesFromStore() throws Exception {
// Given
String id = "uniqueId";
DeleteRequest request = mock(DeleteRequest.class);
// When
Promise<ResourceResponse, ResourceException> promise = policyResource.deleteInstance(mockServerContext, id, request);
// Then
verify(mockStore).delete(id);
assertThat(promise).succeeded().withId().isNotNull();
}
use of org.forgerock.json.resource.DeleteRequest in project OpenAM by OpenRock.
the class ApplicationsResourceTest method shouldNotDeleteInstanceWhenSubjectIsNull.
@Test(expectedExceptions = BadRequestException.class)
public void shouldNotDeleteInstanceWhenSubjectIsNull() throws EntitlementException, ResourceException {
//Given
SSOTokenContext subjectContext = mock(SSOTokenContext.class);
Context context = ClientContext.newInternalClientContext(subjectContext);
String resourceId = "RESOURCE_ID";
DeleteRequest request = mock(DeleteRequest.class);
Subject subject = null;
given(subjectContext.getCallerSubject()).willReturn(subject);
//When
Promise<ResourceResponse, ResourceException> result = applicationsResource.deleteInstance(context, resourceId, request);
//Then
verify(applicationManagerWrapper, never()).deleteApplication(subject, "REALM", resourceId);
result.getOrThrowUninterruptibly();
}
use of org.forgerock.json.resource.DeleteRequest in project OpenAM by OpenRock.
the class PolicyResourceWithCopyMoveSupport method movePolicy.
private ActionResponse movePolicy(Context context, String resourceId, ActionRequest request) throws ResourceException {
ActionResponse copyResponse = copyPolicy(context, resourceId, request);
DeleteRequest deleteRequest = Requests.newDeleteRequest("policies", resourceId);
router.handleDelete(context, deleteRequest).getOrThrowUninterruptibly();
return copyResponse;
}
use of org.forgerock.json.resource.DeleteRequest in project OpenAM by OpenRock.
the class Requester method delete.
/**
* Request to delete a specified resource at a specified endpoint.
*
* @param location Endpoint destination of this request. May not be null.
* @param resourceId Resource ID to delete. May not be null.
* @param context Context of this request.
* @return The {@link org.forgerock.json.JsonValue} returned from the endpoint.
* @throws ResourceException If any exception occurred during processing.
*/
public JsonValue delete(String location, String resourceId, Context context) throws ResourceException {
Reject.ifTrue(StringUtils.isEmpty(location), "The endpoint destination may not be null or empty.");
Reject.ifTrue(StringUtils.isEmpty(resourceId), "The resourceId to delete may not be null or empty.");
final Router rootRouter = router.get();
final DeleteRequest deleteRequest = Requests.newDeleteRequest(location, resourceId);
return rootRouter.handleDelete(context, deleteRequest).getOrThrowUninterruptibly().getContent();
}
Aggregations