### Question:
XACMLPrivilegeUtils { public static PolicySet addPolicyToPolicySet(Policy policy, PolicySet policySet) throws JAXBException { if (policySet == null || policy == null) { return policySet; } JAXBContext jaxbContext = JAXBContext.newInstance( XACMLConstants.XACML3_CORE_PKG); List<JAXBElement<?>> pList = policySet.getPolicySetOrPolicyOrPolicySetIdReference(); JAXBElement<Policy> policyElement = objectFactory.createPolicy(policy); pList.add(policyElement); return policySet; } private  XACMLPrivilegeUtils(); static String toXACML(Privilege privilege); static String toXML(Policy policy); static String toXML(PolicySet policySet); static void writeXMLToStream(PolicySet policySet, OutputStream outputStream); static Policy privilegeToPolicy(Privilege privilege); static String privilegeNameToPolicyId(String privilegeName,
            String applicationName); static List<AnyOf> entitlementSubjectToAnyOfList(
            EntitlementSubject es); static AnyOf entitlementSubjectToAnyOf(
            EntitlementSubject es); static List<AnyOf> resourceNamesToAnyOfList(
            Set<String> resourceNames, String applicationName); static AnyOf applicationNameToAnyOf(String applicationName); static List<AnyOf> actionNamesToAnyOfList(
            Set<String> actionNames, String applicationName); static Match resourceNameToMatch(String resourceName,
            String applicationName); static Match resourceNameToNotMatch(String resourceName,
            String applicationName); static Match actionNameToMatch(String actionName,
            String applicationName); static Match applicationNameToMatch(String applicationName); static Condition eSubjectConditionToXCondition(
            EntitlementSubject es, EntitlementCondition ec); static String getRuleCombiningAlgId(String applicationName); static Set<Privilege> policySetToPrivileges(PolicySet policySet); static Privilege policyToPrivilege(Policy policy); static String getApplicationNameFromPolicy(Policy policy); static Set<String> getResourceNamesFromPolicy(Policy policy); static String policyIdToPrivilegeName(String policyId); static String getVariableById(Policy policy, String id); static PolicySet privilegesToPolicySet(String realm, Collection<Privilege> privileges); static PolicySet newPolicySet(String realm); static PolicySet addPolicyToPolicySet(Policy policy,
            PolicySet policySet); static Map<String, Boolean> getActionValuesFromPolicy(Policy policy); static EntitlementSubject getEntitlementSubjectFromPolicy(Policy policy); static EntitlementCondition getEntitlementConditionFromPolicy(Policy policy); static PolicySet streamToPolicySet(InputStream stream); static Set<Policy> getPoliciesFromPolicySet(PolicySet policySet); static Policy referralToPolicy(ReferralPrivilege privilege); static Policy referralToPolicyInternal(ReferralPrivilege privilege); static boolean isReferralPolicy(Policy policy); static ReferralPrivilege policyToReferral(Policy policy); static AnyOf realmsAppsResourcesToAnyOf(Set<String> realms,
            Map<String, Set<String>> appsResources); static void validate(Privilege privilege, PrivilegeValidator privilegeValidator); @VisibleForTesting static boolean containsUndesiredCharacters(String s);  }### Answer:
@Test public void shouldAddPolicyToPolicySet() throws JAXBException { Policy policy = new Policy(); PolicySet policySet = new PolicySet(); XACMLPrivilegeUtils.addPolicyToPolicySet(policy, policySet); assertPolicySetContainsSameSinglePolicy(policySet, policy); }
@Test public void shouldNotAddNullToPolicySetAndSoShouldLeavePolicySetUnchanged() throws JAXBException { Policy policy = null; PolicySet policySet = new PolicySet(); XACMLPrivilegeUtils.addPolicyToPolicySet(policy, policySet); assertEquals(policySet.getPolicySetOrPolicyOrPolicySetIdReference().size(), 0, "Expected PolicySet to remain " + "empty as a result of not adding null to the empty PolicySet."); }