use of com.sun.identity.entitlement.xacml3.core.Version in project OpenAM by OpenRock.
the class XACMLPrivilegeUtilsTest method assertPolicySetContentsMatchPrivilegesContent.
private void assertPolicySetContentsMatchPrivilegesContent(PolicySet policySet, Set<Privilege> privileges) {
if (privileges != null && !privileges.isEmpty()) {
assertTrue(policySet != null, "Expected PolicySet to not be null.");
}
List<Policy> policies = getPoliciesFromPolicySet(policySet);
assertEquals(policies.size(), privileges.size(), "Mismatch between number of Policy elements in PolicySet, " + "and number of original Privileges.");
List<String> policyIdList = new ArrayList<String>();
for (Policy policy : policies) {
policyIdList.add(policy.getPolicyId());
}
List<String> privilegeIdList = new ArrayList<String>();
for (Privilege privilege : privileges) {
privilegeIdList.add(privilege.getName());
}
assertTrue(policyIdList.containsAll(privilegeIdList), "Not all Privilege names were included in the " + "PolicySet.");
assertTrue(privilegeIdList.containsAll(policyIdList), "Extra names were added to the PolicySet which were " + "not in the list of Privilege names.");
List<String> descriptionList = new ArrayList<String>();
for (Policy policy : policies) {
descriptionList.add(policy.getDescription());
}
for (Privilege privilege : privileges) {
String description = privilege.getDescription();
assertTrue(descriptionList.contains(description), "Privilege with description '" + description + "' not " + "found in PolicySet.");
}
String privilegesVersion = formatMillisecondsAsTimestamp(now);
for (Policy policy : policies) {
assertEquals(policy.getVersion().getValue(), privilegesVersion, "Policy found with version not matching " + "Privilege creation date.");
}
}
Aggregations