### Question:
XACMLPrivilegeUtils { public static Policy referralToPolicy(ReferralPrivilege privilege) throws JSONException { Policy policy = null; try { policy = referralToPolicyInternal(privilege); } catch (JAXBException je) { PrivilegeManager.debug.error( "JAXBException while mapping referral to policy:", je); } return policy; } 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 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 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);  }### Answer:
@Test public void shouldReturnXACMLPolicyWhenGivenValidReferralPrivilegeSet() throws JSONException, EntitlementException { ReferralPrivilege referralPrivilege = createArbitraryReferralPrivilege("ReferralPrivilege1", now); Policy policy = XACMLPrivilegeUtils.referralToPolicy(referralPrivilege); assertPolicyContentMatchesReferralPrivilegeContent(policy, referralPrivilege); }
@Test public void shouldReturnNullWhenGivenNullAsReferralPrivilege() throws JSONException { ReferralPrivilege referralPrivilege = null; Policy policy = XACMLPrivilegeUtils.referralToPolicy(referralPrivilege); assertNull(policy, "Expected Policy to be null."); }