@Test
public void testCreatePatientConsentXACMLPolicy_when_redactActions_is_not_empty() throws SAXException, IOException {

	List<String> redactActions=new ArrayList<String>();
	redactActions.add("treatment");
	redactActions.add("diagnose");
	String result=xACMLPolicyProviderForCDA.createPatientConsentXACMLPolicy(new OrganizationPolicy(), null, null, new ArrayList<String>(), new ArrayList<String>(), redactActions, new ArrayList<String>());
	//Subject to change when xacml schema changes. If that happens you may generate the xacml file and use online xml escaper to change this part.
	assertXMLEqual(result,"<?xml version=\"1.0\" encoding=\"UTF-8\"?><PolicySet xmlns=\"urn:oasis:names:tc:xacml:2.0:policy:schema:os\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:2.0:policy:schema:os http://docs.oasis-open.org/xacml/access_control-xacml-2.0-policy-schema-os.xsd\" PolicySetId=\"null-null\" PolicyCombiningAlgId=\"urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:deny-overrides\"><Target/><!-- DISCLOSURE AUTHORIZATION POLICY --><Policy PolicyId=\"urn:oasis:names:tc:xspa:1.0:nwhin:exchange:query\" RuleCombiningAlgId=\"urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:deny-overrides\"><Description>Denies the request if authorization does not exist.</Description><Target><Resources><Resource><ResourceMatch MatchId=\"urn:oasis:names:tc:xacml:1.0:function:string-equal\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">DocumentQuery</AttributeValue><ResourceAttributeDesignator AttributeId=\"urn:gov:hhs:fha:nhinc:service-type\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"/></ResourceMatch></Resource><Resource><ResourceMatch MatchId=\"urn:oasis:names:tc:xacml:1.0:function:string-equal\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">DocumentRetrieve</AttributeValue><ResourceAttributeDesignator AttributeId=\"urn:gov:hhs:fha:nhinc:service-type\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"/></ResourceMatch></Resource></Resources></Target><Rule RuleId=\"urn:gov:hhs:fha:nhinc:docquery:notauthorized\" Effect=\"Permit\"><Description>If request is to disclose then permit.</Description><Target/><Condition><Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-equal\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Disclose</AttributeValue><ResourceAttributeDesignator AttributeId=\"urn:oasis:names:tc:xspa:2.0:resource:patient:authorization\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"/></Apply></Condition></Rule><Rule RuleId=\"urn:gov:hhs:fha:nhinc:docquery:allowedpous\" Effect=\"Deny\"><Description>If request in not in list then deny.</Description><Target/><Condition><Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:not\"><Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of\"><SubjectAttributeDesignator AttributeId=\"urn:oasis:names:tc:xspa:1.0:subject:purposeofuse\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"/><Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-bag\"></Apply></Apply></Apply></Condition></Rule><Rule RuleId=\"urn:gov:hhs:fha:nhinc:docquery:allowedrecipients\" Effect=\"Deny\"><Description>If request in not in list then deny.</Description><Target/><Condition><Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:not\"><Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of\"><SubjectAttributeDesignator AttributeId=\"urn:oasis:names:tc:xacml:2.0:subject:subject-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"/><Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-bag\"></Apply></Apply></Apply></Condition></Rule><Rule RuleId=\"urn:gov:hhs:fha:nhinc:docquery:requiredpermissions\" Effect=\"Deny\"><Description>If request in not in list then deny.</Description><Target/><Condition><Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:not\"><Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-subset\"><Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-bag\"></Apply><SubjectAttributeDesignator AttributeId=\"urn:oasis:names:tc:xspa:2.0:subject:sensitivity:privileges\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"/></Apply></Apply></Condition></Rule></Policy><!-- DATA REDACTION POLICY --><Policy PolicyId=\"urn:gov:hhs:onc:ds4p:redact\" RuleCombiningAlgId=\"urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:deny-overrides\"><Target><Resources><Resource><ResourceMatch MatchId=\"urn:oasis:names:tc:xacml:1.0:function:string-equal\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">DS4PRedactAuthorization</AttributeValue><ResourceAttributeDesignator AttributeId=\"urn:gov:hhs:fha:nhinc:service-type\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"/></ResourceMatch></Resource></Resources></Target><Rule RuleId=\"urn:gov:hhs:onc:ds4p:anyServiceType:RedactAllowRule\" Effect=\"Permit\"><Description>Determine is Redaction is allowed for specific data sensitivity</Description><Target/><Condition><Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of\"><ResourceAttributeDesignator AttributeId=\"urn:oasis:names:tc:xspa:2.0:resource:redactauthorization\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"/><Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-bag\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">treatment</AttributeValue><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">diagnose</AttributeValue></Apply></Apply></Condition></Rule><Rule RuleId=\"urn:gov:hhs:onc:ds4p:anyServiceType:RedactDenyRule\" Effect=\"Deny\"><Description>Determine is Redaction is not allowed for specific data sensitivity</Description><Target/><Condition><Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:not\"><Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of\"><ResourceAttributeDesignator AttributeId=\"urn:oasis:names:tc:xspa:2.0:resource:redactauthorization\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"/><Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-bag\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">treatment</AttributeValue><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">diagnose</AttributeValue></Apply></Apply></Apply></Condition></Rule></Policy><!-- EMERGENCY TREATMENT OVERRIDE POLICY --><Policy PolicyId=\"urn:gov:hhs:fha:nhinc:anyServiceType:EmergencyPolicy\" RuleCombiningAlgId=\"urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:permit-overrides\"><Target/><Rule RuleId=\"urn:gov:hhs:fha:nhinc:anyServiceType:EmergencyRule\" Effect=\"Permit\"><Description>Purpose of Use is Emergency so Permit All</Description><Target/><Condition><Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-equal\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">ETREAT</AttributeValue><SubjectAttributeDesignator AttributeId=\"urn:oasis:names:tc:xspa:1.0:subject:purposeofuse\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"/></Apply></Condition></Rule></Policy></PolicySet>");
}