### Question:
UmaPolicy { public static String idOf(JsonValue policy) throws BadRequestException { if (!policy.isDefined(POLICY_ID_KEY)) { throw new BadRequestException("Missing required field: " + POLICY_ID_KEY); } return policy.get(POLICY_ID_KEY).asString(); } private  UmaPolicy(ResourceSetDescription resourceSet, JsonValue policy, Collection<String> underlyingPolicyIds); static String idOf(JsonValue policy); static UmaPolicy valueOf(ResourceSetDescription resourceSet, JsonValue policy); static UmaPolicy fromUnderlyingPolicies(ResourceSetDescription resourceSet, Collection<ResourceResponse> policies); String getId(); String getRevision(); JsonValue asJson(); Collection<String> getUnderlyingPolicyIds(); synchronized Set<String> getScopes(); Set<JsonValue> asUnderlyingPolicies(String policyOwnerName); @Override boolean equals(Object o); @Override int hashCode(); synchronized Set<String> getSubjects(); String getResourceServerId(); ResourceSetDescription getResourceSet();  }### Answer:
@Test(expectedExceptions = BadRequestException.class) public void shouldFailForMissingIdOfPolicy() throws Exception { JsonValue policy = json(object()); String policyId = UmaPolicy.idOf(policy); }
@Test public void shouldGetIdOfPolicy() throws Exception { JsonValue policy = createUmaPolicyJson(); String policyId = UmaPolicy.idOf(policy); assertThat(policyId).isEqualTo("POLICY_ID"); }