use of org.forgerock.json.resource.ResourceException in project OpenAM by OpenRock.
the class PendingRequestResourceTest method actionInstanceShouldHandleDenyAction.
@SuppressWarnings("unchecked")
@Test
public void actionInstanceShouldHandleDenyAction() throws Exception {
//Given
Context context = mockContext("REALM");
ActionRequest request = Requests.newActionRequest("", "deny");
mockPendingRequestsForUser("alice", "REALM", 1);
//When
Promise<ActionResponse, ResourceException> promise = resource.actionCollection(context, request);
//Then
verify(service).denyPendingRequest(anyString(), anyString());
assertThat(promise).succeeded();
}
use of org.forgerock.json.resource.ResourceException in project OpenAM by OpenRock.
the class PendingRequestResourceTest method shouldReadPendingRequest.
@SuppressWarnings("unchecked")
@Test
public void shouldReadPendingRequest() throws Exception {
//Given
Context context = mock(Context.class);
ReadRequest request = Requests.newReadRequest("");
String id = mockPendingRequest();
//When
Promise<ResourceResponse, ResourceException> promise = resource.readInstance(context, id, request);
//Then
assertThat(promise).succeeded();
}
use of org.forgerock.json.resource.ResourceException in project OpenAM by OpenRock.
the class PendingRequestResourceTest method actionCollectionShouldHandleApproveAction.
@SuppressWarnings("unchecked")
@Test
public void actionCollectionShouldHandleApproveAction() throws Exception {
//Given
Context context = mockContext("REALM");
ActionRequest request = Requests.newActionRequest("", "approve");
mockPendingRequestsForUser("alice", "REALM", 2);
mockPendingRequestApprovalService();
//When
Promise<ActionResponse, ResourceException> promise = resource.actionCollection(context, request);
//Then
verify(service, times(2)).approvePendingRequest(eq(context), anyString(), any(JsonValue.class), anyString());
assertThat(promise).succeeded();
}
use of org.forgerock.json.resource.ResourceException in project OpenAM by OpenRock.
the class PendingRequestResourceTest method actionInstanceShouldReturnNotSupportedExceptionForUnsupportedAction.
@SuppressWarnings("unchecked")
@Test
public void actionInstanceShouldReturnNotSupportedExceptionForUnsupportedAction() {
//Given
Context context = mock(Context.class);
ActionRequest request = Requests.newActionRequest("", "other");
//When
Promise<ActionResponse, ResourceException> promise = resource.actionCollection(context, request);
//Then
assertThat(promise).failedWithResourceException().isInstanceOf(NotSupportedException.class);
}
use of org.forgerock.json.resource.ResourceException in project OpenAM by OpenRock.
the class ResourceSetResourceTest method actionCollectionShouldHandleUnsupportedAction.
@Test
public void actionCollectionShouldHandleUnsupportedAction() {
//Given
Context context = mock(Context.class);
ActionRequest request = mock(ActionRequest.class);
given(request.getAction()).willReturn("UNSUPPORTED_ACTION");
//When
Promise<ActionResponse, ResourceException> promise = resource.actionCollection(context, request);
//Then
assertThat(promise).failedWithException().isInstanceOf(NotSupportedException.class);
}
Aggregations