use of org.forgerock.openam.entitlement.rest.model.json.BatchPolicyRequest in project OpenAM by OpenRock.
the class PolicyRequestFactoryTest method shouldRetrieveBatchRequest.
@Test
public void shouldRetrieveBatchRequest() throws EntitlementException {
// When...
given(subjectContext.getCallerSubject()).willReturn(restSubject);
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("resources", Arrays.asList("/resource/a", "/resource/b"));
given(actionRequest.getContent()).willReturn(JsonValue.json(properties));
// Given...
Context context = buildContextStructure("/abc");
PolicyRequest request = factory.buildRequest(PolicyAction.EVALUATE, context, actionRequest);
// Then...
assertThat(request).isNotNull();
assertThat(request.getRealm()).isEqualTo("/abc");
assertThat(request).isInstanceOfAny(BatchPolicyRequest.class);
BatchPolicyRequest batchRequest = (BatchPolicyRequest) request;
assertThat(batchRequest.getResources()).containsOnly("/resource/a", "/resource/b");
verify(subjectContext).getCallerSubject();
verify(actionRequest, times(2)).getContent();
verifyNoMoreInteractions(subjectContext, actionRequest);
}
use of org.forgerock.openam.entitlement.rest.model.json.BatchPolicyRequest in project OpenAM by OpenRock.
the class BatchPolicyRequestTest method shouldConstructBatchPolicyRequest.
@Test
public void shouldConstructBatchPolicyRequest() throws EntitlementException {
given(subjectContext.getCallerSubject()).willReturn(restSubject);
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("resources", Arrays.asList("/resource/a", "/resource/b"));
given(actionRequest.getContent()).willReturn(JsonValue.json(properties));
Context context = buildContextStructure("/abc");
BatchPolicyRequest request = BatchPolicyRequest.getBatchPolicyRequest(context, actionRequest, tokenManager);
assertThat(request).isNotNull();
assertThat(request.getResources()).containsOnly("/resource/a", "/resource/b");
verify(subjectContext).getCallerSubject();
verify(actionRequest, times(2)).getContent();
verifyNoMoreInteractions(subjectContext, actionRequest);
}
Aggregations