use of org.forgerock.json.resource.ActionRequest in project OpenAM by OpenRock.
the class BatchResourceTest method shouldRejectNonBatchActions.
@Test
public void shouldRejectNonBatchActions() {
//given
Context mockContext = Mockito.mock(Context.class);
ActionRequest mockRequest = mock(ActionRequest.class);
given(mockRequest.getAction()).willReturn("false");
@SuppressWarnings("unchecked") ExceptionHandler<ResourceException> handler = mock(ExceptionHandler.class);
//when
Promise<ActionResponse, ResourceException> result = batchResource.actionCollection(mockContext, mockRequest);
result.thenOnException(handler);
//then
verify(handler, times(1)).handleException(any(ResourceException.class));
verifyNoMoreInteractions(handler);
}
use of org.forgerock.json.resource.ActionRequest in project OpenAM by OpenRock.
the class ScriptResourceTest method shouldReturnErrorWhenActionNotRecognised.
@Test(expectedExceptions = NotSupportedException.class)
@SuppressWarnings("unchecked")
public void shouldReturnErrorWhenActionNotRecognised() throws ResourceException {
// given
ActionRequest request = prepareActionRequestForValidate("var a = 123;var b = 456;", "JAVASCRIPT", "invalid_action");
// when
scriptResource.actionCollection(context, request).getOrThrowUninterruptibly();
// then - exception
}
use of org.forgerock.json.resource.ActionRequest in project OpenAM by OpenRock.
the class ScriptResourceTest method shouldReturnErrorWhenNoScriptSpecified.
@Test(expectedExceptions = BadRequestException.class)
@SuppressWarnings("unchecked")
public void shouldReturnErrorWhenNoScriptSpecified() throws ResourceException {
// given
JsonValue requestJson = json(object(field(SCRIPT_LANGUAGE, "JAVASCRIPT")));
ActionRequest request = mock(ActionRequest.class);
when(request.getContent()).thenReturn(requestJson);
when(request.getAction()).thenReturn("validate");
// when
scriptResource.actionCollection(context, request).getOrThrowUninterruptibly();
// then - exception
}
use of org.forgerock.json.resource.ActionRequest in project OpenAM by OpenRock.
the class UmaPolicyResourceTest method shouldThrowNotSupportedExceptionForActionInstance.
@Test
@SuppressWarnings("unchecked")
public void shouldThrowNotSupportedExceptionForActionInstance() {
//Given
Context context = mock(Context.class);
ActionRequest request = Requests.newActionRequest("/policies", "ACTION_ID");
//When
Promise<ActionResponse, ResourceException> result = policyResource.actionInstance(context, "RESOURCE_SET_ID", request);
//Then
assertThat(result).failedWithException().isInstanceOf(NotSupportedException.class);
}
use of org.forgerock.json.resource.ActionRequest in project OpenAM by OpenRock.
the class UmaPolicyResourceTest method shouldThrowNotSupportedExceptionForActionCollection.
@Test
@SuppressWarnings("unchecked")
public void shouldThrowNotSupportedExceptionForActionCollection() {
//Given
Context context = mock(Context.class);
ActionRequest request = Requests.newActionRequest("/policies", "ACTION_ID");
//When
Promise<ActionResponse, ResourceException> result = policyResource.actionCollection(context, request);
//Then
assertThat(result).failedWithException().isInstanceOf(NotSupportedException.class);
}
Aggregations