use of org.forgerock.openam.entitlement.rest.model.json.TreePolicyRequest in project OpenAM by OpenRock.
the class PolicyRequestFactoryTest method shouldRetrieveTreeRequest.
@Test
public void shouldRetrieveTreeRequest() throws EntitlementException {
// When...
given(subjectContext.getCallerSubject()).willReturn(restSubject);
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("resource", "/resource/a");
given(actionRequest.getContent()).willReturn(JsonValue.json(properties));
// Given...
Context context = buildContextStructure("/abc");
PolicyRequest request = factory.buildRequest(PolicyAction.TREE_EVALUATE, context, actionRequest);
// Then...
assertThat(request).isNotNull();
assertThat(request.getRealm()).isEqualTo("/abc");
assertThat(request).isInstanceOfAny(TreePolicyRequest.class);
TreePolicyRequest treeRequest = (TreePolicyRequest) request;
assertThat(treeRequest.getResource()).isEqualTo("/resource/a");
verify(subjectContext).getCallerSubject();
verify(actionRequest, times(2)).getContent();
verifyNoMoreInteractions(subjectContext, actionRequest);
}
Aggregations