Search in sources :

Example 1 with TreePolicyRequest

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);
}
Also used : Context(org.forgerock.services.context.Context) ClientContext(org.forgerock.services.context.ClientContext) SubjectContext(org.forgerock.openam.rest.resource.SubjectContext) RealmContext(org.forgerock.openam.rest.RealmContext) HashMap(java.util.HashMap) TreePolicyRequest(org.forgerock.openam.entitlement.rest.model.json.TreePolicyRequest) TreePolicyRequest(org.forgerock.openam.entitlement.rest.model.json.TreePolicyRequest) PolicyRequest(org.forgerock.openam.entitlement.rest.model.json.PolicyRequest) BatchPolicyRequest(org.forgerock.openam.entitlement.rest.model.json.BatchPolicyRequest) Test(org.testng.annotations.Test)

Aggregations

HashMap (java.util.HashMap)1 BatchPolicyRequest (org.forgerock.openam.entitlement.rest.model.json.BatchPolicyRequest)1 PolicyRequest (org.forgerock.openam.entitlement.rest.model.json.PolicyRequest)1 TreePolicyRequest (org.forgerock.openam.entitlement.rest.model.json.TreePolicyRequest)1 RealmContext (org.forgerock.openam.rest.RealmContext)1 SubjectContext (org.forgerock.openam.rest.resource.SubjectContext)1 ClientContext (org.forgerock.services.context.ClientContext)1 Context (org.forgerock.services.context.Context)1 Test (org.testng.annotations.Test)1