Search in sources :

Example 6 with DeleteRequest

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);
}
Also used : DeleteRequest(org.forgerock.json.resource.DeleteRequest) Test(org.testng.annotations.Test)

Example 7 with 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();
}
Also used : ResourceResponse(org.forgerock.json.resource.ResourceResponse) ResourceException(org.forgerock.json.resource.ResourceException) DeleteRequest(org.forgerock.json.resource.DeleteRequest) Test(org.testng.annotations.Test)

Example 8 with DeleteRequest

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();
}
Also used : ClientContext(org.forgerock.services.context.ClientContext) RealmContext(org.forgerock.openam.rest.RealmContext) SSOTokenContext(org.forgerock.openam.rest.resource.SSOTokenContext) Context(org.forgerock.services.context.Context) SSOTokenContext(org.forgerock.openam.rest.resource.SSOTokenContext) ResourceResponse(org.forgerock.json.resource.ResourceResponse) ResourceException(org.forgerock.json.resource.ResourceException) Matchers.anyString(org.mockito.Matchers.anyString) DeleteRequest(org.forgerock.json.resource.DeleteRequest) Subject(javax.security.auth.Subject) Test(org.testng.annotations.Test)

Example 9 with DeleteRequest

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;
}
Also used : DeleteRequest(org.forgerock.json.resource.DeleteRequest) ActionResponse(org.forgerock.json.resource.ActionResponse)

Example 10 with DeleteRequest

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();
}
Also used : Router(org.forgerock.json.resource.Router) DeleteRequest(org.forgerock.json.resource.DeleteRequest)

Aggregations

DeleteRequest (org.forgerock.json.resource.DeleteRequest)32 Test (org.testng.annotations.Test)27 ResourceResponse (org.forgerock.json.resource.ResourceResponse)24 ResourceException (org.forgerock.json.resource.ResourceException)23 Context (org.forgerock.services.context.Context)15 JsonValue (org.forgerock.json.JsonValue)9 RealmContext (org.forgerock.openam.rest.RealmContext)7 ArrayList (java.util.ArrayList)6 Subject (javax.security.auth.Subject)6 Matchers.anyString (org.mockito.Matchers.anyString)6 HashSet (java.util.HashSet)5 Responses.newResourceResponse (org.forgerock.json.resource.Responses.newResourceResponse)5 SSOTokenContext (org.forgerock.openam.rest.resource.SSOTokenContext)4 ClientContext (org.forgerock.services.context.ClientContext)4 EntitlementException (com.sun.identity.entitlement.EntitlementException)3 List (java.util.List)3 CreateRequest (org.forgerock.json.resource.CreateRequest)3 Connection (org.forgerock.json.resource.Connection)2 QueryRequest (org.forgerock.json.resource.QueryRequest)2 QueryResourceHandler (org.forgerock.json.resource.QueryResourceHandler)2