### Question:
PolicyRequest { public Subject getPolicySubject() { return policySubject; } PolicyRequest(final PolicyRequestBuilder<?> builder); Subject getRestSubject(); Subject getPolicySubject(); String getApplication(); String getRealm(); Map<String, Set<String>> getEnvironment(); abstract List<Entitlement> dispatch(PolicyEvaluator evaluator);  }### Answer:
@Test public void shouldAllowJsonSubject() throws Exception { final String subjectName = "test"; given(subjectContext.getCallerSubject()).willReturn(restSubject); final JsonValue jwt = getJsonSubject(subjectName); given(actionRequest.getContent()).willReturn(json(object(field("subject", object(field("claims", jwt.asMap())))))); Context context = buildContextStructure("/abc"); PolicyRequest request = getRequest(context, actionRequest); Subject policySubject = request.getPolicySubject(); Set<JwtPrincipal> jwtPrincipals = policySubject.getPrincipals(JwtPrincipal.class); assertThat(jwtPrincipals).hasSize(1); assertThat(jwtPrincipals).contains(new JwtPrincipal(jwt)); }
@Test public void shouldAllowJwtSubject() throws Exception { final String subjectName = "test"; given(subjectContext.getCallerSubject()).willReturn(restSubject); Jwt jwt = getJwtSubject(subjectName); given(actionRequest.getContent()).willReturn(json(object(field("subject", object(field("jwt", jwt.build())))))); Context context = buildContextStructure("/abc"); PolicyRequest request = getRequest(context, actionRequest); Subject policySubject = request.getPolicySubject(); Set<JwtPrincipal> jwtPrincipals = policySubject.getPrincipals(JwtPrincipal.class); assertThat(jwtPrincipals).hasSize(1); assertThat(jwtPrincipals).contains(new JwtPrincipal(getJsonSubject(subjectName))); }