use of org.forgerock.json.resource.ActionResponse in project OpenAM by OpenRock.
the class UmaEnabledFilterTest method testFilterAction.
@Test(dataProvider = "factories")
public void testFilterAction(UmaProviderSettingsFactory factory, boolean expectFailure) throws Exception {
// Given
UmaEnabledFilter filter = new UmaEnabledFilter(factory);
ActionRequest request = Requests.newActionRequest("test", "test", "test");
// When
Promise<ActionResponse, ResourceException> promise = filter.filterAction(context, request, requestHandler);
// Then
checkResult(expectFailure, promise);
if (expectFailure) {
verifyNoMoreInteractions(requestHandler);
} else {
verify(requestHandler).handleAction(context, request);
}
}
use of org.forgerock.json.resource.ActionResponse in project OpenAM by OpenRock.
the class ResourceSetResourceTest method revokeAllUserPoliciesActionShouldHandleResourceException.
@Test
public void revokeAllUserPoliciesActionShouldHandleResourceException() {
//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(new NotFoundException().<Void>asPromise());
//When
Promise<ActionResponse, ResourceException> promise = resource.actionCollection(context, request);
//Then
assertThat(promise).failedWithException().isInstanceOf(ResourceException.class);
}
use of org.forgerock.json.resource.ActionResponse in project OpenAM by OpenRock.
the class ResourceSetResourceTest method actionInstanceShouldNotBeSupported.
@Test
public void actionInstanceShouldNotBeSupported() {
//Given
Context context = mock(Context.class);
ActionRequest request = mock(ActionRequest.class);
//When
Promise<ActionResponse, ResourceException> promise = resource.actionInstance(context, "RESOURCE_SET_UID", request);
//Then
assertThat(promise).failedWithException().isInstanceOf(NotSupportedException.class);
}
Aggregations