use of org.forgerock.json.resource.ActionResponse in project OpenAM by OpenRock.
the class ResourceSetResourceTest method shouldRevokeAllUserPolicies.
@Test
public void shouldRevokeAllUserPolicies() throws ResourceException {
//Given
Context context = mock(Context.class);
ActionRequest request = mock(ActionRequest.class);
given(contextHelper.getRealm(context)).willReturn("REALM");
given(contextHelper.getUserId(context)).willReturn("RESOURCE_OWNER_ID");
given(request.getAction()).willReturn("revokeAll");
given(resourceSetService.revokeAllPolicies(context, "REALM", "RESOURCE_OWNER_ID")).willReturn(Promises.<Void, ResourceException>newResultPromise(null));
//When
Promise<ActionResponse, ResourceException> promise = resource.actionCollection(context, request);
//Then
assertThat(promise).succeeded().withObject().isNotNull();
JsonValue jsonContent = promise.getOrThrowUninterruptibly().getJsonContent();
assertThat(jsonContent.asMap()).isEmpty();
}
use of org.forgerock.json.resource.ActionResponse 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.ActionResponse 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.ActionResponse 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.ActionResponse 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