Search in sources :

Example 31 with DeleteRequest

use of org.forgerock.json.resource.DeleteRequest in project OpenAM by OpenRock.

the class UmaEnabledFilterTest method testFilterDelete.

@Test(dataProvider = "factories")
public void testFilterDelete(UmaProviderSettingsFactory factory, boolean expectFailure) throws Exception {
    // Given
    UmaEnabledFilter filter = new UmaEnabledFilter(factory);
    DeleteRequest request = Requests.newDeleteRequest("test");
    // When
    Promise<ResourceResponse, ResourceException> promise = filter.filterDelete(context, request, requestHandler);
    // Then
    checkResult(expectFailure, promise);
    if (expectFailure) {
        verifyNoMoreInteractions(requestHandler);
    } else {
        verify(requestHandler).handleDelete(context, request);
    }
}
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 32 with DeleteRequest

use of org.forgerock.json.resource.DeleteRequest in project OpenAM by OpenRock.

the class UmaPolicyResourceTest method shouldHandledFailedDeletePolicy.

@Test
@SuppressWarnings("unchecked")
public void shouldHandledFailedDeletePolicy() {
    //Given
    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);
    //When
    Promise<ResourceResponse, ResourceException> result = policyResource.deleteInstance(context, "RESOURCE_SET_UID", request);
    //Then
    assertThat(result).failedWithResourceException().isEqualTo(resourceException);
}
Also used : Context(org.forgerock.services.context.Context) ResourceResponse(org.forgerock.json.resource.ResourceResponse) ResourceException(org.forgerock.json.resource.ResourceException) DeleteRequest(org.forgerock.json.resource.DeleteRequest) Test(org.testng.annotations.Test)

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