[Policy-52, Policy-92, Policy-93] Policy Enhancements and bugfixes 87/6187/2
authorTarun Tej Velaga <tt3868@att.com>
Mon, 24 Jul 2017 17:13:43 +0000 (17:13 +0000)
committerTarun Tej Velaga <tt3868@att.com>
Tue, 25 Jul 2017 14:23:59 +0000 (14:23 +0000)
Change-Id: I5675cf4527e17963b3142cf7184c0df31a766197
Signed-off-by: Tarun Tej Velaga <tt3868@att.com>
152 files changed:
BRMSGateway/dependency.json
BRMSGateway/src/main/java/org/openecomp/policy/brmsInterface/BRMSPush.java
ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/Constraint.java
ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopParameter.java [new file with mode: 0644]
ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/GuardPolicy.java
ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/MatchParameters.java [new file with mode: 0644]
ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java
ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/policy_guard_1707_appc.yaml
ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/policy_guard_OpenECOMP_demo_vDNS.yaml
ECOMP-PAP-REST/pip.properties
ECOMP-PAP-REST/src/main/java/hibernate.cfg.xml [deleted file]
ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/DecisionPolicy.java
ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/Policy.java
ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/SafePolicyBuilder.java
ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.java
ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/BRMSDictionaryController.java
ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java
ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryController.java
ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/DescriptiveDictionaryController.java
ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/DictionaryController.java
ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/FirewallDictionaryController.java
ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/MicroServiceDictionaryController.java
ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/SafePolicyController.java
ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/elk/client/ElkConnectorImpl.java
ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/elk/client/PolicyElasticData.java
ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/elk/client/PolicyElasticSearchController.java
ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/policycontroller/PolicyCreation.java
ECOMP-PAP-REST/src/main/resources/Decision_GuardBLPolicyTemplate.xml
ECOMP-PAP-REST/src/main/resources/Decision_GuardPolicyTemplate.xml
ECOMP-PAP-REST/src/test/java/org/openecomp/policy/pap/ia/DbAuditCompareEntriesTest.java
ECOMP-PAP-REST/src/test/java/org/openecomp/policy/pap/xacml/rest/controller/DictionaryControllerTest.java
ECOMP-PAP-REST/src/test/java/org/openecomp/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.java
ECOMP-PDP-REST/pom.xml
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/XACMLPdpServlet.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/controller/PolicyEngineServices.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/ActionPolicyService.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/BRMSParamPolicyService.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/ClosedLoopFaultPolicyService.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/ClosedLoopPMPolicyService.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/ConfigPolicyService.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/CreateUpdateConfigPolicyService.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/CreateUpdateDictionaryService.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/CreateUpdateFirewallPolicyService.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/DeletePolicyService.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/FirewallPolicyService.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/GetConfigService.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/GetDecisionService.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/GetDictionaryService.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/GetMetricsService.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/MicroServicesPolicyService.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/NotificationService.java [new file with mode: 0644]
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PAPServices.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PDPServices.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PushPolicyService.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/SendEventService.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationController.java
ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationServer.java
ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/XACMLPdpServletTest.java
ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/services/PDPServicesTest.java [new file with mode: 0644]
ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/test/NotificationAPITest.java [new file with mode: 0644]
ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/test/PolicyEngineServicesTest.java [new file with mode: 0644]
ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/test/getConfigTest.java [new file with mode: 0644]
ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/test/getDictionaryTest.java [new file with mode: 0644]
ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/auth/test/FilterTests.java [new file with mode: 0644]
ECOMP-PDP-REST/src/test/resources/client.properties [new file with mode: 0644]
ECOMP-PDP-REST/src/test/resources/fail.xacml.pdp.properties [new file with mode: 0644]
ECOMP-PDP-REST/src/test/resources/pass.xacml.pdp.properties [new file with mode: 0644]
ECOMP-PDP-REST/src/test/resources/test.drl [new file with mode: 0644]
ECOMP-PDP-REST/xacml.pdp.properties
ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/pdp/std/functions/FunctionDefinitionCustomRegexpMatch.java
ECOMP-REST/src/main/java/org/openecomp/policy/rest/adapter/YAMLParams.java
ECOMP-SDK-APP/src/main/webapp/WEB-INF/fusion/conf/fusion.properties
ECOMP-XACML/src/main/java/org/openecomp/policy/xacml/std/pip/engines/OperationHistoryEngine.java [new file with mode: 0644]
ECOMP-XACML/src/main/java/org/openecomp/policy/xacml/std/pip/engines/aaf/AAFEngine.java
ECOMP-XACML/src/main/resources/META-INF/operationHistoryPU.xml [new file with mode: 0644]
ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/DOMResponseConformanceTest.java [deleted file]
ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/DOMResponseTest.java [deleted file]
ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestAnnotation.java [deleted file]
ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestBase.java [deleted file]
ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestPolicy.java [deleted file]
ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/XACMLEngineTest.java [deleted file]
ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/RequestCategoryTest.java [deleted file]
ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/RequestConformanceTest.java [deleted file]
ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/RequestDefaultCategoryTest.java [deleted file]
ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/RequestMainTest.java [deleted file]
ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/ResponseConformanceTest.java [deleted file]
ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/ResponseTest.java [deleted file]
ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/std/pap/StdEngineFactoryTest.java [new file with mode: 0644]
ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/util/AAFEngineTest.java [new file with mode: 0644]
ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/util/MetricsUtilTest.java [new file with mode: 0644]
ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/util/XACMLPolicyScannerTest.java [new file with mode: 0644]
ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/util/XACMLPolicyWriterTest.java [new file with mode: 0644]
ECOMP-XACML/src/test/resources/Action_TestActionPolicy.1.xml [new file with mode: 0644]
ECOMP-XACML/src/test/resources/Config_SampleTest1206.1.xml [new file with mode: 0644]
ECOMP-XACML/src/test/resources/pdps/default/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml [new file with mode: 0644]
ECOMP-XACML/src/test/resources/pdps/default/xacml.pip.properties [new file with mode: 0644]
ECOMP-XACML/src/test/resources/pdps/default/xacml.policy.properties [new file with mode: 0644]
ECOMP-XACML/src/test/resources/pdps/xacml.properties [new file with mode: 0644]
POLICY-SDK-APP/config/policyLogger.properties [new file with mode: 0644]
POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyManagerServlet.java
POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyNotificationMail.java
POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java
POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/ActionPolicyController.java
POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java
POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSRawController.java
POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopFaultController.java
POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopPMController.java
POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateDcaeMicroServiceController.java
POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateFirewallController.java
POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DashboardController.java
POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DecisionPolicyController.java
POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java
POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java
POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyValidationController.java
POLICY-SDK-APP/src/main/webapp/app/policyApp/CSS/bootstrap/docs/assets/js/vendor/autoprefixer.js
POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/PushtabWindow/removeGroupPoliciesWindow.html
POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js
POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js
POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DCAEMicroServicePolicyTemplate.html
POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DecisionPolicyTemplate.html
POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/css/main.css
POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/modals.html
POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/searchNavbar.html
POLICY-SDK-APP/src/test/java/org/openecomp/policy/admin/PolicyManagerServletTest.java
POLICY-SDK-APP/src/test/java/org/openecomp/policy/controller/AdminTabControllerTest.java
POLICY-SDK-APP/src/test/java/org/openecomp/policy/controller/CreateDcaeMicroServiceControllerTest.java
POLICY-SDK-APP/src/test/resources/Action_TestActionPolicy.1.xml [new file with mode: 0644]
POLICY-SDK-APP/src/test/resources/Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml [new file with mode: 0644]
POLICY-SDK-APP/src/test/resources/Config_BRMS_Raw_TestBRMSRawPolicy.1.xml [new file with mode: 0644]
POLICY-SDK-APP/src/test/resources/Config_FW_TestFireWallPolicy.1.xml [new file with mode: 0644]
POLICY-SDK-APP/src/test/resources/Config_Fault_TestClosedLoopPolicy.1.xml [new file with mode: 0644]
POLICY-SDK-APP/src/test/resources/Config_MS_vFirewall.1.xml [new file with mode: 0644]
POLICY-SDK-APP/src/test/resources/Config_PM_TestClosedLoopPMPolicy.1.xml [new file with mode: 0644]
POLICY-SDK-APP/src/test/resources/Config_SampleTest1206.1.xml
POLICY-SDK-APP/src/test/resources/Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml [new file with mode: 0644]
POLICY-SDK-APP/src/test/resources/JSONConfig.json [new file with mode: 0644]
POLICY-SDK-APP/src/test/resources/com.Action_TestActionPolicy.1.json [new file with mode: 0644]
POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt [new file with mode: 0644]
POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Raw_TestBRMSRawPolicy.1.txt [new file with mode: 0644]
POLICY-SDK-APP/src/test/resources/com.Config_FW_TestFireWallPolicy.1.json [new file with mode: 0644]
POLICY-SDK-APP/src/test/resources/com.Config_Fault_TestClosedLoopPolicy.1.json [new file with mode: 0644]
POLICY-SDK-APP/src/test/resources/com.Config_MS_vFirewall.1.json [new file with mode: 0644]
POLICY-SDK-APP/src/test/resources/com.Config_PM_TestClosedLoopPMPolicy.1.json [new file with mode: 0644]
PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryType.java
PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientEnd.java
PolicyEngineUtils/src/main/java/org/openecomp/policy/utils/PolicyUtils.java
packages/base/src/files/install/elk/config/elasticsearch.yml
packages/base/src/files/install/servers/brmsgw/dependency.json
packages/base/src/files/install/servers/pap/bin/pip.properties
packages/base/src/files/install/servers/pdp/bin/xacml.pdp.properties
packages/install/src/files/pdp.conf

index adf56b7..a883cc9 100644 (file)
@@ -6,7 +6,7 @@
                        "version": "1.1.0-SNAPSHOT"
                }, {
                        "groupId": "org.onap.policy.drools-applications",
-                       "artifactId": "controlloop",
+                       "artifactId": "events",
                        "version": "1.1.0-SNAPSHOT"
                }, {
                        "groupId": "org.onap.policy.drools-applications",
index 3254eac..def57e2 100644 (file)
@@ -99,7 +99,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
  * BRMSPush: Application responsible to push policies to the BRMS PDP Policy Repository (PR). 
  * Mavenize and push policy to PR
  * 
- * @version 0.9 
+ * @version 1.0 
  */
 
 @SuppressWarnings("deprecation")
@@ -589,7 +589,14 @@ public class BRMSPush {
                 result = artifact;
             }
         }
-        return result;
+        return additionalNexusLatestCheck(selectedName, result);
+       }
+       
+       // Additional Check due to Limitations from Nexus API to check if the artifact is the latest.
+       private NexusArtifact additionalNexusLatestCheck(String selectedName, NexusArtifact result) {
+               String nextVersion = incrementVersion(result.getVersion());
+        List<NexusArtifact> artifact = getArtifactFromNexus(selectedName, nextVersion);
+        return artifact.isEmpty()? result: additionalNexusLatestCheck(selectedName, artifact.get(0));
        }
 
        private boolean checkRemoteSync(String selectedName, String version) {
@@ -630,7 +637,7 @@ public class BRMSPush {
                                }
                        }
                }
-               return new ArrayList<NexusArtifact>();
+               return new ArrayList<>();
        }
 
        private void setVersion(String selectedName) {
@@ -908,7 +915,7 @@ public class BRMSPush {
 
                Dependency controlloopDependency = new Dependency();
                controlloopDependency.setGroupId("org.onap.policy.drools-applications");
-               controlloopDependency.setArtifactId("controlloop");
+               controlloopDependency.setArtifactId("events");
                controlloopDependency.setVersion(version);
                dependencyList.add(controlloopDependency);
 
index 42a04e7..89526c5 100644 (file)
@@ -26,40 +26,46 @@ import java.util.Map;
 
 public class Constraint {
 
-       private Integer num;
-       private String duration;
-       private Map<String, String> time_in_range;
+       private Integer freq_limit_per_target;
+       private Map<String,String> time_window;
+       private Map<String, String> active_time_range;
        
        private List<String> blacklist;
        
        public Constraint() {
                // Do Nothing empty constructor. 
        }
-       
-       public Integer getNum() {
-               return num;
+
+       public Integer getFreq_limit_per_target() {
+               return freq_limit_per_target;
        }
 
-       public void setNum(Integer num) {
-               this.num = num;
+
+       public void setFreq_limit_per_target(Integer freq_limit_per_target) {
+               this.freq_limit_per_target = freq_limit_per_target;
        }
 
-       public String getDuration() {
-               return duration;
+
+       public Map<String, String> getTime_window() {
+               return time_window;
        }
 
-       public void setDuration(String duration) {
-               this.duration = duration;
+
+       public void setTime_window(Map<String, String> time_window) {
+               this.time_window = time_window;
        }
 
-       public Map<String, String> getTime_in_range() {
-               return time_in_range;
+
+       public Map<String, String> getActive_time_range() {
+               return active_time_range;
        }
 
-       public void setTime_in_range(Map<String, String> time_in_range) {
-               this.time_in_range = time_in_range;
+
+       public void setActive_time_range(Map<String, String> active_time_range) {
+               this.active_time_range = active_time_range;
        }
 
+
        public List<String> getBlacklist() {
                return blacklist;
        }
@@ -68,69 +74,65 @@ public class Constraint {
                this.blacklist = blacklist;
        }
 
-       public Constraint(Integer num, String duration) {
-               this.num = num;
-               this.duration = duration;
+       public Constraint(Integer freq_limit_per_target, Map<String, String> time_window) {
+               this.freq_limit_per_target = freq_limit_per_target;
+               if(time_window!=null){
+                       this.time_window = Collections.unmodifiableMap(time_window);
+               }
        }
        
        public Constraint(List<String> blacklist) {
                this.blacklist = new LinkedList<>(blacklist);
-               
-       }
-
-       public Constraint(Map<String, String> time_in_range, List<String> blacklist) {
-               if (time_in_range != null) {
-                       this.time_in_range = Collections.unmodifiableMap(time_in_range);
-               }
-               this.blacklist = new LinkedList<>(blacklist);
        }
        
-       public Constraint(Integer num, String duration, List<String> blacklist) {
-               this.num = num;
-               this.duration = duration;
+       public Constraint(Integer freq_limit_per_target, Map<String, String> time_window, List<String> blacklist) {
+               this.freq_limit_per_target = freq_limit_per_target;
+               this.time_window = Collections.unmodifiableMap(time_window);
                this.blacklist = new LinkedList<>(blacklist);
        }
        
-       public Constraint(Integer num, String duration, Map<String, String> time_in_range) {
-               this(num, duration);
-               if (time_in_range != null) {
-                       this.time_in_range = Collections.unmodifiableMap(time_in_range);
+       public Constraint(Integer freq_limit_per_target, Map<String, String> time_window, Map<String, String> active_time_range) {
+               this(freq_limit_per_target, time_window);
+               if (active_time_range != null) {
+                       this.active_time_range = Collections.unmodifiableMap(active_time_range);
                }
        }
        
-       public Constraint(Integer num, String duration, Map<String, String> time_in_range, List<String> blacklist) {
-               this(num, duration);
-               if (time_in_range != null) {
-                       this.time_in_range = Collections.unmodifiableMap(time_in_range);
+       public Constraint(Integer freq_limit_per_target, Map<String, String> time_window, Map<String, String> active_time_range, List<String> blacklist) {
+               this(freq_limit_per_target, time_window);
+               if (active_time_range != null) {
+                       this.active_time_range = Collections.unmodifiableMap(active_time_range);
+               }
+               if(blacklist!=null){
+                       this.blacklist = new LinkedList<>(blacklist);
                }
-               this.blacklist = new LinkedList<>(blacklist);
        }
        
        public Constraint(Constraint constraint) {
-               this.num = constraint.num;
-               this.duration = constraint.duration;
-               if (constraint.time_in_range != null) {
-                       this.time_in_range = Collections.unmodifiableMap(constraint.time_in_range);
+               this.freq_limit_per_target = constraint.freq_limit_per_target;
+               this.time_window = constraint.time_window;
+               if (constraint.active_time_range != null) {
+                       this.active_time_range = Collections.unmodifiableMap(constraint.active_time_range);
                }
                this.blacklist = new LinkedList<>(constraint.blacklist);
        }
        
        public boolean isValid() {
-               return ((num == null && duration != null)|| (duration == null && num != null))? false : true;
+               return ((freq_limit_per_target == null && time_window != null)|| (time_window == null && freq_limit_per_target != null))? false : true;
        }
        
        @Override
        public String toString() {
-               return "Constraint [num=" + num + ", duration=" + duration + ", time_in_range=" + time_in_range + ", blacklist=" + blacklist + "]";
+               return "Constraint [freq_limit_per_target=" + freq_limit_per_target + ", time_window=" + time_window + ", active_time_range=" + active_time_range + ", blacklist=" + blacklist + "]";
        }
 
        @Override
        public int hashCode() {
                final int prime = 31;
                int result = 1;
-               result = prime * result + ((num == null) ? 0 : num.hashCode());
-               result = prime * result + ((duration == null) ? 0 : duration.hashCode());
-               result = prime * result + ((time_in_range == null) ? 0 : time_in_range.hashCode());
+               result = prime * result + ((freq_limit_per_target == null) ? 0 : freq_limit_per_target.hashCode());
+               result = prime * result + ((time_window == null) ? 0 : time_window.hashCode());
+               result = prime * result + ((active_time_range == null) ? 0 : active_time_range.hashCode());
                result = prime * result + ((blacklist == null) ? 0 : blacklist.hashCode());
                return result;
        }
@@ -144,20 +146,20 @@ public class Constraint {
                if (getClass() != obj.getClass())
                        return false;
                Constraint other = (Constraint) obj;
-               if (num == null) {
-                       if (other.num != null) 
+               if (freq_limit_per_target == null) {
+                       if (other.freq_limit_per_target != null) 
                                return false;
-               } else if (!num.equals(other.num))
+               } else if (!freq_limit_per_target.equals(other.freq_limit_per_target))
                        return false;
-               if (duration == null) {
-                       if (other.duration != null)
+               if (time_window == null) {
+                       if (other.time_window != null)
                                return false;
-               } else if (!duration.equals(other.duration))
+               } else if (!time_window.equals(other.time_window))
                        return false;
-               if (time_in_range == null) {
-                       if (other.time_in_range != null)
+               if (active_time_range == null) {
+                       if (other.active_time_range != null)
                                return false;
-               } else if (!time_in_range.equals(other.time_in_range))
+               } else if (!active_time_range.equals(other.active_time_range))
                        return false;
                if (blacklist == null) {
                        if (other.blacklist != null)
diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopParameter.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopParameter.java
new file mode 100644 (file)
index 0000000..e65b981
--- /dev/null
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.policy.controlloop.policy.guard;
+
+public class ControlLoopParameter {
+       private String controlLoopName;
+       private String version;
+       
+       public String getControlLoopName() {
+               return controlLoopName;
+       }
+
+       public void setControlLoopName(String controlLoopName) {
+               this.controlLoopName = controlLoopName;
+       }
+
+       public String getVersion() {
+               return version;
+       }
+
+       public void setVersion(String version) {
+               this.version = version;
+       }
+
+       public ControlLoopParameter(String controlLoopName, String version) {
+               super();
+               this.controlLoopName = controlLoopName;
+               this.version = version;
+       }
+
+       public ControlLoopParameter(ControlLoopParameter cl) {
+
+               this.controlLoopName = cl.controlLoopName;
+               this.version = cl.version;
+       }
+
+       @Override
+       public String toString() {
+               return "ControlLoopParameter [controlLoopName=" + controlLoopName + ", version=" + version + "]";
+       }
+
+       @Override
+       public int hashCode() {
+               final int prime = 31;
+               int result = 1;
+               result = prime * result + ((controlLoopName == null) ? 0 : controlLoopName.hashCode());
+               result = prime * result + ((version == null) ? 0 : version.hashCode());
+               return result;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               ControlLoopParameter other = (ControlLoopParameter) obj;
+               if (controlLoopName == null) {
+                       if (other.controlLoopName != null)
+                               return false;
+               } else if (!controlLoopName.equals(other.controlLoopName))
+                       return false;
+               if (version == null) {
+                       if (other.version != null)
+                               return false;
+               } else if (!version.equals(other.version))
+                       return false;
+               return true;
+       }
+}
index a4d56ff..830736b 100644 (file)
@@ -29,8 +29,7 @@ public class GuardPolicy {
        private String id = UUID.randomUUID().toString();
        private String name;
        private String description;
-       private String actor;
-       private String recipe;
+       private MatchParameters match_parameters;
        private LinkedList<Constraint> limit_constraints;
        
        public GuardPolicy() {
@@ -61,20 +60,12 @@ public class GuardPolicy {
                this.description = description;
        }
 
-       public String getActor() {
-               return actor;
+       public MatchParameters getMatch_parameters() {
+               return match_parameters;
        }
 
-       public void setActor(String actor) {
-               this.actor = actor;
-       }
-
-       public String getRecipe() {
-               return recipe;
-       }
-
-       public void setRecipe(String recipe) {
-               this.recipe = recipe;
+       public void setMatch_parameters(MatchParameters match_parameters) {
+               this.match_parameters = match_parameters;
        }
 
        public LinkedList<Constraint> getLimit_constraints() {
@@ -89,32 +80,31 @@ public class GuardPolicy {
                this.id = id;
        }
        
-       public GuardPolicy(String name, String actor, String recipe) {
+       public GuardPolicy(String name, MatchParameters matchParameters) {
                this.name = name;
-               this.actor = actor;
-               this.recipe = recipe;
+               this.match_parameters = matchParameters;
        }
        
-       public GuardPolicy(String id, String name, String description, String actor, String recipe) {
-               this(name, actor, recipe);
+       public GuardPolicy(String id, String name, String description, MatchParameters matchParameters) {
+               this(name, matchParameters);
                this.id = id;
                this.description = description;
        }
        
-       public GuardPolicy(String name, String actor, String recipe, List<Constraint> limit_constraints) {
-               this(name, actor, recipe);
+       public GuardPolicy(String name, MatchParameters matchParameters, List<Constraint> limitConstraints) {
+               this(name, matchParameters);
                if (limit_constraints != null) {
-                       this.limit_constraints = (LinkedList<Constraint>) Collections.unmodifiableList(limit_constraints);
+                       this.limit_constraints = (LinkedList<Constraint>) Collections.unmodifiableList(limitConstraints);
                }
        }
        
-       public GuardPolicy(String name, String description, String actor, String recipe, List<Constraint> limit_constraints) {
-               this(name, actor, recipe, limit_constraints);
+       public GuardPolicy(String name, String description, MatchParameters matchParameters, List<Constraint> limitConstraints) {
+               this(name, matchParameters, limitConstraints);
                this.description = description;
        }
        
-       public GuardPolicy(String id, String name, String description, String actor, String recipe, List<Constraint> limit_constraints) {
-               this(name, description, actor, recipe, limit_constraints);
+       public GuardPolicy(String id, String name, String description, MatchParameters matchParameters, List<Constraint> limitConstraints) {
+               this(name, description, matchParameters, limitConstraints);
                this.id = id;
        }
        
@@ -122,36 +112,31 @@ public class GuardPolicy {
                this.id = policy.id;
                this.name = policy.name;
                this.description = policy.description;
-               this.actor = policy.actor;
-               this.recipe = policy.recipe;
+               this.match_parameters = new MatchParameters(policy.match_parameters);
                if (policy.limit_constraints != null) {
                        this.limit_constraints = (LinkedList<Constraint>) Collections.unmodifiableList(policy.limit_constraints);
                }
        }
        
        public boolean isValid() {
-               if(id==null || name ==null|| actor==null|| recipe==null){
-                       return false;
-               }
-               return true;
+               return (id==null || name ==null)? false : true;
        }
        
        @Override
        public String toString() {
-               return "Policy [id=" + id + ", name=" + name + ", description=" + description + ", actor=" + actor + ", recipe="
-                               + recipe + ", limitConstraints=" + limit_constraints + "]";
+               return "Policy [id=" + id + ", name=" + name + ", description=" + description + ", match_parameters=" 
+                               +match_parameters + ", limitConstraints=" + limit_constraints + "]";
        }
 
        @Override
        public int hashCode() {
                final int prime = 31;
                int result = 1;
-               result = prime * result + ((actor == null) ? 0 : actor.hashCode());
                result = prime * result + ((description == null) ? 0 : description.hashCode());
                result = prime * result + ((id == null) ? 0 : id.hashCode());
                result = prime * result + ((name == null) ? 0 : name.hashCode());
                result = prime * result + ((limit_constraints == null) ? 0 : limit_constraints.hashCode());
-               result = prime * result + ((recipe == null) ? 0 : recipe.hashCode());
+               result = prime * result + ((match_parameters == null) ? 0 : match_parameters.hashCode());
                return result;
        }
 
@@ -164,11 +149,6 @@ public class GuardPolicy {
                if (getClass() != obj.getClass())
                        return false;
                GuardPolicy other = (GuardPolicy) obj;
-               if (actor == null) {
-                       if (other.actor != null) 
-                               return false;
-               } else if (!actor.equals(other.actor))
-                       return false;
                if (description == null) {
                        if (other.description != null)
                                return false;
@@ -189,10 +169,10 @@ public class GuardPolicy {
                                return false;
                } else if (!limit_constraints.equals(other.limit_constraints))
                        return false;
-               if (recipe == null) {
-                       if (other.recipe != null)
+               if (match_parameters==null){
+                       if(other.match_parameters !=null)
                                return false;
-               } else if (!recipe.equals(other.recipe))
+               } else if(!match_parameters.equals(other.match_parameters))
                        return false;
                return true;
        }
diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/MatchParameters.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/MatchParameters.java
new file mode 100644 (file)
index 0000000..3696ab4
--- /dev/null
@@ -0,0 +1,142 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.policy.controlloop.policy.guard;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class MatchParameters {
+       private String controlLoopName;
+       private String actor;
+       private String recipe;
+       private List<String> targets;
+
+       public MatchParameters() {
+               // Do Nothing Empty Constructor.
+       }       
+       
+       public String getControlLoopName() {
+               return controlLoopName;
+       }
+
+       public void setControlLoopName(String controlLoopName) {
+               this.controlLoopName = controlLoopName;
+       }
+
+       public String getActor() {
+               return actor;
+       }
+
+       public void setActor(String actor) {
+               this.actor = actor;
+       }
+
+       public String getRecipe() {
+               return recipe;
+       }
+
+       public void setRecipe(String recipe) {
+               this.recipe = recipe;
+       }
+
+       public List<String> getTargets() {
+               return targets;
+       }
+
+       public void setTargets(List<String> targets) {
+               this.targets = targets;
+       }
+
+       public MatchParameters(String actor, String recipe) {
+               this.actor = actor;
+               this.recipe = recipe;
+       }
+
+       public MatchParameters(String actor, String recipe, List<String> targets) {
+               this(actor, recipe);
+               if (targets != null) {
+                       this.targets = new LinkedList<>(targets);
+               }
+       }
+
+       public MatchParameters(String controlLoopName, String actor, String recipe, List<String> targets) {
+               this(actor, recipe, targets);
+               this.controlLoopName = controlLoopName;
+       }
+
+       public MatchParameters(MatchParameters matchParameters) {
+
+               this.controlLoopName = matchParameters.controlLoopName;
+               this.actor = matchParameters.actor;
+               this.recipe = matchParameters.recipe;
+               if (matchParameters.targets != null) {
+                       this.targets = new LinkedList<>(matchParameters.targets);
+               }
+       }
+
+       @Override
+       public String toString() {
+               return "MatchParameters [controlLoopName=" + controlLoopName + ", actor=" + actor + ", recipe=" + recipe
+                               + ", targets=" + targets + "]";
+       }
+
+       @Override
+       public int hashCode() {
+               final int prime = 31;
+               int result = 1;
+               result = prime * result + ((actor == null) ? 0 : actor.hashCode());
+               result = prime * result + ((controlLoopName == null) ? 0 : controlLoopName.hashCode());
+               result = prime * result + ((recipe == null) ? 0 : recipe.hashCode());
+               result = prime * result + ((targets == null) ? 0 : targets.hashCode());
+               return result;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               MatchParameters other = (MatchParameters) obj;
+               if (actor == null) {
+                       if (other.actor != null)
+                               return false;
+               } else if (!actor.equals(other.actor))
+                       return false;
+               if (controlLoopName == null) {
+                       if (other.controlLoopName != null)
+                               return false;
+               } else if (!controlLoopName.equals(other.controlLoopName))
+                       return false;
+               if (recipe == null) {
+                       if (other.recipe != null)
+                               return false;
+               } else if (!recipe.equals(other.recipe))
+                       return false;
+               if (targets == null) {
+                       if (other.targets != null)
+                               return false;
+               } else if (!targets.equals(other.targets))
+                       return false;
+               return true;
+       }
+}
\ No newline at end of file
index 3137a12..9dff9f3 100644 (file)
@@ -66,7 +66,13 @@ public class ControlLoopGuardBuilderTest {
                        //
                        // Add a guard policy without limit constraint
                        //
-                       GuardPolicy policy1 = new GuardPolicy("1111", "guardpolicy1", "guardpolicy1", "APPC", "restart");
+            String clname = "CL_vUSP123";
+            LinkedList<String> targets = new LinkedList<String>();
+            targets.add("s1");
+            targets.add("s2");
+            targets.add("s3");
+            MatchParameters matchParameters = new MatchParameters(clname, "APPC", "Restart", targets);
+            GuardPolicy policy1 = new GuardPolicy("id123", "guardpolicy1", "description aaa", matchParameters);
                        builder = builder.addGuardPolicy(policy1);
                        //
                        // Assert there is no limit constraint associated with the only guard policy
@@ -83,13 +89,16 @@ public class ControlLoopGuardBuilderTest {
                        //
                        // Add a constraint to policy1
                        //
-                       Map<String, String> time_in_range = new HashMap<String, String>();
-                       time_in_range.put("arg2", "PT5H");
-                       time_in_range.put("arg3", "PT24H");
+            Map<String, String> active_time_range = new HashMap<String, String>();
+            active_time_range.put("start", "00:00:00-05:00");
+            active_time_range.put("end", "23:59:59-05:00");
                        List<String> blacklist = new LinkedList<String>();
                        blacklist.add("eNodeB_common_id1");
                        blacklist.add("eNodeB_common_id2");
-                       Constraint cons = new Constraint(5, "PT15M", time_in_range, blacklist);
+            Map<String, String> time_window = new HashMap<String, String>();
+            time_window.put("value", "10");
+            time_window.put("units", "minute");
+            Constraint cons = new Constraint(5, time_window, active_time_range, blacklist);
                        builder = builder.addLimitConstraint(policy1.getId(), cons);
                        //
                        // Add a duplicate constraint to policy1
@@ -142,12 +151,12 @@ public class ControlLoopGuardBuilderTest {
                        fail(e.getMessage());
                }
        }
-
+       
        @Test
        public void test1() {
                this.test("src/test/resources/v2.0.0-guard/policy_guard_OpenECOMP_demo_vDNS.yaml");
        }
-
+       
        @Test
        public void test2() {
                this.test("src/test/resources/v2.0.0-guard/policy_guard_1707_appc.yaml");
index 797a7a8..6442cd5 100644 (file)
@@ -6,19 +6,19 @@ guards:
     name: APPC 5 Restart
     description: 
       We only allow 5 restarts over 15 minute window during the day time hours (i.e. avoid midnight to 5am)
-    actor: APPC
-    recipe: Restart
+    match_parameters:
+      controlLoopName: CL_NAME_ABC_123
+      actor: APPC
+      recipe: Restart
+      targets:
+        - s1
+          s2
+          s3
     limit_constraints:
-      - num: 5
-        #
-        # https://www.w3.org/TR/xmlschema-2/#duration
-        #
-        duration: PT15M
-        #
-        # XACML function time-in-range
-        #
-        # Assumption is that the "current time" is the 1st argument
-        #
-        time_in_range:
-          arg2: PT5H
-          arg3: PT24H
\ No newline at end of file
+      - freq_limit_per_target: 5
+        time_window: 
+          value: 15
+          units: minute
+        active_time_range:
+          start: 00:00:00-05:00
+          end: 23:59:59-05:00
\ No newline at end of file
index 414e814..f2390fa 100644 (file)
@@ -5,11 +5,15 @@ guards:
   - id: unique_guard_ONAP_vDNS_1
     name: MSO Spinup
     description: We only spin up 1 instance over a 10 minute window
-    actor: MSO
-    recipe: VF Module Create
+    match_parameters:
+      actor: MSO
+      recipe: VF Module Create
     limit_constraints:
-      - num: 1
+      - freq_limit_per_target: 1
         #
         # https://www.w3.org/TR/xmlschema-2/#duration
         #
-        duration: PT10M
+        time_window:
+          value: 10
+          units: hour
+        
\ No newline at end of file
index 61aa1eb..d9df903 100644 (file)
 #
 # Default PIP Configuration from Policy. 
 # 
-xacml.pip.engines=AAF,sql1
+xacml.pip.engines=AAF,historydb
 
 ### AAF PIP Configuration. 
 AAF.description=AAFEngine to communicate with AAF to take decisions
 AAF.classname=org.openecomp.policy.xacml.std.pip.engines.aaf.AAFEngine
 AAF.name=AAFEngine
 
-### sql1 PIP Configuration. 
-# Class from XACML resource. 
-sql1.classname=com.att.research.xacml.std.pip.engines.jdbc.JDBCEngine
-sql1.name=OperationsHistory
-sql1.description=Database of operations performed via closed loop.
-sql1.issuer=org:openecomp:xacml:sql123
-sql1.type=jdbc
-sql1.jdbc.driver=com.mysql.jdbc.Driver
-sql1.jdbc.url=jdbc:mysql://localhost:3306/policy
-sql1.jdbc.conn.user=root
-sql1.jdbc.conn.password=password
-
-#Each of the following resolvers corresponds to a specific time window. The only difference between them is the "interval" in the "select" SQL query and the "issuer".
-sql1.resolvers=tw5min,tw10min,tw30min,tw1h,tw12h,tw1d,tw5d,tw1w,tw1mon
-
-##############################################
-sql1.resolver.tw5min.select=select count(*) as count from operationshistory10 where outcome<>'Failure_Guard' and actor=? and operation=? and target=? and endtime between date_sub(now(),interval 5 minute) and now()
-sql1.resolver.tw5min.field.count.issuer=org:openecomp:xacml:sql:tw5min
-
-sql1.resolver.tw5min.classname=com.att.research.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver
-sql1.resolver.tw5min.name=OperationsCount
-sql1.resolver.tw5min.description=This returns the number of previous operations within the given time window
-sql1.resolver.tw5min.fields=count
-sql1.resolver.tw5min.field.count.id=count
-sql1.resolver.tw5min.field.count.datatype=http://www.w3.org/2001/XMLSchema#integer
-sql1.resolver.tw5min.field.count.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw5min.parameters=actor,operation,target
-sql1.resolver.tw5min.parameter.actor.id=actor
-sql1.resolver.tw5min.parameter.actor.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw5min.parameter.actor.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw5min.parameter.operation.id=recipe
-sql1.resolver.tw5min.parameter.operation.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw5min.parameter.operation.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw5min.parameter.target.id=target
-sql1.resolver.tw5min.parameter.target.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw5min.parameter.target.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-
-##############################################
-sql1.resolver.tw10min.select=select count(*) as count from operationshistory10 where outcome<>'Failure_Guard' and actor=? and operation=? and target=? and endtime between date_sub(now(),interval 10 minute) and now()
-sql1.resolver.tw10min.field.count.issuer=org:openecomp:xacml:sql:tw10min
-
-sql1.resolver.tw10min.classname=com.att.research.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver
-sql1.resolver.tw10min.name=OperationsCount
-sql1.resolver.tw10min.description=This returns the number of previous operations within the given time window
-sql1.resolver.tw10min.fields=count
-sql1.resolver.tw10min.field.count.id=count
-sql1.resolver.tw10min.field.count.datatype=http://www.w3.org/2001/XMLSchema#integer
-sql1.resolver.tw10min.field.count.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw10min.parameters=actor,operation,target
-sql1.resolver.tw10min.parameter.actor.id=actor
-sql1.resolver.tw10min.parameter.actor.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw10min.parameter.actor.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw10min.parameter.operation.id=recipe
-sql1.resolver.tw10min.parameter.operation.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw10min.parameter.operation.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw10min.parameter.target.id=target
-sql1.resolver.tw10min.parameter.target.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw10min.parameter.target.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-
-##############################################
-sql1.resolver.tw30min.select=select count(*) as count from operationshistory10 where outcome<>'Failure_Guard' and actor=? and operation=? and target=? and endtime between date_sub(now(),interval 30 minute) and now()
-sql1.resolver.tw30min.field.count.issuer=org:openecomp:xacml:sql:tw30min
-
-sql1.resolver.tw30min.classname=com.att.research.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver
-sql1.resolver.tw30min.name=OperationsCount
-sql1.resolver.tw30min.description=This returns the number of previous operations within the given time window
-sql1.resolver.tw30min.fields=count
-sql1.resolver.tw30min.field.count.id=count
-sql1.resolver.tw30min.field.count.datatype=http://www.w3.org/2001/XMLSchema#integer
-sql1.resolver.tw30min.field.count.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw30min.parameters=actor,operation,target
-sql1.resolver.tw30min.parameter.actor.id=actor
-sql1.resolver.tw30min.parameter.actor.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw30min.parameter.actor.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw30min.parameter.operation.id=recipe
-sql1.resolver.tw30min.parameter.operation.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw30min.parameter.operation.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw30min.parameter.target.id=target
-sql1.resolver.tw30min.parameter.target.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw30min.parameter.target.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-
-##############################################
-sql1.resolver.tw1h.select=select count(*) as count from operationshistory10 where outcome<>'Failure_Guard' and actor=? and operation=? and target=? and endtime between date_sub(now(),interval 1 hour) and now()
-sql1.resolver.tw1h.field.count.issuer=org:openecomp:xacml:sql:tw1h
-
-sql1.resolver.tw1h.classname=com.att.research.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver
-sql1.resolver.tw1h.name=OperationsCount
-sql1.resolver.tw1h.description=This returns the number of previous operations within the given time window
-sql1.resolver.tw1h.fields=count
-sql1.resolver.tw1h.field.count.id=count
-sql1.resolver.tw1h.field.count.datatype=http://www.w3.org/2001/XMLSchema#integer
-sql1.resolver.tw1h.field.count.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1h.parameters=actor,operation,target
-sql1.resolver.tw1h.parameter.actor.id=actor
-sql1.resolver.tw1h.parameter.actor.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1h.parameter.actor.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1h.parameter.operation.id=recipe
-sql1.resolver.tw1h.parameter.operation.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1h.parameter.operation.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1h.parameter.target.id=target
-sql1.resolver.tw1h.parameter.target.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1h.parameter.target.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-
-
-##############################################
-sql1.resolver.tw12h.select=select count(*) as count from operationshistory10 where outcome<>'Failure_Guard' and actor=? and operation=? and target=? and endtime between date_sub(now(),interval 12 hour) and now()
-sql1.resolver.tw12h.field.count.issuer=org:openecomp:xacml:sql:tw12h
-
-sql1.resolver.tw12h.classname=com.att.research.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver
-sql1.resolver.tw12h.name=OperationsCount
-sql1.resolver.tw12h.description=This returns the number of previous operations within the given time window
-sql1.resolver.tw12h.fields=count
-sql1.resolver.tw12h.field.count.id=count
-sql1.resolver.tw12h.field.count.datatype=http://www.w3.org/2001/XMLSchema#integer
-sql1.resolver.tw12h.field.count.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw12h.parameters=actor,operation,target
-sql1.resolver.tw12h.parameter.actor.id=actor
-sql1.resolver.tw12h.parameter.actor.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw12h.parameter.actor.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw12h.parameter.operation.id=recipe
-sql1.resolver.tw12h.parameter.operation.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw12h.parameter.operation.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw12h.parameter.target.id=target
-sql1.resolver.tw12h.parameter.target.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw12h.parameter.target.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-
-
-#############################
-sql1.resolver.tw1d.select=select count(*) as count from operationshistory10 where outcome<>'Failure_Guard' and actor=? and operation=? and target=? and endtime between date_sub(now(),interval 1 day) and now()
-sql1.resolver.tw1d.field.count.issuer=org:openecomp:xacml:sql:tw1d
-
-sql1.resolver.tw1d.classname=com.att.research.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver
-sql1.resolver.tw1d.name=OperationsCount
-sql1.resolver.tw1d.description=This returns the number of previous operations within the given time window
-sql1.resolver.tw1d.fields=count
-sql1.resolver.tw1d.field.count.id=count
-sql1.resolver.tw1d.field.count.datatype=http://www.w3.org/2001/XMLSchema#integer
-sql1.resolver.tw1d.field.count.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1d.parameters=actor,operation,target
-sql1.resolver.tw1d.parameter.actor.id=actor
-sql1.resolver.tw1d.parameter.actor.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1d.parameter.actor.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1d.parameter.operation.id=recipe
-sql1.resolver.tw1d.parameter.operation.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1d.parameter.operation.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1d.parameter.target.id=target
-sql1.resolver.tw1d.parameter.target.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1d.parameter.target.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-
-
-#############################
-sql1.resolver.tw5d.select=select count(*) as count from operationshistory10 where outcome<>'Failure_Guard' and actor=? and operation=? and target=? and endtime between date_sub(now(),interval 5 day) and now()
-sql1.resolver.tw5d.field.count.issuer=org:openecomp:xacml:sql:tw5d
-
-sql1.resolver.tw5d.classname=com.att.research.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver
-sql1.resolver.tw5d.name=OperationsCount
-sql1.resolver.tw5d.description=This returns the number of previous operations within the given time window
-sql1.resolver.tw5d.fields=count
-sql1.resolver.tw5d.field.count.id=count
-sql1.resolver.tw5d.field.count.datatype=http://www.w3.org/2001/XMLSchema#integer
-sql1.resolver.tw5d.field.count.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw5d.parameters=actor,operation,target
-sql1.resolver.tw5d.parameter.actor.id=actor
-sql1.resolver.tw5d.parameter.actor.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw5d.parameter.actor.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw5d.parameter.operation.id=recipe
-sql1.resolver.tw5d.parameter.operation.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw5d.parameter.operation.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw5d.parameter.target.id=target
-sql1.resolver.tw5d.parameter.target.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw5d.parameter.target.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-
-
-#############################
-sql1.resolver.tw1w.select=select count(*) as count from operationshistory10 where outcome<>'Failure_Guard' and actor=? and operation=? and target=? and endtime between date_sub(now(),interval 1 week) and now()
-sql1.resolver.tw1w.field.count.issuer=org:openecomp:xacml:sql:tw1w
-
-sql1.resolver.tw1w.classname=com.att.research.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver
-sql1.resolver.tw1w.name=OperationsCount
-sql1.resolver.tw1w.description=This returns the number of previous operations within the given time window
-sql1.resolver.tw1w.fields=count
-sql1.resolver.tw1w.field.count.id=count
-sql1.resolver.tw1w.field.count.datatype=http://www.w3.org/2001/XMLSchema#integer
-sql1.resolver.tw1w.field.count.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1w.parameters=actor,operation,target
-sql1.resolver.tw1w.parameter.actor.id=actor
-sql1.resolver.tw1w.parameter.actor.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1w.parameter.actor.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1w.parameter.operation.id=recipe
-sql1.resolver.tw1w.parameter.operation.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1w.parameter.operation.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1w.parameter.target.id=target
-sql1.resolver.tw1w.parameter.target.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1w.parameter.target.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-
-#############################
-sql1.resolver.tw1mon.select=select count(*) as count from operationshistory10 where outcome<>'Failure_Guard' and actor=? and operation=? and target=? and endtime between date_sub(now(),interval 1 month) and now()
-sql1.resolver.tw1mon.field.count.issuer=org:openecomp:xacml:sql:tw1mon
-
-sql1.resolver.tw1mon.classname=com.att.research.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver
-sql1.resolver.tw1mon.name=OperationsCount
-sql1.resolver.tw1mon.description=This returns the number of previous operations within the given time window
-sql1.resolver.tw1mon.fields=count
-sql1.resolver.tw1mon.field.count.id=count
-sql1.resolver.tw1mon.field.count.datatype=http://www.w3.org/2001/XMLSchema#integer
-sql1.resolver.tw1mon.field.count.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1mon.parameters=actor,operation,target
-sql1.resolver.tw1mon.parameter.actor.id=actor
-sql1.resolver.tw1mon.parameter.actor.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1mon.parameter.actor.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1mon.parameter.operation.id=recipe
-sql1.resolver.tw1mon.parameter.operation.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1mon.parameter.operation.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1mon.parameter.target.id=target
-sql1.resolver.tw1mon.parameter.target.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1mon.parameter.target.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
+# PIP Engine Definition
+#
+historydb.classname=org.openecomp.policy.xacml.std.pip.engines.OperationHistoryEngine
+historydb.issuer=org:onap:xacml:guard:historydb
+historydb.name=operationHistoryDB
\ No newline at end of file
diff --git a/ECOMP-PAP-REST/src/main/java/hibernate.cfg.xml b/ECOMP-PAP-REST/src/main/java/hibernate.cfg.xml
deleted file mode 100644 (file)
index e2ba058..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ============LICENSE_START=======================================================
-  ECOMP-PAP-REST
-  ================================================================================
-  Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
-  ================================================================================
-  Licensed under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-  
-       http://www.apache.org/licenses/LICENSE-2.0
-  
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-  ============LICENSE_END=========================================================
-  -->
-
-
-<!DOCTYPE hibernate-configuration SYSTEM
-    "classpath://org/hibernate/hibernate-configuration-3.0.dtd">
-
-<hibernate-configuration>
-       <session-factory>
-               
-               <!-- Hibernate JPA Mapping Classes -->
-               <mapping class="org.openecomp.policy.rest.jpa.Attribute"/>
-               <mapping class="org.openecomp.policy.rest.jpa.ActionPolicyDict"/>
-               <mapping class="org.openecomp.policy.rest.jpa.ActionList"/>
-               <mapping class="org.openecomp.policy.rest.jpa.AddressGroup"/>
-               <mapping class="org.openecomp.policy.rest.jpa.BRMSParamTemplate"/>
-               <mapping class="org.openecomp.policy.rest.jpa.Category"/>
-               <mapping class="org.openecomp.policy.rest.jpa.ClosedLoopD2Services"/>
-               <mapping class="org.openecomp.policy.rest.jpa.ClosedLoopSite"/>
-               <mapping class="org.openecomp.policy.rest.jpa.ConstraintType"/>
-               <mapping class="org.openecomp.policy.rest.jpa.ConstraintValue"/>
-               <mapping class="org.openecomp.policy.rest.jpa.Datatype"/>       
-               <mapping class="org.openecomp.policy.rest.jpa.DCAEuuid"/>
-               <mapping class="org.openecomp.policy.rest.jpa.DecisionSettings"/>
-               <mapping class="org.openecomp.policy.rest.jpa.RainyDayTreatments"/>     
-               <mapping class="org.openecomp.policy.rest.jpa.DescriptiveScope"/>
-               <mapping class="org.openecomp.policy.rest.jpa.EcompName"/>
-               <mapping class="org.openecomp.policy.rest.jpa.EnforcingType"/>
-               <mapping class="org.openecomp.policy.rest.jpa.FirewallDictionaryList"/>
-               <mapping class="org.openecomp.policy.rest.jpa.FWTag"/>
-        <mapping class="org.openecomp.policy.rest.jpa.FWTagPicker"/>
-               <mapping class="org.openecomp.policy.rest.jpa.FunctionDefinition"/>
-               <mapping class="org.openecomp.policy.rest.jpa.FunctionArgument"/>
-               <mapping class="org.openecomp.policy.rest.jpa.GroupPolicyScopeList"/>
-               <mapping class="org.openecomp.policy.rest.jpa.GroupServiceList"/>
-               <mapping class="org.openecomp.policy.rest.jpa.MicroServiceConfigName"/>
-               <mapping class="org.openecomp.policy.rest.jpa.MicroServiceLocation"/>
-               <mapping class="org.openecomp.policy.rest.jpa.MicroServiceModels"/>
-               <mapping class="org.openecomp.policy.rest.jpa.PEPOptions"/>
-               <mapping class="org.openecomp.policy.rest.jpa.PolicyScopeClosedLoop"/>
-               <mapping class="org.openecomp.policy.rest.jpa.PolicyScopeResource"/>
-               <mapping class="org.openecomp.policy.rest.jpa.PolicyScopeType"/>
-               <mapping class="org.openecomp.policy.rest.jpa.PolicyScopeService"/>
-               <mapping class="org.openecomp.policy.rest.jpa.PolicyEditorScopes"/>
-               <mapping class="org.openecomp.policy.rest.jpa.PolicyVersion"/>
-               <mapping class="org.openecomp.policy.rest.jpa.PortList"/>
-               <mapping class="org.openecomp.policy.rest.jpa.PrefixList"/>
-               <mapping class="org.openecomp.policy.rest.jpa.ProtocolList"/>
-               <mapping class="org.openecomp.policy.rest.jpa.ServiceList"/>
-               <mapping class="org.openecomp.policy.rest.jpa.SecurityZone"/>
-               <mapping class="org.openecomp.policy.rest.jpa.TermList"/>
-               <mapping class="org.openecomp.policy.rest.jpa.UserInfo"/>
-               <mapping class="org.openecomp.policy.rest.jpa.VarbindDictionary"/>
-               <mapping class="org.openecomp.policy.rest.jpa.VNFType"/>
-               <mapping class="org.openecomp.policy.rest.jpa.VSCLAction"/>
-               <mapping class="org.openecomp.policy.rest.jpa.Zone"/>
-               <mapping class="org.openecomp.policy.rest.jpa.RiskType"/>
-               <mapping class="org.openecomp.policy.rest.jpa.SafePolicyWarning"/>
-               <mapping class="org.openecomp.policy.rest.jpa.ClosedLoops"/>
-        <mapping class="org.openecomp.policy.rest.jpa.BRMSController"/>
-        <mapping class="org.openecomp.policy.rest.jpa.BRMSDependency"/>
-        <mapping class="org.openecomp.policy.rest.jpa.MicroServiceAttribute"/>
-       </session-factory>
-</hibernate-configuration>
index 180b989..5a566c9 100644 (file)
@@ -50,6 +50,7 @@ import org.openecomp.policy.controlloop.policy.guard.Constraint;
 import org.openecomp.policy.controlloop.policy.guard.ControlLoopGuard;
 import org.openecomp.policy.controlloop.policy.guard.Guard;
 import org.openecomp.policy.controlloop.policy.guard.GuardPolicy;
+import org.openecomp.policy.controlloop.policy.guard.MatchParameters;
 import org.openecomp.policy.controlloop.policy.guard.builder.ControlLoopGuardBuilder;
 import org.openecomp.policy.pap.xacml.rest.XACMLPapServlet;
 import org.openecomp.policy.pap.xacml.rest.util.JPAUtils;
@@ -57,6 +58,7 @@ import org.openecomp.policy.rest.adapter.PolicyRestAdapter;
 import org.openecomp.policy.rest.jpa.Datatype;
 import org.openecomp.policy.rest.jpa.DecisionSettings;
 import org.openecomp.policy.rest.jpa.FunctionDefinition;
+import org.openecomp.policy.utils.PolicyUtils;
 import org.openecomp.policy.xacml.api.XACMLErrorConstants;
 import org.openecomp.policy.xacml.std.pip.engines.aaf.AAFEngine;
 import org.openecomp.policy.xacml.util.XACMLPolicyScanner;
@@ -86,7 +88,7 @@ public class DecisionPolicy extends Policy {
        private static final Logger LOGGER      = FlexLogger.getLogger(DecisionPolicy.class);
        
        public static final String FUNCTION_NOT = "urn:oasis:names:tc:xacml:1.0:function:not";
-       private static final String AAFProvider = "AAF";
+       private static final String AAFPROVIDER = "AAF";
        public static final String GUARD_YAML = "GUARD_YAML";
     public static final String GUARD_BL_YAML = "GUARD_BL_YAML";
     public static final String RAINY_DAY = "Rainy_Day";
@@ -200,7 +202,7 @@ public class DecisionPolicy extends Policy {
                        allOf.getMatch().add(createMatch(ECOMPNAME, (policyAdapter.getEcompName())));
                        
                        Map<String, String> dynamicFieldComponentAttributes = policyAdapter.getDynamicFieldConfigAttributes();
-                       if(policyAdapter.getRuleProvider()!=null && policyAdapter.getRuleProvider().equals(AAFProvider)){
+                       if(policyAdapter.getRuleProvider()!=null && policyAdapter.getRuleProvider().equals(AAFPROVIDER)){
                                dynamicFieldComponentAttributes = new HashMap<>();
                        }
                        
@@ -221,9 +223,7 @@ public class DecisionPolicy extends Policy {
                        decisionPolicy.setTarget(target);
 
                        Map<String, String> dynamicFieldDecisionSettings = policyAdapter.getDynamicSettingsMap();
-                       
-                       //dynamicVariableList = policyAdapter.getDynamicVariableList();
-                       if(policyAdapter.getRuleProvider()!=null && policyAdapter.getRuleProvider().equals(AAFProvider)){
+                       if(policyAdapter.getRuleProvider()!=null && policyAdapter.getRuleProvider().equals(AAFPROVIDER)){
                                dynamicFieldDecisionSettings = new HashMap<>();
                        }
                        
@@ -231,13 +231,10 @@ public class DecisionPolicy extends Policy {
                        for (String keyField : dynamicFieldDecisionSettings.keySet()) {
                                String key = keyField;
                                String value = dynamicFieldDecisionSettings.get(key);
-                               //String dataType = (String) dynamicVariableList.get(counter);
                                String dataType = getDataType(key);
                                VariableDefinitionType dynamicVariable = createDynamicVariable(key, value, dataType);
                                decisionPolicy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().add(dynamicVariable);
                        }
-                       
-                       
                        Map<String, String> dynamicFieldTreatmentAttributes = policyAdapter.getRainydayMap();
                        
                        if(policyAdapter.getRuleProvider().equals(RAINY_DAY)){
@@ -252,24 +249,39 @@ public class DecisionPolicy extends Policy {
                        }
 
                }
-
                setPreparedToSave(true);
                return true;
        }
        
-       public PolicyType getGuardPolicy(Map<String, String> yamlParams, String ruleProvider) {
+       public PolicyType getGuardPolicy(Map<String, String> yamlParams, String ruleProvider) throws BuilderException{
                try {
                        ControlLoopGuardBuilder builder = ControlLoopGuardBuilder.Factory.buildControlLoopGuard(new Guard());
-                       GuardPolicy policy1 = new GuardPolicy((policyAdapter.getUuid()!=null? policyAdapter.getUuid(): UUID.randomUUID().toString()) ,yamlParams.get(POLICY_NAME), yamlParams.get(DESCRIPTION), yamlParams.get("actor"), yamlParams.get("recipe"));
+                       MatchParameters matchParameters = new MatchParameters(yamlParams.get("actor"), yamlParams.get("recipe"));
+                       matchParameters.setControlLoopName(yamlParams.get("clname"));
+                       if(yamlParams.containsKey("targets")){
+                               String targetString = yamlParams.get("targets");
+                               List<String> targets = null;
+                               if(targetString!=null && !targetString.isEmpty()){
+                                       if (targetString.contains(",")){
+                                               targets = Arrays.asList(targetString.split(","));
+                                       }
+                                       else{
+                                               targets = new ArrayList<>();
+                                               targets.add(targetString);
+                                       }       
+                               }
+                               matchParameters.setTargets(targets);
+                       }
+                       GuardPolicy policy1 = new GuardPolicy((policyAdapter.getUuid()!=null? policyAdapter.getUuid(): UUID.randomUUID().toString()) ,yamlParams.get(POLICY_NAME), yamlParams.get(DESCRIPTION), matchParameters);
                        builder = builder.addGuardPolicy(policy1);
-                       Map<String, String> time_in_range = new HashMap<>();
-                       time_in_range.put("arg2", yamlParams.get("guardActiveStart"));
-                       time_in_range.put("arg3", yamlParams.get("guardActiveEnd"));
+            Map<String, String> activeTimeRange = new HashMap<>();
+            activeTimeRange.put("start", yamlParams.get("guardActiveStart"));
+            activeTimeRange.put("end", yamlParams.get("guardActiveEnd"));
                        String blackListString = yamlParams.get("blackList");
                        List<String> blackList = null;
                        if(blackListString!=null){
                                if (blackListString.contains(",")){
-                                       blackList = Arrays.asList(blackListString.split(","));
+                                       blackList = Arrays.asList(blackListString.split(","));                                                          
                                }
                                else{
                                        blackList = new ArrayList<>();
@@ -278,18 +290,30 @@ public class DecisionPolicy extends Policy {
                        }
                        File templateFile;
                        Path xacmlTemplatePath;
-                       Constraint cons;
                        ClassLoader classLoader = getClass().getClassLoader();
+                       Constraint cons = new Constraint();
                        switch (ruleProvider){
                        case GUARD_BL_YAML:
                                templateFile = new File(classLoader.getResource(XACML_BLGUARD_TEMPLATE).getFile());
                                xacmlTemplatePath = templateFile.toPath();
-                               cons = new Constraint(time_in_range,blackList);
+                cons.setActive_time_range(activeTimeRange);
+                cons.setBlacklist(blackList);
                                break;
                        default:
                                templateFile = new File(classLoader.getResource(XACML_GUARD_TEMPLATE).getFile());
                                xacmlTemplatePath = templateFile.toPath();
-                               cons = new Constraint(Integer.parseInt(yamlParams.get("limit")), yamlParams.get("timeWindow"), time_in_range);
+                               Map<String,String> timeWindow = new HashMap<>();
+                               if(!PolicyUtils.isInteger(yamlParams.get("timeWindow"))){
+                                       throw new BuilderException("time window is not in Integer format.");
+                               }
+                               String timeUnits = yamlParams.get("timeUnits");
+                               if(timeUnits==null || !(timeUnits.equalsIgnoreCase("minute") || timeUnits.equalsIgnoreCase("hour") || timeUnits.equalsIgnoreCase("day") 
+                                               || timeUnits.equalsIgnoreCase("week") || timeUnits.equalsIgnoreCase("month")||timeUnits.equalsIgnoreCase("year"))){
+                                       throw new BuilderException("time Units is not in proper format.");
+                               }
+                               timeWindow.put("value", yamlParams.get("timeWindow"));
+                               timeWindow.put("units", yamlParams.get("timeUnits"));
+                               cons = new Constraint(Integer.parseInt(yamlParams.get("limit")),timeWindow,activeTimeRange);
                                break;
                        }
                        builder = builder.addLimitConstraint(policy1.getId(), cons);
@@ -297,7 +321,6 @@ public class DecisionPolicy extends Policy {
                        Results results = builder.buildSpecification();
                        // YAML TO XACML 
                        ControlLoopGuard yamlGuardObject = SafePolicyBuilder.loadYamlGuard(results.getSpecification());
-                       
                String xacmlTemplateContent;
                try {
                                xacmlTemplateContent = new String(Files.readAllBytes(xacmlTemplatePath));
@@ -305,25 +328,28 @@ public class DecisionPolicy extends Policy {
                                yamlSpecs.put(POLICY_NAME, yamlParams.get(POLICY_NAME));
                                yamlSpecs.put(DESCRIPTION, yamlParams.get(DESCRIPTION));
                                yamlSpecs.put(ECOMPNAME, yamlParams.get(ECOMPNAME));
-                               yamlSpecs.put("actor", yamlGuardObject.getGuards().getFirst().getActor());
-                               yamlSpecs.put("recipe", yamlGuardObject.getGuards().getFirst().getRecipe());
-                               if(yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getNum()!=null){
-                                       yamlSpecs.put("limit", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getNum().toString());
+                               yamlSpecs.put("actor", yamlGuardObject.getGuards().getFirst().getMatch_parameters().getActor());
+                               yamlSpecs.put("recipe", yamlGuardObject.getGuards().getFirst().getMatch_parameters().getRecipe());
+                               yamlSpecs.put("clname", yamlGuardObject.getGuards().getFirst().getMatch_parameters().getControlLoopName());
+                               if(yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getFreq_limit_per_target()!=null){
+                                       yamlSpecs.put("limit", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getFreq_limit_per_target().toString());
                                }
-                               if(yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getDuration()!=null){
-                                       yamlSpecs.put("timeWindow", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getDuration());
+                               if(yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getTime_window()!=null){
+                                       yamlSpecs.put("twValue", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getTime_window().get("value"));
+                                       yamlSpecs.put("twUnits", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getTime_window().get("units"));
                                }
-                               yamlSpecs.put("guardActiveStart", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getTime_in_range().get("arg2"));
-                               yamlSpecs.put("guardActiveEnd", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getTime_in_range().get("arg3"));
-                       String xacmlPolicyContent = SafePolicyBuilder.generateXacmlGuard(xacmlTemplateContent,yamlSpecs, yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getBlacklist());
+                               yamlSpecs.put("guardActiveStart", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getActive_time_range().get("start"));
+                               yamlSpecs.put("guardActiveEnd", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getActive_time_range().get("end"));
+                       String xacmlPolicyContent = SafePolicyBuilder.generateXacmlGuard(xacmlTemplateContent,yamlSpecs, yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getBlacklist(), yamlGuardObject.getGuards().getFirst().getMatch_parameters().getTargets());
                       // Convert the  Policy into Stream input to Policy Adapter. 
                        Object policy = XACMLPolicyScanner.readPolicy(new ByteArrayInputStream(xacmlPolicyContent.getBytes(StandardCharsets.UTF_8)));
                                return (PolicyType) policy;
                        } catch (IOException e) {
-                               LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Error while creating the policy " + e.getMessage() + e);
+                               LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Error while creating the policy " + e.getMessage() , e);
                        }
                } catch (BuilderException e) {
-                       LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Error while creating the policy " + e.getMessage() +e);
+                       LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Error while creating the policy " + e.getMessage() ,e);
+                       throw e;
                }
                return null;
        }
@@ -384,7 +410,7 @@ public class DecisionPolicy extends Policy {
                dynamicFieldTwoRuleAlgorithms = policyAdapter.getDynamicRuleAlgorithmField2();
                dropDownMap = createDropDownMap();
                
-               if(policyAdapter.getRuleProvider()!=null && policyAdapter.getRuleProvider().equals(AAFProvider)){
+               if(policyAdapter.getRuleProvider()!=null && policyAdapter.getRuleProvider().equals(AAFPROVIDER)){
                        // Values for AAF Provider are here for XML Creation. 
                        ConditionType condition = new ConditionType();
                        ApplyType decisionApply = new ApplyType();
@@ -427,7 +453,7 @@ public class DecisionPolicy extends Policy {
                        if(!permitRule){
                                AdviceExpressionsType adviceExpressions = new AdviceExpressionsType();
                                AdviceExpressionType adviceExpression = new AdviceExpressionType();
-                               adviceExpression.setAdviceId(AAFProvider);
+                               adviceExpression.setAdviceId(AAFPROVIDER);
                                adviceExpression.setAppliesTo(EffectType.DENY);
                                AttributeAssignmentExpressionType assignment = new AttributeAssignmentExpressionType();
                                assignment.setAttributeId("aaf.response");
@@ -511,7 +537,7 @@ public class DecisionPolicy extends Policy {
                // Create Target in Rule
                AllOfType allOfInRule = new AllOfType();
 
-               // Creating match for ACCESS in rule target
+               // Creating match for DECIDE in rule target
                MatchType accessMatch = new MatchType();
                AttributeValueType accessAttributeValue = new AttributeValueType();
                accessAttributeValue.setDataType(STRING_DATATYPE);
@@ -539,11 +565,11 @@ public class DecisionPolicy extends Policy {
                errorcodeAttributeValue.getContent().add(errorcode);
                errorcodeMatch.setAttributeValue(errorcodeAttributeValue);
                AttributeDesignatorType errorcodeAttributeDesignator = new AttributeDesignatorType();
-               errorcodeAttributeDesignator.setCategory(CATEGORY_ACTION);
+               errorcodeAttributeDesignator.setCategory(CATEGORY_RESOURCE);
                errorcodeAttributeDesignator.setDataType(STRING_DATATYPE);
                errorcodeAttributeDesignator.setAttributeId("ErrorCode");
                errorcodeMatch.setAttributeDesignator(errorcodeAttributeDesignator);
-               errorcodeMatch.setMatchId(FUNCTION_STRING_EQUAL_IGNORE);
+               errorcodeMatch.setMatchId(FUNCTION_STRING_REGEXP_MATCH);
                
                allOfInRule.getMatch().add(errorcodeMatch);
                
@@ -707,7 +733,6 @@ public class DecisionPolicy extends Policy {
        
        private void populateDataTypeList(String value1) {
                String dataType = null;
-
                if(value1.contains("S_")) {
                        value1 = value1.substring(2, value1.length());
                        DecisionSettings decisionSettings = findDecisionSettingsBySettingId(value1.substring(2, value1.length()));
@@ -732,17 +757,16 @@ public class DecisionPolicy extends Policy {
                } catch (Exception e) {
                        LOGGER.error("Exception Occured"+e);
                }
-               Map<String, String> dropDownMap = new HashMap<>();
+               Map<String, String> dropDownOptions = new HashMap<>();
                if(jpaUtils!=null){
                        Map<Datatype, List<FunctionDefinition>> functionMap = jpaUtils.getFunctionDatatypeMap();
                        for (Map.Entry<Datatype,List<FunctionDefinition>> map: functionMap.entrySet()) {
                                for (FunctionDefinition functionDef : map.getValue()) {
-                                       dropDownMap.put(functionDef.getShortname(),functionDef.getXacmlid());
+                                       dropDownOptions.put(functionDef.getShortname(),functionDef.getXacmlid());
                                }
                        }
                }
-               
-               return dropDownMap;
+               return dropDownOptions;
        }
        
        private String getDataType(String key) {
index a074643..bdd3612 100644 (file)
@@ -105,6 +105,7 @@ public abstract class Policy {
        public static final String FUNCTION_BOOLEAN_ONE_AND_ONLY = "urn:oasis:names:tc:xacml:1.0:function:boolean-one-and-only";
        public static final String FUNCTION_STRING_EQUAL = "urn:oasis:names:tc:xacml:1.0:function:string-equal";
        public static final String FUNCTION_STRING_REGEX_MATCH = "org.openecomp.function.regex-match";
+       public static final String FUNCTION_STRING_REGEXP_MATCH = "urn:oasis:names:tc:xacml:1.0:function:string-regexp-match";
        public static final String FUNCTION_STRING_EQUAL_IGNORE = "urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case";
        public static final String INTEGER_DATATYPE = "http://www.w3.org/2001/XMLSchema#integer";
        public static final String BOOLEAN_DATATYPE = "http://www.w3.org/2001/XMLSchema#boolean";
index c4f5358..bd69a88 100644 (file)
@@ -30,11 +30,11 @@ import org.yaml.snakeyaml.Yaml;
 import org.yaml.snakeyaml.constructor.Constructor;
 
 public class SafePolicyBuilder {
-
+       
        private SafePolicyBuilder(){
                //Private Constructor. 
        }
-       
+
        public static ControlLoopGuard loadYamlGuard(String specification) {
                //
                // Read the yaml into our Java Object
@@ -45,7 +45,20 @@ public class SafePolicyBuilder {
                return (ControlLoopGuard) obj;
        }
        
-       public static String generateXacmlGuard(String xacmlFileContent,Map<String, String> generateMap, List<String> blacklist) {
+       public static String generateXacmlGuard(String xacmlFileContent,Map<String, String> generateMap, List<String> blacklist, List<String> targets) {
+               //Setup default values and Targets. 
+               StringBuilder targetRegex= new StringBuilder(".*|");
+               if(targets!=null && !targets.isEmpty()){
+                       targetRegex = new StringBuilder();
+            for(String t : targets){
+               targetRegex.append(t + "|");
+            }
+               }
+               if(generateMap.get("clname")==null|| generateMap.get("clname").isEmpty()){
+                       generateMap.put("clname",".*");
+               }
+               generateMap.put("targets", targetRegex.toString().substring(0, targetRegex.length()-1));
+               // Replace values. 
                for(Map.Entry<String,String> map: generateMap.entrySet()){
                        Pattern p = Pattern.compile("\\$\\{" +map.getKey() +"\\}");
                        Matcher m = p.matcher(xacmlFileContent);
index 65f0ede..3ddeee3 100644 (file)
@@ -22,6 +22,7 @@ package org.openecomp.policy.pap.xacml.rest.controller;
 
 import java.io.PrintWriter;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -170,6 +171,7 @@ public class ActionPolicyDictionaryController {
                        }else{
                                if(!isFakeUpdate) {
                                        actionPolicyDict.setUserModifiedBy(this.getUserInfo(userId));
+                                       actionPolicyDict.setModifiedDate(new Date());
                                        commonClassDao.update(actionPolicyDict); 
                                }
                        } 
index eb03aa9..4dda095 100644 (file)
@@ -23,6 +23,7 @@ package org.openecomp.policy.pap.xacml.rest.controller;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.nio.charset.StandardCharsets;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -324,6 +325,7 @@ public class BRMSDictionaryController{
                         }
                     }else{
                         brmsDependency.setUserModifiedBy(this.getUserInfo(userId));
+                        brmsDependency.setModifiedDate(new Date());
                         commonClassDao.update(brmsDependency); 
                     }
                     if(duplicateflag) {
@@ -476,6 +478,7 @@ public class BRMSDictionaryController{
                         }
                     }else{
                         brmsController.setUserModifiedBy(this.getUserInfo(userId));
+                        brmsController.setModifiedDate(new Date());
                         commonClassDao.update(brmsController); 
                     }
                     if(duplicateflag) {
index 9aab267..f97d846 100644 (file)
@@ -21,6 +21,7 @@
 package org.openecomp.policy.pap.xacml.rest.controller;
 
 import java.io.PrintWriter;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -325,6 +326,7 @@ public class ClosedLoopDictionaryController{
                                }else{
                                        vSCLAction.setUserCreatedBy(this.getUserInfo(userId));
                                        vSCLAction.setUserModifiedBy(this.getUserInfo(userId));
+                                       vSCLAction.setModifiedDate(new Date());
                                        commonClassDao.save(vSCLAction);
                                }
                        }else{
@@ -453,6 +455,7 @@ public class ClosedLoopDictionaryController{
                        }else{
                                if(!isFakeUpdate) {
                                        vNFType.setUserModifiedBy(this.getUserInfo(userId));
+                                       vNFType.setModifiedDate(new Date());
                                        commonClassDao.update(vNFType); 
                                }
                        } 
@@ -592,6 +595,7 @@ public class ClosedLoopDictionaryController{
                        }else{
                                if(!isFakeUpdate){
                                        pEPOptions.setUserModifiedBy(this.getUserInfo(userId));
+                                       pEPOptions.setModifiedDate(new Date());
                                        commonClassDao.update(pEPOptions);
                                }
                        }
@@ -712,6 +716,7 @@ public class ClosedLoopDictionaryController{
                        }else{
                                if(!isFakeUpdate){
                                        serviceData.setUserModifiedBy(this.getUserInfo(userId));
+                                       serviceData.setModifiedDate(new Date());
                                        commonClassDao.update(serviceData); 
                                }
                        }
@@ -830,6 +835,7 @@ public class ClosedLoopDictionaryController{
                        }else{
                                if(!isFakeUpdate) {
                                        siteData.setUserModifiedBy(this.getUserInfo(userId));
+                                       siteData.setModifiedDate(new Date());
                                        commonClassDao.update(siteData);
                                }
                        }
@@ -949,6 +955,7 @@ public class ClosedLoopDictionaryController{
                        }else{
                                if(!isFakeUpdate){
                                        varbindDictionary.setUserModifiedBy(this.getUserInfo(userId));
+                                       varbindDictionary.setModifiedDate(new Date());
                                        commonClassDao.update(varbindDictionary);
                                }
                        }
index fc525bb..c9a2006 100644 (file)
@@ -22,6 +22,7 @@ package org.openecomp.policy.pap.xacml.rest.controller;
 
 import java.io.PrintWriter;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -169,6 +170,7 @@ public class DecisionPolicyDictionaryController {
                        }else{
                                if(!isFakeUpdate) {
                                        decisionSettings.setUserModifiedBy(this.getUserInfo(userId));
+                                       decisionSettings.setModifiedDate(new Date());
                                        commonClassDao.update(decisionSettings); 
                                }
                        }
@@ -248,7 +250,7 @@ public class DecisionPolicyDictionaryController {
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
-                       model.put("rainyDayDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(RainyDayTreatments.class, "bbID")));
+                       model.put("rainyDayDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(RainyDayTreatments.class, "bbid")));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
                        response.getWriter().write(j.toString());
index a64cdf7..0ea1da1 100644 (file)
@@ -21,6 +21,7 @@
 package org.openecomp.policy.pap.xacml.rest.controller;
 
 import java.io.PrintWriter;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -169,6 +170,7 @@ public class DescriptiveDictionaryController {
                        }else{
                                if(!isFakeUpdate){
                                        descriptiveScope.setUserModifiedBy(this.getUserInfo(userId));
+                                       descriptiveScope.setModifiedDate(new Date());
                                        commonClassDao.update(descriptiveScope); 
                                }
                        } 
index 49d841a..b01f9b0 100644 (file)
@@ -22,6 +22,7 @@ package org.openecomp.policy.pap.xacml.rest.controller;
 
 import java.io.PrintWriter;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -204,6 +205,7 @@ public class DictionaryController {
                        }else{
                                if(!isFakeUpdate) {
                                        attributeData.setUserModifiedBy(this.getUserInfo(userId));
+                                       attributeData.setModifiedDate(new Date());
                                        commonClassDao.update(attributeData); 
                                }
                        } 
@@ -357,6 +359,7 @@ public class DictionaryController {
                        }else{
                                if(!isFakeUpdate){
                                        ecompData.setUserModifiedBy(this.getUserInfo(userId));
+                                       ecompData.setModifiedDate(new Date());
                                        commonClassDao.update(ecompData);
                                }
                        } 
index 6c9d713..5172f45 100644 (file)
@@ -23,6 +23,7 @@ package org.openecomp.policy.pap.xacml.rest.controller;
 import java.io.PrintWriter;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -1969,6 +1970,7 @@ public class FirewallDictionaryController {
                                }
                        }else{
                                fwTagPicker.setUserModifiedBy(this.getUserInfo(userId));
+                               fwTagPicker.setModifiedDate(new Date());
                                commonClassDao.update(fwTagPicker); 
                        } 
 
@@ -2130,6 +2132,7 @@ public class FirewallDictionaryController {
                                }   
                        }else{
                                fwTag.setUserModifiedBy(this.getUserInfo(userId));
+                               fwTag.setModifiedDate(new Date());
                                commonClassDao.update(fwTag); 
                        } 
 
index ecf8462..b933a4f 100644 (file)
@@ -62,7 +62,11 @@ public class MicroServiceDictionaryController {
        private static final Logger LOGGER  = FlexLogger.getLogger(MicroServiceDictionaryController.class);
 
        private static CommonClassDao commonClassDao;
-       
+
+       public static void setCommonClassDao(CommonClassDao commonClassDao) {
+               MicroServiceDictionaryController.commonClassDao = commonClassDao;
+       }
+
        @Autowired
        public MicroServiceDictionaryController(CommonClassDao commonClassDao){
                MicroServiceDictionaryController.commonClassDao = commonClassDao;
index 42dfb88..8c88e68 100644 (file)
@@ -21,6 +21,7 @@
 package org.openecomp.policy.pap.xacml.rest.controller;
 
 import java.io.PrintWriter;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -155,6 +156,7 @@ public class SafePolicyController {
                        } else {
                                if (!isFakeUpdate) {
                                        riskTypeData.setUserModifiedBy(this.getUserInfo(userId));
+                                       riskTypeData.setModifiedDate(new Date());
                                        commonClassDao.update(riskTypeData);
                                }
                        }
index 4dd48ad..a6315f8 100644 (file)
@@ -206,17 +206,19 @@ public class ElkConnectorImpl implements ElkConnector{
                                "            \"must\" : [";
                
                String match_params = "";
+               boolean first = true;
                for(Entry<String, String> entry : filter_s.entrySet()){
                        String key = entry.getKey();
                        String value = entry.getValue();
-                       if(filter_s.size() == 1){
-                               match_params = "\"match\" : {\""+key+"\" : \""+value+"\" }";
+                       if(first){
+                               match_params = "\"match\" : {\""+key+"\" : \""+value+"\" }},";
+                               first = false;
                        }else{
-                               match_params = match_params + "match\" : { \""+key+"\" : \""+value+"\" } ,";
+                               match_params = match_params + "{\"match\" : { \""+key+"\" : \""+value+"\" } },";
                        }
                }
                if(match_params.endsWith(",")){
-                       match_params = match_params.substring(0, match_params.length()-1);
+                       match_params = match_params.substring(0, match_params.length()-2);
                }
 
                matches_s = matches_s + "{\n" + match_params + "\n}" ;
index d4cf812..15eae89 100644 (file)
@@ -123,7 +123,11 @@ public class PolicyElasticData {
                this.configName = policyData.getConfigName();
                this.configType = policyData.getConfigType();
                this.jsonBody = policyData.getJsonBody();
-               this.jsonBodyData = policyData.getJsonBodyData(); 
+               if(configPolicyType.startsWith("ClosedLoop")){
+                       this.jsonBodyData = jsonBody; 
+               }else{
+                       this.jsonBodyData = policyData.getJsonBodyData(); 
+               }
                
                this.serviceTypePolicyName = policyData.getServiceTypePolicyName();
                this.verticaMetrics = policyData.getVerticaMetrics();
index a18a229..e5250d6 100644 (file)
@@ -65,6 +65,7 @@ import org.openecomp.policy.rest.jpa.VNFType;
 import org.openecomp.policy.rest.jpa.VSCLAction;
 import org.openecomp.policy.rest.jpa.VarbindDictionary;
 import org.openecomp.policy.xacml.api.XACMLErrorConstants;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
@@ -96,6 +97,7 @@ public class PolicyElasticSearchController{
        
        public static CommonClassDao commonClassDao;
 
+       @Autowired
        public PolicyElasticSearchController(CommonClassDao commonClassDao) {
                PolicyElasticSearchController.commonClassDao = commonClassDao;
        }
@@ -219,12 +221,16 @@ public class PolicyElasticSearchController{
                                        String searchText = searchData.getQuery();
                                        String descriptivevalue = searchData.getDescriptiveScope();
                                        if(descriptivevalue != null){
-                                               DescriptiveScope dsSearch = (DescriptiveScope) commonClassDao.getEntityItem(DescriptiveScope.class, "descriptiveScopeName", searchData.getDescriptiveScope());
+                                               DescriptiveScope dsSearch = (DescriptiveScope) commonClassDao.getEntityItem(DescriptiveScope.class, "descriptiveScopeName", descriptivevalue);
                                                if(dsSearch != null){
                                                        String[] descriptiveList =  dsSearch.getSearch().split("AND");
                                                        for(String keyValue : descriptiveList){
                                                                String[] entry = keyValue.split(":");
-                                                               searchKeyValue.put(entry[0], entry[1]);
+                                                               if(searchData.getPolicyType() != null && "closedLoop".equals(searchData.getPolicyType())){
+                                                                       searchKeyValue.put("jsonBodyData", "*" +entry[1] +"*");
+                                                               }else{
+                                                                       searchKeyValue.put(entry[0], entry[1]);
+                                                               }
                                                        }
                                                }
                                        }
@@ -257,16 +263,16 @@ public class PolicyElasticSearchController{
                                                searchKeyValue.put("jsonBodyData."+d2Service+"", "true");
                                        }       
                                        if(searchData.getVnfType() != null){
-                                               searchKeyValue.put("jsonBodyData.vnfType", searchData.getVnfType());                                    
+                                               searchKeyValue.put("jsonBodyData", "*" +searchData.getVnfType() +"*");                                  
                                        }
                                        if(searchData.getPolicyStatus() != null){
-                                               searchKeyValue.put("jsonBodyData.closedLoopPolicyStatus", searchData.getPolicyStatus());
+                                               searchKeyValue.put("jsonBodyData", "*" +searchData.getPolicyStatus()+"*");
                                        }
                                        if(searchData.getVproAction() != null){
-                                               searchKeyValue.put("jsonBodyData.actions", searchData.getVproAction());
+                                               searchKeyValue.put("jsonBodyData", "*" +searchData.getVproAction()+"*");
                                        }
                                        if(searchData.getServiceType() != null){
-                                               searchKeyValue.put("jsonBodyData.serviceTypePolicyName", searchData.getServiceType());
+                                               searchKeyValue.put("serviceType", searchData.getServiceType());
                                        }
                                        if(searchData.getBindTextSearch() != null){
                                                searchKeyValue.put(searchData.getBindTextSearch(), searchText);
index 0d84519..e6f322a 100644 (file)
@@ -379,14 +379,20 @@ public class PolicyCreation extends AbstractPolicyCreation{
                                                        && policyData.getYamlparams()!=null){
                                                attributeMap.put("actor", policyData.getYamlparams().getActor());
                                                attributeMap.put("recipe", policyData.getYamlparams().getRecipe());
+                                               attributeMap.put("clname", policyData.getYamlparams().getClname());
                                                attributeMap.put("limit", policyData.getYamlparams().getLimit());
                                                attributeMap.put("timeWindow", policyData.getYamlparams().getTimeWindow());
+                                               attributeMap.put("timeUnits", policyData.getYamlparams().getTimeUnits());
                                                attributeMap.put("guardActiveStart", policyData.getYamlparams().getGuardActiveStart());
                                                attributeMap.put("guardActiveEnd", policyData.getYamlparams().getGuardActiveEnd());
                                                if(policyData.getYamlparams().getBlackList()!=null){
                                                        String blackList = StringUtils.join(policyData.getYamlparams().getBlackList(), ",");
                                                        attributeMap.put("blackList", blackList);
                                                }
+                                               if(policyData.getYamlparams().getTargets()!=null){
+                                                       String targets = StringUtils.join(policyData.getYamlparams().getTargets(),",");
+                                                       attributeMap.put("targets", targets);
+                                               }
                                        }
                                        if(policyData.getRuleProvider()!=null && policyData.getRuleProvider().equals(DecisionPolicy.RAINY_DAY)){
                                                attributeMap.put("ServiceType", policyData.getRainyday().getServiceType());
@@ -513,8 +519,11 @@ public class PolicyCreation extends AbstractPolicyCreation{
                }
                catch (Exception e){
                        LOGGER.error("Exception Occured : "+e);
+                       body = "error";
+                       response.addHeader("error", e.getMessage());    
+                       response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
                }
-               return new ResponseEntity<String>(body, status);
+               return new ResponseEntity<>(body, status);
        }
 
        @ExceptionHandler({ HttpMessageNotReadableException.class })
index 1e428ff..7e4201a 100644 (file)
                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">${ECOMPName}</AttributeValue>
                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ECOMPName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
                 </Match>
-                <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">${actor}</AttributeValue>
                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="actor" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
                 </Match>
-                <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">${recipe}</AttributeValue>
                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="recipe" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
                 </Match>
+                <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">${clname}</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="clname" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
             </AllOf>
         </AnyOf>
     </Target>
index 6701a08..d404080 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:com:xacml:policy:id:d56af069-6cf1-430c-ba07-e26602e06a52" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides"> 
+<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:com:xacml:policy:id:d56af069-6cf1-430c-ba07-e26602e06a52" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-unless-deny"> 
     <Description>${description}</Description>
     <Target>
         <AnyOf>
                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">${ECOMPName}</AttributeValue>
                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ECOMPName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
                 </Match>
-                <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">${actor}</AttributeValue>
                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="actor" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
                 </Match>
-                <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">${recipe}</AttributeValue>
                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="recipe" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
                 </Match>
+                <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">${targets}</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="target" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">${clname}</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="clname" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
             </AllOf>
         </AnyOf>
     </Target>
@@ -37,8 +45,8 @@
             </AnyOf>
         </Target>
         <Condition>
-            <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:or">
-                <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:not">
+               <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:not">
+                       <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
                     <Apply FunctionId="urn:oasis:names:tc:xacml:2.0:function:time-in-range">
                         <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:time-one-and-only">
                             <AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:environment:current-time" DataType="http://www.w3.org/2001/XMLSchema#time" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment" MustBePresent="false"/>
                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">${guardActiveStart}</AttributeValue>
                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">${guardActiveEnd}</AttributeValue>
                     </Apply>
-                </Apply>
-                <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-less-than-or-equal">
-                    <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-one-and-only">
-                        <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="count" DataType="http://www.w3.org/2001/XMLSchema#integer" Issuer="org:openecomp:xacml:sql:${timeWindow}" MustBePresent="false"/>
-                    </Apply>
-                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#integer">${limit}</AttributeValue>
+                    <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-greater-than-or-equal">
+                       <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-one-and-only">
+                               <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="count" DataType="http://www.w3.org/2001/XMLSchema#integer" Issuer="org:onap:xacml:guard:historydb:tw:${twValue}:${twUnits}" MustBePresent="false"/>
+                       </Apply>
+                       <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#integer">${limit}</AttributeValue>
+                       </Apply>
                 </Apply>
             </Apply>
         </Condition>
         </Target>
         <Condition>
             <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:not">
-                <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:or">
-                       <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:not">
-                               <Apply FunctionId="urn:oasis:names:tc:xacml:2.0:function:time-in-range">
-                               <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:time-one-and-only">
+                <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:not">
+                               <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
+                       <Apply FunctionId="urn:oasis:names:tc:xacml:2.0:function:time-in-range">
+                               <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:time-one-and-only">
                                <AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:environment:current-time" DataType="http://www.w3.org/2001/XMLSchema#time" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment" MustBePresent="false"/>
                                </Apply>
                                <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">${guardActiveStart}</AttributeValue>
                                <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">${guardActiveEnd}</AttributeValue>
                        </Apply>
-                       </Apply>
-                       <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-less-than-or-equal">
-                       <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-one-and-only">
-                               <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="count" DataType="http://www.w3.org/2001/XMLSchema#integer" Issuer="org:openecomp:xacml:sql:${timeWindow}" MustBePresent="false"/>
-                       </Apply>
-                       <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#integer">${limit}</AttributeValue>
+                       <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-greater-than-or-equal">
+                               <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-one-and-only">
+                                       <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="count" DataType="http://www.w3.org/2001/XMLSchema#integer" Issuer="org:onap:xacml:guard:historydb:tw:${twValue}:${twUnits}" MustBePresent="false"/>
+                               </Apply>
+                               <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#integer">${limit}</AttributeValue>
+                               </Apply>
                        </Apply>
                </Apply>
             </Apply>
index 3e1ef04..2fef9a7 100644 (file)
@@ -447,4 +447,4 @@ public class DbAuditCompareEntriesTest {
                assertEquals(1, result.size());
                logger.info("testResourceRegistrationEntity: Exit");
        }
-}
+}
\ No newline at end of file
index fa2899a..82427e8 100644 (file)
@@ -25,24 +25,36 @@ import static org.junit.Assert.*;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+
 import java.io.BufferedReader;
 import java.io.StringReader;
 import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.List;
+
+import javax.json.Json;
+import javax.json.JsonObject;
 import javax.servlet.http.HttpServletRequest;
+
+import org.json.JSONObject;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
 import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
 import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.openecomp.policy.rest.adapter.PolicyRestAdapter;
 import org.openecomp.policy.rest.dao.CommonClassDao;
 import org.openecomp.policy.rest.jpa.Attribute;
 import org.openecomp.policy.rest.jpa.MicroServiceModels;
 import org.openecomp.policy.rest.jpa.PolicyEditorScopes;
 import org.springframework.mock.web.MockHttpServletResponse;
 
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.github.fge.jackson.JsonLoader;
+
 /**
  * The class <code>DictionaryControllerTest</code> contains tests
  * for the class {@link <code>DictionaryController</code>}*
@@ -51,7 +63,6 @@ import org.springframework.mock.web.MockHttpServletResponse;
  * where they have write privileges and can execute time-sensitive
  * tasks.
  */
-
 public class DictionaryControllerTest {
        
        private static Logger logger = FlexLogger.getLogger(DictionaryControllerTest.class);
index 87b5e3d..c1f2973 100644 (file)
 
 package org.openecomp.policy.pap.xacml.rest.controller;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 import java.io.BufferedReader;
 import java.io.StringReader;
 import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.List;
+
 import javax.servlet.http.HttpServletRequest;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 import org.mockito.Mockito;
 import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
 import org.openecomp.policy.common.logging.flexlogger.Logger;
@@ -35,12 +47,7 @@ import org.openecomp.policy.rest.jpa.DCAEuuid;
 import org.openecomp.policy.rest.jpa.MicroServiceLocation;
 import org.openecomp.policy.rest.jpa.MicroServiceModels;
 import org.openecomp.policy.rest.jpa.UserInfo;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
 import org.springframework.mock.web.MockHttpServletResponse;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
 
 /**
  * The class <code>MicroServiceDictionaryControllerTest</code> contains tests
@@ -50,6 +57,7 @@ import static org.mockito.Mockito.*;
  * where they have write privileges and can execute time-sensitive
  * tasks.
  */
+
 public class MicroServiceDictionaryControllerTest {
        
        private static Logger logger = FlexLogger.getLogger(MicroServiceDictionaryControllerTest.class);
@@ -84,8 +92,9 @@ public class MicroServiceDictionaryControllerTest {
         
         doNothing().when(commonClassDao).delete(microServiceModels);
                
-       
-               controller = new MicroServiceDictionaryController(commonClassDao);
+               MicroServiceDictionaryController.setCommonClassDao(commonClassDao);     
+               
+               controller = new MicroServiceDictionaryController();
        
         HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
         
index 3357851..142d81b 100644 (file)
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
        <modelVersion>4.0.0</modelVersion>
-       
+
        <parent>
                <groupId>org.openecomp.policy.engine</groupId>
                <artifactId>PolicyEngineSuite</artifactId>
                <version>1.1.0-SNAPSHOT</version>
        </parent>
-       
+
        <artifactId>ECOMP-PDP-REST</artifactId>
-       
+
        <description>ECOMP PDP REST</description>
        <properties>
-        <springframework.version>4.3.3.RELEASE</springframework.version>
-    </properties>
+               <springframework.version>4.3.3.RELEASE</springframework.version>
+       </properties>
        <packaging>war</packaging>
        <build>
                <plugins>
-                       <plugin>
-                       <artifactId>maven-war-plugin</artifactId>
-                       <version>2.1</version>
-                       <configuration>
-                               <attachClasses>true</attachClasses>
-                       </configuration>
-                       </plugin>
-       </plugins>
+                       <plugin>
+                               <artifactId>maven-war-plugin</artifactId>
+                               <version>2.1</version>
+                               <configuration>
+                                       <attachClasses>true</attachClasses>
+                               </configuration>
+                       </plugin>
+               </plugins>
        </build>
        <dependencies>
                <dependency>
                        <groupId>org.mariadb.jdbc</groupId>
                        <artifactId>mariadb-java-client</artifactId>
                        <version>1.2.3</version>
-               </dependency>           
+               </dependency>
                <dependency>
                        <groupId>postgresql</groupId>
                        <artifactId>postgresql</artifactId>
                        <version>9.1-901.jdbc4</version>
                </dependency>
+               <dependency>
+                       <groupId>org.springframework</groupId>
+                       <artifactId>spring-test</artifactId>
+                       <version>${springframework.version}</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.awaitility</groupId>
+                       <artifactId>awaitility</artifactId>
+                       <version>3.0.0</version>
+                       <scope>test</scope>
+               </dependency>
                <dependency>
                        <groupId>org.hsqldb</groupId>
                        <artifactId>hsqldb</artifactId>
                        <artifactId>jersey-core</artifactId>
                        <version>1.18</version>
                </dependency>
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <version>4.12</version>
+                       <scope>test</scope>
+               </dependency>
                <dependency>
                        <groupId>javax.websocket</groupId>
                        <artifactId>javax.websocket-api</artifactId>
                        <scope>provided</scope>
                </dependency>
                <dependency>
-                       <groupId>com.att.nsa</groupId>
-                       <artifactId>cambriaClient</artifactId>
-                       <version>0.0.1</version>
-                       <exclusions>
-                               <exclusion>
-                                       <artifactId>slf4j-log4j12</artifactId>
-                                       <groupId>org.slf4j</groupId>
-                               </exclusion>
-                       </exclusions>
+                       <groupId>com.att.nsa</groupId>
+                       <artifactId>cambriaClient</artifactId>
+                       <version>0.0.1</version>
+                       <exclusions>
+                               <exclusion>
+                                       <artifactId>slf4j-log4j12</artifactId>
+                                       <groupId>org.slf4j</groupId>
+                               </exclusion>
+                       </exclusions>
                </dependency>
                <dependency>
                        <groupId>org.mockito</groupId>
                        <artifactId>mockito-core</artifactId>
                        <version>1.9.5</version>
-               </dependency>     
+               </dependency>
                <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-mock</artifactId>
                        <version>1.5.6</version>
                </dependency>
                <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-core</artifactId>
-            <version>${springframework.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-web</artifactId>
-            <version>${springframework.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-webmvc</artifactId>
-            <version>${springframework.version}</version>
-        </dependency>
-        <dependency>
+                       <groupId>org.springframework</groupId>
+                       <artifactId>spring-core</artifactId>
+                       <version>${springframework.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.springframework</groupId>
+                       <artifactId>spring-web</artifactId>
+                       <version>${springframework.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.springframework</groupId>
+                       <artifactId>spring-webmvc</artifactId>
+                       <version>${springframework.version}</version>
+               </dependency>
+               <dependency>
                        <groupId>io.springfox</groupId>
                        <artifactId>springfox-swagger2</artifactId>
                        <version>2.5.0</version>
                        <exclusions>
                                <exclusion>
                                        <groupId>com.fasterxml.jackson.core</groupId>
-                               <artifactId>jackson-annotations</artifactId>
+                                       <artifactId>jackson-annotations</artifactId>
                                </exclusion>
                        </exclusions>
                </dependency>
                                </exclusion>
                                <exclusion>
                                        <groupId>javax.persistence</groupId>
-                       <artifactId>persistence-api</artifactId>
-                               </exclusion>
-                               <exclusion>
-                                       <groupId>com.att.aft</groupId>
-                               <artifactId>dme2</artifactId>
+                                       <artifactId>persistence-api</artifactId>
                                </exclusion>
                        </exclusions>
                </dependency>
index a247fe6..12dfbd2 100644 (file)
@@ -270,13 +270,7 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
 
                // CreateUpdatePolicy ResourceName  
                createUpdateResourceName = properties.getProperty("createUpdatePolicy.impl.className", CREATE_UPDATE_POLICY_SERVICE);
-               try{
-                       Class<?> createUpdateclass = Class.forName(createUpdateResourceName);
-                       createUpdatePolicyConstructor = createUpdateclass.getConstructor(PolicyParameters.class, String.class, boolean.class);
-               }catch(Exception e){
-                       PolicyLogger.error(MessageCodes.MISS_PROPERTY_ERROR, "createUpdatePolicy.impl.className", "xacml.pdp.init");
-                       throw new ServletException("Could not find the Class name : " +createUpdateResourceName + "\n" +e.getMessage());
-               }
+               setCreateUpdatePolicyConstructor(createUpdateResourceName);
 
                // Create an IntegrityMonitor
                try {
@@ -1159,4 +1153,14 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
        public static Constructor<?> getCreateUpdatePolicyConstructor(){
                return createUpdatePolicyConstructor;
        }
+       
+       private static void setCreateUpdatePolicyConstructor(String createUpdateResourceName) throws ServletException{
+               try{
+                       Class<?> createUpdateclass = Class.forName(createUpdateResourceName);
+                       createUpdatePolicyConstructor = createUpdateclass.getConstructor(PolicyParameters.class, String.class, boolean.class);
+               }catch(Exception e){
+                       PolicyLogger.error(MessageCodes.MISS_PROPERTY_ERROR, "createUpdatePolicy.impl.className", "xacml.pdp.init");
+                       throw new ServletException("Could not find the Class name : " +createUpdateResourceName + "\n" +e.getMessage());
+               }
+       }
 }
index a9d80fd..48539ad 100644 (file)
@@ -58,6 +58,8 @@ import org.openecomp.policy.pdp.rest.api.services.GetDecisionService;
 import org.openecomp.policy.pdp.rest.api.services.GetDictionaryService;
 import org.openecomp.policy.pdp.rest.api.services.GetMetricsService;
 import org.openecomp.policy.pdp.rest.api.services.ListConfigService;
+import org.openecomp.policy.pdp.rest.api.services.NotificationService;
+import org.openecomp.policy.pdp.rest.api.services.NotificationService.NotificationServiceType;
 import org.openecomp.policy.pdp.rest.api.services.PolicyEngineImportService;
 import org.openecomp.policy.pdp.rest.api.services.PushPolicyService;
 import org.openecomp.policy.pdp.rest.api.services.SendEventService;
@@ -81,8 +83,9 @@ import springfox.documentation.annotations.ApiIgnore;
 @Api(value = "Policy Engine Services")
 @RequestMapping("/")
 public class PolicyEngineServices {
-       private static Logger logger = FlexLogger
-                       .getLogger(PolicyEngineServices.class.getName());
+       private static Logger logger = FlexLogger.getLogger(PolicyEngineServices.class.getName());
+       private static final String NOTIFICATIONPERM = "notification"; 
+       
        private final AtomicLong configCounter = new AtomicLong();
        private final AtomicLong configNameCounter = new AtomicLong();
        private final AtomicLong eventCounter = new AtomicLong();
@@ -97,6 +100,7 @@ public class PolicyEngineServices {
        private final AtomicLong policyEngineImportCounter = new AtomicLong();
        private final AtomicLong deprecatedCounter = new AtomicLong();
        private final AtomicLong metricCounter = new AtomicLong();
+       private final AtomicLong notificationCounter = new AtomicLong();
 
        @ApiImplicitParams({
                        @ApiImplicitParam(name = "Authorization", required = true, paramType = "Header"),
@@ -118,7 +122,7 @@ public class PolicyEngineServices {
                        status = getConfigService.getResponseCode();
                }
                configCounter.incrementAndGet();
-               return new ResponseEntity<Collection<PolicyConfig>>(policyConfig, status);
+               return new ResponseEntity<>(policyConfig, status);
        }
 
        @ApiImplicitParams({
@@ -135,8 +139,7 @@ public class PolicyEngineServices {
                Collection<PolicyConfig> policyConfig = null;
                HttpStatus status = HttpStatus.UNAUTHORIZED;
                // Check Permissions.
-               if (PDPApiAuth.checkPermissions(clientEncoding, requestID,
-                               "getConfigByPolicyName")) {
+               if (PDPApiAuth.checkPermissions(clientEncoding, requestID,"getConfigByPolicyName")) {
                        ConfigRequestParameters configRequestParameters = new ConfigRequestParameters();
                        configRequestParameters.setPolicyName(configNameRequest
                                        .getPolicyName());
@@ -194,6 +197,71 @@ public class PolicyEngineServices {
                metricCounter.incrementAndGet();
                return new ResponseEntity<>(response, status);
        }
+       
+       @ApiImplicitParams({
+               @ApiImplicitParam(name = "Authorization", required = true, paramType = "Header"),
+               @ApiImplicitParam(name = "Environment", required = true, paramType = "Header") })
+       @ApiOperation(value = "Registers DMaaP Topic to recieve notification from Policy Engine")
+       @RequestMapping(value = "/getNotification", method = RequestMethod.POST)
+       @ResponseBody
+       public ResponseEntity<String> getNotification(
+                       @RequestBody String notificationTopic,
+                       @RequestHeader(value = "ClientAuth", required = true) String clientEncoding,
+                       @RequestHeader(value = "X-ECOMP-RequestID", required = false) String requestID) {
+               String policyResponse = "Error Unauthorized to use Notification Service.";
+               HttpStatus status = HttpStatus.UNAUTHORIZED;
+               // Check Permissions.
+               if (PDPApiAuth.checkPermissions(clientEncoding, requestID, NOTIFICATIONPERM)) {
+                       NotificationService notificationService = new NotificationService(notificationTopic, requestID, NotificationServiceType.ADD);
+                       policyResponse = notificationService.getResult();
+                       status = notificationService.getResponseCode();
+               }
+               notificationCounter.incrementAndGet();
+               return new ResponseEntity<>(policyResponse, status);
+       }
+       
+       @ApiImplicitParams({
+               @ApiImplicitParam(name = "Authorization", required = true, paramType = "Header"),
+               @ApiImplicitParam(name = "Environment", required = true, paramType = "Header") })
+       @ApiOperation(value = "De-Registers DMaaP Topic to stop recieving notifications from Policy Engine")
+       @RequestMapping(value = "/stopNotification", method = RequestMethod.POST)
+       @ResponseBody
+       public ResponseEntity<String> stopNotification(
+                       @RequestBody String notificationTopic,
+                       @RequestHeader(value = "ClientAuth", required = true) String clientEncoding,
+                       @RequestHeader(value = "X-ECOMP-RequestID", required = false) String requestID) {
+               String policyResponse = "Error Unauthorized to use Notification Service.";
+               HttpStatus status = HttpStatus.UNAUTHORIZED;
+               // Check Permissions.
+               if (PDPApiAuth.checkPermissions(clientEncoding, requestID, NOTIFICATIONPERM)) {
+                       NotificationService notificationService = new NotificationService(notificationTopic, requestID, NotificationServiceType.REMOVE);
+                       policyResponse = notificationService.getResult();
+                       status = notificationService.getResponseCode();
+               }
+               notificationCounter.incrementAndGet();
+               return new ResponseEntity<>(policyResponse, status);
+       }
+       
+       @ApiImplicitParams({
+               @ApiImplicitParam(name = "Authorization", required = true, paramType = "Header"),
+               @ApiImplicitParam(name = "Environment", required = true, paramType = "Header") })
+       @ApiOperation(value = "Sends Heartbeat to DMaaP Topic Registry to continue recieving notifications from Policy Engine")
+       @RequestMapping(value = "/sendHeartbeat", method = RequestMethod.POST)
+       @ResponseBody
+       public ResponseEntity<String> sendHeartbeat(
+                       @RequestBody String notificationTopic,
+                       @RequestHeader(value = "ClientAuth", required = true) String clientEncoding,
+                       @RequestHeader(value = "X-ECOMP-RequestID", required = false) String requestID) {
+               String policyResponse = "Error Unauthorized to use Heartbeat Service.";
+               HttpStatus status = HttpStatus.UNAUTHORIZED;
+               // Check Permissions.
+               if (PDPApiAuth.checkPermissions(clientEncoding, requestID, NOTIFICATIONPERM)) {
+                       NotificationService notificationService = new NotificationService(notificationTopic, requestID, NotificationServiceType.HB);
+                       policyResponse = notificationService.getResult();
+                       status = notificationService.getResponseCode();
+               }
+               return new ResponseEntity<>(policyResponse, status);
+       }
 
        @ApiImplicitParams({
                        @ApiImplicitParam(name = "Authorization", required = true, paramType = "Header"),
@@ -314,7 +382,7 @@ public class PolicyEngineServices {
                                status = createPolicyService.getResponseCode();
                        } catch (InstantiationException | IllegalAccessException
                                        | IllegalArgumentException | InvocationTargetException e) {
-                               logger.error(e.getMessage());
+                               logger.error(e.getMessage(), e);
                                response = "Problem with CreateUpdate Policy Service. ";
                                status = HttpStatus.INTERNAL_SERVER_ERROR;
                        }
@@ -346,7 +414,7 @@ public class PolicyEngineServices {
                                status = updatePolicyService.getResponseCode();
                        } catch (InstantiationException | IllegalAccessException
                                        | IllegalArgumentException | InvocationTargetException e) {
-                               logger.error(e.getMessage());
+                               logger.error(e.getMessage(), e);
                                response = "Problem with CreateUpdate Policy Service. ";
                                status = HttpStatus.INTERNAL_SERVER_ERROR;
                        }
@@ -571,7 +639,8 @@ public class PolicyEngineServices {
                                + "\nTotal PolicyEngine Import Calls: "
                                + policyEngineImportCounter
                                + "\nTotal Deprecated Policy Calls: " + deprecatedCounter
-                               + "\nTotal Metrics Calls:" + metricCounter;
+                               + "\nTotal Metrics Calls:" + metricCounter
+                               + "\nTotal Notification Calls:" + notificationCounter;
        }
 
        @ExceptionHandler({ HttpMessageNotReadableException.class })
index 14c5366..7640cad 100644 (file)
@@ -35,8 +35,8 @@ import org.openecomp.policy.xacml.std.pap.StdPAPPolicy;
  * @version 0.1
  */
 public class ActionPolicyService {
-       private static Logger LOGGER = FlexLogger.getLogger(ActionPolicyService.class.getName());
-       private static PAPServices papServices = null;
+       private static final Logger LOGGER = FlexLogger.getLogger(ActionPolicyService.class.getName());
+       private PAPServices papServices = null;
        
        private PolicyParameters policyParameters = null;
        private String message = null;
index 971f2fd..37d0766 100644 (file)
@@ -36,15 +36,14 @@ import org.openecomp.policy.xacml.std.pap.StdPAPPolicy;
  * @version 0.1
  */
 public class BRMSParamPolicyService{
-       private static Logger LOGGER = FlexLogger.getLogger(BRMSParamPolicyService.class.getName());
-       private static PAPServices papServices = null;
+       private static final Logger LOGGER = FlexLogger.getLogger(BRMSParamPolicyService.class.getName());
+       private PAPServices papServices = null;
        
        private PolicyParameters policyParameters = null;
        private String message = null;
        private String policyName = null;
        private String policyScope = null;
-       private String date = null;
-       private boolean levelCheck = false;
+       private String date = null; 
        private Map<AttributeType, Map<String, String>> drlRuleAndUIParams = null;
        
        public BRMSParamPolicyService(String policyName, String policyScope,
@@ -57,7 +56,7 @@ public class BRMSParamPolicyService{
        }
 
        public Boolean getValidation() {
-               levelCheck = PolicyApiUtils.isNumeric(policyParameters.getRiskLevel());
+               boolean levelCheck = PolicyApiUtils.isNumeric(policyParameters.getRiskLevel());
                if(!levelCheck){
                        message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.";
                        return false;
index a85533b..b2ff00e 100644 (file)
@@ -36,8 +36,8 @@ import org.openecomp.policy.xacml.std.pap.StdPAPPolicy;
  * @version 0.1 
  */
 public class ClosedLoopFaultPolicyService{
-       private static Logger LOGGER = FlexLogger.getLogger(ClosedLoopFaultPolicyService.class.getName());
-       private static PAPServices papServices = null;
+       private static final Logger LOGGER = FlexLogger.getLogger(ClosedLoopFaultPolicyService.class.getName());
+       private PAPServices papServices = null;
        
        private PolicyParameters policyParameters = null;
        private String message = null;
@@ -68,6 +68,7 @@ public class ClosedLoopFaultPolicyService{
                        configBody = PolicyApiUtils.stringToJsonObject(policyParameters.getConfigBody());
                } catch(JsonException| IllegalStateException e){
                        message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " improper JSON object : " + policyParameters.getConfigBody();
+                       LOGGER.error("Json Parse Exception.", e);
                        return false;
                }
                return true;
@@ -89,20 +90,25 @@ public class ClosedLoopFaultPolicyService{
                } else {
                        operation = "create";
                }
-               boolean levelCheck = PolicyApiUtils.isNumeric(policyParameters.getRiskLevel());
                // get values and attributes from the JsonObject
-               String ecompName = configBody.get("ecompname").toString().replace("\"", "");
-               String jsonBody = configBody.toString();
-               if (ecompName==null||ecompName.equals("")){
+               if(!configBody.containsKey("ecompname")){
+                       message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Ecomp Name given.";
+                       LOGGER.error(message);
+                       return message;
+               }
+               String ecompName = configBody.get("ecompname").toString().trim().replace("\"", "");
+               if (ecompName==null||ecompName.trim().isEmpty()){
                        message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Ecomp Name given.";
                        LOGGER.error(message);
                        return message;
                }
+               boolean levelCheck = PolicyApiUtils.isNumeric(policyParameters.getRiskLevel());
                if (!levelCheck){
                        message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.";
                        LOGGER.error(message);
                        return message;
                }
+               String jsonBody = configBody.toString();
                // Create Policy. 
                StdPAPPolicy newPAPPolicy = new StdPAPPolicy("ClosedLoop_Fault", policyName, policyParameters.getPolicyDescription(), ecompName, 
                                jsonBody, false, oldPolicyName, null, updateFlag, policyScope, 0, policyParameters.getRiskLevel(),
index 15a2c3a..3fb8f46 100644 (file)
@@ -36,9 +36,9 @@ import org.openecomp.policy.xacml.std.pap.StdPAPPolicy;
  * @version 0.1
  */
 public class ClosedLoopPMPolicyService{
-       private static Logger LOGGER = FlexLogger.getLogger(ClosedLoopPMPolicyService.class.getName());
-       private static PAPServices papServices = null;
+       private static final Logger LOGGER = FlexLogger.getLogger(ClosedLoopPMPolicyService.class.getName());
        
+       private PAPServices papServices = null;
        private PolicyParameters policyParameters = null;
        private String message = null;
        private String policyName = null;
@@ -68,6 +68,7 @@ public class ClosedLoopPMPolicyService{
                        configBody = PolicyApiUtils.stringToJsonObject(policyParameters.getConfigBody());
                } catch(JsonException| IllegalStateException e){
                        message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " improper JSON object : " + policyParameters.getConfigBody();
+                       LOGGER.error("Error during parsing JSON config body for Closed loop PM policy  " , e);
                        return false;
                }
                return true;
@@ -85,21 +86,31 @@ public class ClosedLoopPMPolicyService{
                } else {
                        operation = "create";
                }
-               boolean levelCheck = PolicyApiUtils.isNumeric(policyParameters.getRiskLevel());
                // get values and attributes from the JsonObject
-               String ecompName = configBody.get("ecompname").toString().replace("\"", "");
-               String serviceType = configBody.get("serviceTypePolicyName").toString().replace("\"", "");
-               String jsonBody = configBody.toString();
-               if (ecompName==null||ecompName.equals("")){
+               if(!configBody.containsKey("ecompname")){
                        message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Ecomp Name given.";
                        LOGGER.error(message);
                        return message;
                }
+               if(!configBody.containsKey("serviceTypePolicyName")){
+                       message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Service Type Policy Name given.";
+                       LOGGER.error(message);
+                       return message;
+               }
+               String ecompName = configBody.get("ecompname").toString().trim().replace("\"", "");
+               if (ecompName==null||ecompName.trim().isEmpty()){
+                       message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Ecomp Name given.";
+                       LOGGER.error(message);
+                       return message;
+               }
+               boolean levelCheck = PolicyApiUtils.isNumeric(policyParameters.getRiskLevel());
                if (!levelCheck){
                        message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.";
                        LOGGER.error(message);
                        return message;
                }
+               String jsonBody = configBody.toString();
+               String serviceType = configBody.get("serviceTypePolicyName").toString().replace("\"", "");
                // Create Policy. 
                StdPAPPolicy newPAPPolicy = new StdPAPPolicy("ClosedLoop_PM", policyName, policyParameters.getPolicyDescription(), ecompName, 
                                jsonBody, false, null, serviceType, updateFlag, policyScope, 0, policyParameters.getRiskLevel(),
index 8edd1ac..3401d55 100644 (file)
@@ -37,15 +37,14 @@ import org.openecomp.policy.xacml.std.pap.StdPAPPolicy;
  * @version 0.1
  */
 public class ConfigPolicyService {
-       private static Logger LOGGER = FlexLogger.getLogger(ConfigPolicyService.class.getName());
-       private static PAPServices papServices = null;
+       private static final Logger LOGGER = FlexLogger.getLogger(ConfigPolicyService.class.getName());
+       private PAPServices papServices = null;
        
        private PolicyParameters policyParameters = null;
        private String message = null;
        private String policyName = null;
        private String policyScope = null;
        private String date = null;
-       private boolean levelCheck = false;
        private String ecompName = null;
        private String configName = null;
        
@@ -67,6 +66,7 @@ public class ConfigPolicyService {
                        message = XACMLErrorConstants.ERROR_DATA_ISSUE+ "No Config Body Type given.";
                        return false;
                }
+               boolean levelCheck = false;
                levelCheck = PolicyApiUtils.isNumeric(policyParameters.getRiskLevel());
                if (!levelCheck){
                        message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.";
@@ -111,7 +111,7 @@ public class ConfigPolicyService {
                String body = policyParameters.getConfigBody();
                String configBody = null;
                //check body for JSON form and remove single quotes if present
-               if (configType.equalsIgnoreCase("JSON")) {
+               if ("JSON".equalsIgnoreCase(configType)) {
                        if (body.contains("'")) {
                                configBody = body.replace("'", "\"");
                        } else {
index 850115f..6dde8a2 100644 (file)
@@ -37,7 +37,7 @@ import org.openecomp.policy.xacml.api.XACMLErrorConstants;
 import org.springframework.http.HttpStatus;
 
 public class CreateUpdateConfigPolicyService {
-    private static Logger LOGGER = FlexLogger.getLogger(CreateUpdateConfigPolicyService.class.getName());
+    private static final Logger LOGGER = FlexLogger.getLogger(CreateUpdateConfigPolicyService.class.getName());
     
     private String response = null;
     private HttpStatus status = HttpStatus.BAD_REQUEST;
@@ -75,16 +75,32 @@ public class CreateUpdateConfigPolicyService {
         Map<AttributeType, Map<String, String>> attributes = new HashMap<>();
         attributes.put(AttributeType.MATCHING, configPolicyAPIRequest.getConfigAttributes());
         policyParameters.setAttributes(attributes);
-        policyParameters.setConfigBodyType(PolicyType.valueOf(configPolicyAPIRequest.getConfigType()));
+        if(configPolicyAPIRequest.getConfigType()==null){
+               String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy ConfigType given.";
+            LOGGER.error(message);
+            throw new PolicyException(message);
+        }
+        try{
+               policyParameters.setConfigBodyType(PolicyType.valueOf(configPolicyAPIRequest.getConfigType()));
+        }catch(IllegalArgumentException e){
+               String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Improper ConfigType given.";
+            LOGGER.error(message, e);
+            throw new PolicyException(message);
+        }
         policyParameters.setConfigBody(configPolicyAPIRequest.getBody());
         policyParameters.setRiskLevel(configPolicyAPIRequest.getRiskLevel());
         policyParameters.setRiskType(configPolicyAPIRequest.getRiskType());
         policyParameters.setGuard(Boolean.parseBoolean(configPolicyAPIRequest.getGuard()));
-        try {
-            policyParameters.setTtlDate(new SimpleDateFormat("dd-MM-yyyy").parse(configPolicyAPIRequest.getTtlDate()));
-        } catch (ParseException e) {
-            LOGGER.warn("Error Parsing date given " + configPolicyAPIRequest.getTtlDate());
+        if(configPolicyAPIRequest.getTtlDate()==null){
+               LOGGER.warn("No TTL date given ");
             policyParameters.setTtlDate(null);
+        }else{
+               try {
+                policyParameters.setTtlDate(new SimpleDateFormat("dd-MM-yyyy").parse(configPolicyAPIRequest.getTtlDate()));
+            } catch (ParseException e) {
+                LOGGER.warn("Error Parsing date given " + configPolicyAPIRequest.getTtlDate(), e);
+                policyParameters.setTtlDate(null);
+            }
         }
         CreateUpdatePolicyService createUpdatePolicyService = new CreateUpdatePolicyServiceImpl(policyParameters, requestID, updateFlag);
         status = createUpdatePolicyService.getResponseCode();
index 1c3049d..3c102fa 100644 (file)
@@ -34,7 +34,7 @@ import org.openecomp.policy.xacml.api.XACMLErrorConstants;
 import org.springframework.http.HttpStatus;
 
 public class CreateUpdateDictionaryService {
-    private static Logger LOGGER = FlexLogger.getLogger(CreateUpdateDictionaryService.class.getName());
+    private static final Logger LOGGER = FlexLogger.getLogger(CreateUpdateDictionaryService.class.getName());
     
     private String dictionaryResult = null;
     private HttpStatus status = HttpStatus.BAD_REQUEST;
@@ -54,7 +54,7 @@ public class CreateUpdateDictionaryService {
                     requestUUID = UUID.fromString(requestID);
                 } catch (IllegalArgumentException e) {
                     requestUUID = UUID.randomUUID();
-                    LOGGER.info("Generated Random UUID: " + requestUUID.toString());
+                    LOGGER.info("Generated Random UUID: " + requestUUID.toString(),e);
                 }
             }else{
                 requestUUID = UUID.randomUUID();
@@ -110,13 +110,12 @@ public class CreateUpdateDictionaryService {
             json = PolicyApiUtils.stringToJsonObject(dictionaryParameters.getDictionaryJson());
         } catch(JsonException| IllegalStateException e){
             message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " improper Dictionary JSON object : " + dictionaryParameters.getDictionaryJson();
-            LOGGER.error(message);
+            LOGGER.error(message, e);
             return message;
         }
         String dictionaryFields = json.toString();
         PAPServices papServices = new PAPServices();
-        String result = (String) papServices.callPAP(new ByteArrayInputStream(dictionaryFields.getBytes()), new String[] {"operation="+operation, "apiflag=api", "dictionaryType="+dictionaryParameters.getDictionary()}, dictionaryParameters.getRequestID(), "dictionaryItem");
-        return result;
+        return (String) papServices.callPAP(new ByteArrayInputStream(dictionaryFields.getBytes()), new String[] {"operation="+operation, "apiflag=api", "dictionaryType="+dictionaryParameters.getDictionary()}, dictionaryParameters.getRequestID(), "dictionaryItem");
     }
 
     private boolean getValidation() {
@@ -136,11 +135,9 @@ public class CreateUpdateDictionaryService {
             message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Dictionary JSON given.";
             return false;
         }
-        if (updateFlag && dictionaryParameters.getDictionary().equalsIgnoreCase("MicroServiceDictionary")){
-               if (!dictionaryParameters.getDictionaryJson().contains("initialFields")){
-                       message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Mising the required field initialFields.";
-                       return false;
-               }
+        if (updateFlag && "MicroServiceDictionary".equalsIgnoreCase(dictionaryParameters.getDictionary())&& !dictionaryParameters.getDictionaryJson().contains("initialFields")){
+               message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Mising the required field initialFields.";
+               return false;
         }
         return true;
     }
index b547f8d..3e5dce1 100644 (file)
@@ -33,7 +33,7 @@ import org.openecomp.policy.xacml.api.XACMLErrorConstants;
 import org.springframework.http.HttpStatus;
 
 public class CreateUpdateFirewallPolicyService {
-    private static Logger LOGGER = FlexLogger.getLogger(CreateUpdateFirewallPolicyService.class.getName());
+    private static final Logger LOGGER = FlexLogger.getLogger(CreateUpdateFirewallPolicyService.class.getName());
     
     private String response = null;
     private HttpStatus status = HttpStatus.BAD_REQUEST;
@@ -73,7 +73,7 @@ public class CreateUpdateFirewallPolicyService {
         try {
             policyParameters.setTtlDate(new SimpleDateFormat("dd-MM-yyyy").parse(configFirewallPolicyAPIRequest.getTtlDate()));
         } catch (NullPointerException | ParseException e) {
-            LOGGER.warn("Error Parsing date given " + configFirewallPolicyAPIRequest.getTtlDate());
+            LOGGER.warn("Error Parsing date given " + configFirewallPolicyAPIRequest.getTtlDate(), e);
             policyParameters.setTtlDate(null);
         }
         CreateUpdatePolicyService createUpdatePolicyService = new CreateUpdatePolicyServiceImpl(policyParameters, requestID, updateFlag);
index 4032a8a..6112c42 100644 (file)
@@ -33,7 +33,7 @@ import org.openecomp.policy.xacml.api.XACMLErrorConstants;
 import org.springframework.http.HttpStatus;
 
 public class CreateUpdatePolicyServiceImpl implements CreateUpdatePolicyService {
-       private static Logger LOGGER = FlexLogger.getLogger(CreateUpdatePolicyService.class.getName());
+       private static final Logger LOGGER = FlexLogger.getLogger(CreateUpdatePolicyServiceImpl.class.getName());
     
     private String policyResult = null;
     private HttpStatus status = HttpStatus.BAD_REQUEST;
@@ -55,7 +55,7 @@ public class CreateUpdatePolicyServiceImpl implements CreateUpdatePolicyService
                     requestUUID = UUID.fromString(requestID);
                 } catch (IllegalArgumentException e) {
                     requestUUID = UUID.randomUUID();
-                    LOGGER.info("Generated Random UUID: " + requestUUID.toString());
+                    LOGGER.info("Generated Random UUID: " + requestUUID.toString(), e);
                 }
             }else{
                 requestUUID = UUID.randomUUID();
@@ -233,7 +233,6 @@ public class CreateUpdatePolicyServiceImpl implements CreateUpdatePolicyService
         if (policyName==null||policyName.trim().isEmpty()){
             message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
             return false;
-        
         }
         message = PolicyUtils.emptyPolicyValidator(policyScope);
         if(!message.contains("success")){
index d0978fc..3b1ea23 100644 (file)
@@ -31,7 +31,7 @@ import org.openecomp.policy.xacml.std.pap.StdPAPPolicy;
 import org.springframework.http.HttpStatus;
 
 public class DeletePolicyService {
-    private static Logger LOGGER = FlexLogger.getLogger(DeletePolicyService.class.getName());
+    private static final Logger LOGGER = FlexLogger.getLogger(DeletePolicyService.class.getName());
     
     private String deleteResult = null;
     private HttpStatus status = HttpStatus.BAD_REQUEST;
@@ -53,7 +53,7 @@ public class DeletePolicyService {
                     requestUUID = UUID.fromString(requestID);
                 } catch (IllegalArgumentException e) {
                     requestUUID = UUID.randomUUID();
-                    LOGGER.info("Generated Random UUID: " + requestUUID.toString());
+                    LOGGER.info("Generated Random UUID: " + requestUUID.toString(), e);
                 }
             }else{
                 requestUUID = UUID.randomUUID();
@@ -74,7 +74,7 @@ public class DeletePolicyService {
        if(deleteResult==null){
                return;
        }
-        if (deleteResult.contains("BAD REQUEST")||deleteResult.contains("PE300")||deleteResult.contains("not exist")||deleteResult.contains("Invalid policyName")) {
+        if (deleteResult.contains("BAD REQUEST")||deleteResult.contains("PE300")||deleteResult.contains("PE200")||deleteResult.contains("not exist")||deleteResult.contains("Invalid policyName")) {
             status = HttpStatus.BAD_REQUEST;
         } else if (deleteResult.contains("locked down")){
             status = HttpStatus.ACCEPTED;
@@ -174,6 +174,10 @@ public class DeletePolicyService {
 
  private boolean getValidation() {
      // While Validating, extract the required values.
+        if (deletePolicyParameters.getPolicyName()==null||deletePolicyParameters.getPolicyName().trim().isEmpty()){
+         message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
+         return false;
+     }
      if (!deletePolicyParameters.getPolicyName().contains("xml")) {
          if (deletePolicyParameters.getPolicyName() != null
                  && deletePolicyParameters.getPolicyName().contains(".")) {
@@ -188,10 +192,6 @@ public class DeletePolicyService {
      } else {
          policyName = deletePolicyParameters.getPolicyName();
      }
-     if (deletePolicyParameters.getPolicyName()==null||deletePolicyParameters.getPolicyName().trim().isEmpty()){
-         message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
-         return false;
-     }
      policyType = deletePolicyParameters.getPolicyType();
      if(policyType== null || policyType.trim().isEmpty()){
          message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No PolicyType given.";
index 1d4305a..f301bf0 100644 (file)
@@ -36,15 +36,14 @@ import org.openecomp.policy.xacml.std.pap.StdPAPPolicy;
  * @version 0.1
  */
 public class FirewallPolicyService {
-       private static Logger LOGGER = FlexLogger.getLogger(FirewallPolicyService.class.getName());
-       private static PAPServices papServices = null;
+       private static final Logger LOGGER = FlexLogger.getLogger(FirewallPolicyService.class.getName());
        
+       private  PAPServices papServices = null;
        private PolicyParameters policyParameters = null;
        private String message = null;
        private String policyName = null;
        private String policyScope = null;
        private String date = null;
-       private boolean levelCheck = false;
        private JsonObject firewallJson = null;
        
        public FirewallPolicyService(String policyName, String policyScope,
@@ -65,12 +64,14 @@ public class FirewallPolicyService {
                        firewallJson = PolicyApiUtils.stringToJsonObject(policyParameters.getConfigBody());
                } catch(JsonException| IllegalStateException e){
                        message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " improper JSON object : " + policyParameters.getConfigBody();
+                       LOGGER.error("Error while parsing JSON body for creating Firewall Policy " , e);
                        return false;
                }
-               if(firewallJson==null){
+               if(firewallJson==null|| firewallJson.isEmpty()){
                        message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Config-Body given.";
                        return false;
                }
+               boolean levelCheck = false;
                levelCheck = PolicyApiUtils.isNumeric(policyParameters.getRiskLevel());
                if (!levelCheck){
                        message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.";
@@ -92,6 +93,11 @@ public class FirewallPolicyService {
                        operation = "create";
                }
                //set values for basic policy information
+               if(!firewallJson.containsKey("configName")){
+                       message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No configName given in firwall JSON.";
+                       LOGGER.error(message);
+                       return message;
+               }
                String configName = firewallJson.get("configName").toString();
                String configDescription = "";
                String json = firewallJson.toString();
index b501a5c..2363877 100644 (file)
@@ -20,6 +20,7 @@
 package org.openecomp.policy.pdp.rest.api.services;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -43,7 +44,7 @@ import org.openecomp.policy.xacml.api.XACMLErrorConstants;
 import org.springframework.http.HttpStatus;
 
 public class GetConfigService {
-    private static Logger LOGGER = FlexLogger.getLogger(GetConfigService.class.getName());
+    private static final Logger LOGGER = FlexLogger.getLogger(GetConfigService.class.getName());
     
     private ConfigRequestParameters configRequestParameters = null;
     private String message = null;
@@ -61,7 +62,7 @@ public class GetConfigService {
                     requestUUID = UUID.fromString(requestID);
                 } catch (IllegalArgumentException e) {
                     requestUUID = UUID.randomUUID();
-                    LOGGER.info("Generated Random UUID: " + requestUUID.toString());
+                    LOGGER.info("Generated Random UUID: " + requestUUID.toString(),e);
                 }
             }else{
                 requestUUID = UUID.randomUUID();
@@ -69,11 +70,12 @@ public class GetConfigService {
             }
             this.configRequestParameters.setRequestID(requestUUID);
         }
-        policyConfigs = new ArrayList<PolicyConfig>();
+        policyConfigs = new ArrayList<>();
         try{
             run();
             specialCheck();
         }catch(PolicyConfigException e){
+               LOGGER.error(e);
             PolicyConfig policyConfig = new PolicyConfig();
             policyConfig.setPolicyConfigMessage(e.getMessage());
             policyConfig.setPolicyConfigStatus(PolicyConfigStatus.CONFIG_NOT_FOUND);
@@ -83,7 +85,7 @@ public class GetConfigService {
     }
     
     private void specialCheck() {
-        if(policyConfigs==null || policyConfigs.size()==0){
+        if(policyConfigs==null || policyConfigs.isEmpty()){
             responseCode = HttpStatus.BAD_REQUEST;
         }else if(policyConfigs.size()==1){
             for(PolicyConfig policyConfig: policyConfigs){
@@ -125,7 +127,7 @@ public class GetConfigService {
 
     private Collection<PolicyConfig> configResult(
             Collection<PDPResponse> generateRequest) {
-        Collection<PolicyConfig> result = new HashSet<PolicyConfig>();
+        Collection<PolicyConfig> result = new HashSet<>();
         if (generateRequest == null) {
             return null;
         }
@@ -151,7 +153,7 @@ public class GetConfigService {
     private Collection<PolicyConfig> filterResults(
             Collection<PolicyConfig> policyConfigs,
             ConfigRequestParameters configRequestParameters) {
-        List<PolicyConfig> policyConfig = new ArrayList<PolicyConfig>();
+        List<PolicyConfig> policyConfig = new ArrayList<>();
         for(PolicyConfig config: policyConfigs){
             if(config.getPolicyName()!=null && configRequestParameters.getPolicyName()!=null && configRequestParameters.getPolicyName().trim().length()>0){
                 if(!config.getPolicyName().matches(configRequestParameters.getPolicyName())){
@@ -172,9 +174,23 @@ public class GetConfigService {
                 if(configRequestParameters.getConfigAttributes()!=null && configRequestParameters.getConfigAttributes().size()>0){
                     boolean flag = false; 
                     for(String key: configRequestParameters.getConfigAttributes().keySet()){
-                        if(!config.getMatchingConditions().containsKey(key) || !config.getMatchingConditions().get(key).matches(configRequestParameters.getConfigAttributes().get(key))){
-                            flag = true;
-                            break;
+                       if(key.equals("RiskType")||key.equals("RiskLevel")||key.equals("guard")||key.equals("TTLDate")){
+                               continue;
+                       }
+                        if(config.getMatchingConditions().containsKey(key)){
+                               if(config.getMatchingConditions().get(key).contains(",")){
+                                       List<String> elements = Arrays.asList(config.getMatchingConditions().get(key).split(","));
+                                       if(!elements.contains(configRequestParameters.getConfigAttributes().get(key))){
+                                               flag=true;
+                                       }
+                               }else if(!config.getMatchingConditions().get(key).matches(configRequestParameters.getConfigAttributes().get(key))){
+                               flag = true;
+                               }
+                        }else{
+                               flag = true;
+                        }
+                        if(flag){
+                               break;
                         }
                     }
                     if(flag){
@@ -184,7 +200,7 @@ public class GetConfigService {
             }
             policyConfig.add(config);
         }
-        if(policyConfig.size()==0){
+        if(policyConfig.isEmpty()){
             PolicyConfig pConfig = new PolicyConfig();
             pConfig.setPolicyConfigStatus(PolicyConfigStatus.CONFIG_NOT_FOUND);
             pConfig.setPolicyConfigMessage(XACMLErrorConstants.ERROR_DATA_ISSUE+"No Match Found, for the parameters sent.");
@@ -226,7 +242,7 @@ public class GetConfigService {
         }else{
             LOGGER.info("Ecomp Name is not given. ");
         }
-        JsonObject model = Json.createObjectBuilder()
+        return Json.createObjectBuilder()
                 .add("Request",Json.createObjectBuilder()
                                 .add("AccessSubject",Json.createObjectBuilder()
                                                 .add("Attribute",subjectArray))
@@ -240,7 +256,6 @@ public class GetConfigService {
                                                                         .add("Value","Config")
                                                                         .add("AttributeId","urn:oasis:names:tc:xacml:1.0:resource:resource-id")))))
                 .build();
-        return model;
     }
     
     private JsonArrayBuilder getResourceArray(Map<String, String> configAttributes) throws PolicyConfigException{
@@ -261,7 +276,7 @@ public class GetConfigService {
             }
         }else{
             // ConfigAttributes is Null. So add basic values.
-            configAttributes = new HashMap<String,String>();
+            configAttributes = new HashMap<>();
             configAttributes.put("RiskType", ".*");
             configAttributes.put("RiskLevel", ".*");
             configAttributes.put("guard", ".*");
index f70c3fb..1ef5e53 100644 (file)
@@ -21,6 +21,7 @@ package org.openecomp.policy.pdp.rest.api.services;
 
 import java.util.Collection;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.UUID;
 
 import javax.json.Json;
@@ -40,7 +41,7 @@ import org.openecomp.policy.xacml.api.XACMLErrorConstants;
 import org.springframework.http.HttpStatus;
 
 public class GetDecisionService {
-    private static Logger LOGGER = FlexLogger.getLogger(GetDecisionService.class.getName());
+    private static final Logger LOGGER = FlexLogger.getLogger(GetDecisionService.class.getName());
     
     private DecisionResponse decisionResponse = null;
     private HttpStatus status = HttpStatus.BAD_REQUEST;
@@ -60,7 +61,7 @@ public class GetDecisionService {
                     requestUUID = UUID.fromString(requestID);
                 } catch (IllegalArgumentException e) {
                     requestUUID = UUID.randomUUID();
-                    LOGGER.info("Generated Random UUID: " + requestUUID.toString());
+                    LOGGER.info("Generated Random UUID: " + requestUUID.toString(),e);
                 }
             }else{
                 requestUUID = UUID.randomUUID();
@@ -117,24 +118,33 @@ public class GetDecisionService {
 
     private JsonObject getModel() throws PolicyDecisionException{
         JsonArrayBuilder resourceArray = Json.createArrayBuilder();
-        for (String key : decisionAttributes.keySet()) {
-            if (key.isEmpty()) {
+        for (Entry<String,String> key : decisionAttributes.entrySet()) {
+            if (key.getKey().isEmpty()) {
                 String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot have an Empty Key";
                 LOGGER.error(message);
                 throw new PolicyDecisionException(message);
             }
             JsonObjectBuilder resourceBuilder = Json.createObjectBuilder();
-            if (decisionAttributes.get(key).matches("[0-9]+")) {
-                int val = Integer.parseInt(decisionAttributes.get(key));
-                resourceBuilder.add("Value", val);
+            if (key.getValue().matches("[0-9]+")) {
+               
+               if ((key.getKey().equals("ErrorCode")) || (key.getKey().equals("WorkStep"))) {
+                    
+                       resourceBuilder.add("Value", key.getValue());
+
+               } else {
+                       
+                    int val = Integer.parseInt(key.getValue());
+                    resourceBuilder.add("Value", val);
+                    
+               }
+               
             } else {
-                resourceBuilder.add("Value", decisionAttributes.get(key));
+                resourceBuilder.add("Value", key.getValue());
             }
-            resourceBuilder.add("AttributeId", key);
+            resourceBuilder.add("AttributeId", key.getKey());
             resourceArray.add(resourceBuilder);
         }
-        JsonObject model = Json
-                .createObjectBuilder()
+        return Json.createObjectBuilder()
                 .add("Request", Json.createObjectBuilder()
                                 .add("AccessSubject", Json.createObjectBuilder()
                                                 .add("Attribute", Json.createObjectBuilder()
@@ -147,7 +157,6 @@ public class GetDecisionService {
                                                                 .add("Value", "DECIDE")
                                                                 .add("AttributeId", "urn:oasis:names:tc:xacml:1.0:action:action-id"))))
                 .build();
-        return model;
     }
 
     private boolean getValidation() {
index 2305ecb..04567e2 100644 (file)
@@ -35,7 +35,7 @@ import org.openecomp.policy.xacml.api.XACMLErrorConstants;
 import org.springframework.http.HttpStatus;
 
 public class GetDictionaryService {
-    private static Logger LOGGER = FlexLogger.getLogger(GetDictionaryService.class.getName());
+    private static final Logger LOGGER = FlexLogger.getLogger(GetDictionaryService.class.getName());
     
     private DictionaryResponse dictionaryResponse = null;
     private HttpStatus status = HttpStatus.BAD_REQUEST;
@@ -52,7 +52,7 @@ public class GetDictionaryService {
                     requestUUID = UUID.fromString(requestID);
                 } catch (IllegalArgumentException e) {
                     requestUUID = UUID.randomUUID();
-                    LOGGER.info("Generated Random UUID: " + requestUUID.toString());
+                    LOGGER.info("Generated Random UUID: " + requestUUID.toString(), e);
                 }
             }else{
                 requestUUID = UUID.randomUUID();
@@ -72,10 +72,8 @@ public class GetDictionaryService {
     }
 
     private void specialCheck() {
-        if(dictionaryResponse!=null){
-            if(dictionaryResponse.getResponseMessage()!=null && dictionaryResponse.getResponseMessage().contains("PE300")){
-                status = HttpStatus.BAD_REQUEST;
-            }
+        if(dictionaryResponse!=null && (dictionaryResponse.getResponseMessage()!=null && dictionaryResponse.getResponseMessage().contains("PE300"))){
+               status = HttpStatus.BAD_REQUEST;
         }
     }
 
@@ -115,7 +113,7 @@ public class GetDictionaryService {
                 json = PolicyApiUtils.stringToJsonObject(datas);
             } catch(JsonException| IllegalStateException e){
                 message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " improper Dictionary JSON object : " + dictionaryParameters.getDictionaryJson();
-                LOGGER.error(message);
+                LOGGER.error(message, e);
                 response.setResponseMessage(message);
                 response.setResponseCode(400);
                 return response;
@@ -126,6 +124,11 @@ public class GetDictionaryService {
         } else {
             response.setResponseCode(400);
             response.setResponseMessage(result);
+            if(result!=null && result.contains("PE200")){
+               status=HttpStatus.INTERNAL_SERVER_ERROR;
+            }else{
+               status=HttpStatus.BAD_REQUEST;
+            }
         }
         return response;
     }
index dc431b0..5a90bfa 100644 (file)
@@ -34,12 +34,11 @@ import org.openecomp.policy.xacml.api.XACMLErrorConstants;
 import org.springframework.http.HttpStatus;
 
 public class GetMetricsService {
-       private static Logger LOGGER = FlexLogger
-                       .getLogger(GetDictionaryService.class.getName());
+       private static final Logger LOGGER = FlexLogger
+                       .getLogger(GetMetricsService.class.getName());
 
        private MetricsResponse response = null;
        private HttpStatus status = HttpStatus.BAD_REQUEST;
-       private String message = null;
        private MetricsRequestParameters metricsParameters = null;
 
        public GetMetricsService(String requestID) {
@@ -49,7 +48,7 @@ public class GetMetricsService {
                                requestUUID = UUID.fromString(requestID);
                        } catch (IllegalArgumentException e) {
                                requestUUID = UUID.randomUUID();
-                               LOGGER.info("Generated Random UUID: " + requestUUID.toString());
+                               LOGGER.info("Generated Random UUID: " + requestUUID.toString(), e);
                        }
                } else {
                        requestUUID = UUID.randomUUID();
@@ -72,11 +71,9 @@ public class GetMetricsService {
        }
 
        private void specialCheck() {
-               if (response != null) {
-                       if (response.getResponseMessage() != null
-                                       && response.getResponseMessage().contains("PE300")) {
+               if (response != null && (response.getResponseMessage() != null
+                                       && response.getResponseMessage().contains("PE300"))) {
                                status = HttpStatus.BAD_REQUEST;
-                       }
                }
        }
 
@@ -100,11 +97,12 @@ public class GetMetricsService {
                                metricsParameters.getRequestID(), "metrics");
 
                JSONObject json = null;
+               String message = null;
                if (result != null) {
                        if (result.length() > 81 && result.contains("{")) {
                                try {
                                        String responseMessage = result.substring(0, 82);
-                                       String jsonString = result.substring(result.indexOf("{"),
+                                       String jsonString = result.substring(result.indexOf('{'),
                                                        result.length());
                                        json = new JSONObject(jsonString);
 
index 636b7fb..3188292 100644 (file)
@@ -36,9 +36,9 @@ import org.openecomp.policy.xacml.std.pap.StdPAPPolicy;
  * @version 0.1
  */
 public class MicroServicesPolicyService{
-       private static Logger LOGGER = FlexLogger.getLogger(MicroServicesPolicyService.class.getName());
-       private static PAPServices papServices = null;
+       private static final Logger LOGGER = FlexLogger.getLogger(MicroServicesPolicyService.class.getName());
        
+       private PAPServices papServices = null;
        private PolicyParameters policyParameters = null;
        private String message = null;
        private String policyName = null;
@@ -46,7 +46,6 @@ public class MicroServicesPolicyService{
        private String date = null;
        private String ecompName = null;
        private JsonObject microServiceAttributes = null;
-       private boolean levelCheck = false;
        
        public MicroServicesPolicyService(String policyName, String policyScope, PolicyParameters policyParameters, String date) {
                this.policyParameters = policyParameters;
@@ -65,6 +64,7 @@ public class MicroServicesPolicyService{
                        microServiceAttributes = PolicyApiUtils.stringToJsonObject(policyParameters.getConfigBody());
                } catch(JsonException| IllegalStateException e){
                        message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " improper JSON object : " + policyParameters.getConfigBody();
+                       LOGGER.error("Error while parsing JSON body for MicroService Policy creation. ", e);
                        return false;
                }
                ecompName = policyParameters.getEcompName();
@@ -72,6 +72,7 @@ public class MicroServicesPolicyService{
                        message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Ecomp Name given.";
                        return false;
                }
+               boolean levelCheck = false;
                levelCheck = PolicyApiUtils.isNumeric(policyParameters.getRiskLevel());
                if (!levelCheck){
                        message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.";
@@ -96,7 +97,13 @@ public class MicroServicesPolicyService{
         String uuid = null;
         String msLocation = null;
         String configName = null;
-        String microService = microServiceAttributes.get("service").toString().replace("\"", "");
+        String microService = null;
+        String policyDescription=null;
+        String priority=null;
+        String version=null;
+        if (microServiceAttributes.get("service")!=null){
+               microService = microServiceAttributes.get("service").toString().replace("\"", "");
+        }
         if (microServiceAttributes.get("uuid")!=null){
             uuid = microServiceAttributes.get("uuid").toString().replace("\"", "");
         }
@@ -106,10 +113,15 @@ public class MicroServicesPolicyService{
         if (microServiceAttributes.get("configName")!=null){
             configName = microServiceAttributes.get("configName").toString().replace("\"", "");
         }
-        String policyDescription = microServiceAttributes.get("description").toString().replace("\"", "");
-        String priority = microServiceAttributes.get("priority").toString().replace("\"", "");
-        String version = microServiceAttributes.get("version").toString().replace("\"", "");
-
+        if(microServiceAttributes.containsKey("description")){
+               policyDescription = microServiceAttributes.get("description").toString().replace("\"", "");
+        }
+        if(microServiceAttributes.containsKey("priority")){
+               priority = microServiceAttributes.get("priority").toString().replace("\"", "");
+        }
+        if(microServiceAttributes.containsKey("version")){
+               version = microServiceAttributes.get("version").toString().replace("\"", "");
+        }
         // Create Policy. 
         StdPAPPolicy newPAPPolicy = new StdPAPPolicy("Micro Service", policyName, policyDescription, ecompName, 
                 configName, microService, uuid, msLocation, microServiceAttributes.toString(), priority, 
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/NotificationService.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/NotificationService.java
new file mode 100644 (file)
index 0000000..4b453fa
--- /dev/null
@@ -0,0 +1,314 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP-PDP-REST
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.policy.pdp.rest.api.services;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.openecomp.policy.api.PolicyException;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.openecomp.policy.rest.XACMLRestProperties;
+import org.openecomp.policy.utils.BusPublisher;
+import org.openecomp.policy.xacml.api.XACMLErrorConstants;
+import org.springframework.http.HttpStatus;
+
+import com.att.research.xacml.util.XACMLProperties;
+
+public class NotificationService {
+       public static final String BACKUPFILE = "topicBackup.txt";
+       private static Logger logger = FlexLogger.getLogger(GetDictionaryService.class.getName());
+       private static ConcurrentHashMap<String, Date> topicQueue = new ConcurrentHashMap<>();
+       private static int interval = 15000;  
+       private static Thread backUpthread = null;
+       private static Object resourceLock = new Object();
+       private static List<String> dmaapList = null;
+       private static String dmaapServers = null;
+       private static String aafLogin = null;
+       private static String aafPassword = null;
+       
+       private String notificationResponse = null;
+       private HttpStatus status = HttpStatus.BAD_REQUEST;
+       
+       /**
+        * NotificationService Constructor.  
+        * 
+        * @param notificationTopic Topic Name in String format. 
+        * @param requestID Request ID in String format. 
+        * @param serviceType Needs to be NotificationServiceType based enumeration value. 
+        */
+       public NotificationService(String notificationTopic, String requestID, NotificationServiceType serviceType) {
+               init();
+               if(dmaapServers==null || aafLogin==null || aafPassword==null){
+                       notificationResponse = XACMLErrorConstants.ERROR_DATA_ISSUE + "DMaaP properties are missing from the property file";
+                       return;
+               }
+               UUID requestUUID = null;
+               if (requestID != null && !requestID.isEmpty()) {
+                       try {
+                               requestUUID = UUID.fromString(requestID);
+                       } catch (IllegalArgumentException e) {
+                               requestUUID = UUID.randomUUID();
+                               logger.info("Generated Random UUID: " + requestUUID.toString(), e);
+                       }
+               }else{
+                       requestUUID = UUID.randomUUID();
+                       logger.info("Generated Random UUID: " + requestUUID.toString());
+               }
+        try{
+            run(notificationTopic, serviceType);
+        }catch(PolicyException e){
+               notificationResponse = XACMLErrorConstants.ERROR_DATA_ISSUE + e;
+            status = HttpStatus.BAD_REQUEST;
+        }
+       }
+
+       private static void init() {
+               if(dmaapServers==null || aafLogin==null || aafPassword==null){
+                       dmaapServers = XACMLProperties.getProperty(XACMLRestProperties.PROP_NOTIFICATION_SERVERS);
+                       aafLogin = XACMLProperties.getProperty("DMAAP_AAF_LOGIN");
+                       aafPassword = XACMLProperties.getProperty("DMAAP_AAF_PASSWORD");
+                       interval = Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_NOTIFICATION_DELAY, Integer.toString(interval)));
+                       if(dmaapServers==null || aafLogin==null || aafPassword==null){
+                               logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "DMaaP properties are missing from the property file ");
+                               return;
+                       }
+                       // Cleanup Values. 
+                       dmaapServers= dmaapServers.trim();
+                       aafLogin = aafLogin.trim();
+                       aafPassword = aafPassword.trim();
+                       // Get servers to List. 
+                       if(dmaapServers.contains(",")) {
+                               dmaapList = new ArrayList<>(Arrays.asList(dmaapServers.split("\\s*,\\s*")));
+                       } else {
+                               dmaapList = new ArrayList<>();
+                               dmaapList.add(dmaapServers);
+                       }
+                       callThread();
+               }
+       }
+
+       private void run(String notificationTopic, NotificationServiceType serviceType) throws PolicyException{
+               // Check Validation
+        if(notificationTopic==null){
+               String message = "Notification Topic is null";
+            logger.error(message);
+            throw new PolicyException(message);
+        }
+        notificationTopic = notificationTopic.trim();
+        if(notificationTopic.isEmpty()){
+               String message = "Notification Topic is not valid. ";
+            logger.error(message);
+            throw new PolicyException(message);
+        }
+        // if already exists give error.Saying already registered. 
+        // Get Result. 
+        try{
+            status = HttpStatus.OK;
+            switch (serviceType) {
+                       case ADD:
+                               addTopic(notificationTopic);
+                               notificationResponse = "Success!! Please give permissions to " + aafLogin + " that PDP will use to publish on given topic :" + notificationTopic +
+                               "\n Start calling /sendHeartbeat API at an interval less than " + Integer.toString(interval) + "ms";
+                               break;
+                       case REMOVE:
+                               removeTopic(notificationTopic);
+                               notificationResponse = "Notification Topic :" + notificationTopic + " has been removed and PDP will not publish notifications to this Topic.";
+                               break;
+                       case HB:
+                               heartBeat(notificationTopic);
+                               notificationResponse = "Success!! HeartBeat registered.";
+                               break;
+                       }
+        }catch (Exception e){
+            logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
+            status = HttpStatus.BAD_REQUEST;
+            throw new PolicyException(e);
+        }
+       }
+       
+       // Used to register Heart beat. 
+       private void heartBeat(String notificationTopic) throws PolicyException{
+               if(!topicQueue.isEmpty()&& topicQueue.containsKey(notificationTopic)){
+                       topicQueue.put(notificationTopic, new Date());
+               }else{
+                       logger.info("Failed HeartBeat, Topic " + notificationTopic + "is not registered.");
+                       throw new PolicyException("Failed HeartBeat, Topic " + notificationTopic + "is not registered.");
+               }
+       }
+
+       // Used to remove Topic.
+       private static void removeTopic(String notificationTopic) throws PolicyException{ 
+               if(topicQueue.containsKey(notificationTopic)){
+                       topicQueue.remove(notificationTopic);
+                       removeTopicFromBackup(notificationTopic);
+               }else{
+                       logger.info("Failed Removal, Topic " + notificationTopic + " is not registered.");
+                       throw new PolicyException("Failed Removal, Topic " + notificationTopic + " is not registered.");
+               }
+       }
+
+       private static void removeTopicFromBackup(String notificationTopic) {
+               synchronized (resourceLock) {
+                       try (Stream<String> lines = Files.lines(Paths.get(BACKUPFILE))) {
+                               List<String> replaced = lines.map(line-> (line.split("=")[0].equals(notificationTopic)?"":line)).collect(Collectors.toList());
+                               try (PrintWriter pw = new PrintWriter( BACKUPFILE, "UTF-8")) {
+                                       replaced.forEach(line-> {
+                                               if(line.trim().isEmpty()){
+                                                       return;
+                                               }
+                                               pw.println(line);
+                                       });
+                               }
+                               lines.close();
+                       } catch (IOException e) {
+                               logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + " Could not remove/recreate the backup. ", e);
+                       }
+               }
+       }
+
+       // Used to add Topic. 
+       private void addTopic(String notificationTopic) throws PolicyException{
+               // validate if topic exists. 
+               if(!topicQueue.isEmpty()&& topicQueue.containsKey(notificationTopic)){
+                       topicQueue.put(notificationTopic, new Date());
+                       logger.info("Topic " + notificationTopic + " is already registered.");
+                       throw new PolicyException("Topic " + notificationTopic + " is already registered.");
+               }
+               topicQueue.put(notificationTopic, new Date());
+               addTopictoBackUp(notificationTopic);
+       }
+
+       private void addTopictoBackUp(String notificationTopic) {
+               synchronized (resourceLock) {
+                       try {
+                               Files.write(Paths.get(BACKUPFILE),( notificationTopic+"="+new Date().toString()+"\n").getBytes() , StandardOpenOption.APPEND);
+                       } catch (IOException e) {
+                               logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + " Could not add to the backup. ", e);
+                       }
+               }
+       }
+
+       // Maintains BackUp and Queue Topic. 
+       private static void callThread() {
+               // Create the backup file if it not exists. 
+               backup();
+               if(backUpthread==null){
+                       Runnable task = () -> {
+                               logger.info("BackUpThread not set. Starting now !");
+                               threadTask();
+                       };
+                       backUpthread = new Thread(task);
+                       backUpthread.start();
+               }
+       }
+
+       private static void backup(){
+               synchronized (resourceLock) {
+                       try{
+                               File backUpFile = new File(BACKUPFILE);
+                               if(!backUpFile.exists() && backUpFile.createNewFile()){
+                                       logger.info(" BackUp File for topic's has been created !");
+                               }else{
+                                       // File Already exists. Process file and load the Memory. 
+                                       Stream<String> stream = Files.lines(Paths.get(BACKUPFILE));
+                                       Map<String,Date> data = stream.map(line -> line.split(",")).collect(Collectors.toMap(e->e[0],e-> new Date()));
+                                       stream.close();
+                                       data.forEach((key, value)->logger.debug("Topic retrieved from backUp : " + key + " with Time : " + value));
+                                       topicQueue.putAll(data);
+                               }
+                       }catch(IOException e){
+                               logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + " Could not process the backup. ", e);
+                       }
+               }
+       }
+
+       private static void threadTask() {
+               while(true){
+                       try {
+                               TimeUnit.MILLISECONDS.sleep(interval);
+                               for(Map.Entry<String, Date> map : topicQueue.entrySet()){
+                                       Date currentTime = new Date();
+                                       long timeDiff = 0;
+                                       timeDiff = currentTime.getTime()-map.getValue().getTime();
+                                       if(timeDiff < (interval+1500)){
+                                               removeTopic(map.getKey());
+                                       }
+                               }
+                       } catch (InterruptedException | PolicyException e) {
+                               logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error during thread execution ", e);
+                       }
+               }
+       }
+
+       public String getResult() {
+               return notificationResponse;
+       }
+
+       public HttpStatus getResponseCode() {
+               return status;
+       }
+
+       /**
+        * Entry point for sending Notifications from Notification Server. 
+        * @param notification String JSON format of notification message which needs to be sent. 
+        */
+       public static void sendNotification(String notification) {
+               init();
+               for (String topic: topicQueue.keySet()){
+                       sendDmaapMessage(topic, notification);
+               }
+       }
+       
+       private static void sendDmaapMessage(String topic, String notification) {
+               BusPublisher publisher = new BusPublisher.DmaapPublisherWrapper(dmaapList, 
+                                                                              topic, 
+                                                                              aafLogin, 
+                                                                              aafPassword);
+               // Sending notification through DMaaP Message Router
+               publisher.send( "MyPartitionKey", notification);
+               logger.debug("Message Published on DMaaP :" + dmaapList.get(0) + "for Topic: " + topic);
+               publisher.close();
+       }
+       
+       /**
+        *  Notification service Type Enumeration 
+        */
+       public enum NotificationServiceType{
+               ADD,
+               REMOVE,
+               HB
+       }
+
+}
\ No newline at end of file
index 4a705f5..66a5570 100644 (file)
@@ -459,6 +459,11 @@ public class PAPServices {
                         + "Group Policy Scope List Exist Error:  The Group Policy Scope List for this Dictionary Item already exist in the database. "
                         + "Duplicate Group Policy Scope Lists for multiple groupNames is not allowed. "
                         + "Please review the request and verify that the groupPolicyScopeListData1 is unique compared to existing groups.";
+            } else if("PolicyInPDP".equals(connection.getHeaderField("error"))){
+               response = XACMLErrorConstants.ERROR_DATA_ISSUE
+                        + "Policy Exist Error:  The Policy trying to be deleted is active in PDP. "
+                        + "Active PDP Polcies are not allowed to be deleted from PAP. "
+                        + "Please First remove the policy from PDP in order to successfully delete the Policy from PAP.";
             }
             LOGGER.error(response);
         } else if (connection.getResponseCode() == 500 && connection.getHeaderField("error") != null) {
@@ -499,7 +504,7 @@ public class PAPServices {
                         + "Could not create or update the policy for and unknown reason";
             }else{
                 response = XACMLErrorConstants.ERROR_DATA_ISSUE
-                        + "BAD REQUEST:  Error occured while attempting perform this operation.. the request may be incorrect.";
+                        + "BAD REQUEST:  Error occured while attempting perform this operation.. the request may be incorrect. " + connection.getHeaderField("error");
             }
             LOGGER.error(response);
         } else {
index a25c322..fb7b8e2 100644 (file)
@@ -70,12 +70,12 @@ import com.att.research.xacml.std.json.JSONResponse;
 import com.att.research.xacml.util.XACMLProperties;
 
 public class PDPServices {
-    private static Logger LOGGER = FlexLogger.getLogger(PDPServices.class.getName());
+    private static final Logger LOGGER = FlexLogger.getLogger(PDPServices.class.getName());
     // Change the default Priority value here. 
     private static final int DEFAULT_PRIORITY = 9999;
     private boolean unique = false;
     private Boolean decide = false;
-    private Matches match = null;
+    private Request rainydayRequest = null;
     
     public Collection<PDPResponse> generateRequest(String jsonString, UUID requestID, boolean unique, boolean decide) throws PolicyException{
         this.unique = unique;
@@ -85,13 +85,17 @@ public class PDPServices {
         // Create Request. We need XACML API here.
         try {
             Request request = JSONRequest.load(jsonString);
+            // Assign a rainy day treatment request to parse the decided treatment
+               if (jsonString.contains("BB_ID")) {
+                       rainydayRequest = request;
+               }
             // Call the PDP
-            LOGGER.debug("--- Generating Request: ---\n" + JSONRequest.toString(request));
+            LOGGER.info("--- Generating Request: ---\n" + JSONRequest.toString(request));
             response = callPDP(request, requestID);
         } catch (Exception e) {
             LOGGER.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID + e);
             PDPResponse pdpResponse = new PDPResponse();
-            results = new HashSet<PDPResponse>();
+            results = new HashSet<>();
             pdpResponse.setPolicyConfigMessage("Unable to Call PDP. Error with the URL");
             pdpResponse.setPolicyConfigStatus(PolicyConfigStatus.CONFIG_NOT_FOUND);
             pdpResponse.setPolicyResponseStatus(PolicyResponseStatus.NO_ACTION_REQUIRED);
@@ -101,9 +105,9 @@ public class PDPServices {
         if (response != null) {
             results = checkResponse(response);
         } else {
-            LOGGER.debug("No Response Received from PDP");
+            LOGGER.info("No Response Received from PDP");
             PDPResponse pdpResponse = new PDPResponse();
-            results = new HashSet<PDPResponse>();
+            results = new HashSet<>();
             pdpResponse.setPolicyConfigMessage("No Response Received");
             pdpResponse.setPolicyConfigStatus(PolicyConfigStatus.CONFIG_NOT_FOUND);
             pdpResponse.setPolicyResponseStatus(PolicyResponseStatus.NO_ACTION_REQUIRED);
@@ -119,10 +123,19 @@ public class PDPServices {
         Map<Integer, PDPResponse> uniqueResult = new HashMap<>();
         for (Result result : response.getResults()) {
             if (!result.getDecision().equals(Decision.PERMIT)) {
-                LOGGER.debug("Decision not a Permit. "  + result.getDecision().toString());
+                LOGGER.info("Decision not a Permit. "  + result.getDecision().toString());
                 PDPResponse pdpResponse = new PDPResponse();
                 if (decide) {
-                    pdpResponse.setDecision(PolicyDecision.DENY);
+                       String indeterminatePropValue = XACMLProperties.getProperty("decision.inStringdeterminate.response");
+                       if(result.getDecision().equals(Decision.INDETERMINATE)&& indeterminatePropValue != null){
+                               if("PERMIT".equalsIgnoreCase(indeterminatePropValue)){
+                                       pdpResponse.setDecision(PolicyDecision.PERMIT);
+                               }else{
+                                       pdpResponse.setDecision(PolicyDecision.DENY);
+                               }
+                       }else{
+                               pdpResponse.setDecision(PolicyDecision.DENY);
+                       }
                     for(Advice advice: result.getAssociatedAdvice()){
                         for(AttributeAssignment attribute: advice.getAttributeAssignments()){
                             pdpResponse.setDetails(attribute.getAttributeValue().getValue().toString());
@@ -140,7 +153,13 @@ public class PDPServices {
                     // check for Decision for decision based calls.
                     PDPResponse pdpResponse = new PDPResponse();
                     pdpResponse.setDecision(PolicyDecision.PERMIT);
-                    pdpResponse.setDetails("Decision Permit. OK!");
+                    
+                       //if this is a Rainy Day treatment decision we need to get the selected treatment
+                       if(rainydayRequest!=null){
+                               pdpResponse.setDetails(getRainyDayTreatment(result));
+                       } else {
+                        pdpResponse.setDetails("Decision Permit. OK!");
+                       }
                     combinedResult.add(pdpResponse);
                     return combinedResult;
                 }
@@ -152,7 +171,7 @@ public class PDPServices {
                         String configURL = null;
                         String policyName = null;
                         String policyVersion = null;
-                        match = new Matches();
+                        Matches match = new Matches();
                         Map<String, String> matchingConditions = new HashMap<>();
                         Map<String, String> configAttributes = new HashMap<>();
                         Map<String, String> responseAttributes = new HashMap<>();
@@ -161,7 +180,7 @@ public class PDPServices {
                         Map<String, String> adviseAttributes = new HashMap<>();
                         for (AttributeAssignment attribute : advice.getAttributeAssignments()) {
                             adviseAttributes.put(attribute.getAttributeId().stringValue(), attribute.getAttributeValue().getValue().toString());
-                            if (attribute.getAttributeValue().getValue().toString().equalsIgnoreCase("CONFIGURATION")) {
+                            if ("CONFIGURATION".equalsIgnoreCase(attribute.getAttributeValue().getValue().toString())) {
                                 config++;
                             } else if (attribute.getDataTypeId().stringValue().endsWith("anyURI")) {
                                 uri++;
@@ -169,29 +188,29 @@ public class PDPServices {
                                     configURL = attribute.getAttributeValue().getValue().toString();
                                     pdpConfigLocation = configURL.replace("$URL", XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_WEBAPPS));
                                 } else {
-                                    if (!(attribute.getIssuer().equalsIgnoreCase("PDP"))) {
+                                    if (!("PDP".equalsIgnoreCase(attribute.getIssuer()))) {
                                         throw new PolicyException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Error having multiple URI in the Policy");
                                     }
                                 }
-                            } else if (attribute.getAttributeId().stringValue().equalsIgnoreCase("PolicyName")) {
+                            } else if ("PolicyName".equalsIgnoreCase(attribute.getAttributeId().stringValue())) {
                                 policyName = attribute.getAttributeValue().getValue().toString();
-                            } else if (attribute.getAttributeId().stringValue().equalsIgnoreCase("VersionNumber")) {
+                            } else if ("VersionNumber".equalsIgnoreCase(attribute.getAttributeId().stringValue())) {
                                 policyVersion = attribute.getAttributeValue().getValue().toString();
-                            } else if (attribute.getAttributeId().stringValue().equalsIgnoreCase("Priority")){
+                            } else if ("Priority".equalsIgnoreCase(attribute.getAttributeId().stringValue())){
                                 try{
                                     priority = Integer.parseInt(attribute.getAttributeValue().getValue().toString());
                                 } catch(Exception e){
-                                    LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE+ "Unable to Parse Integer for Priority. Setting to default value");
+                                    LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE+ "Unable to Parse Integer for Priority. Setting to default value",e);
                                     priority = DEFAULT_PRIORITY;
                                 }
                             } else if (attribute.getAttributeId().stringValue().startsWith("matching")) {
                                 matchingConditions.put(attribute.getAttributeId().stringValue()
                                         .replaceFirst("(matching).", ""),attribute.getAttributeValue().getValue().toString());
-                                if (attribute.getAttributeId().stringValue()
-                                        .replaceFirst("(matching).", "").equals("ECOMPName")) {
+                                if ("ECOMPName".equals(attribute.getAttributeId().stringValue()
+                                        .replaceFirst("(matching).", ""))) {
                                     match.setEcompName(attribute.getAttributeValue().getValue().toString());
-                                } else if (attribute.getAttributeId().stringValue()
-                                        .replaceFirst("(matching).", "").equals("ConfigName")) {
+                                } else if ("ConfigName".equals(attribute.getAttributeId().stringValue()
+                                        .replaceFirst("(matching).", ""))) {
                                     match.setConfigName(attribute.getAttributeValue().getValue().toString());
                                 } else {
                                     configAttributes.put(attribute.getAttributeId().stringValue()
@@ -296,6 +315,23 @@ public class PDPServices {
         
         return combinedResult;
     }
+    
+    private String getRainyDayTreatment(Result result) {
+       String treatment = null;
+       if (rainydayRequest!=null&& !result.getAssociatedAdvice().isEmpty()) {
+               // Get the desired treatment for requested errorCode from the Advice
+               for (Advice advice : result.getAssociatedAdvice()) {
+                       Map<String, String> adviseAttributes = new HashMap<>();
+                       for (AttributeAssignment attribute : advice.getAttributeAssignments()) {
+                               adviseAttributes.put(attribute.getAttributeId().stringValue(), attribute.getAttributeValue().getValue().toString());
+                               if ("treatment".equalsIgnoreCase(attribute.getAttributeId().stringValue())){
+                                       treatment = attribute.getAttributeValue().getValue().toString();
+                               }
+                       }   
+               }
+       }
+       return treatment;
+    }
 
     private PDPResponse configCall(String pdpConfigLocation) throws Exception{
         PDPResponse pdpResponse = new PDPResponse();
@@ -392,7 +428,7 @@ public class PDPServices {
         // call the PDPEngine to decide and give the response on the Request.
         try {
             response = pdpEngine.decide(request);
-            LOGGER.debug("Response from the PDP is: \n" + JSONResponse.toString(response));
+            LOGGER.info("Response from the PDP is: \n" + JSONResponse.toString(response));
         } catch (Exception e) {
             LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
             return null;
index ee8683f..a703c50 100644 (file)
@@ -34,7 +34,7 @@ import com.att.research.xacml.api.pap.PAPException;
 import com.att.research.xacml.api.pap.PDPPolicy;
 
 public class PushPolicyService {
-    private static Logger LOGGER = FlexLogger.getLogger(PushPolicyService.class.getName());
+    private static final Logger LOGGER = FlexLogger.getLogger(PushPolicyService.class.getName());
     
     private String pushResult = null;
     private HttpStatus status = HttpStatus.BAD_REQUEST;
@@ -57,7 +57,7 @@ public class PushPolicyService {
                     requestUUID = UUID.fromString(requestID);
                 } catch (IllegalArgumentException e) {
                     requestUUID = UUID.randomUUID();
-                    LOGGER.info("Generated Random UUID: " + requestUUID.toString());
+                    LOGGER.info("Generated Random UUID: " + requestUUID.toString(), e);
                 }
             }else{
                 requestUUID = UUID.randomUUID();
@@ -107,31 +107,6 @@ public class PushPolicyService {
              LOGGER.error(response);
              return response;
         }
-        /* //String activeVersion = papServices.getActiveVersion(policyScope, filePrefix, policyName, clientScope, pushPolicyParameters.getRequestID());
-        LOGGER.debug("The active version of " + policyScope + File.separator + filePrefix + policyName + " is " + activeVersion);
-        String id = null;
-        if ("pe100".equalsIgnoreCase(activeVersion)) {
-            response = XACMLErrorConstants.ERROR_PERMISSIONS + "response code of the URL is 403. PEP is not Authorized for making this Request!! "
-                    + "Contact Administrator for this Scope. "; 
-            LOGGER.error(response);
-            return response;
-        } else if ("pe300".equalsIgnoreCase(activeVersion)) {
-            response = XACMLErrorConstants.ERROR_DATA_ISSUE + "response code of the URL is 404.  "
-                    + "This indicates a problem with getting the version from the PAP or the policy does not exist.";
-            LOGGER.error(response);
-            return response;
-        }
-        if (!activeVersion.equalsIgnoreCase("0")) {
-            id = policyScope + "." + filePrefix + policyName + "." + activeVersion + ".xml";
-            LOGGER.debug("The policyId is " + id);
-        } else {
-            response = XACMLErrorConstants.ERROR_DATA_ISSUE + "could not retrieve the activeVersion for this policy.  "
-                    + "This indicates the policy does not exist, please verify the policy exists."; 
-            LOGGER.error(response);
-            return response;
-        }
-        StdPDPPolicy selectedPolicy = papServices.getGitPath(policyScope, filePrefix, policyName, activeVersion, clientScope, pushPolicyParameters.getRequestID(), id);
-        */
         try {
             LOGGER.debug("StdPDPPolicy object contains: " + selectedPolicy.getId() + ", " + selectedPolicy.getName() + ", " + selectedPolicy.getLocation().toString());
             response = copyPolicy(selectedPolicy, pdpGroup, clientScope, pushPolicyParameters.getRequestID());
@@ -181,9 +156,9 @@ public class PushPolicyService {
         // While Validating, extract the required values.
         if (pushPolicyParameters.getPolicyName() != null
                 && pushPolicyParameters.getPolicyName().contains(".")) {
-            policyName = pushPolicyParameters.getPolicyName().substring(pushPolicyParameters.getPolicyName().lastIndexOf(".") + 1,
+            policyName = pushPolicyParameters.getPolicyName().substring(pushPolicyParameters.getPolicyName().lastIndexOf('.') + 1,
                     pushPolicyParameters.getPolicyName().length());
-            policyScope = pushPolicyParameters.getPolicyName().substring(0,pushPolicyParameters.getPolicyName().lastIndexOf("."));
+            policyScope = pushPolicyParameters.getPolicyName().substring(0,pushPolicyParameters.getPolicyName().lastIndexOf('.'));
             LOGGER.info("Name is " + policyName + "   scope is " + policyScope);
         } else {
             message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.";
index 412adfa..c16872e 100644 (file)
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.UUID;
 
 import javax.json.Json;
@@ -42,7 +43,7 @@ import org.openecomp.policy.xacml.api.XACMLErrorConstants;
 import org.springframework.http.HttpStatus;
 
 public class SendEventService {
-    private static Logger LOGGER = FlexLogger.getLogger(SendEventService.class.getName());
+    private static final Logger LOGGER = FlexLogger.getLogger(SendEventService.class.getName());
     
     private Collection<PolicyResponse> policyResponses = null;
     private HttpStatus status = HttpStatus.BAD_REQUEST;
@@ -59,7 +60,7 @@ public class SendEventService {
                     requestUUID = UUID.fromString(requestID);
                 } catch (IllegalArgumentException e) {
                     requestUUID = UUID.randomUUID();
-                    LOGGER.info("Generated Random UUID: " + requestUUID.toString());
+                    LOGGER.info("Generated Random UUID: " + requestUUID.toString(), e);
                 }
             }else{
                 requestUUID = UUID.randomUUID();
@@ -67,7 +68,7 @@ public class SendEventService {
             }
             this.eventRequestParameters.setRequestID(requestUUID);
         }
-        policyResponses = new ArrayList<PolicyResponse>();
+        policyResponses = new ArrayList<>();
         try{
             run();
         }catch(PolicyEventException e){
@@ -104,7 +105,7 @@ public class SendEventService {
             Collection<PDPResponse> generateRequest) {
         Collection<PolicyResponse> result = new HashSet<>();
         if (generateRequest == null) {
-            return null;
+            return result;
         }
         if (!generateRequest.isEmpty()) {
             for (PDPResponse stdStatus : generateRequest) {
@@ -123,29 +124,27 @@ public class SendEventService {
     private JsonObject getModel() throws PolicyEventException{
         JsonArrayBuilder resourceArray = Json.createArrayBuilder();
         Map<String,String> eventAttributes = eventRequestParameters.getEventAttributes();
-        for (String key : eventAttributes.keySet()) {
-            if (key.isEmpty()) {
+        for (Entry<String,String> key : eventAttributes.entrySet()) {
+            if (key.getKey().isEmpty()) {
                 String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot have an Empty Key";
                 LOGGER.error(message);
                 throw new PolicyEventException(message);
             }
             JsonObjectBuilder resourceBuilder = Json.createObjectBuilder();
-            if (eventAttributes.get(key).matches("[0-9]+")) {
-                int val = Integer.parseInt(eventAttributes.get(key));
+            if (key.getValue().matches("[0-9]+")) {
+                int val = Integer.parseInt(key.getValue());
                 resourceBuilder.add("Value", val);
             } else {
-                resourceBuilder.add("Value", eventAttributes.get(key));
+                resourceBuilder.add("Value", key.getValue());
             }
-            resourceBuilder.add("AttributeId", key);
+            resourceBuilder.add("AttributeId", key.getKey());
             resourceArray.add(resourceBuilder);
         }
-        JsonObject model = Json
-                .createObjectBuilder()
+        return Json.createObjectBuilder()
                 .add("Request", Json.createObjectBuilder()
                                 .add("Resource",Json.createObjectBuilder()
                                                 .add("Attribute",resourceArray)))
                 .build();
-        return model;
     }
 
     private boolean getValidation() {
index a226a3a..214151d 100644 (file)
@@ -36,6 +36,7 @@ import java.nio.file.Paths;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.Map;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.filefilter.WildcardFileFilter;
@@ -81,7 +82,7 @@ public class NotificationController {
        private static String pdpURL = null;
        private static Boolean notificationFlag = false; 
        
-       public void check(PDPStatus newStatus,HashMap<String, PolicyDef> policyContainer) {
+       public void check(PDPStatus newStatus,Map<String, PolicyDef> policyContainer) {
                boolean updated = false;
                boolean removed = false;
                Notification notification = new Notification();
@@ -167,15 +168,11 @@ public class NotificationController {
                                        notificationJSON= record(notification);
                                }catch(Exception e){
                                        LOGGER.error(e);
-                                       // TODO:EELF Cleanup - Remove LOGGER
-                                       //PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "");
                                }
                                NotificationServer.setUpdate(notificationJSON);
                                ManualNotificationUpdateThread.setUpdate(notificationJSON);
                        } catch (JsonProcessingException e) {
                                LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e.getMessage());
-                               // TODO:EELF Cleanup - Remove LOGGER
-                               //PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "");
                        }
                }
        }
@@ -194,15 +191,13 @@ public class NotificationController {
        private void sendremove(PDPPolicy oldPolicy) {
                removed = new Removed();
                // Want to know what is removed ?
-               // LOGGER.info("The Policy removed is: " + oldPolicy.getId());
-               // LOGGER.info("The version no. is: " + oldPolicy.getVersion());
                LOGGER.info("Policy removed: " + oldPolicy.getId()+ " with version number: " + oldPolicy.getVersion());
                removed.setPolicyName(oldPolicy.getId());
                removed.setVersionNo(oldPolicy.getVersion());
                removeFile(oldPolicy);
        }
 
-       private void sendUpdate(PDPPolicy newPolicy,HashMap<String, PolicyDef> policyContainer) {
+       private void sendUpdate(PDPPolicy newPolicy,Map<String, PolicyDef> policyContainer) {
                updated = new Updated();
                // Want to know what is new ?
                LOGGER.info("The new Policy is: " + newPolicy.getId());
@@ -327,8 +322,6 @@ public class NotificationController {
                        json = om.writeValueAsString(record);
                } catch (JsonProcessingException e) {
                        LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e.getMessage());
-                       // TODO:EELF Cleanup - Remove LOGGER
-                       //PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "");
                }
                LOGGER.info(json);
                return json;
index 21fb8f3..55ab760 100644 (file)
@@ -42,6 +42,7 @@ import org.openecomp.policy.common.logging.eelf.MessageCodes;
 import org.openecomp.policy.common.logging.eelf.PolicyLogger;
 import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
 import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.openecomp.policy.pdp.rest.api.services.NotificationService;
 import org.openecomp.policy.rest.XACMLRestProperties;
 import org.openecomp.policy.utils.BusPublisher;
 import org.openecomp.policy.xacml.api.XACMLErrorConstants;
@@ -63,7 +64,7 @@ import com.att.research.xacml.util.XACMLProperties;
 @ServerEndpoint(value = "/notifications")
 public class NotificationServer {
        private static final Logger LOGGER      = FlexLogger.getLogger(NotificationServer.class);
-       private static Queue<Session> queue = new ConcurrentLinkedQueue<Session>();
+       private static Queue<Session> queue = new ConcurrentLinkedQueue<>();
        private static String update = null;
        private static  String hosts = null;
        private static URL aURL = null;
@@ -104,7 +105,7 @@ public class NotificationServer {
 
                LOGGER.debug("Notification set to " + propNotificationType);
                if (propNotificationType.equals("ueb")){
-                       
+
                        String topic = null;
                        try {
                                aURL = new URL(pdpURL);
@@ -118,7 +119,7 @@ public class NotificationServer {
                        hosts = XACMLProperties.getProperty(XACMLRestProperties.PROP_NOTIFICATION_SERVERS);
                        String apiKey = XACMLProperties.getProperty(XACMLRestProperties.PROP_UEB_API_KEY);
                        String apiSecret = XACMLProperties.getProperty(XACMLRestProperties.PROP_UEB_API_SECRET);
-                       
+
                        LOGGER.debug("Creating Publisher for host: " + hosts + " with topic: " + topic);
                        CambriaBatchingPublisher pub = null;
                        try {
@@ -126,7 +127,7 @@ public class NotificationServer {
                                        LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "UEB properties are missing from the property file ");
                                        throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE + "UEB properties are missing from the property file ");
                                }
-                               
+
                                hosts.trim();
                                topic.trim();
                                apiKey.trim();
@@ -136,8 +137,8 @@ public class NotificationServer {
                                                .onTopic ( topic )
                                                .authenticatedBy ( apiKey, apiSecret )
                                                .build ()
-                                       ;
-                               
+                                               ;
+
                        } catch (MalformedURLException e1) {
                                LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error creating the UEB publisher" + e1.getMessage());
                        } catch (GeneralSecurityException e1) {
@@ -147,7 +148,7 @@ public class NotificationServer {
                                try {
                                        pub.send( "MyPartitionKey", notification );
                                } catch (IOException e) {
-                                       LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error sending notification update" + e.getMessage() + e);
+                                       LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error sending notification update" + e.getMessage());
                                }
                                // close the publisher. The batching publisher does not send events
                                // immediately, so you MUST use close to send any remaining messages.
@@ -156,7 +157,7 @@ public class NotificationServer {
                                // they're returned to your app. You could, for example, persist to disk
                                // and try again later.
                                final List<?> stuck = pub.close ( 20, TimeUnit.SECONDS );
-                               
+
                                if (!stuck.isEmpty()){
                                        LOGGER.error( stuck.size() + " messages unsent" );
                                }else{
@@ -184,7 +185,7 @@ public class NotificationServer {
                                
                                List<String> dmaapList = null;
                                if(dmaapServers.contains(",")) {
-                                       dmaapList = new ArrayList<String>(Arrays.asList(dmaapServers.split("\\s*,\\s*")));
+                                       dmaapList = new ArrayList<>(Arrays.asList(dmaapServers.split("\\s*,\\s*")));
                                } else {
                                        dmaapList = new ArrayList<>();
                                        dmaapList.add(dmaapServers);
@@ -213,9 +214,11 @@ public class NotificationServer {
                                LOGGER.info(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error in sending the Event Notification: "+ e.getMessage());
                        }
                }
+               NotificationService.sendNotification(notification);
        }
-       
+
        public static void setUpdate(String update) {
                NotificationServer.update = update;
        }
+       
 }
index 581abbe..e0d2f18 100644 (file)
@@ -95,7 +95,6 @@ public class XACMLPdpServletTest extends TestCase{
        
                System.setProperty("xacml.properties", "xacml.pdp.properties");
                System.setProperty("xacml.rest.pdp.config", "config_testing");
-               System.setProperty("xacml.rest.pep.idfile", "testclient.properties"); 
                System.setProperty("xacml.rest.pdp.webapps", "/webapps");
                System.setProperty("xacml.rootPolicies", "test_PolicyEngine.xml");
                System.setProperty("xacml.referencedPolicies", "test_PolicyEngine.xml");
diff --git a/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/services/PDPServicesTest.java b/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/services/PDPServicesTest.java
new file mode 100644 (file)
index 0000000..fd20e31
--- /dev/null
@@ -0,0 +1,194 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP-PDP-REST
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.policy.pdp.rest.api.services;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+import java.util.Map.Entry;
+
+import javax.json.Json;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+
+import org.junit.*;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+import org.openecomp.policy.api.DecisionRequestParameters;
+import org.openecomp.policy.api.PolicyDecisionException;
+import org.openecomp.policy.pdp.rest.api.models.PDPResponse;
+import org.openecomp.policy.pdp.rest.config.PDPRestConfig;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {PDPRestConfig.class})
+@WebAppConfiguration
+public class PDPServicesTest {
+       /**
+        * Run the PDPServices() constructor test.
+        *
+        * @generatedBy CodePro at 7/20/17 9:26 AM
+        */
+       @Test
+       public void testPDPServices_1()
+               throws Exception {
+               PDPServices result = new PDPServices();
+               assertNotNull(result);
+               // add additional test code here
+       }
+
+       /**
+        * Run the Collection<PDPResponse> generateRequest(String,UUID,boolean,boolean) method test.
+        *
+        * @throws Exception
+        *
+        * @generatedBy CodePro at 7/20/17 9:26 AM
+        */
+       @Test
+       public void testGenerateRequest_1()
+               throws Exception {
+               DecisionRequestParameters pep = new DecisionRequestParameters();
+               Map<String,String> eventAttributes = new HashMap<>();
+               eventAttributes.put("TEST", "test");
+               pep.setECOMPComponentName("te123");
+               pep.setDecisionAttributes(eventAttributes);
+               PDPServices fixture = new PDPServices();
+
+               //Failure Tests. 
+               String jsonString = getModel(pep).toString();
+               UUID requestID = UUID.randomUUID();
+
+               Collection<PDPResponse> result = fixture.generateRequest(jsonString, requestID, false, true);
+
+               // add additional test code here
+               // An unexpected exception was thrown in user code while executing this test:
+               //    java.lang.NoClassDefFoundError: Could not initialize class org.openecomp.policy.pdp.rest.api.services.PDPServices
+               assertNotNull(result);
+       
+       }
+
+    private JsonObject getModel(DecisionRequestParameters pep) throws PolicyDecisionException{
+        JsonArrayBuilder resourceArray = Json.createArrayBuilder();
+        
+        Map<String, String> decisionAttributes = pep.getDecisionAttributes();
+        for (Entry<String,String> key : decisionAttributes.entrySet()) {
+            JsonObjectBuilder resourceBuilder = Json.createObjectBuilder();
+            if (key.getValue().matches("[0-9]+")) {
+               
+               if ((key.getKey().equals("ErrorCode")) || (key.getKey().equals("WorkStep"))) {
+                    
+                       resourceBuilder.add("Value", key.getValue());
+
+               } else {
+                       
+                    int val = Integer.parseInt(key.getValue());
+                    resourceBuilder.add("Value", val);
+                    
+               }
+               
+            } else {
+                resourceBuilder.add("Value", key.getValue());
+            }
+            resourceBuilder.add("AttributeId", key.getKey());
+            resourceArray.add(resourceBuilder);
+        }
+        return Json.createObjectBuilder()
+                .add("Request", Json.createObjectBuilder()
+                                .add("AccessSubject", Json.createObjectBuilder()
+                                                .add("Attribute", Json.createObjectBuilder()
+                                                                .add("Value", pep.getECOMPComponentName())
+                                                                .add("AttributeId", "ECOMPName")))
+                                .add("Resource", Json.createObjectBuilder()
+                                                .add("Attribute", resourceArray))
+                                .add("Action", Json.createObjectBuilder()
+                                                .add("Attribute", Json.createObjectBuilder()
+                                                                .add("Value", "DECIDE")
+                                                                .add("AttributeId", "urn:oasis:names:tc:xacml:1.0:action:action-id"))))
+                .build();
+    }
+    
+       /**
+        * Run the Collection<PDPResponse> generateRequest(String,UUID,boolean,boolean) method test.
+        *
+        * @throws Exception
+        *
+        * @generatedBy CodePro at 7/20/17 9:26 AM
+        */
+       @Test(expected = org.openecomp.policy.api.PolicyException.class)
+       public void testGenerateRequest_2()
+               throws Exception {
+               PDPServices fixture = new PDPServices();
+               fixture.generateRequest("", UUID.randomUUID(), true, true);
+               String jsonString = "";
+               UUID requestID = UUID.randomUUID();
+               boolean unique = true;
+               boolean decide = true;
+
+               Collection<PDPResponse> result = fixture.generateRequest(jsonString, requestID, unique, decide);
+
+               // add additional test code here
+               assertNotNull(result);
+       }
+
+       /**
+        * Perform pre-test initialization.
+        *
+        * @throws Exception
+        *         if the initialization fails for some reason
+        *
+        * @generatedBy CodePro at 7/20/17 9:26 AM
+        */
+       @Before
+       public void setUp()
+               throws Exception {
+               // add additional set up code here
+       }
+
+       /**
+        * Perform post-test clean-up.
+        *
+        * @throws Exception
+        *         if the clean-up fails for some reason
+        *
+        * @generatedBy CodePro at 7/20/17 9:26 AM
+        */
+       @After
+       public void tearDown()
+               throws Exception {
+               // Add additional tear down code here
+       }
+
+       /**
+        * Launch the test.
+        *
+        * @param args the command line arguments
+        *
+        * @generatedBy CodePro at 7/20/17 9:26 AM
+        */
+       public static void main(String[] args) {
+               new org.junit.runner.JUnitCore().run(PDPServicesTest.class);
+       }
+}
\ No newline at end of file
diff --git a/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/test/NotificationAPITest.java b/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/test/NotificationAPITest.java
new file mode 100644 (file)
index 0000000..8d6cf89
--- /dev/null
@@ -0,0 +1,87 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP-PDP-REST
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.policy.pdp.rest.api.test;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.policy.pdp.rest.api.services.NotificationService;
+import org.openecomp.policy.pdp.rest.api.services.NotificationService.NotificationServiceType;
+import org.openecomp.policy.xacml.api.XACMLErrorConstants;
+import org.springframework.http.HttpStatus;
+
+import com.att.research.xacml.util.XACMLProperties;
+
+public class NotificationAPITest {
+       
+       @Before
+       public void setup() throws IOException{
+               // Fix properties for next test cases. 
+               XACMLProperties.reloadProperties();
+               System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/pass.xacml.pdp.properties");
+               XACMLProperties.getProperties();
+       }
+       
+       @Test
+       public void testPropertyFailure() throws IOException{
+               // Change properties and fail. 
+               XACMLProperties.reloadProperties();
+               System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/fail.xacml.pdp.properties");
+               XACMLProperties.getProperties();
+               NotificationService notificationService = new NotificationService(null,null,null);
+               assertEquals(HttpStatus.BAD_REQUEST, notificationService.getResponseCode());
+               setup();
+       }
+       
+       @Test
+       public void testFailureTopicName(){
+               NotificationService notificationService = new NotificationService(null,null,null);
+               assertEquals(HttpStatus.BAD_REQUEST, notificationService.getResponseCode());
+               assertEquals(XACMLErrorConstants.ERROR_DATA_ISSUE + "org.openecomp.policy.api.PolicyException: Notification Topic is null", notificationService.getResult());
+               notificationService = new NotificationService(" ",null,null);
+               assertEquals(HttpStatus.BAD_REQUEST, notificationService.getResponseCode());
+               assertEquals(XACMLErrorConstants.ERROR_DATA_ISSUE + "org.openecomp.policy.api.PolicyException: Notification Topic is not valid. ", notificationService.getResult());
+       }
+       
+       @Test
+       public void testFailureServiceType(){
+               NotificationService notificationService = new NotificationService("test",null,null);
+               assertEquals(HttpStatus.BAD_REQUEST, notificationService.getResponseCode());
+       }
+       
+       @Test 
+       public void threadTest() throws InterruptedException{
+               NotificationService notificationSerivce = new NotificationService("test",null,NotificationServiceType.ADD);
+               assertEquals(HttpStatus.OK, notificationSerivce.getResponseCode());
+               // Wait for thread to remove the Topic Entry. 
+               await().atMost(Integer.toUnsignedLong(2500),TimeUnit.MILLISECONDS).until(()-> {
+                       // Trying to remove again should fail
+                       NotificationService nService = new NotificationService("test",null,NotificationServiceType.REMOVE);
+                       return HttpStatus.BAD_REQUEST.equals(nService.getResponseCode());
+               });
+               // Coverage Tests, Call Notification Service.
+               NotificationService.sendNotification("test");
+       }
+}
diff --git a/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/test/PolicyEngineServicesTest.java b/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/test/PolicyEngineServicesTest.java
new file mode 100644 (file)
index 0000000..eb514a8
--- /dev/null
@@ -0,0 +1,832 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP-PDP-REST
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.policy.pdp.rest.api.test;
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openecomp.policy.api.AttributeType;
+import org.openecomp.policy.api.ConfigRequestParameters;
+import org.openecomp.policy.api.DecisionRequestParameters;
+import org.openecomp.policy.api.DeletePolicyCondition;
+import org.openecomp.policy.api.DeletePolicyParameters;
+import org.openecomp.policy.api.DictionaryParameters;
+import org.openecomp.policy.api.DictionaryType;
+import org.openecomp.policy.api.EventRequestParameters;
+import org.openecomp.policy.api.PolicyClass;
+import org.openecomp.policy.api.PolicyConfigType;
+import org.openecomp.policy.api.PolicyParameters;
+import org.openecomp.policy.api.PolicyType;
+import org.openecomp.policy.api.PushPolicyParameters;
+import org.openecomp.policy.pdp.rest.XACMLPdpServlet;
+import org.openecomp.policy.pdp.rest.api.models.ConfigFirewallPolicyAPIRequest;
+import org.openecomp.policy.pdp.rest.api.models.ConfigNameRequest;
+import org.openecomp.policy.pdp.rest.api.models.ConfigPolicyAPIRequest;
+import org.openecomp.policy.pdp.rest.api.services.CreateUpdatePolicyServiceImpl;
+import org.openecomp.policy.pdp.rest.config.PDPRestConfig;
+import org.openecomp.policy.utils.PolicyUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.web.context.WebApplicationContext;
+
+import com.att.research.xacml.util.XACMLProperties;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {PDPRestConfig.class})
+@WebAppConfiguration
+public class PolicyEngineServicesTest {
+       private static final String CLIENTAUTHHEADER = "ClientAuth";
+       private static final String UUIDHEADER = "X-ECOMP-RequestID";
+       // This value is as per test resource code. Don't change this. 
+       private static final String CLIENTAUTHVALUE = "Basic cHl0aG9uOnRlc3Q=";
+       private static final String ERRORCLIENTVALUE = "Basic dGVzdDp0ZXN0MTIz";
+       
+       private MockMvc mockMvc;
+       private HttpHeaders headers;
+       
+       @Autowired
+       private WebApplicationContext webApplicationContext;
+       
+       @Before()
+       public void setup() throws IOException{
+               headers = new HttpHeaders();
+               headers.add(CLIENTAUTHHEADER, CLIENTAUTHVALUE);
+               XACMLProperties.reloadProperties();
+               System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/pass.xacml.pdp.properties");
+               XACMLProperties.getProperties();
+               this.mockMvc = webAppContextSetup(webApplicationContext).build();
+       }
+       
+       @Test
+       public void getConfigAPIFailureTest() throws Exception{
+               ConfigRequestParameters pep = new ConfigRequestParameters();
+               pep.setPolicyName(".*");
+               mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON))
+                               .andExpect(status().is(400));
+               // Authorization tests. 
+               mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, ""))
+                               .andExpect(status().isUnauthorized());
+               mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, "Basic 123"))
+                               .andExpect(status().isUnauthorized());
+               mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, ERRORCLIENTVALUE))
+                               .andExpect(status().isUnauthorized());
+               // Set wrong request. 
+               pep.setPolicyName(null);
+               pep.setConfigName("test");
+               mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep)).headers(headers).header(UUIDHEADER, "123").contentType(MediaType.APPLICATION_JSON))
+               .andExpect(status().isBadRequest());
+       }
+       
+       @Test
+       public void getConfigServiceTest() throws Exception{
+               ConfigRequestParameters pep = new ConfigRequestParameters();
+               pep.setPolicyName(".*");
+               mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep)).headers(headers).header(UUIDHEADER, UUID.randomUUID()).contentType(MediaType.APPLICATION_JSON))
+                               .andExpect(status().isOk());
+               // Without policyName and using ecompName and other fields. 
+               pep.setPolicyName(null);
+               pep.setEcompName("test");
+               pep.setConfigName("test");
+               mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep)).headers(headers).contentType(MediaType.APPLICATION_JSON))
+               .andExpect(status().isOk());
+               // with config attributes. 
+               Map<String, String> configAttributes = new HashMap<>();
+               configAttributes.put("test", "test");
+               pep.setConfigAttributes(configAttributes);
+               pep.makeUnique(true);
+               mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep)).headers(headers).contentType(MediaType.APPLICATION_JSON))
+               .andExpect(status().isOk());
+       }
+       
+       @Test
+       public void getConfigByPolicyNameTest() throws Exception{
+               ConfigNameRequest pep = new ConfigNameRequest();
+               pep.setPolicyName(".*");
+               mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON))
+               .andExpect(status().is(400));
+               // Authorization tests. 
+               mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, ""))
+               .andExpect(status().isUnauthorized());
+               mockMvc.perform(post("/getConfigByPolicyName").content(PolicyUtils.objectToJsonString(pep)).headers(headers).header(UUIDHEADER, UUID.randomUUID()).contentType(MediaType.APPLICATION_JSON))
+                               .andExpect(status().isOk());
+       }
+       
+       @Test
+       public void listConfigTest() throws Exception{
+               ConfigRequestParameters pep = new ConfigRequestParameters();
+               pep.setPolicyName(".*");
+               mockMvc.perform(post("/listConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON))
+               .andExpect(status().is(400));
+               // Authorization tests. 
+               mockMvc.perform(post("/listConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, ""))
+               .andExpect(status().isUnauthorized());
+               mockMvc.perform(post("/listConfig").content(PolicyUtils.objectToJsonString(pep)).headers(headers).header(UUIDHEADER, UUID.randomUUID()).contentType(MediaType.APPLICATION_JSON))
+                               .andExpect(status().isOk());
+       }
+       
+       @Test
+       public void getMetricsTest() throws Exception{
+               //Failure Tests. 
+               mockMvc.perform(get("/getMetrics")).andExpect(status().isBadRequest());
+               mockMvc.perform(get("/getMetrics").header(CLIENTAUTHHEADER, "Basic 123")).andExpect(status().isUnauthorized());
+               //Service Tests. 
+               mockMvc.perform(get("/getMetrics").headers(headers).header(UUIDHEADER, "123")).andExpect(status().isOk());
+               mockMvc.perform(get("/getMetrics").headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isOk());
+               mockMvc.perform(get("/getMetrics").headers(headers)).andExpect(status().isOk());
+       }
+       
+       @Test
+       public void getNotificationAuthFailureTest() throws Exception{
+               mockMvc.perform(post("/getNotification").header(CLIENTAUTHHEADER, "").content("test")).andExpect(status().isUnauthorized());
+               mockMvc.perform(post("/getNotification").header(CLIENTAUTHHEADER, "Basic test123").content("test")).andExpect(status().isUnauthorized());
+               mockMvc.perform(post("/getNotification").header(CLIENTAUTHHEADER, ERRORCLIENTVALUE).content(" ")).andExpect(status().isUnauthorized());
+       }
+       
+       @Test
+       public void getNotificationTopicFailureTest() throws Exception{
+               mockMvc.perform(post("/getNotification")).andExpect(status().isBadRequest());
+               mockMvc.perform(post("/getNotification").headers(headers).content("")).andExpect(status().isBadRequest());
+       }
+       
+       @Test
+       public void getNotificationTopicValidFailTest() throws Exception{
+               // Check failures. 
+               mockMvc.perform(post("/getNotification").headers(headers).content(" ")).andExpect(status().isBadRequest());
+               mockMvc.perform(post("/stopNotification").headers(headers).content(" ")).andExpect(status().isBadRequest());
+               mockMvc.perform(post("/sendHeartbeat").headers(headers).content(" ")).andExpect(status().isBadRequest()); 
+       }
+       
+       @Test
+       public void getNotificationTopicValidPassTest() throws Exception{
+               // Add a Topic. 
+               mockMvc.perform(post("/getNotification").headers(headers).header(UUIDHEADER, "123").content("test")).andExpect(status().isOk());
+               // Try to add same topic should fail.  
+               mockMvc.perform(post("/getNotification").headers(headers).header(UUIDHEADER, UUID.randomUUID()).content("test")).andExpect(status().isBadRequest());
+               // do a heart beat. 
+               mockMvc.perform(post("/sendHeartbeat").headers(headers).content("test")).andExpect(status().isOk());
+               // remove the added Topic. 
+               mockMvc.perform(post("/stopNotification").headers(headers).content("test")).andExpect(status().isOk());
+               // try to remove again should fail. 
+               mockMvc.perform(post("/sendHeartbeat").headers(headers).content("test")).andExpect(status().isBadRequest());
+       }
+       
+       @Test
+       public void sendEventTest() throws Exception{
+               EventRequestParameters pep = new EventRequestParameters();
+               Map<String,String> eventAttributes = new HashMap<>();
+               eventAttributes.put("TEST", "test");
+               pep.setEventAttributes(eventAttributes);
+               //Failure Tests. 
+               mockMvc.perform(post("/sendEvent")).andExpect(status().isBadRequest());
+               mockMvc.perform(post("/sendEvent").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, "Basic 123")).andExpect(status().isUnauthorized());
+               //Service Tests. 
+               mockMvc.perform(post("/sendEvent").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, "123")).andExpect(status().isOk());
+               pep.setEventAttributes(null);
+               mockMvc.perform(post("/sendEvent").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setEventAttributes(eventAttributes);
+               mockMvc.perform(post("/sendEvent").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isOk());
+               pep.setEventAttributes(eventAttributes);
+               pep.setRequestID(UUID.randomUUID());
+               mockMvc.perform(post("/sendEvent").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isOk());
+       }
+       
+       @Test
+       public void getDecisionTest() throws Exception{
+               DecisionRequestParameters pep = new DecisionRequestParameters();
+               Map<String,String> eventAttributes = new HashMap<>();
+               eventAttributes.put("TEST", "test");
+               pep.setECOMPComponentName("te123");
+               pep.setDecisionAttributes(eventAttributes);
+               //Failure Tests. 
+               mockMvc.perform(post("/getDecision")).andExpect(status().isBadRequest());
+               mockMvc.perform(post("/getDecision").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, "Basic 123")).andExpect(status().isUnauthorized());
+               //Service Tests. 
+               mockMvc.perform(post("/getDecision").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, "123")).andExpect(status().isOk());
+               pep.setDecisionAttributes(null);
+               pep.setECOMPComponentName(null);
+               mockMvc.perform(post("/getDecision").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setECOMPComponentName("testing");
+               mockMvc.perform(post("/getDecision").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setDecisionAttributes(eventAttributes);
+               pep.setRequestID(UUID.randomUUID());
+               mockMvc.perform(post("/getDecision").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isOk());
+       }
+       
+       @Test
+       public void pushPolicyTest() throws Exception{
+               PushPolicyParameters pep = new PushPolicyParameters();
+               //Failure Tests. 
+               mockMvc.perform(put("/pushPolicy")).andExpect(status().isBadRequest());
+               mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, "Basic 123")).andExpect(status().isUnauthorized());
+               //Service Tests. 
+               mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setPolicyName("scopeless");
+               mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setPolicyName("testing.test");
+               pep.setPolicyType("wrong");
+               mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setPolicyType("BRMS_PARAM");
+               mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setPolicyType("BRMS_RAW");
+               mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setPolicyType("MicroService");
+               mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setPolicyType("ClosedLoop_PM");
+               mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setPolicyType("ClosedLoop_Fault");
+               mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setPolicyType("Base");
+               mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setPolicyType("Decision");
+               mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setPolicyType("Action");
+               mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setPolicyType("Firewall");
+               mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setPdpGroup("default");
+               mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, "123")).andExpect(status().isBadRequest());
+               pep.setRequestID(UUID.randomUUID());
+               mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+       }
+       
+       @Test
+       public void deletePolicyTest() throws Exception{
+               DeletePolicyParameters pep = new DeletePolicyParameters();
+               //Failure Tests. 
+               mockMvc.perform(delete("/deletePolicy")).andExpect(status().isBadRequest());
+               mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, "Basic 123")).andExpect(status().isUnauthorized());
+               //Service Tests. 
+               mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setPolicyName("testing");
+               mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, "test123")).andExpect(status().isBadRequest());
+               pep.setPolicyName("testscope.name");
+               mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setPolicyName("testscope.name");
+               pep.setPolicyType("wrong");
+               pep.setRequestID(UUID.randomUUID());
+               mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setPolicyType("BRMS_PARAM");
+               pep.setPolicyComponent("wrong");
+               pep.setRequestID(null);
+               mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setPolicyType("BRMS_RAW");
+               pep.setPolicyComponent("PDP");
+               mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setPolicyType("MicroService");
+               pep.setPolicyComponent("PAP");
+               mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setPolicyType("ClosedLoop_PM");
+               pep.setPolicyComponent("PDP");
+               pep.setDeleteCondition(DeletePolicyCondition.ALL);
+               mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setPolicyType("ClosedLoop_Fault");
+               pep.setDeleteCondition(DeletePolicyCondition.ONE);
+               mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setPolicyType("Base");
+               pep.setPolicyComponent("PAP");
+               mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setPolicyType("Decision");
+               pep.setPolicyComponent("PDP");
+               pep.setPolicyName("test.xml");
+               mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setPolicyType("Action");
+               pep.setPolicyName("scope.Config_test.xml");
+               mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setPdpGroup("default");
+               mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setPolicyComponent("PAP");
+               pep.setPolicyType("Firewall");
+               pep.setDeleteCondition(null);
+               mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setPolicyComponent("PAP");
+               pep.setDeleteCondition(DeletePolicyCondition.ONE);
+               mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setPolicyComponent("fail");
+               mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setPolicyComponent("PDP");
+               pep.setPolicyName("testscope.policyName");
+               mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setPolicyComponent(null);
+               mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+       }
+       
+       @Test
+       public void createUpdatePolicyTest() throws Exception{
+               PolicyParameters pep = new PolicyParameters();
+               //Failure Tests. 
+               mockMvc.perform(put("/createPolicy")).andExpect(status().isBadRequest());
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, "Basic 123")).andExpect(status().isUnauthorized());
+               mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, "Basic 123")).andExpect(status().isUnauthorized());
+               //Service Tests. 
+               setCreateUpdateImpl();
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setPolicyName("failName");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, "test 123")).andExpect(status().isBadRequest());
+               pep.setPolicyName("test. name");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setPolicyName("   ");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setPolicyName("test. ");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setPolicyName("te st.name");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setPolicyName("test.name");
+               pep.setPolicyDescription("testá");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setPolicyName("test.name");
+               pep.setPolicyDescription("good");
+               pep.setTtlDate(new Date());
+               pep.setRequestID(UUID.randomUUID());
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+       }
+       
+       @Test
+       public void brmsPolicyCreationTests() throws Exception{
+               PolicyParameters pep = new PolicyParameters();
+               pep.setPolicyName("test.name");
+               pep.setPolicyDescription("good");
+               pep.setTtlDate(new Date());
+               pep.setRequestID(UUID.randomUUID());
+               setCreateUpdateImpl();
+               // Checks for BRMS Param Policy. 
+               pep.setPolicyConfigType(PolicyConfigType.BRMS_PARAM);
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setRiskLevel("test");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               Map<AttributeType, Map<String,String>> attributes = new HashMap<>();
+               Map<String,String> matching = new HashMap<>();
+               matching.put("key", "value");
+               attributes.put(AttributeType.MATCHING, matching);
+               pep.setAttributes(attributes);
+               pep.setRiskLevel("5");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+               mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+               // Checks for BRMS Raw Policy
+               pep.setPolicyConfigType(PolicyConfigType.BRMS_RAW);
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("test");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setRiskLevel(null);
+               pep.setConfigBody("package droolsexample\n\n import com.sample.ItemCity;\nimport java.math.BigDecimal;\nrule \"Nagpur Medicine Item\"\n\n   when\n      item : ItemCity(purchaseCity == ItemCity.City.NAGPUR,\n         typeofItem == ItemCity.Type.MEDICINES)\n   then\n      BigDecimal tax = new BigDecimal(0.0);\n      item.setLocalTax(tax.multiply(item.getSellPrice()));\nend");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setRiskLevel("5");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+               mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+       }
+       
+       @Test
+       public void baseConfigTests() throws Exception{
+               PolicyParameters pep = new PolicyParameters();
+               pep.setPolicyName("test.name");
+               pep.setPolicyDescription("good");
+               pep.setTtlDate(new Date());
+               pep.setRequestID(UUID.randomUUID());
+               setCreateUpdateImpl();
+               // Checks for Base config Policy. 
+               pep.setPolicyConfigType(PolicyConfigType.Base);
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("testbody");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBodyType(PolicyType.OTHER);
+               pep.setRiskLevel("test");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setRiskLevel("4");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setEcompName("ec nam-e");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setEcompName("ecompName");
+               pep.setConfigName("tes config");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigName("configName");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+               pep.setConfigBody("{'test':'test}");
+               pep.setConfigBodyType(PolicyType.JSON);
+               mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+               Map<AttributeType, Map<String,String>> attributes = new HashMap<>();
+               Map<String,String> matching = new HashMap<>();
+               matching.put("key", "value");
+               attributes.put(AttributeType.MATCHING, matching);
+               pep.setAttributes(attributes);
+               pep.setConfigBody("testBody");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+       }
+       
+       @Test
+       public void closedLoopPolicyTests() throws Exception{
+               PolicyParameters pep = new PolicyParameters();
+               pep.setPolicyName("test.name");
+               pep.setPolicyDescription("good");
+               pep.setTtlDate(new Date());
+               pep.setRequestID(UUID.randomUUID());
+               setCreateUpdateImpl();
+               // Checks for Closed loop Policy. 
+               pep.setPolicyConfigType(PolicyConfigType.ClosedLoop_Fault);
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("te stá");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("testBody");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("{\"key\":\"value\"}");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("{\"ecompname\":\"\"}");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("{\"ecompname\":\"test\"}");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+               pep.setRiskLevel("test");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setRiskLevel("4");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+               mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+       }
+       
+       @Test
+       public void closedLoopPMTests() throws Exception{
+               PolicyParameters pep = new PolicyParameters();
+               pep.setPolicyName("test.name");
+               pep.setPolicyDescription("good");
+               pep.setTtlDate(new Date());
+               pep.setRequestID(UUID.randomUUID());
+               setCreateUpdateImpl();
+               // Checks for Closed loop Policy. 
+               pep.setPolicyConfigType(PolicyConfigType.ClosedLoop_PM);
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("te stá");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("testBody");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("{\"key\":\"value\"}");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("{\"ecompname\":\"\"}");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("{\"ecompname\":\"test\"}");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("{\"ecompname\":\"test\", \"serviceTypePolicyName\":\"value\"}");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+               pep.setRiskLevel("test");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setRiskLevel("4");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+               mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+       }
+       
+       @Test
+       public void firewallPolicyTests() throws Exception{
+               PolicyParameters pep = new PolicyParameters();
+               pep.setPolicyName("test.name");
+               pep.setPolicyDescription("good");
+               pep.setTtlDate(new Date());
+               pep.setRequestID(UUID.randomUUID());
+               setCreateUpdateImpl();
+               // Checks for Closed loop Policy. 
+               pep.setPolicyConfigType(PolicyConfigType.Firewall);
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("te st");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("{}");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("{\"test\":\"test\"}");
+               pep.setRiskLevel("test");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setRiskLevel("4");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("{\"configName\":\"test\"}");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+               mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+       }
+       
+       @Test
+       public void microServicePolicyTests() throws Exception{
+               PolicyParameters pep = new PolicyParameters();
+               pep.setPolicyName("test.name");
+               pep.setPolicyDescription("good");
+               pep.setTtlDate(new Date());
+               pep.setRequestID(UUID.randomUUID());
+               setCreateUpdateImpl();
+               // Checks for Closed loop Policy. 
+               pep.setPolicyConfigType(PolicyConfigType.MicroService);
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("te st");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("{}");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setConfigBody("{\"test\":\"test\"}");
+               pep.setEcompName("   ");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setEcompName("testecomp");
+               pep.setRiskLevel("fail");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setRiskLevel("4");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+               pep.setConfigBody("{\"service\":\"test\",\"uuid\":\"test\",\"location\":\"test\",\"configName\":\"test\",\"description\":\"test\",\"priority\":\"test\",\"version\":\"test\"}");
+               mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+       }
+       
+       @Test
+       public void actionDecisionPolicyCreationTests() throws Exception{
+               PolicyParameters pep = new PolicyParameters();
+               pep.setPolicyName("test.name");
+               pep.setPolicyDescription("good");
+               pep.setTtlDate(new Date());
+               pep.setRequestID(UUID.randomUUID());
+               setCreateUpdateImpl();
+               // Checks for action Policy. 
+               pep.setPolicyClass(PolicyClass.Action);
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               Map<AttributeType, Map<String,String>> attributes = new HashMap<>();
+               pep.setAttributes(attributes);
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               attributes.put(AttributeType.MATCHING, new HashMap<>());
+               pep.setAttributes(attributes);
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               Map<String,String> matching = new HashMap<>();
+               matching.put("key", "value");
+               attributes.put(AttributeType.MATCHING, matching);
+               pep.setAttributes(attributes);
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setActionAttribute("A1");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setActionPerformer("PEX");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setActionPerformer("PEP");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+               mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+               // Checks for Decision Policy. 
+               pep.setPolicyClass(PolicyClass.Decision);
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setEcompName("xyz");
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+               attributes.remove(AttributeType.MATCHING);
+               attributes.put(AttributeType.SETTINGS, matching);
+               pep.setAttributes(attributes);
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+               attributes.put(AttributeType.MATCHING, matching);
+               pep.setAttributes(attributes);
+               mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+               mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+       }
+       
+       @Test
+       public void createUpdateDictionaryTests() throws Exception{
+               DictionaryParameters pep = new DictionaryParameters();
+               //Failure Tests. 
+               mockMvc.perform(put("/createDictionaryItem")).andExpect(status().isBadRequest());
+               mockMvc.perform(put("/createDictionaryItem").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, "Basic 123")).andExpect(status().isUnauthorized());
+               mockMvc.perform(put("/updateDictionaryItem").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, "Basic 123")).andExpect(status().isUnauthorized());
+               //Service Tests.
+               mockMvc.perform(put("/createDictionaryItem").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
+               pep.setDictionaryType(DictionaryType.MicroService);
+               mockMvc.perform(put("/createDictionaryItem").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               mockMvc.perform(put("/createDictionaryItem").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
+               pep.setDictionary("test dict");
+               pep.setRequestID(UUID.randomUUID());
+               mockMvc.perform(put("/createDictionaryItem").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+               pep.setDictionaryJson("{\"test\":\"value\"}");
+               mockMvc.perform(put("/createDictionaryItem").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isInternalServerError());
+               pep.setDictionaryJson("test123");
+               mockMvc.perform(put("/updateDictionaryItem").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, "123")).andExpect(status().isBadRequest());
+               pep.setDictionary("MicroServiceDictionary");
+               mockMvc.perform(put("/createDictionaryItem").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isBadRequest());
+       }
+       
+       @Test
+       public void getDictionaryTests() throws Exception{
+               DictionaryParameters pep = new DictionaryParameters();
+               //Failure Tests. 
+               mockMvc.perform(post("/getDictionaryItems")).andExpect(status().isBadRequest());
+               mockMvc.perform(post("/getDictionaryItems").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, "Basic 123")).andExpect(status().isUnauthorized());
+               //Service Tests.
+               mockMvc.perform(post("/getDictionaryItems").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
+               pep.setDictionaryType(DictionaryType.Common);
+               mockMvc.perform(post("/getDictionaryItems").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, UUID.randomUUID().toString())).andExpect(status().isBadRequest());
+               pep.setDictionary("EcompName");
+               mockMvc.perform(post("/getDictionaryItems").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+               pep.setRequestID(UUID.randomUUID());
+               mockMvc.perform(post("/getDictionaryItems").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers)).andExpect(status().isInternalServerError());
+       }
+       
+       @Test
+       public void policyEngineImportTests() throws Exception{
+               //Failure Tests. 
+               mockMvc.perform(post("/policyEngineImport")).andExpect(status().isBadRequest());
+       }
+       
+       @Test
+       public void oldConfigAPITests() throws Exception{
+               ConfigPolicyAPIRequest pep = new ConfigPolicyAPIRequest();
+               //Failure Tests. 
+               mockMvc.perform(put("/createConfig")).andExpect(status().isBadRequest());
+               mockMvc.perform(put("/createConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, "Basic 123")).andExpect(status().isUnauthorized());
+               mockMvc.perform(put("/updateConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, "Basic 123")).andExpect(status().isUnauthorized());
+               //Service Tests.
+               mockMvc.perform(put("/createConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
+               pep.setPolicyScope("test");
+               mockMvc.perform(put("/createConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
+               pep.setPolicyName("name");
+               mockMvc.perform(put("/createConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
+               pep.setConfigType("OTHER");
+               mockMvc.perform(put("/createConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
+               pep.setTtlDate(new Date().toString());
+               mockMvc.perform(put("/updateConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
+       }
+       
+       @Test
+       public void oldFirewallAPITests() throws Exception{
+               ConfigFirewallPolicyAPIRequest pep = new ConfigFirewallPolicyAPIRequest();
+               //Failure Tests. 
+               mockMvc.perform(put("/createFirewallConfig")).andExpect(status().isBadRequest());
+               mockMvc.perform(put("/createFirewallConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, "Basic 123")).andExpect(status().isUnauthorized());
+               mockMvc.perform(put("/updateFirewallConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, "Basic 123")).andExpect(status().isUnauthorized());
+               //Service Tests.
+               mockMvc.perform(put("/createFirewallConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
+               pep.setPolicyScope("test");
+               mockMvc.perform(put("/createFirewallConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
+               pep.setPolicyName("name");
+               mockMvc.perform(put("/createFirewallConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
+               pep.setTtlDate(new Date().toString());
+               mockMvc.perform(put("/updateFirewallConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
+                               .headers(headers).header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
+       }
+       
+       private void setCreateUpdateImpl() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+               Method setter = XACMLPdpServlet.class.getDeclaredMethod("setCreateUpdatePolicyConstructor", String.class);
+               setter.setAccessible(true);
+               setter.invoke(new XACMLPdpServlet(), CreateUpdatePolicyServiceImpl.class.getName());
+       }
+
+       //Health Check Tests
+       @Test
+       public void getCountTest() throws Exception {
+               mockMvc.perform(get("/count"))          
+               .andExpect(status().isOk());
+       }
+}
diff --git a/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/test/getConfigTest.java b/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/test/getConfigTest.java
new file mode 100644 (file)
index 0000000..ebe86b0
--- /dev/null
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP-PDP-REST
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.policy.pdp.rest.api.test;
+
+import static org.junit.Assert.assertEquals;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+import org.openecomp.policy.api.ConfigRequestParameters;
+import org.openecomp.policy.api.PolicyConfigStatus;
+import org.openecomp.policy.pdp.rest.api.models.PolicyConfig;
+import org.openecomp.policy.pdp.rest.api.services.GetConfigService;
+
+public class getConfigTest {
+       private static final String TEST = "test";
+       
+       @SuppressWarnings("unchecked")
+       @Test
+       public void filterMethodTest() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException{
+               ConfigRequestParameters configRequestParameters = new ConfigRequestParameters();
+               GetConfigService getConfigService= new GetConfigService(configRequestParameters, null);
+               Method filter = GetConfigService.class.getDeclaredMethod("filterResults", Collection.class,ConfigRequestParameters.class);
+               filter.setAccessible(true);
+               List<PolicyConfig> policyConfigs = new LinkedList<>();
+               
+               List<PolicyConfig> filterResults = (List<PolicyConfig>) filter.invoke(getConfigService, policyConfigs,configRequestParameters);
+               assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND, filterResults.get(0).getPolicyConfigStatus());
+               // Check again with some values 
+               configRequestParameters.setPolicyName(TEST);
+               configRequestParameters.setEcompName(TEST);
+               configRequestParameters.setConfigName(TEST);
+               Map<String,String> configAttributes = new HashMap<>();
+               configAttributes.put(TEST, TEST);
+               configRequestParameters.setConfigAttributes(configAttributes);
+               PolicyConfig pConfig = new PolicyConfig();
+               pConfig.setPolicyName(TEST);
+               Map<String,String> matching = new HashMap<>();
+               matching.put("ECOMPName", TEST);
+               matching.put("ConfigName", TEST);
+               matching.put("TEST", TEST);
+               pConfig.setMatchingConditions(matching);
+               policyConfigs.add(pConfig);
+               filterResults = (List<PolicyConfig>) filter.invoke(getConfigService, policyConfigs,configRequestParameters);
+               assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND, filterResults.get(0).getPolicyConfigStatus());
+       }
+}
diff --git a/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/test/getDictionaryTest.java b/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/test/getDictionaryTest.java
new file mode 100644 (file)
index 0000000..3ade07c
--- /dev/null
@@ -0,0 +1,231 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP-PDP-REST
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.policy.pdp.rest.api.test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.lang.reflect.Method;
+
+import org.junit.Test;
+import org.openecomp.policy.api.DictionaryParameters;
+import org.openecomp.policy.pdp.rest.api.services.GetDictionaryService;
+
+public class getDictionaryTest {
+       
+       @Test
+       public void dictionaryJsonTest() throws Exception{
+               Method formatDictionary = GetDictionaryService.class.getDeclaredMethod("formatDictionaryJson", String.class);
+               formatDictionary.setAccessible(true);
+               String input="{\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\","
+                               + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\","
+                               + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\"}";
+               DictionaryParameters dp = new DictionaryParameters();
+               dp.setDictionary("test");
+               GetDictionaryService gds = new GetDictionaryService(dp, null);
+               String result = (String) formatDictionary.invoke(gds, input);
+               assertNull(result);
+               //
+               dp.setDictionary("EcompName");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("Attribute");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("Action");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("BRMSParamTemplate");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("VSCLAction");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("VNFType");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("PEPOptions");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("Varbind");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("Service");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("Site");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("Settings");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("DescriptiveScope");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("Enforcer");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("ActionList");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("ProtocolList");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("Zone");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("SecurityZone");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("PrefixList");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("AddressGroup");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("ServiceGroup");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("ServiceList");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("TermList");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("RuleList");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("FirewallRuleList");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("Term");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("MicroServiceLocation");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("MicroServiceConfigName");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("DCAEUUID");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("MicroServiceModels");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("PolicyScopeService");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("PolicyScopeResource");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("PolicyScopeType");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("PolicyScopeClosedLoop");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("GroupPolicyScopeList");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("RiskType");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("SafePolicyWarning");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+               //
+               dp.setDictionary("MicroServiceDictionary");
+               gds = new GetDictionaryService(dp, null);
+               result = (String) formatDictionary.invoke(gds, input);
+               assertNotNull(result);
+       }
+}
diff --git a/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/auth/test/FilterTests.java b/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/auth/test/FilterTests.java
new file mode 100644 (file)
index 0000000..944dd90
--- /dev/null
@@ -0,0 +1,199 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP-PDP-REST
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.pdp.rest.auth.test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.policy.pdp.rest.restAuth.PDPAuthenticationFilter;
+
+import com.att.research.xacml.util.XACMLProperties;
+import com.mockrunner.mock.web.MockRequestDispatcher;
+
+public class FilterTests {
+       
+       private PDPAuthenticationFilter authenticationFilter = new PDPAuthenticationFilter(); 
+       private final String VALIDHEADERVALUE = "Basic dGVzdHBkcDphbHBoYTQ1Ng==";
+       
+       @Before
+       public void setUp() throws Exception{
+               authenticationFilter.init(null);
+               XACMLProperties.reloadProperties();
+               System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/pass.xacml.pdp.properties");
+               XACMLProperties.getProperties();
+       }
+       
+       @Test
+       public void testDoFilterError() throws IOException, ServletException {
+           // create the objects to be mocked
+           HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
+           HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
+           FilterChain filterChain = mock(FilterChain.class);
+           //
+           when(httpServletRequest.getRequestURI()).thenReturn("error");
+           authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
+                   filterChain);
+           // verify if unauthorized
+           verify(httpServletResponse).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+       }
+       
+       @Test
+       public void testDoFilterNotification() throws IOException, ServletException {
+           // create the objects to be mocked
+           HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
+           HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
+           FilterChain filterChain = mock(FilterChain.class);
+           // 
+           when(httpServletRequest.getRequestURI()).thenReturn("notifications");
+           authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
+                   filterChain);
+           verify(filterChain).doFilter(httpServletRequest,httpServletResponse);
+       }
+       
+       @Test
+       public void testDoFilterSwagger() throws Exception{
+               // create the objects to be mocked
+           HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
+           HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
+           FilterChain filterChain = mock(FilterChain.class);
+           //
+           when(httpServletRequest.getRequestURI()).thenReturn("/pdp/swagger");
+           when(httpServletRequest.getRequestDispatcher("/api/swagger")).thenReturn(new MockRequestDispatcher());
+           authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
+                   filterChain);
+           verify(httpServletRequest).getRequestDispatcher("/api/swagger");
+           when(httpServletRequest.getRequestURI()).thenReturn("/pdp/api-docs/"); 
+           when(httpServletRequest.getRequestDispatcher("/api/api-docs/")).thenReturn(new MockRequestDispatcher());
+           authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
+                   filterChain);
+           verify(httpServletRequest).getRequestDispatcher("/api/api-docs/");
+           when(httpServletRequest.getRequestURI()).thenReturn("/pdp/configuration");
+           when(httpServletRequest.getRequestDispatcher("/api/configuration")).thenReturn(new MockRequestDispatcher());
+           authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
+                   filterChain);
+           verify(httpServletRequest).getRequestDispatcher("/api/configuration");
+       }
+       
+       @Test
+       public void newRequestAuthFailTest() throws Exception{
+               // create the objects to be mocked
+           HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
+           HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
+           FilterChain filterChain = mock(FilterChain.class);
+           //
+           when(httpServletRequest.getRequestURI()).thenReturn("/pdp/api/getConfig");
+           when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn("error");
+           authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
+                   filterChain);
+           // verify if unauthorized
+           verify(httpServletResponse).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+       }
+       
+       @Test
+       public void tokenFailureTest() throws Exception{
+               // create the objects to be mocked
+           HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
+           HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
+           FilterChain filterChain = mock(FilterChain.class);
+           //
+           when(httpServletRequest.getRequestURI()).thenReturn("/pdp/api/getConfig");
+           when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn("Basic test123");
+           authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
+                   filterChain);
+           // verify if unauthorized
+           verify(httpServletResponse).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+       }
+       
+       @Test
+       public void oldRequestAuthPassTest() throws Exception{
+               // create the objects to be mocked
+           HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
+           HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
+           FilterChain filterChain = mock(FilterChain.class);
+           // New request no environment header check 
+           when(httpServletRequest.getRequestURI()).thenReturn("/pdp/api/getConfig");
+           when(httpServletRequest.getRequestDispatcher("/api/getConfig")).thenReturn(new MockRequestDispatcher());
+           when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn(VALIDHEADERVALUE);
+           authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
+                   filterChain);
+           // verify if authorized
+           verify(httpServletRequest).getRequestDispatcher("/api/getConfig");
+           //
+           // Old Requests Checks
+           //
+           when(httpServletRequest.getRequestURI()).thenReturn("/pdp/getConfig");
+           when(httpServletRequest.getRequestDispatcher("/api//getConfig")).thenReturn(new MockRequestDispatcher());
+           when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn(VALIDHEADERVALUE);
+           authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
+                   filterChain);
+           // verify if authorized
+           verify(httpServletRequest).getRequestDispatcher("/api//getConfig");
+       }
+       
+       @Test
+       public void newRequestAuthPassTest() throws Exception{
+               // create the objects to be mocked
+           HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
+           HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
+           FilterChain filterChain = mock(FilterChain.class);
+               //
+           // Requests with Valid Environment Header values. 
+           //
+           when(httpServletRequest.getRequestURI()).thenReturn("/pdp/getConfig");
+           when(httpServletRequest.getRequestDispatcher("/api//getConfig")).thenReturn(new MockRequestDispatcher());
+           when(httpServletRequest.getHeader(PDPAuthenticationFilter.ENVIRONMENT_HEADER)).thenReturn("DEVL");
+           when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn(VALIDHEADERVALUE);
+           authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
+                   filterChain);
+           // verify if authorized
+           verify(httpServletRequest).getRequestDispatcher("/api//getConfig");
+           // New request no environment header check 
+           when(httpServletRequest.getRequestURI()).thenReturn("/pdp/api/getConfig");
+           when(httpServletRequest.getRequestDispatcher("/api/getConfig")).thenReturn(new MockRequestDispatcher());
+           when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn(VALIDHEADERVALUE);
+           authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
+                   filterChain);
+           // verify if authorized
+           verify(httpServletRequest).getRequestDispatcher("/api/getConfig");
+           //
+           //
+           // Requests with InValid Environment Header
+           //
+           when(httpServletRequest.getRequestURI()).thenReturn("/pdp/getConfig");
+           when(httpServletRequest.getRequestDispatcher("/api//getConfig")).thenReturn(new MockRequestDispatcher());
+           when(httpServletRequest.getHeader(PDPAuthenticationFilter.ENVIRONMENT_HEADER)).thenReturn("TEST");
+           when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn(VALIDHEADERVALUE);
+           authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
+                   filterChain);
+           // verify if unauthorized
+           verify(httpServletResponse).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+       }
+}
diff --git a/ECOMP-PDP-REST/src/test/resources/client.properties b/ECOMP-PDP-REST/src/test/resources/client.properties
new file mode 100644 (file)
index 0000000..13aa106
--- /dev/null
@@ -0,0 +1,2 @@
+#Don't Change this
+python=test,MASTER
\ No newline at end of file
diff --git a/ECOMP-PDP-REST/src/test/resources/fail.xacml.pdp.properties b/ECOMP-PDP-REST/src/test/resources/fail.xacml.pdp.properties
new file mode 100644 (file)
index 0000000..52ca6ab
--- /dev/null
@@ -0,0 +1,171 @@
+###
+# ============LICENSE_START=======================================================
+# ECOMP-PDP-REST
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# 
+#      http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+# Default XACML Properties File for PDP RESTful servlet
+#
+# Standard API Factories
+#
+xacml.dataTypeFactory=com.att.research.xacml.std.StdDataTypeFactory
+xacml.pdpEngineFactory=com.att.research.xacmlatt.pdp.ATTPDPEngineFactory
+xacml.pepEngineFactory=com.att.research.xacml.std.pep.StdEngineFactory
+# NOT USED SEE BELOW xacml.pipFinderFactory=org.openecomp.policy.xacml.std.pip.StdPIPFinderFactory
+xacml.traceEngineFactory=com.att.research.xacml.std.trace.LoggingTraceEngineFactory
+#
+# AT&T PDP Implementation Factories
+#
+xacml.att.evaluationContextFactory=com.att.research.xacmlatt.pdp.std.StdEvaluationContextFactory
+xacml.att.combiningAlgorithmFactory=com.att.research.xacmlatt.pdp.std.StdCombiningAlgorithmFactory
+xacml.att.functionDefinitionFactory=org.openecomp.policy.xacml.custom.EcompFunctionDefinitionFactory
+# NOT USED SEE BELOW xacml.att.policyFinderFactory=org.openecomp.policy.pdp.std.StdPolicyFinderFactory
+# creteUpdate Policy Implementation Class details. 
+createUpdatePolicy.impl.className=org.openecomp.policy.pdp.rest.api.services.CreateUpdatePolicyServiceImpl
+# AAF Implementation class details
+aafClient.impl.className=org.openecomp.policy.utils.AAFPolicyClientImpl
+#
+# AT&T RESTful PDP Implementation Factories
+#
+xacml.pipFinderFactory=org.openecomp.policy.pdp.rest.impl.XACMLPdpPIPFinderFactory
+xacml.att.policyFinderFactory=org.openecomp.policy.pdp.rest.XACMLPdpPolicyFinderFactory
+#
+# When set to true, this flag tells the StdPolicyFinderFactory to combined all the root policy files into
+# into one PolicySet and use the given Policy Algorithm.
+#
+xacml.att.policyFinderFactory.combineRootPolicies=urn:com:att:xacml:3.0:policy-combining-algorithm:combined-permit-overrides
+#
+# PDP RESTful API properties
+# 
+# Set this to the address where the XACML-PAP-REST servlet is running
+xacml.rest.pap.url=http://localhost:8070/pap/
+
+#if multiple paps exist, the xacml.rest.pap.url can be removed and they can be defined like this:
+#xacml.rest.pap.urls=http://localhost:9090/pap/,http://localhost:9091/pap/
+
+#
+# Give the running PDP an ID for the PAP. The url that its running as is a good choice.
+# The PAP identifies PDP's using the URL of the PDP.
+#
+xacml.rest.pdp.id=http://localhost:8082/pdp/
+
+# Give the port number used for the PDP
+
+xacml.jmx.port=0
+
+
+# Notification Properties
+# Notifcation type: websocket, ueb or dmaap... if left blank websocket is the default
+NOTIFICATION_TYPE=websocket
+NOTIFICATION_SERVERS=
+NOTIFICATION_TOPIC=
+NOTIFICATION_DELAY=500
+UEB_API_KEY=
+UEB_API_SECRET=
+DMAAP_AAF_LOGIN=test
+DMAAP_AAF_PASSWORD=test
+
+#
+# Set the directory where the PDP holds its Policy Cache and PIP Configuration
+#
+xacml.rest.pdp.config=config
+
+xacml.rest.pdp.webapps=/home/users/PolicyEngine/webapps/ConfigPAP/
+#
+# Initialize register with PAP servlet
+#
+xacml.rest.pdp.register=true
+#
+# Sleep period in seconds between register attempts
+#
+xacml.rest.pdp.register.sleep=15
+#
+# number of attempts to register. -1 means keep trying forever.
+#
+xacml.rest.pdp.register.retries=-1
+#
+# max number of bytes in a POST of a XML/JSON request
+# old value #32767
+xacml.rest.pdp.maxcontent=99999999 
+#
+# Set UserID here
+xacml.rest.pdp.userid=testpdp
+# Set Password here
+xacml.rest.pdp.password=alpha456
+
+# id PAP
+xacml.rest.pap.userid=testpap
+#if multiple paps have different logins, they can be defined like this:
+#http\://localhost\:9090/pap/.xacml.rest.pap.userid=testpap
+
+# pass PAP
+xacml.rest.pap.password=alpha123
+#http\://localhost\:9090/pap/.xacml.rest.pap.password=alpha123
+
+# Delay for Notifications Don't change this. Value in milliSec.  
+xacml.rest.notification.delay=30
+# Buffer Size. 
+REQUEST_BUFFER_SIZE=15
+
+#properties for MySql xacml database:  PLEASE DO NOT REMOVE... NEEDED FOR APIs
+javax.persistence.jdbc.driver=com.mysql.jdbc.Driver
+javax.persistence.jdbc.url=jdbc:mysql://localhost:3306/xacml
+javax.persistence.jdbc.user=policy_user
+javax.persistence.jdbc.password=policy_user
+
+
+#***Properties for IntegrityMonitor integration defined in XACMLRestProperties.java***
+
+#The name of the PDP.  Must be unique across the system
+xacml.rest.pdp.resource.name=site_1.pdp_1
+
+#***Properties for IntegrityMonitor integration defined in IntegrityMonitorProperties.java***
+
+#Interval between forward progress counter updates in seconds
+fp_monitor_interval=30
+
+#Number of forward progress counter failures before failover
+failed_counter_threshold=3
+
+#Interval in seconds between test transactions if there is no other traffic
+test_trans_interval=10
+
+#Interval in seconds between updates of the forward progress counter in the DB
+write_fpc_interval=5
+
+#Name of the site
+site_name=site_1
+
+#Node type
+node_type=pdp_xacml
+
+#Dependency groups are groups of resources upon which a node operational state is dependent upon). 
+#Each group is a comma-separated list of resource names and groups are separated by a semicolon.
+#A group may contain one or more members. Resource names must match the resource names defined
+#in the respective servers' properties files
+dependency_groups=site_1.pdplp_1;site_1.astragw_1;site_1.brmsgw_1
+
+# this can be DEVL, TEST, PROD 
+ENVIRONMENT=DEVL
+xacml.rest.pep.idfile = src/test/resources/client.properties
+
+#AAF Policy Name space
+#Not Mandatory for Open Ecomp
+policy.aaf.namespace = 
+policy.aaf.resource = 
+#
+DMAAP_AAF_LOGIN =
diff --git a/ECOMP-PDP-REST/src/test/resources/pass.xacml.pdp.properties b/ECOMP-PDP-REST/src/test/resources/pass.xacml.pdp.properties
new file mode 100644 (file)
index 0000000..0fe3e2a
--- /dev/null
@@ -0,0 +1,171 @@
+###
+# ============LICENSE_START=======================================================
+# ECOMP-PDP-REST
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# 
+#      http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+# Default XACML Properties File for PDP RESTful servlet
+#
+# Standard API Factories
+#
+xacml.dataTypeFactory=com.att.research.xacml.std.StdDataTypeFactory
+xacml.pdpEngineFactory=com.att.research.xacmlatt.pdp.ATTPDPEngineFactory
+xacml.pepEngineFactory=com.att.research.xacml.std.pep.StdEngineFactory
+# NOT USED SEE BELOW xacml.pipFinderFactory=org.openecomp.policy.xacml.std.pip.StdPIPFinderFactory
+xacml.traceEngineFactory=com.att.research.xacml.std.trace.LoggingTraceEngineFactory
+#
+# AT&T PDP Implementation Factories
+#
+xacml.att.evaluationContextFactory=com.att.research.xacmlatt.pdp.std.StdEvaluationContextFactory
+xacml.att.combiningAlgorithmFactory=com.att.research.xacmlatt.pdp.std.StdCombiningAlgorithmFactory
+xacml.att.functionDefinitionFactory=org.openecomp.policy.xacml.custom.EcompFunctionDefinitionFactory
+# NOT USED SEE BELOW xacml.att.policyFinderFactory=org.openecomp.policy.pdp.std.StdPolicyFinderFactory
+# creteUpdate Policy Implementation Class details. 
+createUpdatePolicy.impl.className=org.openecomp.policy.pdp.rest.api.services.CreateUpdatePolicyServiceImpl
+# AAF Implementation class details
+aafClient.impl.className=org.openecomp.policy.utils.AAFPolicyClientImpl
+#
+# AT&T RESTful PDP Implementation Factories
+#
+xacml.pipFinderFactory=org.openecomp.policy.pdp.rest.impl.XACMLPdpPIPFinderFactory
+xacml.att.policyFinderFactory=org.openecomp.policy.pdp.rest.XACMLPdpPolicyFinderFactory
+#
+# When set to true, this flag tells the StdPolicyFinderFactory to combined all the root policy files into
+# into one PolicySet and use the given Policy Algorithm.
+#
+xacml.att.policyFinderFactory.combineRootPolicies=urn:com:att:xacml:3.0:policy-combining-algorithm:combined-permit-overrides
+#
+# PDP RESTful API properties
+# 
+# Set this to the address where the XACML-PAP-REST servlet is running
+xacml.rest.pap.url=http://localhost:8070/pap/
+
+#if multiple paps exist, the xacml.rest.pap.url can be removed and they can be defined like this:
+#xacml.rest.pap.urls=http://localhost:9090/pap/,http://localhost:9091/pap/
+
+#
+# Give the running PDP an ID for the PAP. The url that its running as is a good choice.
+# The PAP identifies PDP's using the URL of the PDP.
+#
+xacml.rest.pdp.id=http://localhost:8082/pdp/
+
+# Give the port number used for the PDP
+
+xacml.jmx.port=0
+
+
+# Notification Properties
+# Notifcation type: websocket, ueb or dmaap... if left blank websocket is the default
+NOTIFICATION_TYPE=websocket
+NOTIFICATION_SERVERS=test
+NOTIFICATION_TOPIC=test
+NOTIFICATION_DELAY=500
+UEB_API_KEY=
+UEB_API_SECRET=
+DMAAP_AAF_LOGIN=test
+DMAAP_AAF_PASSWORD=test
+
+#
+# Set the directory where the PDP holds its Policy Cache and PIP Configuration
+#
+xacml.rest.pdp.config=config
+
+xacml.rest.pdp.webapps=/home/users/PolicyEngine/webapps/ConfigPAP/
+#
+# Initialize register with PAP servlet
+#
+xacml.rest.pdp.register=true
+#
+# Sleep period in seconds between register attempts
+#
+xacml.rest.pdp.register.sleep=15
+#
+# number of attempts to register. -1 means keep trying forever.
+#
+xacml.rest.pdp.register.retries=-1
+#
+# max number of bytes in a POST of a XML/JSON request
+# old value #32767
+xacml.rest.pdp.maxcontent=99999999 
+#
+# Set UserID here
+xacml.rest.pdp.userid=testpdp
+# Set Password here
+xacml.rest.pdp.password=alpha456
+
+# id PAP
+xacml.rest.pap.userid=testpap
+#if multiple paps have different logins, they can be defined like this:
+#http\://localhost\:9090/pap/.xacml.rest.pap.userid=testpap
+
+# pass PAP
+xacml.rest.pap.password=alpha123
+#http\://localhost\:9090/pap/.xacml.rest.pap.password=alpha123
+
+# Delay for Notifications Don't change this. Value in milliSec.  
+xacml.rest.notification.delay=30
+# Buffer Size. 
+REQUEST_BUFFER_SIZE=15
+
+#properties for MySql xacml database:  PLEASE DO NOT REMOVE... NEEDED FOR APIs
+javax.persistence.jdbc.driver=com.mysql.jdbc.Driver
+javax.persistence.jdbc.url=jdbc:mysql://localhost:3306/xacml
+javax.persistence.jdbc.user=policy_user
+javax.persistence.jdbc.password=policy_user
+
+
+#***Properties for IntegrityMonitor integration defined in XACMLRestProperties.java***
+
+#The name of the PDP.  Must be unique across the system
+xacml.rest.pdp.resource.name=site_1.pdp_1
+
+#***Properties for IntegrityMonitor integration defined in IntegrityMonitorProperties.java***
+
+#Interval between forward progress counter updates in seconds
+fp_monitor_interval=30
+
+#Number of forward progress counter failures before failover
+failed_counter_threshold=3
+
+#Interval in seconds between test transactions if there is no other traffic
+test_trans_interval=10
+
+#Interval in seconds between updates of the forward progress counter in the DB
+write_fpc_interval=5
+
+#Name of the site
+site_name=site_1
+
+#Node type
+node_type=pdp_xacml
+
+#Dependency groups are groups of resources upon which a node operational state is dependent upon). 
+#Each group is a comma-separated list of resource names and groups are separated by a semicolon.
+#A group may contain one or more members. Resource names must match the resource names defined
+#in the respective servers' properties files
+dependency_groups=site_1.pdplp_1;site_1.astragw_1;site_1.brmsgw_1
+
+# this can be DEVL, TEST, PROD 
+ENVIRONMENT=DEVL
+xacml.rest.pep.idfile = src/test/resources/client.properties
+
+#AAF Policy Name space
+#Not Mandatory for Open Ecomp
+policy.aaf.namespace = 
+policy.aaf.resource = 
+#
+DMAAP_AAF_LOGIN =
diff --git a/ECOMP-PDP-REST/src/test/resources/test.drl b/ECOMP-PDP-REST/src/test/resources/test.drl
new file mode 100644 (file)
index 0000000..2a58f54
--- /dev/null
@@ -0,0 +1,1121 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * archetype-closed-loop-demo-rules
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.UUID;
+
+import org.onap.policy.controlloop.VirtualControlLoopEvent;
+import org.onap.policy.controlloop.ControlLoopEventStatus;
+import org.onap.policy.controlloop.VirtualControlLoopNotification;
+import org.onap.policy.controlloop.ControlLoopNotificationType;
+import org.onap.policy.controlloop.ControlLoopOperation;
+import org.onap.policy.controlloop.ControlLoopOperationWrapper;
+import org.onap.policy.template.demo.ControlLoopException;
+
+import org.onap.policy.aai.AAINQF199.AAINQF199CloudRegion;
+import org.onap.policy.aai.AAINQF199.AAINQF199ExtraProperties;
+import org.onap.policy.aai.AAINQF199.AAINQF199ExtraProperty;
+import org.onap.policy.aai.AAINQF199.AAINQF199GenericVNF;
+import org.onap.policy.aai.AAINQF199.AAINQF199InstanceFilters;
+import org.onap.policy.aai.AAINQF199.AAINQF199InventoryResponseItem;
+import org.onap.policy.aai.AAINQF199.AAINQF199InventoryResponseItems;
+import org.onap.policy.aai.AAINQF199.AAINQF199Manager;
+import org.onap.policy.aai.AAINQF199.AAINQF199NamedQuery;
+import org.onap.policy.aai.AAINQF199.AAINQF199QueryParameters;
+import org.onap.policy.aai.AAINQF199.AAINQF199Request;
+import org.onap.policy.aai.AAINQF199.AAINQF199RequestWrapper;
+import org.onap.policy.aai.AAINQF199.AAINQF199Response;
+import org.onap.policy.aai.AAINQF199.AAINQF199ResponseWrapper;
+import org.onap.policy.aai.AAINQF199.AAINQF199ServiceInstance;
+import org.onap.policy.aai.AAINQF199.AAINQF199Tenant;
+import org.onap.policy.aai.AAINQF199.AAINQF199VfModule;
+import org.onap.policy.aai.AAINQF199.AAINQF199VServer;
+import org.onap.policy.aai.util.Serialization;
+
+import org.onap.policy.appc.CommonHeader;
+import org.onap.policy.appc.Request;
+import org.onap.policy.appc.Response;
+import org.onap.policy.appc.ResponseCode;
+import org.onap.policy.appc.ResponseStatus;
+import org.onap.policy.appc.ResponseValue;
+
+import org.onap.policy.template.demo.EventManager;
+import org.onap.policy.vnf.trafficgenerator.PGRequest;
+import org.onap.policy.vnf.trafficgenerator.PGStream;
+import org.onap.policy.vnf.trafficgenerator.PGStreams;
+
+import org.onap.policy.mso.MSOManager;
+import org.onap.policy.mso.MSORequest;
+import org.onap.policy.mso.MSORequestStatus;
+import org.onap.policy.mso.MSORequestDetails;
+import org.onap.policy.mso.MSOModelInfo;
+import org.onap.policy.mso.MSOCloudConfiguration;
+import org.onap.policy.mso.MSORequestInfo;
+import org.onap.policy.mso.MSORequestParameters;
+import org.onap.policy.mso.MSORelatedInstanceListElement;
+import org.onap.policy.mso.MSORelatedInstance;
+import org.onap.policy.mso.MSOResponse;
+
+import org.openecomp.policy.drools.system.PolicyEngine;
+
+//
+// These parameters are required to build the runtime policy
+//
+declare Params
+    closedLoopControlName : String
+    actor : String
+    aaiURL : String
+    aaiUsername : String
+    aaiPassword : String
+    msoURL : String
+    msoUsername : String
+    msoPassword : String
+    aaiNamedQueryUUID : String
+    aaiPatternMatch : int 
+    notificationTopic : String
+    appcTopic : String
+end
+
+/*
+*
+* Called once and only once to insert the parameters into working memory for this Closed Loop policy.
+* (Comment SETUP rule out for the first ECOMP opensource release since policy BRMS_GW already puts a Params fact in there)
+*
+*
+*rule "${policyName}.SETUP"
+*      when
+*      then
+*              System.out.println("rule SETUP is triggered.");
+*              Params params = new Params();
+*              params.setClosedLoopControlName("${closedLoopControlName}");
+*              params.setActor("${actor}");
+*              params.setAaiURL("${aaiURL}");
+*              params.setAaiUsername("${aaiUsername}");
+*              params.setAaiPassword("${aaiPassword}");
+*              params.setMsoURL("${msoURL}");
+*              params.setMsoUsername("${msoUsername}");
+*              params.setMsoPassword("${msoPassword}");
+*              params.setAaiNamedQueryUUID("${aaiNamedQueryUUID}");
+*              params.setAaiPatternMatch(${aaiPatternMatch});
+*              params.setNotificationTopic("${notificationTopic}");
+*              params.setAppcTopic("${appcTopic}");
+*              //
+*              // This stays in memory as long as the rule is alive and running
+*              //
+*              insert(params);
+*end
+*/
+/*
+*
+* This rule responds to DCAE Events
+*
+*/
+rule "${policyName}.EVENT"
+       when
+        $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+        $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+        not ( EventManager( closedLoopControlName == $event.closedLoopControlName ))
+       then
+               System.out.println("rule EVENT is triggered.");
+               try {
+                       // 
+                       // Check the requestID in the event to make sure it is not null before we create the EventManager. 
+                       // The EventManager will do extra syntax checking as well check if the closed loop is disabled/
+                       //
+                       if ($event.requestID == null) {
+                               VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+                               notification.notification = ControlLoopNotificationType.REJECTED;
+                               notification.from = "policy";
+                               notification.message = "Missing requestID from DCAE event";
+                               notification.policyName = drools.getRule().getName();
+                               notification.policyScope = "${policyScope}";
+                               notification.policyVersion = "${policyVersion}";
+                               //
+                               // Let interested parties know
+                               //
+                               try {
+                                       System.out.println(Serialization.gsonPretty.toJson(notification));
+                                       PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                               } catch (Exception e) {
+                                       e.printStackTrace();
+                                       System.out.println("Can't deliver notification: " + notification);
+                               }
+                               //
+                               // Retract it from memory
+                               //
+                               retract($event);
+                               System.out.println("Event with requestID=null has been retracted.");
+                       } else {
+                               //
+                               // Create an EventManager
+                               //
+                               EventManager manager = new EventManager($params.getClosedLoopControlName(), $event.requestID, $event.target);
+                               //
+                               // Determine if EventManager can actively process the event (i.e. syntax)
+                               //
+                               VirtualControlLoopNotification notification = manager.activate($event);
+                               notification.from = "policy"; 
+                               notification.policyName = drools.getRule().getName();
+                               notification.policyScope = "${policyScope}";
+                               notification.policyVersion = "${policyVersion}";
+                               //
+                               // Are we actively pursuing this event?
+                               //
+                               if (notification.notification == ControlLoopNotificationType.ACTIVE) {
+                                       //
+                                       // Insert Event Manager into memory, this will now kick off processing.
+                                       //
+                                       insert(manager);
+                                       //
+                                       // Let interested parties know
+                                       //
+                                       try {
+                                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                                       } catch (Exception e) {
+                                               e.printStackTrace();
+                                               System.out.println("Can't deliver notification: " + notification);
+                                       }               
+                               } else {
+                                       //
+                                       // Let interested parties know
+                                       //
+                                       try {
+                                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                                       } catch (Exception e) {
+                                               e.printStackTrace();
+                                               System.out.println("Can't deliver notification: " + notification);
+                                       }
+                                       //
+                                       // Retract it from memory
+                                       //
+                                       retract($event);
+                               }
+                               //
+                               // Now that the manager is inserted into Drools working memory, we'll wait for
+                               // another rule to fire in order to continue processing. This way we can also
+                               // then screen for additional ONSET and ABATED events for this same RequestIDs 
+                               // and for different RequestIDs but with the same closedLoopControlName and target.
+                               //
+                       }
+               //
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+                       notification.notification = ControlLoopNotificationType.REJECTED;
+                       notification.message = "Exception occurred " + e.getMessage();
+                       notification.policyName = drools.getRule().getName();
+                       notification.policyScope = "${policyScope}";
+                       notification.policyVersion = "${policyVersion}";
+                       //
+                       //
+                       //
+                       try {
+                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                       } catch (Exception e1) {
+                               System.out.println("Can't deliver notification: " + notification);
+                               e1.printStackTrace();
+                       }
+                       //
+                       // Retract the event
+                       //
+                       retract($event);
+               }
+end
+
+/*
+*
+* This rule happens when we got a valid ONSET, closed loop is enabled and an Event Manager
+* is created. We can start the operations for this closed loop.
+*
+*/
+rule "${policyName}.EVENT.MANAGER"
+       when
+               $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+               $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+               $manager : EventManager( closedLoopControlName == $event.closedLoopControlName, controlLoopResult == null)
+       then
+               System.out.println("rule EVENT.MANAGER is triggered.");
+               //
+               // Check which event this is.
+               //
+               EventManager.NEW_EVENT_STATUS eventStatus = $manager.onNewEvent($event);
+               //
+               // We only want the initial ONSET event in memory,
+               // all the other events need to be retracted to support
+               // cleanup and avoid the other rules being fired for this event.
+               //
+               if (eventStatus != EventManager.NEW_EVENT_STATUS.FIRST_ONSET) {
+                       System.out.println("Retracting "+eventStatus+" Event.");
+                       retract($event);
+                       return;
+               }
+               //
+               // Now the event in memory is first onset event
+               //
+               try {
+                       //
+                       // Pull the known AAI field from the Event
+                       //
+                       // generic-vnf is needed for vFirewall case
+                       // vserver-name is needed for vLoadBalancer case
+                       //
+                       String genericVNF = $event.AAI.get("generic-vnf.vnf-id");
+                       String vserver = $event.AAI.get("vserver.vserver-name");
+                       //
+                       // Check if we are implementing a simple pattern match.
+                       //
+                       if ($params.getAaiPatternMatch() == 1) {
+                               //
+                               // Yes
+                               //
+                               //Basic naming characteristics:
+                               //VF Name (9 char)+VM name (13 char total)+VFC (19 char total)
+                               //Example: 
+                               //VF Name (9 characters):    cscf0001v
+                               //VM Name(13 characters): cscf0001vm001
+                               //VFC name(19 characters): cscf0001vm001cfg001
+                               //
+                               // zdfw1fwl01fwl02 or zdfw1fwl01fwl01  
+                               // replaced with
+                               // zdfw1fwl01pgn02 or zdfw1fwl01pgn01
+                               //
+                               int index = genericVNF.lastIndexOf("fwl");
+                               if (index == -1) {
+                                       System.err.println("The generic-vnf.vnf-id from DCAE Event is not valid.");
+                               } else {
+                                       genericVNF = genericVNF.substring(0, index) + "pgn" + genericVNF.substring(index+"fwl".length());
+                               }
+                               //
+                               // Construct an APPC request
+                               //
+                               ControlLoopOperation operation = new ControlLoopOperation();
+                               operation.actor = $params.getActor();
+                               operation.operation = "ModifyConfig";
+                               operation.target = $event.target;
+                               //
+                               // Create operationWrapper
+                               //
+                               ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);
+                               //
+                               // insert operationWrapper into memory
+                               //
+                               insert(operationWrapper);
+                               //
+                               Request request = new Request();
+                               request.CommonHeader = new CommonHeader();
+                               request.CommonHeader.RequestID = $event.requestID;
+                               request.Action = operation.operation;
+                               request.Payload = new HashMap<String, Object>();
+                               //
+                               // Fill in the payload
+                               //
+                               request.Payload.put("generic-vnf.vnf-id", genericVNF);
+                               //
+                               PGRequest pgRequest = new PGRequest();
+                               pgRequest.pgStreams = new PGStreams();
+                               
+                               PGStream pgStream;
+                               for(int i = 0; i < 5; i++){
+                                       pgStream = new PGStream();
+                                       pgStream.streamId = "fw_udp"+(i+1);
+                                       pgStream.isEnabled = "true";
+                                       pgRequest.pgStreams.pgStream.add(pgStream);
+                               }
+                               request.Payload.put("pg-streams", pgRequest.pgStreams);
+                               
+                               if (request != null) {
+                                       //
+                                       // Insert request into memory
+                                       //
+                                       insert(request);
+                                       //
+                                       // Tell interested parties we are performing this Operation
+                                       //
+                                       VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+                                       notification.notification = ControlLoopNotificationType.OPERATION;
+                                       // message and history ??
+                                       notification.from = "policy";
+                                       notification.policyName = drools.getRule().getName();
+                                       notification.policyScope = "${policyScope}";
+                                       notification.policyVersion = "${policyVersion}";
+                                       try {
+                                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                                       } catch (Exception e) {
+                                               System.out.println("Can't deliver notification: " + notification);
+                                               e.printStackTrace();
+                                       }
+                                       //
+                                       // Now send the operation request
+                                       //
+                                       if (request instanceof Request) {
+                                               try {
+                                                       System.out.println("APPC request sent:");
+                                                       System.out.println(Serialization.gsonPretty.toJson(request));
+                                                       PolicyEngine.manager.deliver($params.getAppcTopic(), request);
+                                               } catch (Exception e) {
+                                                       e.printStackTrace();
+                                                       System.out.println("Can't deliver request: " + request);
+                                               }
+                                       }
+                               } else {
+                                       //
+                                       // what happens if it is null
+                                       //
+                               }
+                               //
+                       } else {
+                               //
+                               // create AAI named-query request with UUID started with "F199"
+                               //
+                               AAINQF199Request aainqf199request = new AAINQF199Request();
+                               AAINQF199QueryParameters aainqf199queryparam = new AAINQF199QueryParameters();
+                               AAINQF199NamedQuery aainqf199namedquery = new AAINQF199NamedQuery();
+                               AAINQF199InstanceFilters aainqf199instancefilter = new AAINQF199InstanceFilters();
+                               //
+                               // queryParameters
+                               //
+                               aainqf199namedquery.namedQueryUUID = UUID.fromString($params.getAaiNamedQueryUUID()); 
+                               aainqf199queryparam.namedQuery = aainqf199namedquery;
+                               aainqf199request.queryParameters = aainqf199queryparam;
+                               //
+                               // instanceFilters
+                               //
+                               Map aainqf199instancefiltermap = new HashMap();
+                               Map aainqf199instancefiltermapitem = new HashMap();
+                               aainqf199instancefiltermapitem.put("vserver-name", vserver); 
+                               aainqf199instancefiltermap.put("vserver", aainqf199instancefiltermapitem);
+                               aainqf199instancefilter.instanceFilter.add(aainqf199instancefiltermap);
+                               aainqf199request.instanceFilters = aainqf199instancefilter;
+                               //
+                               // print aainqf199request for debug
+                               //
+                               System.out.println("AAI Request sent:");
+                               System.out.println(Serialization.gsonPretty.toJson(aainqf199request));
+                               //
+                               // Create AAINQF199RequestWrapper
+                               //
+                               AAINQF199RequestWrapper aainqf199RequestWrapper = new AAINQF199RequestWrapper($event.requestID, aainqf199request);
+                               //
+                               // insert aainqf199request into memory
+                               //
+                               insert(aainqf199RequestWrapper);
+                       }
+                       //
+               } catch (Exception e) {
+                e.printStackTrace();
+               }
+end
+
+/*
+*
+* This rule happens when we got a valid ONSET, closed loop is enabled, an Event Manager
+* is created, AAI Manager and AAI Request are ready in memory. We can start sending query to AAI and then wait for response.
+*
+*/
+rule "${policyName}.EVENT.MANAGER.AAINQF199REQUEST"
+       when
+               $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+               $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+               $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+               $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)
+       then
+               System.out.println("rule EVENT.MANAGER.AAINQF199REQUEST is triggered.");
+               //
+               // send the request
+               //
+               AAINQF199Response aainqf199response = AAINQF199Manager.postQuery($params.getAaiURL(), $params.getAaiUsername(), $params.getAaiPassword(),
+                                                                                                          $aainqf199RequestWrapper.aainqf199request, $event.requestID);
+               //
+               // Check AAI response
+               //
+               if (aainqf199response == null) {
+                       System.err.println("Failed to get AAI response");
+                       //
+                       // Fail and retract everything
+                       //
+                       retract($event);
+                       retract($manager);
+                       retract($aainqf199RequestWrapper);
+               } else {
+                       //
+                       // Create AAINQF199ResponseWrapper
+                       //
+                       AAINQF199ResponseWrapper aainqf199ResponseWrapper = new AAINQF199ResponseWrapper($event.requestID, aainqf199response);
+                       //
+                       // insert aainqf199ResponseWrapper to memeory
+                       //
+                       insert(aainqf199ResponseWrapper);
+               }
+end
+
+/*
+*
+* This rule happens when we got a valid AAI response. We can start sending request to APPC or MSO now.
+*
+*/
+rule "${policyName}.EVENT.MANAGER.AAINQF199RESPONSE"
+       when 
+               $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+               $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+               $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+               $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)
+               $aainqf199ResponseWrapper : AAINQF199ResponseWrapper(requestID == $event.requestID)
+       then
+               System.out.println("rule EVENT.MANAGER.AAINQF199RESPONSE is triggered.");
+               //
+               // Extract related fields out of AAINQF199RESPONSE
+               //
+               String vnfItemVnfId, vnfItemVnfType, vnfItemPersonaModelId, vnfItemPersonaModelVersion, vnfItemModelName, 
+                      vnfItemModelVersion, vnfItemModelNameVersionId, serviceItemServiceInstanceId, serviceItemPersonaModelId,
+                      serviceItemModelName, serviceItemModelType, serviceItemModelVersion, serviceItemModelNameVersionId,
+                      vfModuleItemVfModuleName, vfModuleItemPersonaModelId, vfModuleItemPersonaModelVersion, vfModuleItemModelName, 
+                      vfModuleItemModelNameVersionId, tenantItemTenantId, cloudRegionItemCloudRegionId;
+               try {
+                       //
+                       // vnfItem
+                       //
+                       vnfItemVnfId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfID;
+                       vnfItemVnfType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfType;
+                       vnfItemVnfType = vnfItemVnfType.substring(vnfItemVnfType.lastIndexOf("/")+1);
+                       vnfItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelId;
+                       vnfItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelVersion;
+                       vnfItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;
+                       vnfItemModelVersion =           $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(2).propertyValue;
+                       vnfItemModelNameVersionId =     $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;
+                       //
+                       // serviceItem
+                       //
+                       serviceItemServiceInstanceId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.serviceInstanceID;
+                       serviceItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelId;
+                       serviceItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;
+                       serviceItemModelType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(1).propertyValue;
+                       serviceItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelVersion;
+                       serviceItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;
+                       //
+                       // Find the index for base vf module and non-base vf module
+                       //
+                       int baseIndex = -1;
+                       int nonBaseIndex = -1;
+                       List<AAINQF199InventoryResponseItem> inventoryItems = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems;
+                       for (AAINQF199InventoryResponseItem m : inventoryItems) {
+                               if (m.vfModule != null && m.vfModule.isBaseVfModule == true) {
+                                       baseIndex = inventoryItems.indexOf(m);
+                               } else if (m.vfModule != null && m.vfModule.isBaseVfModule == false && m.vfModule.orchestrationStatus == null) {
+                                       nonBaseIndex = inventoryItems.indexOf(m);
+                               }
+                               //
+                               if (baseIndex != -1 && nonBaseIndex != -1) {
+                                       break;
+                               }
+                       }
+                       //
+                       // Report the error if either base vf module or non-base vf module is not found
+                       //
+                       if (baseIndex == -1 || nonBaseIndex == -1) {
+                               System.err.println("Either base or non-base vf module is not found from AAI response.");
+                               retract($aainqf199RequestWrapper);
+                               retract($aainqf199ResponseWrapper);
+                               retract($manager);
+                               retract($event);
+                               return;
+                       }
+                       //
+                       // This comes from the base module
+                       //
+                       vfModuleItemVfModuleName =                      $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(baseIndex).vfModule.vfModuleName;
+                       vfModuleItemVfModuleName = vfModuleItemVfModuleName.replace("Vfmodule", "vDNS");
+                       //
+                       // vfModuleItem - NOT the base module
+                       //
+                       vfModuleItemPersonaModelId =            $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.personaModelId;
+                       vfModuleItemPersonaModelVersion =       $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.personaModelVersion;
+                       vfModuleItemModelName =                         $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(0).propertyValue;
+                       vfModuleItemModelNameVersionId =        $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(4).propertyValue;
+                       //
+                       // tenantItem
+                       //
+                       tenantItemTenantId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).tenant.tenantId;
+                       //
+                       // cloudRegionItem
+                       //
+                       cloudRegionItemCloudRegionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).items.inventoryResponseItems.get(0).cloudRegion.cloudRegionId;
+                       //
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+                       notification.notification = ControlLoopNotificationType.REJECTED;
+                       notification.message = "Exception occurred " + e.getMessage();
+                       notification.policyName = drools.getRule().getName();
+                       notification.policyScope = "${policyScope}";
+                       notification.policyVersion = "${policyVersion}";
+                       //
+                       try {
+                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                       } catch (Exception e1) {
+                               System.out.println("Can't deliver notification: " + notification);
+                               e1.printStackTrace();
+                       }
+                       //
+                       notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+                       notification.message = "Invalid named-query response from AAI";
+            //
+            try {
+               System.out.println(Serialization.gsonPretty.toJson(notification));
+                PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+            } catch (Exception e1) {
+                System.out.println("Can't deliver notification: " + notification);
+                e1.printStackTrace();
+            }
+                       //
+                       // Retract everything
+                       //
+                       retract($aainqf199RequestWrapper);
+                       retract($aainqf199ResponseWrapper);
+                       retract($manager);
+                       retract($event);
+                       return;
+               }       
+               //
+               // Extracted fields should not be null
+               //
+               if ((vnfItemVnfId == null) || (vnfItemVnfType == null) ||
+                   (vnfItemPersonaModelId == null) || (vnfItemModelName == null) ||
+                   (vnfItemModelVersion == null) || (vnfItemModelNameVersionId == null) ||
+                   (serviceItemServiceInstanceId == null) || (serviceItemModelName == null) ||
+                   (serviceItemModelType == null) || (serviceItemModelVersion == null) ||
+                   (serviceItemModelNameVersionId == null) || (vfModuleItemVfModuleName == null) ||
+                   (vfModuleItemPersonaModelId == null) || (vfModuleItemPersonaModelVersion == null) ||
+                   (vfModuleItemModelName == null) || (vfModuleItemModelNameVersionId == null) ||
+                   (tenantItemTenantId == null) || (cloudRegionItemCloudRegionId == null)) {
+                       //
+                       System.err.println("some fields are missing from AAI response.");
+                       //
+                       // Fail and retract everything
+                       //
+                       retract($aainqf199RequestWrapper);
+                       retract($aainqf199ResponseWrapper);
+                       retract($manager);
+                       retract($event);
+                       return;
+               }
+               //
+               // We don't need them any more
+               //
+               retract($aainqf199ResponseWrapper);
+               retract($aainqf199RequestWrapper);  
+               //
+               // check the actor of this closed loop
+               //
+               switch ($params.getActor()) {
+                       case "APPC":
+                       {
+                               //
+                               // Construct an APPC request
+                               //
+                               ControlLoopOperation operation = new ControlLoopOperation();
+                               operation.actor = $params.getActor();
+                               operation.operation = "ModifyConfig";
+                               operation.target = $event.target;
+                               //
+                               // Create operationWrapper
+                               //
+                               ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);
+                               //
+                               // insert operationWrapper into memory
+                               //
+                               insert(operationWrapper);
+                               //
+                               Request request = new Request();
+                               request.CommonHeader = new CommonHeader();
+                               request.CommonHeader.RequestID = $event.requestID;
+                               request.Action = operation.operation;
+                               request.Payload = new HashMap<String, Object>();
+                               //
+                               // Fill in the payload
+                               // Hardcode genericVNF for now since AAI has not been ready for vFirewall demo case
+                               //
+                               String genericVNF = "zdfw1fwl01pgn02";
+                               request.Payload.put("generic-vnf.vnf-id", genericVNF);
+                               //
+                               PGRequest pgRequest = new PGRequest();
+                               pgRequest.pgStreams = new PGStreams();
+                               
+                               PGStream pgStream;
+                               for(int i = 0; i < 5; i++){
+                                       pgStream = new PGStream();
+                                       pgStream.streamId = "fw_udp"+(i+1);
+                                       pgStream.isEnabled = "true";
+                                       pgRequest.pgStreams.pgStream.add(pgStream);
+                               }
+                               request.Payload.put("pg-streams", pgRequest.pgStreams);
+                               
+                               if (request != null) {
+                                       //
+                                       // Insert request into memory
+                                       //
+                                       insert(request);
+                                       //
+                                       // Tell interested parties we are performing this Operation
+                                       //
+                                       VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+                                       notification.notification = ControlLoopNotificationType.OPERATION;
+                                       // message and history ??
+                                       notification.from = "policy";
+                                       notification.policyName = drools.getRule().getName();
+                                       notification.policyScope = "${policyScope}";
+                                       notification.policyVersion = "${policyVersion}";
+                                       try {
+                                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                                       } catch (Exception e) {
+                                               System.out.println("Can't deliver notification: " + notification);
+                                               e.printStackTrace();
+                                       }
+                                       //
+                                       // Now send the operation request
+                                       //
+                                       if (request instanceof Request) {
+                                               try {
+                                                       System.out.println("APPC request sent:");
+                                                       System.out.println(Serialization.gsonPretty.toJson(request));
+                                                       PolicyEngine.manager.deliver($params.getAppcTopic(), request);
+                                               } catch (Exception e) {
+                                                       e.printStackTrace();
+                                                       System.out.println("Can't deliver request: " + request);
+                                               }
+                                       }
+                               } else {
+                                       //
+                                       // what happens if it is null
+                                       //
+                               }
+                       }
+                       break;
+                       case "MSO":
+                       {
+                               //
+                               // Construct an operation
+                               //
+                               ControlLoopOperation operation = new ControlLoopOperation();
+                               operation.actor = $params.getActor();
+                               operation.operation = "createModuleInstance";
+                               operation.target = $event.target;
+                               //
+                               // Create operationWrapper
+                               //
+                               ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);
+                               //
+                               // Construct an MSO request
+                               //
+                               MSORequest request = new MSORequest();
+                               request.requestDetails = new MSORequestDetails();
+                               request.requestDetails.modelInfo = new MSOModelInfo();
+                               request.requestDetails.cloudConfiguration = new MSOCloudConfiguration();
+                               request.requestDetails.requestInfo = new MSORequestInfo();
+                               request.requestDetails.requestParameters = new MSORequestParameters();
+                               request.requestDetails.requestParameters.userParams = null;
+                               //
+                               // cloudConfiguration
+                               //
+                               request.requestDetails.cloudConfiguration.lcpCloudRegionId = cloudRegionItemCloudRegionId;
+                               request.requestDetails.cloudConfiguration.tenantId = tenantItemTenantId;
+                               //
+                               // modelInfo
+                               //
+                               request.requestDetails.modelInfo.modelType = "vfModule";
+                               request.requestDetails.modelInfo.modelInvariantId = vfModuleItemPersonaModelId;
+                               request.requestDetails.modelInfo.modelNameVersionId = vfModuleItemModelNameVersionId;
+                               request.requestDetails.modelInfo.modelName = vfModuleItemModelName;
+                               request.requestDetails.modelInfo.modelVersion = vfModuleItemPersonaModelVersion;
+                               //
+                               // requestInfo
+                               //
+                               request.requestDetails.requestInfo.instanceName = vfModuleItemVfModuleName;
+                               request.requestDetails.requestInfo.source = "POLICY";
+                               request.requestDetails.requestInfo.suppressRollback = false;
+                               //
+                               // relatedInstanceList
+                               //
+                               MSORelatedInstanceListElement relatedInstanceListElement1 = new MSORelatedInstanceListElement();
+                               MSORelatedInstanceListElement relatedInstanceListElement2 = new MSORelatedInstanceListElement();
+                               relatedInstanceListElement1.relatedInstance = new MSORelatedInstance();
+                               relatedInstanceListElement2.relatedInstance = new MSORelatedInstance();
+                               //
+                               relatedInstanceListElement1.relatedInstance.instanceId = serviceItemServiceInstanceId;
+                               relatedInstanceListElement1.relatedInstance.modelInfo = new MSOModelInfo();
+                               relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "service";
+                               relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = serviceItemPersonaModelId;
+                               relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId = serviceItemModelNameVersionId;
+                               relatedInstanceListElement1.relatedInstance.modelInfo.modelName = serviceItemModelName;
+                               relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = serviceItemModelVersion;
+                               //
+                               relatedInstanceListElement2.relatedInstance.instanceId = vnfItemVnfId;
+                               relatedInstanceListElement2.relatedInstance.modelInfo = new MSOModelInfo();
+                               relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "vnf";
+                               relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = vnfItemPersonaModelId;
+                               relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = vnfItemModelNameVersionId;
+                               relatedInstanceListElement2.relatedInstance.modelInfo.modelName = vnfItemModelName;
+                               relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = vnfItemModelVersion;
+                               relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = vnfItemVnfType;
+                               //      
+                               request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);
+                               request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);
+                               //
+                               // print MSO request for debug
+                               //
+                               System.out.println("MSO request sent:");
+                               System.out.println(Serialization.gsonPretty.toJson(request));
+                               //
+                               //
+                               //
+                               if (request != null) {
+                                       //
+                                       // Tell interested parties we are performing this Operation
+                                       //
+                                       VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+                                       notification.notification = ControlLoopNotificationType.OPERATION;
+                                       notification.from = "policy";
+                                       notification.policyName = drools.getRule().getName();
+                                       notification.policyScope = "${policyScope}";
+                                       notification.policyVersion = "${policyVersion}";
+                                       try {
+                                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                                       } catch (Exception e) {
+                                               System.out.println("Can't deliver notification: " + notification);
+                                               e.printStackTrace();
+                                       }
+                                       //
+                                       // Concatenate serviceItemServiceInstanceId and vnfItemVnfId to msoURL
+                                       //
+                                       String MSOUrl = $params.getMsoURL() + "/serviceInstances/v2/" + serviceItemServiceInstanceId + "/vnfs/" + vnfItemVnfId + "/vfModules";
+                                       //
+                                       // Call MSO
+                                       //
+                                       MSOResponse response = MSOManager.createModuleInstance(MSOUrl, $params.getMsoURL(), $params.getMsoUsername(), $params.getMsoPassword(), request);
+                                       //
+                                       if (response != null) {
+                                               //
+                                               // Assign requestId
+                                               //
+                                               request.requestId = $event.requestID.toString();                                                
+                                               response.request.requestId = $event.requestID.toString();
+                                               //
+                                               // Insert facts
+                                               //
+                                               insert(operationWrapper);
+                                               insert(request);
+                                               insert(response);
+                                       } else {
+                                               //
+                                               // MSO request not even accepted
+                                               //
+                                               notification.message = operationWrapper.operation.toMessage();
+                                               operationWrapper.operation.message = operationWrapper.operation.toMessage();
+                                               operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+                                               $manager.setControlLoopResult("FAILURE_EXCEPTION");
+                                               notification.history.add(operationWrapper.operation);
+                                               notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;
+                                               //
+                                               // Let interested parties know
+                                               //
+                                               try {
+                                                       System.out.println(Serialization.gsonPretty.toJson(notification));
+                                                       PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                                               } catch (Exception e) {
+                                                       System.out.println("Can't deliver notification: " + notification);
+                                                       e.printStackTrace();
+                                               }
+                           notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+                        try {
+                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                        } catch (Exception e) {
+                               System.out.println("Can't deliver notification: " + notification);
+                               e.printStackTrace();
+                        }
+                                               //
+                                               // Retract everything
+                                               //
+                                               retract($event);
+                                               retract($manager);
+                                       }
+                               } else {
+                                       System.err.println("constructed MSO request is invalid.");
+                               }
+                       }
+                       break; 
+               } 
+end
+               
+/*
+*
+* This rule responds to APPC Response Events
+*
+*/
+rule "${policyName}.APPC.RESPONSE"
+       when
+               $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+               $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+               $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+               $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )
+               $request : Request( getCommonHeader().RequestID == $event.requestID )
+               $response : Response( getCommonHeader().RequestID == $event.requestID ) 
+       then
+               System.out.println("rule APPC.RESPONSE is triggered.");
+               if ($response.Status == null) {
+                       $operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+                       $manager.setControlLoopResult("FAILURE_EXCEPTION");
+               } 
+               //
+               // Get the Response Code
+               //
+               ResponseCode code = ResponseCode.toResponseCode($response.Status.Code);
+               if (code == null) {
+                       $operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+                       $manager.setControlLoopResult("FAILURE_EXCEPTION");
+               }
+               //
+               // Construct notification
+               //
+               VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+               notification.from = "policy";
+               notification.policyName = drools.getRule().getName();
+               notification.policyScope = "${policyScope}";
+               notification.policyVersion = "${policyVersion}";
+               notification.message = $operationWrapper.operation.toMessage();
+               $operationWrapper.operation.message = $operationWrapper.operation.toMessage();
+               //
+               // Ok, let's figure out what APP-C's response is
+               //
+               switch (code) {
+                       case ACCEPT:
+                               $operationWrapper.operation.outcome = "PROCESSING";
+                               break;
+                       case ERROR:
+                       case REJECT:
+                               $operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+                               $manager.setControlLoopResult("FAILURE_EXCEPTION");
+                               break;
+                       case SUCCESS:
+                               $operationWrapper.operation.outcome = "SUCCESS";
+                               $manager.setControlLoopResult("SUCCESS");
+                               break;
+                       case FAILURE:
+                               $operationWrapper.operation.outcome = "FAILURE";
+                               $manager.setControlLoopResult("FAILURE");
+                               break;
+               }
+               if ($operationWrapper.operation.outcome.equals("SUCCESS")) {
+                       notification.history.add($operationWrapper.operation);
+                       notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;
+                       //
+                       // Let interested parties know
+                       //
+                       try {
+                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                       } catch (Exception e) {
+                               System.out.println("Can't deliver notification: " + notification);
+                               e.printStackTrace();
+                       }
+            notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;
+            try {
+               System.out.println(Serialization.gsonPretty.toJson(notification));
+               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+            } catch (Exception e) {
+               System.out.println("Can't deliver notification: " + notification);
+               e.printStackTrace();
+            }
+
+                       //
+                       // We are going to retract these objects from memory
+                       //
+                       System.out.println("Retracting everything");
+                       retract($operationWrapper);
+                       retract($request);
+                       retract($response);
+                       retract($event);
+                       retract($manager);
+               } else if ($operationWrapper.operation.outcome.equals("PROCESSING")) {
+                       retract($response);
+               } else {
+                       notification.history.add($operationWrapper.operation);
+                       notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;
+                       //
+                       // Let interested parties know
+                       //
+                       try {
+                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                       } catch (Exception e) {
+                               System.out.println("Can't deliver notification: " + notification);
+                               e.printStackTrace();
+                       }
+            notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+            //
+            // Let interested parties know
+            //
+            try {
+               System.out.println(Serialization.gsonPretty.toJson(notification));
+               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+            } catch (Exception e) {
+               System.out.println("Can't deliver notification: " + notification);
+               e.printStackTrace();
+            }
+                       //
+                       // We are going to retract these objects from memory
+                       //
+                       System.out.println("Retracting everything");
+                       retract($operationWrapper);
+                       retract($request);
+                       retract($response);
+                       retract($event);
+                       retract($manager);
+               }
+               
+end            
+
+/*
+*
+* This rule is used to clean up APPC response
+*
+*/             
+rule "${policyName}.APPC.RESPONSE.CLEANUP"
+       when
+               $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+        $response : Response($id : getCommonHeader().RequestID )
+               not ( VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), requestID == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) ) 
+       then
+               System.out.println("rule APPC.RESPONSE.CLEANUP is triggered.");
+               retract($response);
+end
+
+/*
+*
+* This rule responds to MSO Response Events
+*
+*/
+rule "${policyName}.MSO.RESPONSE"
+       when
+               $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+               $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+               $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+               $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )
+               $request : MSORequest( requestId == $event.requestID.toString() )
+               $response : MSOResponse( request.requestId == $event.requestID.toString() )     
+       then
+               System.out.println("rule MSO.RESPONSE is triggered.");
+               //
+               // Construct notification
+               //
+               VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+               notification.from = "policy";
+               notification.policyName = drools.getRule().getName();
+               notification.policyScope = "${policyScope}";
+               notification.policyVersion = "${policyVersion}";
+               notification.message = $operationWrapper.operation.toMessage();
+               $operationWrapper.operation.message = $operationWrapper.operation.toMessage();
+               //
+               // The operation can either be succeeded or failed
+               // 
+               if($response.request.requestStatus.requestState.equals("Completed")) {
+                       $operationWrapper.operation.outcome = "SUCCESS";
+                       $manager.setControlLoopResult("SUCCESS");
+                       notification.history.add($operationWrapper.operation);
+                       notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;
+                       //
+                       // Let interested parties know
+                       //
+                       try {
+                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                       } catch (Exception e) {
+                               System.out.println("Can't deliver notification: " + notification);
+                               e.printStackTrace();
+                       }
+                       notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;
+            //
+            // Let interested parties know
+            //
+            try {
+               System.out.println(Serialization.gsonPretty.toJson(notification));
+               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+            } catch (Exception e) {
+               System.out.println("Can't deliver notification: " + notification);
+               e.printStackTrace();
+            }
+            //
+                       // We are going to retract these objects from memory
+                       //
+                       System.out.println("Retracting everything");
+                       retract($operationWrapper);
+                       retract($request);
+                       retract($response);
+                       retract($event);
+                       retract($manager);
+               } else {
+                       $operationWrapper.operation.outcome = "FAILURE";
+                       $manager.setControlLoopResult("FAILURE");
+                       notification.history.add($operationWrapper.operation);
+                       notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;
+                       //
+                       // Let interested parties know
+                       //
+                       try {
+                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                       } catch (Exception e) {
+                               System.out.println("Can't deliver notification: " + notification);
+                               e.printStackTrace();
+                       }
+                       notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+            //
+            // Let interested parties know
+            //
+            try {
+               System.out.println(Serialization.gsonPretty.toJson(notification));
+               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+            } catch (Exception e) {
+               System.out.println("Can't deliver notification: " + notification);
+               e.printStackTrace();
+            }
+            //
+                       // We are going to retract these objects from memory
+                       //
+                       System.out.println("Retracting everything");
+                       retract($operationWrapper);
+                       retract($request);
+                       retract($response);
+                       retract($event);
+                       retract($manager);
+               }
+               
+end                            
index 1f20856..7631d00 100644 (file)
@@ -166,4 +166,7 @@ xacml.rest.pep.idfile = client.properties
 #AAF Policy Name space
 #Not Mandatory for Open Ecomp
 policy.aaf.namespace = 
-policy.aaf.resource = 
\ No newline at end of file
+policy.aaf.resource = 
+# Decision Response settings. 
+# can be either PERMIT or DENY. 
+decision.indeterminate.response=PERMIT
\ No newline at end of file
index 806df21..5b84ab0 100644 (file)
@@ -41,7 +41,7 @@ import com.att.research.xacmlatt.pdp.std.functions.FunctionDefinitionBase;
  * and returning a <code>Boolean</code> for whether the regular expression matches the string representation of the first argument.
  * 
  * 
- * @version $Revision: 0.1 $
+ * @version $Revision: 0.2 $
  * 
  * @param <I> the java class for the data type of the function Input arguments
  */
@@ -107,7 +107,15 @@ public class FunctionDefinitionCustomRegexpMatch<I> extends FunctionDefinitionBa
                regexpValue = elementValueString.substring(0,(elementValueString.length()- regexpValue.length()));
                elementValueString = elementValueString.substring(regexpValue.length(),(elementValueString.length()));
                // 
-               
+               // Supporting multiple values in the element and be able to query them. 
+               if(elementValueString.contains(",")){
+                       String[] elements = elementValueString.split(",");
+                       for(int i=0; i<elements.length; i++){
+                               if(elements[i].trim().matches(regexpValue)) {
+                                       return ER_TRUE;
+                               }
+                       }
+               }
                if (elementValueString.matches(regexpValue)) {
                        return ER_TRUE;
                } else {
index 71a99d2..194ba1a 100644 (file)
@@ -25,11 +25,14 @@ import java.util.List;
 public class YAMLParams {
        private String actor;
        private String recipe;
+       private String clname;
        private String limit;
        private String timeWindow;
+       private String timeUnits;
        private String guardActiveStart;
        private String guardActiveEnd;
        private List<String> blackList;
+       private List<String> targets;
        
        public String getActor() {
                return actor;
@@ -73,4 +76,22 @@ public class YAMLParams {
        public void setBlackList(List<String> blackList) {
                this.blackList = blackList;
        }
+       public String getClname() {
+               return clname;
+       }
+       public void setClname(String clname) {
+               this.clname = clname;
+       }
+       public String getTimeUnits() {
+               return timeUnits;
+       }
+       public void setTimeUnits(String timeUnits) {
+               this.timeUnits = timeUnits;
+       }
+       public List<String> getTargets() {
+               return targets;
+       }
+       public void setTargets(List<String> targets) {
+               this.targets = targets;
+       }
 }
index 25465cb..7140d35 100644 (file)
@@ -1,6 +1,7 @@
 # login settings
 login_method_backdoor       = backdoor
 login_method_attribute_name = login_method
+login_method_csp = csp
 
 #login message
 login.error.hrid.empty = Login failed, please contact system administrator. 
@@ -11,6 +12,8 @@ login.error.user.inactive = Account is disabled, please contact system administr
 user_attribute_name           = user
 roles_attribute_name          = roles
 role_functions_attribute_name = role_functions
+authentication_mechanism = BOTH
+role_function_list = role_function_list
 
 # Import-user LDAP settings
 post_initial_context_factory = com.sun.jndi.ldap.LdapCtxFactory
diff --git a/ECOMP-XACML/src/main/java/org/openecomp/policy/xacml/std/pip/engines/OperationHistoryEngine.java b/ECOMP-XACML/src/main/java/org/openecomp/policy/xacml/std/pip/engines/OperationHistoryEngine.java
new file mode 100644 (file)
index 0000000..30b59cd
--- /dev/null
@@ -0,0 +1,297 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP-XACML
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.xacml.std.pip.engines;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Persistence;
+import javax.persistence.Query;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.persistence.config.PersistenceUnitProperties;
+
+import com.att.research.xacml.api.Attribute;
+import com.att.research.xacml.api.AttributeValue;
+import com.att.research.xacml.api.Identifier;
+import com.att.research.xacml.api.XACML;
+import com.att.research.xacml.api.XACML3;
+import com.att.research.xacml.api.pip.PIPException;
+import com.att.research.xacml.api.pip.PIPFinder;
+import com.att.research.xacml.api.pip.PIPRequest;
+import com.att.research.xacml.api.pip.PIPResponse;
+import com.att.research.xacml.std.IdentifierImpl;
+import com.att.research.xacml.std.StdMutableAttribute;
+import com.att.research.xacml.std.datatypes.DataTypes;
+import com.att.research.xacml.std.pip.StdMutablePIPResponse;
+import com.att.research.xacml.std.pip.StdPIPRequest;
+import com.att.research.xacml.std.pip.StdPIPResponse;
+import com.att.research.xacml.std.pip.engines.StdConfigurableEngine;
+import com.att.research.xacml.util.XACMLProperties;
+
+/**
+ * PIP Engine for Implementing {@link com.att.research.xacml.std.pip.engines.ConfigurableEngine} interface to provide
+ * attribute retrieval from Operation History Table.  
+ * 
+ * @version $Revision$
+ */
+public class OperationHistoryEngine extends StdConfigurableEngine{
+       public static final String DEFAULT_DESCRIPTION          = "PIP for retrieving Operations History from DB";
+       public static final String DEFAULT_ISSUER                       = "org:onap:xacml:guard:historydb";
+       
+       private static final Log LOGGER= LogFactory.getLog(OperationHistoryEngine.class);
+       
+       private static final PIPRequest PIP_REQUEST_ACTOR       = new StdPIPRequest(
+                       XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
+                       new IdentifierImpl("actor"),
+                       XACML.ID_DATATYPE_STRING);
+
+       private static final PIPRequest PIP_REQUEST_RECIPE      = new StdPIPRequest(
+                       XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
+                       new IdentifierImpl("recipe"), 
+                       XACML.ID_DATATYPE_STRING);
+
+       private static final PIPRequest PIP_REQUEST_TARGET      = new StdPIPRequest(
+                       XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
+                       new IdentifierImpl("target"), 
+                       XACML.ID_DATATYPE_STRING);
+
+       private void addIntegerAttribute(StdMutablePIPResponse stdPIPResponse, Identifier category, Identifier attributeId, int value, PIPRequest pipRequest) {
+               AttributeValue<BigInteger> attributeValue       = null;
+               try {
+                       attributeValue  = DataTypes.DT_INTEGER.createAttributeValue(value);
+               } catch (Exception ex) {
+                       LOGGER.error("Failed to convert " + value + " to an AttributeValue<Boolean>", ex);
+               }
+               if (attributeValue != null) {
+                       stdPIPResponse.addAttribute(new StdMutableAttribute(category, attributeId, attributeValue, pipRequest.getIssuer()/*this.getIssuer()*/, false));
+               }
+       }
+
+       public OperationHistoryEngine() {
+               super();
+       }
+
+       @Override
+       public Collection<PIPRequest> attributesRequired() {
+               return new ArrayList<>();
+       }
+
+       @Override
+       public Collection<PIPRequest> attributesProvided() {
+               return new ArrayList<>();
+       }
+
+       @Override
+       public PIPResponse getAttributes(PIPRequest pipRequest, PIPFinder pipFinder) throws PIPException {
+               LOGGER.info("Entering FeqLimiter PIP");
+               /*
+                * First check to see if the issuer is set and then match it
+                */
+               String string;
+               if ((string = pipRequest.getIssuer()) == null) {
+                       LOGGER.info("FeqLimiter PIP - No issuer in the request!");
+                       return StdPIPResponse.PIP_RESPONSE_EMPTY;
+               }
+               else{
+                       //Notice, we are checking here for the base issuer prefix.
+                       if (!string.contains(this.getIssuer())) {
+                               LOGGER.debug("Requested issuer '" + string + "' does not match " + (this.getIssuer() == null ? "null" : "'" + this.getIssuer() + "'"));
+                               LOGGER.info("FeqLimiter PIP - Issuer "+ string +" does not match with: "+this.getIssuer());
+                               return StdPIPResponse.PIP_RESPONSE_EMPTY;
+                       }
+               }
+               String[] s1 = string.split("tw:");
+               String[] s2 = s1[1].split(":");
+               int timeWindowVal = Integer.parseInt(s2[0]);// number [of minutes, hours, days...]
+               String timeWindowScale = s2[1];//e.g., minute, hour, day, week, month, year
+               String actor = getActor(pipFinder).iterator().next();
+               String operation = getRecipe(pipFinder).iterator().next();
+               String target = getTarget(pipFinder).iterator().next();
+               String timeWindow = timeWindowVal + " " + timeWindowScale;
+               LOGGER.info("Going to query DB about: "+actor + " " + operation + " " + target + " " + timeWindow);
+               int countFromDB = getCountFromDB(actor, operation, target, timeWindowVal, timeWindowScale);
+               StdMutablePIPResponse stdPIPResponse    = new StdMutablePIPResponse();
+               this.addIntegerAttribute(stdPIPResponse,
+                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
+                               new IdentifierImpl("count"), 
+                               countFromDB,
+                               pipRequest);
+               return new StdPIPResponse(stdPIPResponse);
+       }
+
+       @Override
+       public void configure(String id, Properties properties) throws PIPException {
+               super.configure(id, properties);
+               if (this.getDescription() == null) {
+                       this.setDescription(DEFAULT_DESCRIPTION);
+               }
+               if (this.getIssuer() == null) {
+                       this.setIssuer(DEFAULT_ISSUER);
+               }
+       }
+
+       private PIPResponse getAttribute(PIPRequest pipRequest, PIPFinder pipFinder) {
+               PIPResponse pipResponse = null;
+               try {
+                       pipResponse     = pipFinder.getMatchingAttributes(pipRequest, this);
+                       if (pipResponse.getStatus() != null && !pipResponse.getStatus().isOk()) {
+                               LOGGER.info("Error retrieving " + pipRequest.getAttributeId().stringValue() + ": " + pipResponse.getStatus().toString());
+                               pipResponse     = null;
+                       }
+                       if (pipResponse!=null && pipResponse.getAttributes().isEmpty()) {
+                               LOGGER.info("No value for " + pipRequest.getAttributeId().stringValue());
+                               pipResponse     = null;
+                       }
+               } catch (PIPException ex) {
+                       LOGGER.error("PIPException getting subject-id attribute: " + ex.getMessage(), ex);                      
+               }
+               return pipResponse;
+       }
+
+
+       private Set<String> getActor(PIPFinder pipFinder) {
+               /*
+                * Get the AT&T UID from either the subject id or the attuid property
+                */
+               PIPResponse pipResponseATTUID   = this.getAttribute(PIP_REQUEST_ACTOR, pipFinder);
+               if (pipResponseATTUID == null) {
+                       return new HashSet<>();
+               }
+               /*
+                * Iterate over all of the returned results and do the LDAP requests
+                */
+               Collection<Attribute> listATTUIDs       = pipResponseATTUID.getAttributes();
+               Set<String> setATTUIDs                  = new HashSet<>();
+               for (Attribute attributeATTUID: listATTUIDs) {
+                       Iterator<AttributeValue<String>> iterAttributeValues    = attributeATTUID.findValues(DataTypes.DT_STRING);
+                       if (iterAttributeValues != null) {
+                               while (iterAttributeValues.hasNext()) {
+                                       String attuid   = iterAttributeValues.next().getValue();
+                                       if (attuid != null) {
+                                               setATTUIDs.add(attuid);
+                                       }
+                               }
+                       }
+               }
+               return setATTUIDs;
+       }
+
+       private Set<String> getRecipe(PIPFinder pipFinder) {
+               /*
+                * Get the AT&T UID from either the subject id or the attuid property
+                */
+               PIPResponse pipResponseATTUID   = this.getAttribute(PIP_REQUEST_RECIPE, pipFinder);
+               if (pipResponseATTUID == null) {
+                       return new HashSet<>();
+               }
+               /*
+                * Iterate over all of the returned results and do the LDAP requests
+                */
+               Collection<Attribute> listATTUIDs       = pipResponseATTUID.getAttributes();
+               Set<String> setATTUIDs                  = new HashSet<>();
+               for (Attribute attributeATTUID: listATTUIDs) {
+                       Iterator<AttributeValue<String>> iterAttributeValues    = attributeATTUID.findValues(DataTypes.DT_STRING);
+                       if (iterAttributeValues != null) {
+                               while (iterAttributeValues.hasNext()) {
+                                       String attuid   = iterAttributeValues.next().getValue();
+                                       if (attuid != null) {
+                                               setATTUIDs.add(attuid);
+                                       }
+                               }
+                       }
+               }
+               return setATTUIDs;
+       }
+
+
+       private Set<String> getTarget(PIPFinder pipFinder) {
+               /*
+                * Get the AT&T UID from either the subject id or the attuid property
+                */
+               PIPResponse pipResponseATTUID   = this.getAttribute(PIP_REQUEST_TARGET, pipFinder);
+               if (pipResponseATTUID == null) {
+                       return new HashSet<>();
+               }
+               /*
+                * Iterate over all of the returned results and do the LDAP requests
+                */
+               Collection<Attribute> listATTUIDs       = pipResponseATTUID.getAttributes();
+               Set<String> setATTUIDs                  = new HashSet<>();
+               for (Attribute attributeATTUID: listATTUIDs) {
+                       Iterator<AttributeValue<String>> iterAttributeValues    = attributeATTUID.findValues(DataTypes.DT_STRING);
+                       if (iterAttributeValues != null) {
+                               while (iterAttributeValues.hasNext()) {
+                                       String attuid   = iterAttributeValues.next().getValue();
+                                       if (attuid != null) {
+                                               setATTUIDs.add(attuid);
+                                       }
+                               }
+                       }
+               }
+               return setATTUIDs;
+       }
+
+       private static int getCountFromDB(String actor, String operation, String target, int timeWindow, String timeUnits){
+               EntityManager em;
+               try{
+                       Properties properties = XACMLProperties.getProperties();
+                       properties.setProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, "META-INF/operationHistoryPU.xml");
+                       em = Persistence.createEntityManagerFactory("OperationsHistoryPU",properties).createEntityManager();
+               }catch(Exception e){
+                       LOGGER.error("Test thread got Exception " + e.getLocalizedMessage() + " Can't connect to Operations History DB.", e);
+                       return -1;
+               }
+               // Preventing SQL injection
+               if(!validTimeUnits(timeUnits)){
+                       LOGGER.error("given PIP timeUnits is not valid. " + timeUnits);
+                       em.close();
+                       return -1;
+               }
+               String sql = "select count(*) as count from operationshistory10 where outcome<>'Failure_Guard' and actor=?"
+                               + " and operation=?"
+                               + " and target=?"
+                               + " and endtime between date_sub(now(),interval ? "+timeUnits+") and now()";
+               Query nq = em.createNativeQuery(sql);
+               nq.setParameter(1, actor);
+               nq.setParameter(2, operation);
+               nq.setParameter(3, target);
+               nq.setParameter(4, timeWindow);
+               int ret = ((Number)nq.getSingleResult()).intValue();
+               LOGGER.info("###########************** History count: " + ret);
+               em.close();
+               return ret;     
+       }
+       
+       // Validating Time Units to prevent SQL Injection. 
+       private static boolean validTimeUnits(String timeUnits) {
+               return (timeUnits.equalsIgnoreCase("minute") || timeUnits.equalsIgnoreCase("hour") || timeUnits.equalsIgnoreCase("day") 
+                       || timeUnits.equalsIgnoreCase("week") || timeUnits.equalsIgnoreCase("month")||timeUnits.equalsIgnoreCase("year"))?
+                               true: false;
+       }
+}
index 92c963a..bdf4d34 100644 (file)
@@ -52,14 +52,14 @@ import com.att.research.xacml.util.XACMLProperties;
 
 /**
  * PIP Engine for Implementing {@link com.att.research.xacml.std.pip.engines.ConfigurableEngine} interface to provide
- * attribute retrieval from AT&T AAF interface.  
+ * attribute retrieval from AAF interface.  
  * 
  * @version $Revision$
  */
 public class AAFEngine extends StdConfigurableEngine {
        
-       public static final String DEFAULT_DESCRIPTION          = "PIP for authenticating aaf attributes using the AT&T AAF REST interface";
-       public static final String DEFAULT_ISSUER                       = "att-aaf";
+       public static final String DEFAULT_DESCRIPTION          = "PIP for authenticating aaf attributes using the AAF REST interface";
+       public static final String DEFAULT_ISSUER                       = "aaf";
        
        private static final String SUCCESS = "Success";
        
diff --git a/ECOMP-XACML/src/main/resources/META-INF/operationHistoryPU.xml b/ECOMP-XACML/src/main/resources/META-INF/operationHistoryPU.xml
new file mode 100644 (file)
index 0000000..a3770d3
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ============LICENSE_START=======================================================
+  PolicyEngineUtils
+  ================================================================================
+  Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+  ================================================================================
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+  
+       http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  ============LICENSE_END=========================================================
+  -->
+
+<persistence version="2.1"
+       xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
+       <persistence-unit name="OperationsHistoryPU" transaction-type="RESOURCE_LOCAL">
+               <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+               <properties>
+                       <property name="eclipselink.ddl-generation" value="create-tables" />
+                       <property name="eclipselink.logging.level" value="INFO" />
+               </properties>
+       </persistence-unit>
+</persistence>
+  
\ No newline at end of file
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/DOMResponseConformanceTest.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/DOMResponseConformanceTest.java
deleted file mode 100644 (file)
index 2083577..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ECOMP-XACML
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.policy.xacml.test;
-
-import static org.junit.Assert.fail;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Test;
-
-import com.att.research.xacml.api.Response;
-import com.att.research.xacml.std.dom.DOMResponse;
-
-/**
- * Tests for handling the XML version of the XACML Response object.
- * 
- * TO RUN - use jUnit
- * In Eclipse select this file or the enclosing directory, right-click and select Run As/JUnit Test
- * 
- * Normally the Response is generated by the PDP and returned through the RESTful interface as JSON.
- * Testing of the XML interface is minimal and not complete.
- * 
- * 
- * 
- *
- */
-public class DOMResponseConformanceTest {
-       
-       // where to find the conformance test XML files
-       private final String CONFORMANCE_DIRECTORY_PATH = "testsets/conformance/xacml3.0-ct-v.0.4";
-       
-       // The request object output from each test conversion from JSON string
-       Response response;
-
-       
-       
-       // Load the Conformance test responses into Response objects, generate the output XML for that Response and compare with the original files.
-       @Test
-       public void testDOMResponse() {
-               List<File> filesInDirectory = null;
-               
-               File conformanceDirectory = null;
-               
-               File currentFile = null;
-               
-               try {
-                       conformanceDirectory = new File(CONFORMANCE_DIRECTORY_PATH);
-                       filesInDirectory = getRequestsInDirectory(conformanceDirectory);
-               } catch (Exception e) {
-                       fail("Unable to set up Conformance tests for dir '" + conformanceDirectory.getAbsolutePath()+"' e="+ e);
-               }
-               
-               // run through each XML file
-               //      - load the file from XML into an internal Response object
-               //      - generate the XML representation from that Response object
-               //      - reload the file into a String
-               //      - compare the 2 XML strings
-               Response xmlResponse = null;
-               try {
-                       for (File f : filesInDirectory) {
-                               currentFile = f;
-
-//// This is a simple way to select just one file for debugging - comment out when not being used
-//if ( ! f.getName().equals("IID302Response.xml")) {   continue;  }
-
-// during debugging it is helpful to know what file it is starting to work on
-//                             System.out.println("starting file="+currentFile.getName());
-                               
-                               
-                               BufferedReader br = new BufferedReader(new FileReader(f));
-                               StringBuffer sb = new StringBuffer();
-                               String line;
-                               while ((line = br.readLine()) != null) {
-                                       sb.append(line + "\n");
-                               }
-                               br.close();
-                               
-                               String xmlFromFile = sb.toString();
-                               
-                               try {
-                                       // load XML into a Response object
-                                       xmlResponse = DOMResponse.load(xmlFromFile);
-                               } catch (Exception e) {
-                                       // if XML does not load, just note it and continue with next file
-                                       System.out.println("XML file did not load: '" + f.getName() + "  e=" + e);
-                                       continue;
-                               }
-//System.out.println(xmlFromFile);                             
-                               
-                               // create String version from the Response object
-                               String xmlResponseString = DOMResponse.toString(xmlResponse, false);
-                               
-                               // Comparing the string directly to the String from the file is difficult.
-                               // We can minimize the problems with newlines and whitespace, but we have other issues with how various object values are represented.
-                               // For instance, and input double of "23.50" is output as "23.5" which is the same value but not identical strings.
-                               // Therefore we take the XML output and use it to create a new Response object, then compare the two objects.
-
-//System.out.println(xmlResponseString);                       
-                               Response reGeneratedResponse = DOMResponse.load(xmlResponseString);
-                               
-                               if ( ! xmlResponse.equals(reGeneratedResponse)) {
-                                       String normalizedFromFile = xmlFromFile.replaceAll("\\r|\\n", "");
-                                       normalizedFromFile = normalizedFromFile.replaceAll("\\s+", " ");
-                                       normalizedFromFile = normalizedFromFile.replaceAll(">\\s*<", "><");
-                                       System.out.println("File="+normalizedFromFile);
-                                       System.out.println("Gend="+ xmlResponseString);
-                                       
-                                       System.out.println(DOMResponse.toString(xmlResponse, true));
-                               
-                                       fail("Output string did not re-generate eqivilent object.");
-                               }
-
-//                             // Normally whitespace is significant in XML.
-//                             // However in this case we are generating an XML string for output and comparing it to a hand-made file.
-//                             // The file may contain extra newlines or fewer spaces then our prettyPrinted output version.
-//                             // Therefore we do the comparison on the un-prettyPrinted generated string.
-//                             // To do this we have to remove the extra whitespace from the version read from the file.
-//                             String normalizedFromFile = xmlFromFile.replaceAll("\\r|\\n", "");
-//                             normalizedFromFile = normalizedFromFile.replaceAll("\\s+", " ");
-//                             normalizedFromFile = normalizedFromFile.replaceAll(">\\s*<", "><");
-//                     
-//                             if ( ! xmlResponseString.equals(normalizedFromFile)) {
-//                                     System.out.println("file="+normalizedFromFile+"\ngend="+xmlResponseString);
-//                                     fail("file not same as generated string: " + f.getName()+ "\nFile="+xmlFromFile + "\nString="+xmlResponseString);
-//                             }
-
-
-                       }                       
-
-               } catch (Exception e) {
-                       fail ("Failed test with '" + currentFile.getName() + "', e=" + e);
-               }
-
-               
-       }
-       
-       
-       
-       //
-       // HELPER to get list of all Request files in the given directory
-       //
-       
-       private List<File> getRequestsInDirectory(File directory) {
-               List<File> fileList = new ArrayList<File>();
-               
-               File[] fileArray = directory.listFiles();
-               for (File f : fileArray) {
-                       if (f.isDirectory()) {
-                               List<File> subDirList = getRequestsInDirectory(f);
-                               fileList.addAll(subDirList);
-                       }
-                       if (f.getName().endsWith("Response.xml")) {
-                               fileList.add(f);
-                       }
-               }
-               return fileList;
-               
-       }
-       
-       
-}
-
-
-/*
-Place to edit long strings output during tests
-
-
-
-
-
-
-
-
-*/
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/DOMResponseTest.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/DOMResponseTest.java
deleted file mode 100644 (file)
index 5c27018..0000000
+++ /dev/null
@@ -1,2316 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ECOMP-XACML
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.policy.xacml.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-import org.junit.Test;
-
-import com.att.research.xacml.api.Attribute;
-import com.att.research.xacml.api.AttributeValue;
-import com.att.research.xacml.api.Decision;
-import com.att.research.xacml.api.Identifier;
-import com.att.research.xacml.api.XACML3;
-import com.att.research.xacml.std.IdentifierImpl;
-import com.att.research.xacml.std.StdAttribute;
-import com.att.research.xacml.std.StdAttributeCategory;
-import com.att.research.xacml.std.StdAttributeValue;
-import com.att.research.xacml.std.StdIdReference;
-import com.att.research.xacml.std.StdMutableAdvice;
-import com.att.research.xacml.std.StdMutableAttribute;
-import com.att.research.xacml.std.StdMutableAttributeAssignment;
-import com.att.research.xacml.std.StdMutableMissingAttributeDetail;
-import com.att.research.xacml.std.StdMutableObligation;
-import com.att.research.xacml.std.StdMutableResponse;
-import com.att.research.xacml.std.StdMutableResult;
-import com.att.research.xacml.std.StdMutableStatus;
-import com.att.research.xacml.std.StdMutableStatusDetail;
-import com.att.research.xacml.std.StdStatusCode;
-import com.att.research.xacml.std.StdVersion;
-import com.att.research.xacml.std.datatypes.DataTypes;
-import com.att.research.xacml.std.datatypes.StringNamespaceContext;
-import com.att.research.xacml.std.datatypes.XPathExpressionWrapper;
-import com.att.research.xacml.std.dom.DOMResponse;
-import com.att.research.xacml.std.dom.DOMStructureException;
-
-/**
- * Test DOM XML Responses
- * 
- * TO RUN - use jUnit
- * In Eclipse select this file or the enclosing directory, right-click and select Run As/JUnit Test
- * 
- * This class was copied from the JSON tests.  At this time only the first two methods have been revised to work with XML.
- * The second method includes multiple instances of all possible fields and has been manually verified.
- * The remaining methods have not been converted because:
- *     - "conversion" consists of replacing the JSON strings with XML
- *     - the replacement would consist of copying the XML from the JUnit output and doing a String replace
- *     - there would be little examination of the (long) XML strings, so their validity would be questionable
- * so the benefit for the cost of doing that work is not clear.
- * 
- *
- */
-public class DOMResponseTest {
-
-       String xmlResponse;
-       
-       StdMutableResponse response;
-       
-       StdMutableResult result;
-       
-       StdMutableStatus status;
-       
-       
-       // Note: Initially test responses without Obligations, Associated Advice, Attributes, or PolicyIdentifier
-       
-       
-       @Test
-       public void testEmptyAndDecisions() {
-               // null response
-               try {
-                       xmlResponse = DOMResponse.toString(null, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               // empty response (no Result object)
-               response = new StdMutableResponse();
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               
-               // just decision, no status
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // just status (empty), no decision
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();                
-               result.setStatus(status);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               // just status (non-empty), no decision
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_OK);
-               result.setStatus(status);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               
-               // test other decisions without Status
-               
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.DENY);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Deny</Decision></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.NOTAPPLICABLE);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>NotApplicable</Decision></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate</Decision></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.INDETERMINATE_DENY);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate{D}</Decision></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.INDETERMINATE_DENYPERMIT);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate{DP}</Decision></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.INDETERMINATE_PERMIT);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate{P}</Decision></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-
-               
-               // test Multiple Decisions - success
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               response.add(result);
-               StdMutableResult result2 = new StdMutableResult();
-               result2.setDecision(Decision.DENY);
-               response.add(result2);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision></Result><Result><Decision>Deny</Decision></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // test Multiple Decisions - one success and one error
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               response.add(result);
-               result2 = new StdMutableResult();
-               result2.setDecision(Decision.INDETERMINATE);
-               response.add(result2);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision></Result><Result><Decision>Indeterminate</Decision></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-       }
-               
-
-       
-       
-       // Test with every field filled in with multiple values where appropriate
-       @Test
-       public void testAllFieldsResponse() {   
-               
-               // fully-loaded multiple response
-               
-               StdMutableResponse response = new StdMutableResponse();
-               // create a Status object
-               StdMutableStatus status = new StdMutableStatus(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               status.setStatusMessage("some status message");
-               StdMutableStatusDetail statusDetailIn = new StdMutableStatusDetail();
-               StdMutableMissingAttributeDetail mad = new StdMutableMissingAttributeDetail();
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "doh"));
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_INTEGER.getId(), "5432"));
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "meh"));
-               mad.setAttributeId(XACML3.ID_ACTION_PURPOSE);
-               mad.setCategory(XACML3.ID_ATTRIBUTE_CATEGORY_ACTION);
-               mad.setDataTypeId(XACML3.ID_DATATYPE_STRING);
-               mad.setIssuer("an Issuer");
-               statusDetailIn.addMissingAttributeDetail(mad);
-               status.setStatusDetail(statusDetailIn);
-               // create a single result object
-               StdMutableResult result = new StdMutableResult(status);
-               // set the decision
-               result.setDecision(Decision.INDETERMINATE);
-               // put the Result into the Response
-               response.add(result);
-
-               
-               // create a new Result with a different Decision
-               status = new StdMutableStatus(StdStatusCode.STATUS_CODE_OK);
-               result = new StdMutableResult(status);
-               result.setDecision(Decision.DENY);
-               
-               StdMutableObligation obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer2", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Ned")));
-               result.addObligation(obligation);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_SUBJECT_CATEGORY_INTERMEDIARY_SUBJECT);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer3", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Maggie")));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer4", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Homer")));
-               result.addObligation(obligation);
-               
-               
-               StdMutableAdvice advice = new StdMutableAdvice();
-               advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "advice-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu")));
-               advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               null, 
-                               XACML3.ID_SUBJECT, 
-                               "advice-issuerNoCategory", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Crusty")));
-               result.addAdvice(advice);
-               
-               
-               response.add(result);
-               
-               
-               // create a new Result with a different Decision
-               // add Child/minor status codes within the main status
-               StdStatusCode childChildChildStatusCode = new StdStatusCode(new IdentifierImpl("childChildChildStatusCode"));
-               StdStatusCode childChildStatusCode = new StdStatusCode(new IdentifierImpl("childChildStatusCode"), childChildChildStatusCode);
-               StdStatusCode child1StatusCode = new StdStatusCode(new IdentifierImpl("child1StatusCode"), childChildStatusCode);
-               StdStatusCode statusCode = new StdStatusCode(XACML3.ID_STATUS_OK, child1StatusCode);
-               
-               status = new StdMutableStatus(statusCode);
-               
-               
-               result = new StdMutableResult(status);
-               result.setDecision(Decision.PERMIT);
-               
-               
-               
-               
-               // add attribute list in result
-               Identifier categoryIdentifier = new IdentifierImpl("firstCategory");
-               Attribute[] attrList = {
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true),
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent2"), new StdAttributeValue<String>(DataTypes.DT_YEARMONTHDURATION.getId(), "P10Y4M"), "BIssue", false),
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent3"), new StdAttributeValue<Double>(DataTypes.DT_DOUBLE.getId(), 765.432), "CIssue", true),
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent4"), new StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), true), "DIssue", true),
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent5"), new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 4567), "EIssue", true),
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrNoIssuer"), new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 4567), null, true) };
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, Arrays.asList(attrList)));
-               categoryIdentifier = new IdentifierImpl("secondCategory");
-               Attribute[] secondAttrList = {
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent12"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu2"), "AIssue2", true),
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent22"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Abc2"), "BIssue2", false),
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent32"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Der2"), "CIssue2", true) };
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, Arrays.asList(secondAttrList)));
-               
-               
-               // add PolicyIdentifierList to result
-               StdIdReference policyIdentifier1 = null;
-               StdIdReference policyIdentifier2 = null;
-               StdIdReference policySetIdentifier1 = null;
-               StdIdReference policySetIdentifier2 = null;
-               try {
-                       policyIdentifier1 = new StdIdReference(new IdentifierImpl("idRef1"), StdVersion.newInstance("1.2.3"));
-                       policyIdentifier2 = new StdIdReference(new IdentifierImpl("idRef2_NoVersion"));
-                       policySetIdentifier1 = new StdIdReference(new IdentifierImpl("idSetRef1"), StdVersion.newInstance("4.5.6.7.8.9.0"));
-                       policySetIdentifier2 = new StdIdReference(new IdentifierImpl("idSetRef2_NoVersion"));
-               } catch (ParseException e1) {
-                       fail("creating policyIds, e="+e1);
-               }
-               
-               result.addPolicyIdentifier(policyIdentifier1);
-               result.addPolicyIdentifier(policyIdentifier2);
-       
-               result.addPolicySetIdentifier(policySetIdentifier1);
-               result.addPolicySetIdentifier(policySetIdentifier2);
-               
-               response.add(result);
-       
-               // convert Response to XML
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-//System.out.println(xmlResponse);
-//System.out.println(DOMResponse.toString(response, true));
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"/><StatusMessage>some status message</StatusMessage><StatusDetail><MissingAttributeDetail Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:action\" AttributeId=\"urn:oasis:names:tc:xacml:2.0:action:purpose\" DataTypeId=\"http://www.w3.org/2001/XMLSchema#string\" Issuer=\"an Issuer\"><AttributeValue>doh</AttributeValue><AttributeValue>5432</AttributeValue><AttributeValue>meh</AttributeValue></MissingAttributeDetail></StatusDetail></Status></Result><Result><Decision>Deny</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:ok\"/></Status><Obligations><Obligation ObligationId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">Bart</AttributeAssignment><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">Ned</AttributeAssignment></Obligation><Obligation ObligationId=\"urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject\"><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">Maggie</AttributeAssignment><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">Homer</AttributeAssignment></Obligation></Obligations><AssociatedAdvice><Advice AdviceId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">Apu</AttributeAssignment><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">Crusty</AttributeAssignment></Advice></AssociatedAdvice></Result><Result><Decision>Permit</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:ok\"><StatusCode Value=\"child1StatusCode\"><StatusCode Value=\"childChildStatusCode\"><StatusCode Value=\"childChildChildStatusCode\"/></StatusCode></StatusCode></StatusCode></Status><Attributes Category=\"firstCategory\"><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Apu</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent3\" Issuer=\"CIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#double\">765.432</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent4\" Issuer=\"DIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#boolean\">true</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent5\" Issuer=\"EIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#integer\">4567</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrNoIssuer\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#integer\">4567</AttributeValue></Attribute></Attributes><Attributes Category=\"secondCategory\"><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent12\" Issuer=\"AIssue2\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Apu2</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent32\" Issuer=\"CIssue2\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Der2</AttributeValue></Attribute></Attributes><PolicyIdentifierList><PolicyIdReference Version=\"1.2.3\">idRef1</PolicyIdReference><PolicyIdReference>idRef2_NoVersion</PolicyIdReference><PolicySetIdReference Version=\"4.5.6.7.8.9.0\">idSetRef1</PolicySetIdReference><PolicySetIdReference>idSetRef2_NoVersion</PolicySetIdReference></PolicyIdentifierList></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-       }
-       
-       
-       
-       
-       // combinations of Status values with Decision values
-       @Test
-       public void testDecisionStatusMatch() {
-               // the tests in this method use different values and do not change structures, so we can re-use the objects
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               result.setStatus(status);
-               response.add(result);
-               
-               // StatusCode = OK
-               status.setStatusCode(StdStatusCode.STATUS_CODE_OK);
-               result.setDecision(Decision.PERMIT);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:ok\"/></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.DENY);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Deny</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:ok\"/></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.NOTAPPLICABLE);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>NotApplicable</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:ok\"/></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               result.setDecision(Decision.INDETERMINATE_DENY);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               result.setDecision(Decision.INDETERMINATE_DENYPERMIT);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               result.setDecision(Decision.INDETERMINATE_PERMIT);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               
-               
-               
-               
-               
-               // StatusCode = SyntaxError
-               status.setStatusCode(StdStatusCode.STATUS_CODE_SYNTAX_ERROR);
-               result.setDecision(Decision.PERMIT);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               result.setDecision(Decision.DENY);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               result.setDecision(Decision.NOTAPPLICABLE);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               result.setDecision(Decision.INDETERMINATE);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:syntax-error\"/></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE_DENY);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate{D}</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:syntax-error\"/></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE_DENYPERMIT);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate{DP}</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:syntax-error\"/></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE_PERMIT);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate{P}</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:syntax-error\"/></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // StatusCode = ProcessingError
-               status.setStatusCode(StdStatusCode.STATUS_CODE_PROCESSING_ERROR);
-               result.setDecision(Decision.PERMIT);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               result.setDecision(Decision.DENY);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               result.setDecision(Decision.NOTAPPLICABLE);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               result.setDecision(Decision.INDETERMINATE);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:processing-error\"/></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE_DENY);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate{D}</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:processing-error\"/></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE_DENYPERMIT);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate{DP}</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:processing-error\"/></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE_PERMIT);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate{P}</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:processing-error\"/></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               
-               // StatusCode = MissingAttribute
-               status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               result.setDecision(Decision.PERMIT);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               result.setDecision(Decision.DENY);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               result.setDecision(Decision.NOTAPPLICABLE);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               result.setDecision(Decision.INDETERMINATE);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"/></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE_DENY);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate{D}</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"/></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE_DENYPERMIT);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate{DP}</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"/></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE_PERMIT);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate{P}</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"/></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-       }
-
-       
-       
-
-       // tests related to Status and its components
-       @Test
-       public void testStatus() {
-               // Status with no StatusCode - error
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               result.setStatus(status);
-               result.setDecision(Decision.PERMIT);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               // Status with StatusMessage when OK
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_OK);
-               status.setStatusMessage("I'm ok, you're ok");
-               result.setStatus(status);
-               result.setDecision(Decision.PERMIT);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:ok\"/><StatusMessage>I'm ok, you're ok</StatusMessage></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // Status with StatusDetail when OK
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_OK);
-               StdMutableStatusDetail statusDetail = new StdMutableStatusDetail();
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.PERMIT);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               // Status with StatusMessage when SyntaxError
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_SYNTAX_ERROR);
-               status.setStatusMessage("I'm ok, you're ok");
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:syntax-error\"/><StatusMessage>I'm ok, you're ok</StatusMessage></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // Status with empty StatusDetail when SyntaxError
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_SYNTAX_ERROR);
-               statusDetail = new StdMutableStatusDetail();
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               
-               // Status with StatusMessage when ProcessingError
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_PROCESSING_ERROR);
-               status.setStatusMessage("I'm ok, you're ok");
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:processing-error\"/><StatusMessage>I'm ok, you're ok</StatusMessage></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // Status with empty StatusDetail when ProcessingError
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_PROCESSING_ERROR);
-               statusDetail = new StdMutableStatusDetail();
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-
-               
-               // Status with StatusMessage when MissingAttribute
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               status.setStatusMessage("I'm ok, you're ok");
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"/><StatusMessage>I'm ok, you're ok</StatusMessage></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // Status with empty StatusDetail when MissingAttribute
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               statusDetail = new StdMutableStatusDetail();
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"/><StatusDetail></StatusDetail></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               
-               // Status with StatusDetail with empty detail when MissingAttribute
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               statusDetail = new StdMutableStatusDetail();
-               StdMutableMissingAttributeDetail mad = new StdMutableMissingAttributeDetail();
-               statusDetail.addMissingAttributeDetail(mad);
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               // Status with StatusDetail with valid detail with no value when MissingAttribute
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               statusDetail = new StdMutableStatusDetail();
-               mad = new StdMutableMissingAttributeDetail();
-               mad.setAttributeId(new IdentifierImpl("mad"));
-               mad.setCategory(XACML3.ID_ACTION);
-               mad.setDataTypeId(DataTypes.DT_STRING.getId());
-               statusDetail.addMissingAttributeDetail(mad);
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"/><StatusDetail><MissingAttributeDetail Category=\"urn:oasis:names:tc:xacml:1.0:action\" AttributeId=\"mad\" DataTypeId=\"http://www.w3.org/2001/XMLSchema#string\"></MissingAttributeDetail></StatusDetail></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // Status with StatusDetail with valid detail with value when MissingAttribute
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               statusDetail = new StdMutableStatusDetail();
-               mad = new StdMutableMissingAttributeDetail();
-               mad.setAttributeId(new IdentifierImpl("mad"));
-               mad.setCategory(XACML3.ID_ACTION);
-               mad.setDataTypeId(DataTypes.DT_STRING.getId()); 
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "meh"));
-               statusDetail.addMissingAttributeDetail(mad);
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"/><StatusDetail><MissingAttributeDetail Category=\"urn:oasis:names:tc:xacml:1.0:action\" AttributeId=\"mad\" DataTypeId=\"http://www.w3.org/2001/XMLSchema#string\"><AttributeValue>meh</AttributeValue></MissingAttributeDetail></StatusDetail></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // Status with StatusDetail with array valid detail with value when MissingAttribute
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               statusDetail = new StdMutableStatusDetail();
-               mad = new StdMutableMissingAttributeDetail();
-               mad.setAttributeId(new IdentifierImpl("mad"));
-               mad.setCategory(XACML3.ID_ACTION);
-               mad.setDataTypeId(DataTypes.DT_STRING.getId()); 
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "meh"));
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "nu?"));
-               statusDetail.addMissingAttributeDetail(mad);
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"/><StatusDetail><MissingAttributeDetail Category=\"urn:oasis:names:tc:xacml:1.0:action\" AttributeId=\"mad\" DataTypeId=\"http://www.w3.org/2001/XMLSchema#string\"><AttributeValue>meh</AttributeValue><AttributeValue>nu?</AttributeValue></MissingAttributeDetail></StatusDetail></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // Status with StatusDetail with valid detail with Integer value when MissingAttribute
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               statusDetail = new StdMutableStatusDetail();
-               mad = new StdMutableMissingAttributeDetail();
-               mad.setAttributeId(new IdentifierImpl("mad"));
-               mad.setCategory(XACML3.ID_ACTION);
-               mad.setDataTypeId(DataTypes.DT_STRING.getId()); 
-               mad.addAttributeValue(new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 1111));
-               statusDetail.addMissingAttributeDetail(mad);
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"/><StatusDetail><MissingAttributeDetail Category=\"urn:oasis:names:tc:xacml:1.0:action\" AttributeId=\"mad\" DataTypeId=\"http://www.w3.org/2001/XMLSchema#string\"><AttributeValue>1111</AttributeValue></MissingAttributeDetail></StatusDetail></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // Status with StatusDetail with array valid detail with Integer value when MissingAttribute
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               statusDetail = new StdMutableStatusDetail();
-               mad = new StdMutableMissingAttributeDetail();
-               mad.setAttributeId(new IdentifierImpl("mad"));
-               mad.setCategory(XACML3.ID_ACTION);
-               mad.setDataTypeId(DataTypes.DT_STRING.getId()); 
-               mad.addAttributeValue(new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 1111));
-               mad.addAttributeValue(new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 2222));
-               statusDetail.addMissingAttributeDetail(mad);
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Indeterminate</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"/><StatusDetail><MissingAttributeDetail Category=\"urn:oasis:names:tc:xacml:1.0:action\" AttributeId=\"mad\" DataTypeId=\"http://www.w3.org/2001/XMLSchema#string\"><AttributeValue>1111</AttributeValue><AttributeValue>2222</AttributeValue></MissingAttributeDetail></StatusDetail></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-//             StringNamespaceContext snc = new StringNamespaceContext();
-//             try {
-//                     snc.add("defaultURI");
-//                     snc.add("md", "referenceForMD");
-//             } catch (Exception e) {
-//                     fail("unable to create NamespaceContext e="+e);
-//             }
-//             XPathExpressionWrapper xpathExpressionWrapper = new XPathExpressionWrapper(snc, "//md:record");
-//
-//TODO - assume that we will never try to pass back an XPathExpression in a MissingAttributeDetail - it doesn't make sense and is unclear how to put into XML
-//             // Status with StatusDetail with valid detail with XPathExpression value when MissingAttribute
-//             response = new StdMutableResponse();
-//             result = new StdMutableResult();
-//             status = new StdMutableStatus();
-//             status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-//             statusDetail = new StdMutableStatusDetail();
-//             mad = new StdMutableMissingAttributeDetail();
-//             mad.setAttributeId(new IdentifierImpl("mad"));
-//             mad.setCategory(XACML3.ID_ACTION);
-//             mad.setDataTypeId(DataTypes.DT_STRING.getId()); 
-//             mad.addAttributeValue(new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper, new IdentifierImpl("xpathCategoryId")));
-//             statusDetail.addMissingAttributeDetail(mad);
-//             status.setStatusDetail(statusDetail);
-//             result.setStatus(status);
-//             result.setDecision(Decision.INDETERMINATE);
-//             response.add(result);
-//             try {
-//                     xmlResponse = DOMResponse.toString(response, false);
-//                     assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"},\"StatusDetail\":\"<MissingAttributeDetail><AttributeValue>1111</AttributeValue><Category>urn:oasis:names:tc:xacml:1.0:action</Category><AttributeId>mad</AttributeId><DataType>http://www.w3.org/2001/XMLSchema#string</DataType></MissingAttributeDetail>\"},\"Decision\":\"Indeterminate\"}]}", xmlResponse);
-//             } catch (Exception e) {
-//                     fail("operation failed, e="+e);
-//             }
-//             
-//             // Status with StatusDetail with array valid detail with XPathExpression value when MissingAttribute
-//             response = new StdMutableResponse();
-//             result = new StdMutableResult();
-//             status = new StdMutableStatus();
-//             status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-//             statusDetail = new StdMutableStatusDetail();
-//             mad = new StdMutableMissingAttributeDetail();
-//             mad.setAttributeId(new IdentifierImpl("mad"));
-//             mad.setCategory(XACML3.ID_ACTION);
-//             mad.setDataTypeId(DataTypes.DT_STRING.getId()); 
-//             mad.addAttributeValue(new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper, new IdentifierImpl("xpathCategoryId1")));
-//             mad.addAttributeValue(new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper, new IdentifierImpl("xpathCategoryId2")));
-//             statusDetail.addMissingAttributeDetail(mad);
-//             status.setStatusDetail(statusDetail);
-//             result.setStatus(status);
-//             result.setDecision(Decision.INDETERMINATE);
-//             response.add(result);
-//             try {
-//                     xmlResponse = DOMResponse.toString(response, false);
-//                     assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"},\"StatusDetail\":\"<MissingAttributeDetail><AttributeValue>1111</AttributeValue><AttributeValue>2222</AttributeValue><Category>urn:oasis:names:tc:xacml:1.0:action</Category><AttributeId>mad</AttributeId><DataType>http://www.w3.org/2001/XMLSchema#string</DataType></MissingAttributeDetail>\"},\"Decision\":\"Indeterminate\"}]}", xmlResponse);
-//             } catch (Exception e) {
-//                     fail("operation failed, e="+e);
-//             }
-               
-//TODO - try with other data types, esp XPathExpression                
-               
-               // Status with StatusDetail with array valid detail with value when SyntaxError
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_SYNTAX_ERROR);
-               statusDetail = new StdMutableStatusDetail();
-               mad = new StdMutableMissingAttributeDetail();
-               mad.setAttributeId(new IdentifierImpl("mad"));
-               mad.setCategory(XACML3.ID_ACTION);
-               mad.setDataTypeId(DataTypes.DT_STRING.getId()); 
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "meh"));
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "nu?"));
-               statusDetail.addMissingAttributeDetail(mad);
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               // Status with StatusDetail with array valid detail with value when ProcessingError
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_PROCESSING_ERROR);
-               statusDetail = new StdMutableStatusDetail();
-               mad = new StdMutableMissingAttributeDetail();
-               mad.setAttributeId(new IdentifierImpl("mad"));
-               mad.setCategory(XACML3.ID_ACTION);
-               mad.setDataTypeId(DataTypes.DT_STRING.getId()); 
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "meh"));
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "nu?"));
-               statusDetail.addMissingAttributeDetail(mad);
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               
-               
-               // Status with nested child StatusCodes (child status containing child status containing...)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               StdStatusCode child1StatusCode = new StdStatusCode(new IdentifierImpl("child1StatusCode"));
-               StdStatusCode statusCode = new StdStatusCode(XACML3.ID_STATUS_OK, child1StatusCode);
-               status = new StdMutableStatus(statusCode);
-               status.setStatusMessage("I'm ok, you're ok");
-               result.setStatus(status);
-               result.setDecision(Decision.PERMIT);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:ok\"><StatusCode Value=\"child1StatusCode\"/></StatusCode><StatusMessage>I'm ok, you're ok</StatusMessage></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               StdStatusCode childChildChildStatusCode = new StdStatusCode(new IdentifierImpl("childChildChildStatusCode"));
-               StdStatusCode childChildStatusCode = new StdStatusCode(new IdentifierImpl("childChildStatusCode"), childChildChildStatusCode);
-               child1StatusCode = new StdStatusCode(new IdentifierImpl("child1StatusCode"), childChildStatusCode);
-               statusCode = new StdStatusCode(XACML3.ID_STATUS_OK, child1StatusCode);
-               status = new StdMutableStatus(statusCode);
-               status.setStatusMessage("I'm ok, you're ok");
-               result.setStatus(status);
-               result.setDecision(Decision.PERMIT);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Status><StatusCode Value=\"urn:oasis:names:tc:xacml:1.0:status:ok\"><StatusCode Value=\"child1StatusCode\"><StatusCode Value=\"childChildStatusCode\"><StatusCode Value=\"childChildChildStatusCode\"/></StatusCode></StatusCode></StatusCode><StatusMessage>I'm ok, you're ok</StatusMessage></Status></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-
-       }
-
-
-       
-       @Test
-       public void testObligations() {
-               
-               // create an XPathExpression for use later
-               StringNamespaceContext snc = new StringNamespaceContext();
-               try {
-                       snc.add("defaultURI");
-                       snc.add("md", "referenceForMD");
-               } catch (Exception e) {
-                       fail("unable to create NamespaceContext e="+e);
-               }
-               XPathExpressionWrapper xpathExpressionWrapper = new XPathExpressionWrapper(snc, "//md:record");
-               XPathExpressionWrapper xpathExpressionWrapper2 = new XPathExpressionWrapper(snc, "//md:hospital");
-               
-               StdMutableObligation obligation;
-
-               // test Obligation single decision no attributes
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Obligations><Obligation ObligationId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"></Obligation></Obligations></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // obligation missing Id
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               
-               
-               //      AttributeAssignment     - with AttributeId, Value,  Category, DataType, Issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Obligations><Obligation ObligationId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">Bart</AttributeAssignment></Obligation></Obligations></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               //      AttributeAssignment     - with AttributeId, Value, no Category, DataType, Issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               null, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Obligations><Obligation ObligationId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">Bart</AttributeAssignment></Obligation></Obligations></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               //      AttributeAssignment     - Missing AttributeId
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               null, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               //      AttributeAssignment     - Missing Value
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               null));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               // AttributeAssignment - missing required DataType (Different than JSON where DataType is optional with default String)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<String>(null, "Bart")));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               // AttributeAssignment - missing issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Obligations><Obligation ObligationId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">Bart</AttributeAssignment></Obligation></Obligations></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // AttributeAssignment - Integer type
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 1111)));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Obligations><Obligation ObligationId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#integer\">1111</AttributeAssignment></Obligation></Obligations></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // AttributeAssignment - XPathExpression type
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper, new IdentifierImpl("SimpleXPathCategory"))));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Obligations><Obligation ObligationId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\" xmlns:md=\"referenceForMD\" xmlns=\"defaultURI\">//md:record</AttributeAssignment></Obligation></Obligations></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               
-
-               //
-               // Technically arrays cannot occur in Obligations and Advice elements.  The XML spec boils down to the following definition:
-               //              <Obligation (attributes of the obligation) >
-               //                      <AttributeAssignment (attributes of this assignment) >value</AttributeAssignment>
-               //                      <AttributeAssignment (attributes of this assignment) >value</AttributeAssignment>
-               //                      :
-               //              </Obligation
-               //      which means that there may be multiple AttributeAssignments but each one has only one value.
-               //      This differs from the Attributes section in which each <Attribute> may have multiple <AttributeValue> elements.
-               // For Obligations and Advice we can simulate an array by having multiple AttributeAssignment elements with the same Category, Id and Issuer.
-               //
-
-               
-               //      AttributeAssignment     - Multiple values with same Category and Id (one way of doing array)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Lisa")));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Maggie")));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Obligations><Obligation ObligationId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">Bart</AttributeAssignment><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">Lisa</AttributeAssignment><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">Maggie</AttributeAssignment></Obligation></Obligations></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               //      AttributeAssignment     - Multiple Integer values with same Category and Id (one way of doing array)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 1111)));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 2222)));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 3333)));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Obligations><Obligation ObligationId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#integer\">1111</AttributeAssignment><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#integer\">2222</AttributeAssignment><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#integer\">3333</AttributeAssignment></Obligation></Obligations></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // Multiple XPathExpression values with same Category and Id (one way of doing array)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper, new IdentifierImpl("SimpleXPathCategory"))));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper2, new IdentifierImpl("SimpleXPathCategory"))));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Obligations><Obligation ObligationId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\" xmlns:md=\"referenceForMD\" xmlns=\"defaultURI\">//md:record</AttributeAssignment><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\" xmlns:md=\"referenceForMD\" xmlns=\"defaultURI\">//md:hospital</AttributeAssignment></Obligation></Obligations></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }       
-               
-       }
-       
-       
-       
-       
-       @Test
-       public void testAdvice() {
-               
-               // create an XPathExpression for use later
-               StringNamespaceContext snc = new StringNamespaceContext();
-               try {
-                       snc.add("defaultURI");
-                       snc.add("md", "referenceForMD");
-               } catch (Exception e) {
-                       fail("unable to create NamespaceContext e="+e);
-               }
-               XPathExpressionWrapper xpathExpressionWrapper = new XPathExpressionWrapper(snc, "//md:record");
-               XPathExpressionWrapper xpathExpressionWrapper2 = new XPathExpressionWrapper(snc, "//md:hospital");
-               
-               StdMutableAdvice Advice;
-
-               // test Advice single decision no attributes
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><AssociatedAdvice><Advice AdviceId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"></Advice></AssociatedAdvice></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // Advice missing Id
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               
-               
-               //      AttributeAssignment     - with AttributeId, Value,  Category, DataType, Issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><AssociatedAdvice><Advice AdviceId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">Bart</AttributeAssignment></Advice></AssociatedAdvice></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               //      AttributeAssignment     - with AttributeId, Value, no Category, DataType, Issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               null, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><AssociatedAdvice><Advice AdviceId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">Bart</AttributeAssignment></Advice></AssociatedAdvice></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               //      AttributeAssignment     - Missing AttributeId
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               null, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               //      AttributeAssignment     - Missing Value
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               null));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               // AttributeAssignment - missing Required DataType (Different than JSON where DataType is optional with default String)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<String>(null, "Bart")));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               // AttributeAssignment - missing issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><AssociatedAdvice><Advice AdviceId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">Bart</AttributeAssignment></Advice></AssociatedAdvice></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // AttributeAssignment - Integer type
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 1111)));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><AssociatedAdvice><Advice AdviceId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#integer\">1111</AttributeAssignment></Advice></AssociatedAdvice></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // AttributeAssignment - XPathExpression type
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper, new IdentifierImpl("SimpleXPathCategory"))));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><AssociatedAdvice><Advice AdviceId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\" xmlns:md=\"referenceForMD\" xmlns=\"defaultURI\">//md:record</AttributeAssignment></Advice></AssociatedAdvice></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               
-
-               //
-               // Technically arrays cannot occur in Obligations and Advice elements.  The XML spec boils down to the following definition:
-               //              <Obligation (attributes of the obligation) >
-               //                      <AttributeAssignment (attributes of this assignment) >value</AttributeAssignment>
-               //                      <AttributeAssignment (attributes of this assignment) >value</AttributeAssignment>
-               //                      :
-               //              </Obligation
-               //      which means that there may be multiple AttributeAssignments but each one has only one value.
-               //      This differs from the Attributes section in which each <Attribute> may have multiple <AttributeValue> elements.
-               // For Obligations and Advice we can simulate an array by having multiple AttributeAssignment elements with the same Category, Id and Issuer.
-               //
-               
-               //      AttributeAssignment     - Multiple values with same Category and Id (one way of doing array)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Lisa")));
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Maggie")));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><AssociatedAdvice><Advice AdviceId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">Bart</AttributeAssignment><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">Lisa</AttributeAssignment><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">Maggie</AttributeAssignment></Advice></AssociatedAdvice></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               //      AttributeAssignment     - Multiple Integer values with same Category and Id (one way of doing array)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 1111)));
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 2222)));
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 3333)));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><AssociatedAdvice><Advice AdviceId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#integer\">1111</AttributeAssignment><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#integer\">2222</AttributeAssignment><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"http://www.w3.org/2001/XMLSchema#integer\">3333</AttributeAssignment></Advice></AssociatedAdvice></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // Multiple XPathExpression values with same Category and Id (one way of doing array)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper, new IdentifierImpl("SimpleXPathCategory"))));
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper2, new IdentifierImpl("SimpleXPathCategory"))));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><AssociatedAdvice><Advice AdviceId=\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\" xmlns:md=\"referenceForMD\" xmlns=\"defaultURI\">//md:record</AttributeAssignment><AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject\" DataType=\"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\" xmlns:md=\"referenceForMD\" xmlns=\"defaultURI\">//md:hospital</AttributeAssignment></Advice></AssociatedAdvice></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-       }
-       
-       
-       
-       
-       
-
-       
-       
-
-       
-       // Attributes tests
-       @Test
-       public void testAttributes() {
-               
-               // create an XPathExpression for use later
-               StringNamespaceContext snc = new StringNamespaceContext();
-               try {
-                       snc.add("defaultURI");
-                       snc.add("md", "referenceForMD");
-               } catch (Exception e) {
-                       fail("unable to create NamespaceContext e="+e);
-               }
-               XPathExpressionWrapper xpathExpressionWrapper = new XPathExpressionWrapper(snc, "//md:record");
-               
-               
-               Identifier categoryIdentifier;
-               List<Attribute> attrList = new ArrayList<Attribute>();
-               StdMutableAttribute mutableAttribute;
-               
-               // Attr list with no entries
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Attributes Category=\"firstCategory\"></Attributes></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // one Attribute
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Attributes Category=\"firstCategory\"><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Apu</AttributeValue></Attribute></Attributes></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // multiple attributes
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent2"), new StdAttributeValue<String>(DataTypes.DT_YEARMONTHDURATION.getId(), "P10Y4M"), "BIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent3"), new StdAttributeValue<Double>(DataTypes.DT_DOUBLE.getId(), 765.432), "CIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent4"), new StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), true), "DIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent5"), new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 4567), "EIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Attributes Category=\"firstCategory\"><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Apu</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent2\" Issuer=\"BIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#yearMonthDuration\">P10Y4M</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent3\" Issuer=\"CIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#double\">765.432</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent4\" Issuer=\"DIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#boolean\">true</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent5\" Issuer=\"EIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#integer\">4567</AttributeValue></Attribute></Attributes></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // IncludeInResult=false/true
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", false));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Attributes Category=\"firstCategory\"></Attributes></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // Missing AttributeId (mandatory)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                               attrList.add(new StdAttribute(categoryIdentifier, null, new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               // Missing mandatory Value
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), null), "AIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               // Missing optional Issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), null, true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Attributes Category=\"firstCategory\"><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Apu</AttributeValue></Attribute></Attributes></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // missing required DataType (different from JSON where DataType is optional and assumed to be String)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(null, "Apu"), "AIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               // same id, same type different issuer
-               // (This is not an array of values because Issuer is different)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart"), "BIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Simpson"), "CIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Attributes Category=\"firstCategory\"><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Apu</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"BIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Bart</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"CIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Simpson</AttributeValue></Attribute></Attributes></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // same id, same type same issuer
-               // (This is an array of values)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart"), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Simpson"), "AIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Attributes Category=\"firstCategory\"><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Apu</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Bart</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Simpson</AttributeValue></Attribute></Attributes></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // same Id, different types, same issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_YEARMONTHDURATION.getId(), "P10Y4M"), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<Double>(DataTypes.DT_DOUBLE.getId(), 765.432), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), true), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 4567), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 4567), "AIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Attributes Category=\"firstCategory\"><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Apu</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#yearMonthDuration\">P10Y4M</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#double\">765.432</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#boolean\">true</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#integer\">4567</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#integer\">4567</AttributeValue></Attribute></Attributes></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // same Id, different types, different issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_YEARMONTHDURATION.getId(), "P10Y4M"), "BIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<Double>(DataTypes.DT_DOUBLE.getId(), 765.432), "CIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), true), "DIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 4567), "EIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 4567), null, true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Attributes Category=\"firstCategory\"><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Apu</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"BIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#yearMonthDuration\">P10Y4M</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"CIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#double\">765.432</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"DIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#boolean\">true</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"EIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#integer\">4567</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#integer\">4567</AttributeValue></Attribute></Attributes></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-
-               // different Id, different types, same issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent2"), new StdAttributeValue<String>(DataTypes.DT_YEARMONTHDURATION.getId(), "AIssue"), "BIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent3"), new StdAttributeValue<Double>(DataTypes.DT_DOUBLE.getId(), 765.432), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent4"), new StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), true), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent5"), new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 4567), "AIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Attributes Category=\"firstCategory\"><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Apu</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent2\" Issuer=\"BIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#yearMonthDuration\">AIssue</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent3\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#double\">765.432</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent4\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#boolean\">true</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent5\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#integer\">4567</AttributeValue></Attribute></Attributes></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // one Attribute of type XPathExpression (the only complex data type)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper, new IdentifierImpl("xpathCategory")), "AIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Attributes Category=\"firstCategory\"><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\" XPathCategory=\"xpathCategory\">//md:record</AttributeValue></Attribute></Attributes></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // multiple sets of values
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true));
-               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent2"), new StdAttributeValue<String>(DataTypes.DT_YEARMONTHDURATION.getId(), "P10Y4M"), "BIssue", false));
-               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent3"), new StdAttributeValue<Double>(DataTypes.DT_DOUBLE.getId(), 765.432), "CIssue", true));
-               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent4"), new StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), true), "DIssue", true));
-               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent5"), new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 4567), "EIssue", true));
-               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrNoIssuer"), new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 4567), null, true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               categoryIdentifier = new IdentifierImpl("secondCategory");
-               Attribute[] secondAttrList = {
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent12"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu2"), "AIssue2", true),
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent22"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Abc2"), "BIssue2", false),
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent32"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Der2"), "CIssue2", true) };
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, Arrays.asList(secondAttrList)));
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Attributes Category=\"firstCategory\"><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Apu</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent3\" Issuer=\"CIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#double\">765.432</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent4\" Issuer=\"DIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#boolean\">true</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent5\" Issuer=\"EIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#integer\">4567</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrNoIssuer\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#integer\">4567</AttributeValue></Attribute></Attributes><Attributes Category=\"secondCategory\"><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent12\" Issuer=\"AIssue2\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Apu2</AttributeValue></Attribute><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent32\" Issuer=\"CIssue2\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Der2</AttributeValue></Attribute></Attributes></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // array of values - same type
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               attrList.clear();
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               mutableAttribute = new StdMutableAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), (Collection<AttributeValue<?>>)null, "AIssue", true);
-
-                       mutableAttribute.addValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"));
-                       mutableAttribute.addValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart"));
-                       mutableAttribute.addValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Homer"));
-                       mutableAttribute.addValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Ned"));
-                       
-               attrList.add(mutableAttribute);
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Attributes Category=\"firstCategory\"><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Apu</AttributeValue><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Bart</AttributeValue><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Homer</AttributeValue><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Ned</AttributeValue></Attribute></Attributes></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // array of values - compatible different types
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               attrList.clear();
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               mutableAttribute = new StdMutableAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), (Collection<AttributeValue<?>>)null, "AIssue", true);
-
-                       mutableAttribute.addValue(new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 4567));
-                       mutableAttribute.addValue(new StdAttributeValue<Double>(DataTypes.DT_DOUBLE.getId(), 765.432));
-                       mutableAttribute.addValue(new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 4567));
-               attrList.add(mutableAttribute);
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Attributes Category=\"firstCategory\"><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#integer\">4567</AttributeValue><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#double\">765.432</AttributeValue><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#integer\">4567</AttributeValue></Attribute></Attributes></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // array of values - incompatible different types (Different from JSON because these are not part of an array in XML, just separate values)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               attrList.clear();
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               mutableAttribute = new StdMutableAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), (Collection<AttributeValue<?>>)null, "AIssue", true);
-
-                       mutableAttribute.addValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"));
-                       mutableAttribute.addValue(new StdAttributeValue<String>(DataTypes.DT_YEARMONTHDURATION.getId(), "P10Y4M"));
-                       mutableAttribute.addValue(new StdAttributeValue<Double>(DataTypes.DT_DOUBLE.getId(), 765.432));
-                       mutableAttribute.addValue(new StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), true));
-                       mutableAttribute.addValue(new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 4567));
-                       mutableAttribute.addValue(new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), 4567));
-               attrList.add(mutableAttribute);
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><Attributes Category=\"firstCategory\"><Attribute IncludeInResult=\"true\" AttributeId=\"attrIdent1\" Issuer=\"AIssue\"><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Apu</AttributeValue><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#yearMonthDuration\">P10Y4M</AttributeValue><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#double\">765.432</AttributeValue><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#boolean\">true</AttributeValue><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#integer\">4567</AttributeValue><AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#integer\">4567</AttributeValue></Attribute></Attributes></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-       }
-       
-       
-       
-       
-       
-       // PolicyIdentifier tests
-       @Test
-       public void testPolicyIdentifier() {
-               
-               StdIdReference policyIdentifier1 = null;
-               StdIdReference policyIdentifier2 = null;
-               StdIdReference policySetIdentifier1 = null;
-               StdIdReference policySetIdentifier2 = null;
-               
-               // multiple PolicyIdentifiers of both types
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               try {
-                       policyIdentifier1 = new StdIdReference(new IdentifierImpl("idRef1"), StdVersion.newInstance("1.2.3"));
-                       policyIdentifier2 = new StdIdReference(new IdentifierImpl("idRef2_NoVersion"));
-                       policySetIdentifier1 = new StdIdReference(new IdentifierImpl("idSetRef1"), StdVersion.newInstance("4.5.6.7.8.9.0"));
-                       policySetIdentifier2 = new StdIdReference(new IdentifierImpl("idSetRef2_NoVersion"));
-               } catch (ParseException e1) {
-                       fail("creating policyIds, e="+e1);
-               }
-               result.addPolicyIdentifier(policyIdentifier1);
-               result.addPolicyIdentifier(policyIdentifier2);
-               result.addPolicySetIdentifier(policySetIdentifier1);
-               result.addPolicySetIdentifier(policySetIdentifier2);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><PolicyIdentifierList><PolicyIdReference Version=\"1.2.3\">idRef1</PolicyIdReference><PolicyIdReference>idRef2_NoVersion</PolicyIdReference><PolicySetIdReference Version=\"4.5.6.7.8.9.0\">idSetRef1</PolicySetIdReference><PolicySetIdReference>idSetRef2_NoVersion</PolicySetIdReference></PolicyIdentifierList></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // PolicyIdentifier exists but has no IdReferences
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               policyIdentifier1 = null;
-               result.addPolicyIdentifier(policyIdentifier1);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               // PolicySetIdentifier exists but has not IdReferences
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               policySetIdentifier1 = null;
-               result.addPolicyIdentifier(policySetIdentifier1);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (DOMStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from object to XML: " + e);
-               }
-               
-               // PolicyIdentifier with PolicyIdReference and no PolicySetIdReference
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               try {
-                       policyIdentifier1 = new StdIdReference(new IdentifierImpl("idRef1"), StdVersion.newInstance("1.2.3"));
-               } catch (ParseException e1) {
-                       fail("creating policyIds, e="+e1);
-               }
-               result.addPolicyIdentifier(policyIdentifier1);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><PolicyIdentifierList><PolicyIdReference Version=\"1.2.3\">idRef1</PolicyIdReference></PolicyIdentifierList></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               
-               // PolicyIdentifier with no PolicyIdReference and with PolicySetIdReference
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               try {
-                       policySetIdentifier1 = new StdIdReference(new IdentifierImpl("idSetRef1"), StdVersion.newInstance("4.5.6.7.8.9.0"));
-               } catch (ParseException e1) {
-                       fail("creating policyIds, e="+e1);
-               }
-               result.addPolicySetIdentifier(policySetIdentifier1);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><PolicyIdentifierList><PolicySetIdReference Version=\"4.5.6.7.8.9.0\">idSetRef1</PolicySetIdReference></PolicyIdentifierList></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // IdReferences without version
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-
-                       policyIdentifier1 = new StdIdReference(new IdentifierImpl("idRef1"), null);
-                       policyIdentifier2 = new StdIdReference(new IdentifierImpl("idRef2_NoVersion"));
-                       policySetIdentifier1 = new StdIdReference(new IdentifierImpl("idSetRef1"));
-                       policySetIdentifier2 = new StdIdReference(new IdentifierImpl("idSetRef2_NoVersion"));
-
-               result.addPolicyIdentifier(policyIdentifier1);
-               result.addPolicyIdentifier(policyIdentifier2);
-               result.addPolicySetIdentifier(policySetIdentifier1);
-               result.addPolicySetIdentifier(policySetIdentifier2);
-               response.add(result);
-               try {
-                       xmlResponse = DOMResponse.toString(response, false);
-                       assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\"><Result><Decision>Permit</Decision><PolicyIdentifierList><PolicyIdReference>idRef1</PolicyIdReference><PolicyIdReference>idRef2_NoVersion</PolicyIdReference><PolicySetIdReference>idSetRef1</PolicySetIdReference><PolicySetIdReference>idSetRef2_NoVersion</PolicySetIdReference></PolicyIdentifierList></Result></Response>", xmlResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-       }
-
-
-//TODO - the XML spec implies that the Result Attributes may include the Content (It is part of the UML)
-       
-       
-       // test indentation???
-       
-       
-}
-
-
-/*
-Place to edit long strings ouput from tests
-
-
-Expected
-<?xml version="1.0" encoding="UTF-8"?><Response xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd"><Result><Decision>Permit</Decision></Result></Response>
-<?xml version="1.0" encoding="UTF-8"?><Response xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd"><Result><Decision>Permit</Decision></Result></Response>
-Actual
-
-
-
- */
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestAnnotation.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestAnnotation.java
deleted file mode 100644 (file)
index 7b45fb7..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ECOMP-XACML
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.policy.xacml.test;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import com.att.research.xacml.api.DataTypeException;
-import com.att.research.xacml.api.Response;
-import com.att.research.xacml.std.annotations.RequestParser;
-import com.att.research.xacml.std.annotations.XACMLAction;
-import com.att.research.xacml.std.annotations.XACMLAttribute;
-import com.att.research.xacml.std.annotations.XACMLEnvironment;
-import com.att.research.xacml.std.annotations.XACMLMultiRequest;
-import com.att.research.xacml.std.annotations.XACMLRequest;
-import com.att.research.xacml.std.annotations.XACMLRequestReference;
-import com.att.research.xacml.std.annotations.XACMLResource;
-import com.att.research.xacml.std.annotations.XACMLSubject;
-import com.att.research.xacml.std.datatypes.HexBinary;
-import com.att.research.xacml.std.datatypes.IPAddress;
-import com.att.research.xacml.std.datatypes.IPv4Address;
-import com.att.research.xacml.std.datatypes.ISO8601DateTime;
-import com.att.research.xacml.std.datatypes.ISO8601Time;
-import com.att.research.xacml.util.FactoryException;
-
-/**
- * This example application shows how to use annotations for Java classes to create requests to send to the
- * engine.
- * 
- *
- */
-public class TestAnnotation extends TestBase {
-       private static final Log logger = LogFactory.getLog(TestAnnotation.class);
-       
-       private int     num;
-       
-       /**
-        * This is a sample class that uses annotations. In addition to demonstrating how to use XACML annotations,
-        * it also demonstrates the various Java objects that can be used and how the request parser will
-        * resolve each object's datatype.
-        * 
-        *
-        */
-       @XACMLRequest(ReturnPolicyIdList=true)
-       public class MyRequestAttributes {
-               
-               public MyRequestAttributes(String user, String action, String resource) {
-                       this.userID = user;
-                       this.action = action;
-                       this.resource = resource;
-                       this.today = new Date();
-                       this.yesterday = Calendar.getInstance();
-                       this.yesterday.add(Calendar.DAY_OF_MONTH, -1);
-               }
-
-               @XACMLSubject(includeInResults=true)
-               String  userID;
-               
-               @XACMLSubject(attributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id-qualifier")
-               boolean admin = false;
-               
-               @XACMLSubject(attributeId="urn:oasis:names:tc:xacml:1.0:subject:key-info", issuer="com:foo:security")
-               HexBinary publicKey = new HexBinary(new byte[] {'1', '0'});
-               
-               @XACMLSubject(attributeId="urn:oasis:names:tc:xacml:1.0:subject:authentication-time")
-               ISO8601Time     authenticationTime = new ISO8601Time(8, 0, 0, 0);
-               
-               /**
-                * Here our base object is "Object", but it is reflected as a Java "String". The parser
-                * will then use the XACML http://www.w3.org/2001/XMLSchema#string as the datatype.
-                */
-               @XACMLSubject(attributeId="urn:oasis:names:tc:xacml:1.0:subject:authentication-method")
-               Object authenticationMethod = new String("RSA Public Key");
-               
-               /**
-                * Here our base object is "String", but we use the annotation for datatype to clarify
-                * that the real XACML data type is http://www.w3.org/2001/XMLSchema#time. The parser will
-                * use the data type factory to convert the "String" to a "ISO8601Time" Java object.
-                */
-               @XACMLSubject(attributeId="urn:oasis:names:tc:xacml:1.0:subject:request-time", datatype="http://www.w3.org/2001/XMLSchema#time")
-               String requestTime = new String("13:20:00-05:00");
-               
-               @XACMLSubject(attributeId="urn:oasis:names:tc:xacml:1.0:subject:session-start-time")
-               ISO8601DateTime sessionStart = new ISO8601DateTime(TimeZone.getDefault().getID(), 2014, 1, 1, 10, 0, 0, 0);
-               
-               @XACMLSubject(attributeId="urn:oasis:names:tc:xacml:3.0:subject:authn-locality:ip-address")
-               IPAddress ip = new IPv4Address(new short[] {123, 134, 156, 255 }, null, null);
-               
-               @XACMLSubject(attributeId="urn:oasis:names:tc:xacml:3.0:subject:authn-locality:dns-name")
-               String dnsName = "localhost";
-               
-               @XACMLAction()
-               String  action;
-               
-               @XACMLAction(attributeId="urn:oasis:names:tc:xacml:1.0:action:implied-action")
-               long    impliedAction;
-               
-               @XACMLResource()
-               String  resource;
-               
-               @XACMLEnvironment()
-               Date            today;
-               
-               @XACMLEnvironment()
-               Calendar        yesterday;
-               
-               /**
-                * This field demonstrates how the parser can detect collections and build a bag of values.
-                */
-               @XACMLAttribute(attributeId="foo:bar:attribute")
-               Collection<Double>              fooBar = Arrays.asList(2.5, 3.5);
-               
-               /**
-                * The XACMLAttribute annotation allows one to specify all the 
-                */
-               @XACMLAttribute(category="foo:bar:category", attributeId="foo:bar:attribute2")
-               double          fooBar2 = 3.999;
-               
-               /**
-                * This field demonstrates how the parser can detect arrays and build a bag of values.
-                */
-               @XACMLAttribute(category="foo:bar:category", attributeId="foo:bar:attribute:many")
-               URI[]           fooBarMany = new URI[] {URI.create("file://opt/app/test"), URI.create("https://localhost:8443/")};
-               
-       };
-
-       @XACMLRequest(
-               Defaults="http://www.w3.org/TR/1999/Rec-xpath-19991116",
-               multiRequest=@XACMLMultiRequest(values={
-                       @XACMLRequestReference(values={"subject1", "action", "resource"}),
-                       @XACMLRequestReference(values={"subject2", "action", "resource"})})
-       )
-       public class MyMultiRequestAttributes {
-               
-               @XACMLSubject(id="subject1")
-               String  userID1 = "John";
-               
-               @XACMLSubject(id="subject2")
-               String  userID2 = "Ringo";
-
-               @XACMLAction(id="action")
-               String  action = "access";
-
-               @XACMLResource(id="resource")
-               String  resource = "www.mywebsite.com";
-       }
-
-       public TestAnnotation(String[] args) throws MalformedURLException, ParseException, HelpException {
-               super(args);
-       }
-
-       @Override
-       public void run() throws IOException, FactoryException {
-               //
-               // We are not going to iterate any existing request files. So we will override
-               // any TestBase code that assumes there are request files present.
-               //
-               //
-               // Configure ourselves
-               //
-               this.configure();
-               //
-               // Cycle through creating a few objects
-               //
-               this.num = 0;
-               this.doRequest(new MyRequestAttributes("John", "access", "www.mywebsite.com"));
-               this.num++;
-               this.doRequest(new MyRequestAttributes("Ringo", "access", "www.mywebsite.com"));
-               this.num++;
-               this.doRequest(new MyMultiRequestAttributes());
-               this.num++;
-       }
-
-       private void doRequest(Object info) {
-               try {
-                       Response response = this.callPDP(RequestParser.parseRequest(info));
-                       Path resultFile;
-                       if (this.output != null) {
-                               resultFile = Paths.get(this.output.toString(), "Response." + String.format("%03d", this.num) + ".json");
-                       } else {
-                               resultFile = Paths.get(this.directory, "results", "Response." + String.format("%03d", this.num) + ".json");
-                       }
-                       //
-                       // Write the response to the result file
-                       //
-                       logger.info("Response is: " + response.toString());
-                       if (resultFile != null) {
-                               Files.write(resultFile, response.toString().getBytes());
-                       }
-               } catch (IllegalArgumentException | IllegalAccessException | DataTypeException | IOException e) {
-                       logger.error(e);
-                       logger.error("Exception Occured"+e);
-               }
-       }
-       
-       public static void main(String[] args) {
-               try {
-                       new TestAnnotation(args).run();
-               } catch (ParseException | IOException | FactoryException e) {
-                       logger.error(e);
-               } catch (HelpException e) {
-                       //
-                       // ignore this, its thrown just to exit the application
-                       // after dumping help to stdout.
-                       //
-               }               
-       }
-}
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestBase.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestBase.java
deleted file mode 100644 (file)
index 3f2469b..0000000
+++ /dev/null
@@ -1,1082 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ECOMP-XACML
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.policy.xacml.test;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.GnuParser;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.entity.ContentType;
-
-import com.att.research.xacml.api.AttributeValue;
-import com.att.research.xacml.api.DataType;
-import com.att.research.xacml.api.DataTypeException;
-import com.att.research.xacml.api.DataTypeFactory;
-import com.att.research.xacml.api.Decision;
-import com.att.research.xacml.api.Identifier;
-import com.att.research.xacml.api.Request;
-import com.att.research.xacml.api.RequestAttributes;
-import com.att.research.xacml.api.Response;
-import com.att.research.xacml.api.Result;
-import com.att.research.xacml.api.pdp.PDPEngine;
-import com.att.research.xacml.api.pdp.PDPEngineFactory;
-import com.att.research.xacml.api.pdp.PDPException;
-import com.att.research.xacml.api.pep.PEPException;
-import com.att.research.xacml.std.IdentifierImpl;
-import com.att.research.xacml.std.StdAttributeValue;
-import com.att.research.xacml.std.StdMutableAttribute;
-import com.att.research.xacml.std.StdMutableRequest;
-import com.att.research.xacml.std.StdMutableRequestAttributes;
-import com.att.research.xacml.std.dom.DOMRequest;
-import com.att.research.xacml.std.dom.DOMResponse;
-import com.att.research.xacml.std.dom.DOMStructureException;
-import com.att.research.xacml.std.json.JSONRequest;
-import com.att.research.xacml.std.json.JSONResponse;
-import com.att.research.xacml.std.json.JSONStructureException;
-import com.att.research.xacml.util.FactoryException;
-import com.att.research.xacml.util.XACMLProperties;
-import com.google.common.base.Splitter;
-import com.google.common.collect.Lists;
-
-/**
- * This is a base class for setting up a test environment. Using properties files, it contains the
- * necessary information for 
- * 1. defining and providing attributes
- * 2. defining and instantiating the PDP engine
- * 3. creating PEP requests and calling the PDP engine
- * 
- *
- */
-public class TestBase extends SimpleFileVisitor<Path> {
-       private static final Log logger = LogFactory.getLog(TestBase.class);
-       
-       public class HelpException extends Exception {
-               private static final long serialVersionUID = 1L;
-               
-       }
-       
-       /**
-        * This private class holds information for properties defined for attribute
-        * generation. The user can configure the properties file such that attributes
-        * can be automatically generated and added into each request.
-        * 
-        *
-        */
-       class Generator {
-               Path file;
-               InputStream is;
-               BufferedReader reader;
-               List<StdMutableAttribute> attributes = new ArrayList<>();
-               
-               public Generator(Path path) {
-                       this.file = path;
-               }
-
-               /**
-                * read - reads in the next line of data
-                * 
-                * @return      String - a line from the csv containing attribute data
-                */
-               public String   read() {
-                       String str = null;
-                       if (is == null) {
-                               try {
-                                       is = Files.newInputStream(file);
-                               } catch (IOException e) {
-                                       logger.error(e);
-                                       return null;
-                               }
-                       }
-                       if (reader == null) {
-                               reader = new BufferedReader(new InputStreamReader(this.is));
-                       }
-                       try {
-                               str = reader.readLine();
-                               if (str == null) {
-                                       //
-                                       // No more strings, close up
-                                       //
-                                       this.close();
-                               }
-                               if (logger.isDebugEnabled()) {
-                                       logger.debug(str);
-                               }
-                       } catch (IOException e) {
-                               logger.error(e);
-                       }
-                       return str;
-               }
-               
-               public void     close() {
-                       if (this.reader != null) {
-                               try {
-                                       this.reader.close();
-                               } catch (IOException idontcare) {
-                               } finally {
-                                       this.reader = null;
-                                       this.is = null;
-                               }
-                       }
-               }
-               
-       }
-       
-       public static final String PROP_GENERATOR = "xacml.attribute.generator";
-       
-       public static final String OPTION_HELP = "help";
-       public static final String OPTION_TESTDIR = "dir";
-       public static final String OPTION_TESTREST = "rest";
-       public static final String OPTION_TESTURL = "url";
-       public static final String OPTION_TESTOUTPUT = "output";
-       public static final String OPTION_LOOP = "loop";
-       public static final String OPTION_TESTNUMBERS = "testNumbers";
-
-       public static final String DEFAULT_RESTURL = "https://localhost:8080/pdp/";     // Modified for test purpose. Port no. 8443 to 8080
-       
-       public static Options options = new Options();
-       static {
-               options.addOption(new Option(OPTION_HELP, false, "Prints help."));
-               options.addOption(new Option(OPTION_TESTDIR, true, "Directory path where all the test properties and data are located."));
-               options.addOption(new Option(OPTION_TESTREST, false, "Test against RESTful PDP."));
-               options.addOption(new Option(OPTION_TESTURL, true, "URL to the RESTful PDP. Default is " + DEFAULT_RESTURL));
-               options.addOption(new Option(OPTION_TESTOUTPUT, true, "Specify a different location for dumping responses."));
-               options.addOption(new Option(OPTION_LOOP, true, "Number of times to loop through the tests. Default is 1. A value of -1 runs indefinitely."));
-               options.addOption(new Option(OPTION_TESTNUMBERS, true, "Comma-separated list of numbers found in the names of the test files to be run.  Numbers must exactly match the file name, e.g. '02'.  Used to limit testing to specific set of tests."));
-       }
-       
-       protected String directory = null;
-       protected Path output = null;
-       protected boolean isREST;
-       protected URL restURL = null;
-       protected int loop = 1;
-       protected PDPEngine engine = null;
-       protected List<Generator> generators = new ArrayList<>();
-       protected static DataTypeFactory dataTypeFactory                = null;
-       
-       private long    permits = 0;
-       private long    denies = 0;
-       private long    notapplicables = 0;
-       private long    indeterminates = 0;
-       
-       private long    expectedPermits = 0;
-       private long    expectedDenies = 0;
-       private long    expectedNotApplicables = 0;
-       private long    expectedIndeterminates = 0;
-       
-       private long    generatedpermits = 0;
-       private long    generateddenies = 0;
-       private long    generatednotapplicables = 0;
-       private long    generatedindeterminates = 0;
-       
-       private long    responseMatches = 0;
-       private long    responseNotMatches = 0;
-       
-       private String[]        testNumbersArray = null;
-       
-       protected final Pattern pattern = Pattern.compile("Request[.]\\d+[.](Permit|Deny|NA|Indeterminate|Generate|Unknown)\\.(json|xml)");
-       
-       public static boolean isJSON(Path file) {
-               return file.toString().endsWith(".json");
-       }
-       
-       public static boolean isXML(Path file) {
-               return file.toString().endsWith(".xml");
-       }
-       
-       public TestBase(String[] args) throws ParseException, MalformedURLException, HelpException {
-               //
-               // Finish Initialization
-               //
-               this.restURL = new URL(DEFAULT_RESTURL);
-               //
-               // Parse arguments
-               //
-               this.parseCommands(args);
-       }
-       
-       /**
-        * Parse in the command line arguments that the following parameters:
-        * 
-        * @param args - command line arguments
-        * @throws ParseException 
-        * @throws MalformedURLException 
-        * @throws HelpException 
-        */
-       protected void parseCommands(String[] args) throws ParseException, MalformedURLException, HelpException {
-               //
-               // Parse the command line options
-               //
-               CommandLine cl;
-               cl = new GnuParser().parse(options, args);
-               //
-               // Check for what we have
-               //
-               if (cl.hasOption(OPTION_HELP)) {
-               new HelpFormatter().printHelp("Usage: -dir testdirectory OPTIONS",
-                               options);
-               throw new HelpException();
-               }
-               if (cl.hasOption(OPTION_TESTDIR)) {
-                       this.directory = cl.getOptionValue(OPTION_TESTDIR);
-               } else {
-                       throw new IllegalArgumentException("You must specify a test directory. -dir path/to/some/where");
-               }
-               if (cl.hasOption(OPTION_TESTREST)) {
-                       this.isREST = true;
-               } else {
-                       this.isREST = false;
-               }
-               if (cl.hasOption(OPTION_TESTURL)) {
-                       this.restURL = new URL(cl.getOptionValue(OPTION_TESTURL));
-               }
-               if (cl.hasOption(OPTION_TESTOUTPUT)) {
-                       this.output = Paths.get(cl.getOptionValue(OPTION_TESTOUTPUT));
-               } else {
-                       this.output = Paths.get(this.directory, "results");
-               }
-               if (cl.hasOption(OPTION_LOOP)) {
-                       this.loop = Integer.parseInt(cl.getOptionValue(OPTION_LOOP));
-               }
-               if (cl.hasOption(OPTION_TESTNUMBERS)) {
-                       String testNumberString = cl.getOptionValue(OPTION_TESTNUMBERS);
-                       testNumbersArray = testNumberString.split(",");
-                       //
-                       // reset strings to include dots so they exactly match pattern in file name
-                       //
-                       for (int i = 0; i < testNumbersArray.length; i++) {
-                               testNumbersArray[i] = "." + testNumbersArray[i] + ".";
-                       }
-               }
-       }
-       
-       /**
-        * Using the command line options that were parsed, configures our test instance.
-        * 
-        * @throws FactoryException
-        */
-       protected void configure() throws FactoryException {
-               //
-               // Setup the xacml.properties file
-               //
-               if (this.directory == null) {
-                       throw new IllegalArgumentException("Must supply a path to a test directory.");
-               }
-               Path pathDir = Paths.get(this.directory, "xacml.properties");
-               if (Files.notExists(pathDir)) {
-                       throw new IllegalArgumentException(pathDir.toString() + " does not exist.");
-               }
-               //
-               // Set it as the System variable so the XACML factories know where the properties are
-               // loaded from.
-               //
-               System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, pathDir.toString());
-               //
-               // Now we can create the data type factory
-               //
-               dataTypeFactory = DataTypeFactory.newInstance();
-               //
-               // Load in what generators we are to create
-               //
-               String generators = XACMLProperties.getProperty(PROP_GENERATOR);
-               if (generators != null) {
-                       //
-                       // Parse the generators
-                       //
-                       for (String generator : Splitter.on(',').trimResults().omitEmptyStrings().split(generators)) {
-                               this.configureGenerator(generator);
-                       }
-               }
-               //
-               // If we are embedded, create our engine
-               //
-               if (this.isREST == false) {
-                       PDPEngineFactory factory = PDPEngineFactory.newInstance();
-                       this.engine = factory.newEngine();
-               }
-               //
-               // Remove all the responses from the results directory
-               //
-               this.removeResults();
-       }
-       
-       /**
-        * Removes all the Response* files from the results directory.
-        * 
-        */
-       public void     removeResults() {
-               try {
-                       //
-                       // Determine where the results are supposed to be written to
-                       //
-                       Path resultsPath;
-                       if (this.output != null) {
-                               resultsPath = this.output;
-                       } else {
-                               resultsPath = Paths.get(this.directory.toString(), "results");
-                       }
-                       //
-                       // Walk the files
-                       //
-                       Files.walkFileTree(resultsPath, new SimpleFileVisitor<Path>() {
-
-                               @Override
-                               public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
-                                       if (file.getFileName().toString().startsWith("Response")) {
-                                               Files.delete(file);
-                                       }
-                                       return super.visitFile(file, attrs);
-                               }                               
-                       });
-               } catch (IOException e) {
-                       logger.error("Failed to removeRequests from " + this.directory + " " + e);
-               }
-       }
-       
-       /**
-        * Configure's a specific generator instance from the properties file.
-        * 
-        * @param generator
-        */
-       protected void configureGenerator(String generator) {
-               String prefix = PROP_GENERATOR + "." + generator;
-               String file = XACMLProperties.getProperty(prefix + ".file");
-               //
-               // Create a generator object
-               //
-               Generator gen = new Generator(Paths.get(this.directory, file));
-               this.generators.add(gen);
-               //
-               // Grab attributes
-               //
-               String attributes = XACMLProperties.getProperty(prefix + ".attributes");
-               for (String attribute : Splitter.on(',').trimResults().omitEmptyStrings().split(attributes)) {
-                       String attributePrefix = prefix + ".attributes." + attribute;
-                       //
-                       // Create an attribute value. It is simply a placeholder for the field within
-                       // the CSV that contains the actual attribute value. It mainly holds the data type
-                       //
-                       Identifier datatype = new IdentifierImpl(XACMLProperties.getProperty(attributePrefix + ".datatype"));
-                       Integer field = Integer.parseInt(XACMLProperties.getProperty(attributePrefix + ".field"));
-                       StdAttributeValue<?> value = new StdAttributeValue<>(datatype, field);
-                       //
-                       // Get the rest of the attribute properties
-                       //
-                       Identifier category = new IdentifierImpl(XACMLProperties.getProperty(attributePrefix + ".category"));
-                       Identifier id = new IdentifierImpl(XACMLProperties.getProperty(attributePrefix + ".id"));
-                       String issuer = XACMLProperties.getProperty(attributePrefix + ".issuer");
-                       boolean include = Boolean.parseBoolean(XACMLProperties.getProperty(attributePrefix + ".include", "false"));
-                       //
-                       // Now we have a skeleton attribute
-                       //
-                       gen.attributes.add(new StdMutableAttribute(category, id, value, issuer, include));
-               }
-       }
-       
-       /**
-        * This runs() the test instance. It first configure's itself and then walks the
-        * requests directory issue each request to the PDP engine.
-        * 
-        * @throws IOException
-        * @throws FactoryException 
-        * 
-        */
-       public void run() throws IOException, FactoryException {
-               //
-               // Configure ourselves
-               //
-               this.configure();
-               //
-               // Loop and run
-               //
-               int runs = 1;
-               do {
-                       long lTimeStart = System.currentTimeMillis();
-                       logger.info("Run number: " + runs);
-                       //
-                       // Walk the request directory
-                       //
-                       Files.walkFileTree(Paths.get(this.directory.toString(), "requests"), this);
-                       long lTimeEnd = System.currentTimeMillis();
-                       logger.info("Run elapsed time: " + (lTimeEnd - lTimeStart) + "ms");
-                       //
-                       // Dump the stats
-                       //
-                       this.dumpStats();
-                       this.resetStats();
-                       //
-                       // Increment
-                       //
-                       runs++;
-               } while ((this.loop == -1 ? true : runs <= this.loop));
-       }
-       
-       @Override
-       public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
-               //
-               // Sanity check the file name
-               //
-               Matcher matcher = this.pattern.matcher(file.getFileName().toString());
-               if (matcher.matches()) {
-                       //
-                       // if user has limited which files to use, check that here
-                       //
-                       if (testNumbersArray != null) {
-                               String fileNameString = file.getFileName().toString();
-                               boolean found = false;
-                               for (String numberString : testNumbersArray) {
-                                       if (fileNameString.contains(numberString)) {
-                                               found = true;
-                                               break;
-                                       }
-                               }
-                               if (found == false) {
-                                       //
-                                       // this test is not in the list to be run, so skip it
-                                       //
-                                       return super.visitFile(file, attrs);
-                               }
-                       }
-                       try {
-                               //
-                               // Pull what this request is supposed to be
-                               //
-                               String group = null;
-                               int count = matcher.groupCount();
-                               if (count >= 1) {
-                                       group = matcher.group(count-1);
-                               }
-                               //
-                               // Send it
-                               //
-                               this.sendRequest(file, group);
-                       } catch (Exception e) {
-                               logger.error(e);
-                               logger.error("Exception Occured"+e);
-                       }
-               }
-               return super.visitFile(file, attrs);
-       }
-       
-       /**
-        * When a request file is encountered, this method is called send the request to the PDP engine. It will also dump
-        * the response object. If the group equals "Generate", then it will loop and send the request with generated attributes
-        * until that list is empty.
-        * 
-        * @param file - Request file. Eg. Request-01-Permit.json
-        * @param group - This is the parsed out string of the request file that defines if it is a Permit/Deny/Generate etc.
-        * @throws Exception
-        */
-       protected void sendRequest(Path file, String group) throws Exception {
-               logger.info(file.toString());
-               int requestCount = 0;
-               do {
-                       //
-                       // Generate the request
-                       //
-                       Request request = this.generateRequest(file, group);
-                       //
-                       // Was something generated?
-                       //
-                       if (request == null) {
-                               //
-                               // Get out of the loop
-                               //
-                               logger.info("NULL request generated.");
-                               break;
-                       }
-                       logger.info(request);
-                       //
-                       // Call the PDP
-                       //
-                       Response response = this.callPDP(request);
-                       //
-                       // Process the response
-                       //
-                       this.processResponse(file, request, response, group, requestCount);
-                       //
-                       // Is this a generated request?
-                       //
-                       if (group.equals("Generate")) {
-                               //
-                               // Yes, increment counter and move
-                               // on to the next generated request.
-                               //
-                               requestCount++;
-                       } else {
-                               //
-                               // Nope, exit the loop
-                               //
-                               break;
-                       }
-               } while (group.equals("Generate"));
-       }
-       
-       /**
-        * Sends the request object to the PDP engine. Either the embedded engine or the RESTful engine.
-        * 
-        * @param request - XACML request object
-        * @return Response - returns the XACML response object
-        */
-       protected Response callPDP(Request request) {
-               //
-               // Send it to the PDP
-               //
-               Response response = null;
-               if (this.isREST) {
-                       try {
-                               String jsonString = JSONRequest.toString(request, false);
-                               //
-                               // Call RESTful PDP
-                               //
-                               response = this.callRESTfulPDP(new ByteArrayInputStream(jsonString.getBytes()));
-                       } catch (Exception e) {
-                               logger.error("Error in sending RESTful request: " + e, e);
-                       }
-               } else {
-                       //
-                       // Embedded call to PDP
-                       //
-                       long lTimeStart = System.currentTimeMillis();
-                       try {
-                               response = this.engine.decide(request);
-                       } catch (PDPException e) {
-                               logger.error(e);
-                       }
-                       long lTimeEnd = System.currentTimeMillis();
-                       logger.info("Elapsed Time: " + (lTimeEnd - lTimeStart) + "ms");
-               }
-               return response;
-       }
-       
-       /**
-        * Reads the request file into a Request object based on its type.
-        * 
-        * If the request has "Generate" in its filename, then this function will add
-        * generated attributes into the request.
-        * 
-        * @param file - Request file. Eg. Request-01-Permit.json
-        * @param group - This is the parsed out string of the request file that defines if it is a Permit/Deny/Generate etc.
-        * @return
-        * @throws JSONStructureException
-        * @throws DOMStructureException
-        * @throws PEPException
-        */
-       protected Request generateRequest(Path file, String group) throws JSONStructureException, DOMStructureException, PEPException {
-               //
-               // Convert to a XACML Request Object
-               //
-               Request request = null;
-               if (TestBase.isJSON(file)) {
-                       request = JSONRequest.load(file.toFile());
-               } else if (TestBase.isXML(file)) {
-                       request = DOMRequest.load(file.toFile());
-               }
-               if (request == null) {
-                       throw new PEPException("Invalid Request File: " + file.toString());
-               }
-               //
-               // Only if this request has "Generate"
-               // Request.XX.Generate.[json|xml]
-               //
-               if (group.equals("Generate")) {
-                       //
-                       // Add attributes to it
-                       //
-                       request = this.onNextRequest(request);
-               }
-               //
-               // Done
-               //
-               return request;
-       }
-
-       /**
-        * Called to add in generated attributes into the request.
-        * 
-        * @param request
-        * @return
-        */
-       protected Request onNextRequest(Request request) {
-               //
-               // If we have no generators, just return
-               //
-               if (this.generators.isEmpty()) {
-                       return request;
-               }
-               //
-               // Copy the request attributes
-               //
-               List<StdMutableRequestAttributes> attributes = new ArrayList<>();
-               for (RequestAttributes a : request.getRequestAttributes()) {
-                       attributes.add(new StdMutableRequestAttributes(a));
-               }
-               //
-               // Iterate the generators
-               //
-               for (Generator generator : this.generators) {
-                       //
-                       // Read a row in
-                       //
-                       String line = generator.read();
-                       //
-                       // Was something read?
-                       //
-                       if (line == null) {
-                               //
-                               // No more rows to read, return null
-                               //
-                               return null;
-                       }
-                       //
-                       // Split the line
-                       //
-                       List<String> fields = Lists.newArrayList(Splitter.on(',').trimResults().split(line));
-                       //
-                       // Now work on the attributes
-                       //
-                       for (StdMutableAttribute attribute : generator.attributes) {
-                               //
-                               // Grab the attribute holder, which holds the datatype and field. There should
-                               // be only ONE object in the collection.
-                               //
-                               AttributeValue<?> value = attribute.getValues().iterator().next();
-                               Integer field = (Integer) value.getValue();
-                               //
-                               // Is the field number valid?
-                               //
-                               if (field >= fields.size()) {
-                                       logger.error("Not enough fields: " + field + "(" + fields.size() + ")");
-                                       return null;
-                               }
-                               //
-                               // Determine what datatype it is
-                               //
-                               DataType<?> dataTypeExtended    = dataTypeFactory.getDataType(value.getDataTypeId());
-                               if (dataTypeExtended == null) {
-                                       logger.error("Failed to determine datatype");
-                                       return null;
-                               }
-                               //
-                               // Create the attribute value
-                               //
-                               try {
-                                       AttributeValue<?> attributeValue = dataTypeExtended.createAttributeValue(fields.get(field));                                    
-                                       //
-                                       // Create the attribute
-                                       //
-                                       StdMutableAttribute newAttribute = new StdMutableAttribute(attribute.getCategory(),
-                                                                                                                                                               attribute.getAttributeId(),
-                                                                                                                                                               attributeValue,
-                                                                                                                                                               attribute.getIssuer(),
-                                                                                                                                                               attribute.getIncludeInResults());
-                                       boolean added = false;
-                                       for (StdMutableRequestAttributes a : attributes) {
-                                               //
-                                               // Does the category exist?
-                                               //
-                                               if (a.getCategory().equals(attribute.getCategory())) {
-                                                       //
-                                                       // Yes - add in the new attribute value
-                                                       //
-                                                       a.add(newAttribute);
-                                                       added = true;
-                                                       break;
-                                               }
-                                       }
-                                       if (added == false) {
-                                               //
-                                               // New category - create it and add it in
-                                               //
-                                               StdMutableRequestAttributes a = new StdMutableRequestAttributes(); 
-                                               a.setCategory(newAttribute.getCategory());
-                                               a.add(newAttribute);
-                                               attributes.add(a);
-                                       }
-                               } catch (DataTypeException e) {
-                                       logger.error(e);
-                                       return null;
-                               }
-                       }
-               }
-               //
-               // Now form our final request
-               //
-               StdMutableRequest newRequest = new StdMutableRequest();
-               newRequest.setCombinedDecision(request.getCombinedDecision());
-               newRequest.setRequestDefaults(request.getRequestDefaults());
-               newRequest.setReturnPolicyIdList(request.getReturnPolicyIdList());
-               newRequest.setStatus(request.getStatus());
-               for (StdMutableRequestAttributes a : attributes) {
-                       newRequest.add(a);
-               }
-               return newRequest;
-       }
-
-       /**
-        * This makes an HTTP POST call to a running PDP RESTful servlet to get a decision.
-        * 
-        * @param file
-        * @return
-        */
-       protected Response callRESTfulPDP(InputStream is) {
-               Response response = null;
-               HttpURLConnection connection = null;
-               try {
-
-                       //
-                       // Open up the connection
-                       //
-                       connection = (HttpURLConnection) this.restURL.openConnection();
-                       connection.setRequestProperty("Content-Type", "application/json");
-                       //
-                       // Setup our method and headers
-                       //
-            connection.setRequestMethod("POST");
-            connection.setUseCaches(false);
-            //
-            // Adding this in. It seems the HttpUrlConnection class does NOT
-            // properly forward our headers for POST re-direction. It does so
-            // for a GET re-direction.
-            //
-            // So we need to handle this ourselves.
-            //
-            connection.setInstanceFollowRedirects(false);
-                       connection.setDoOutput(true);
-                       connection.setDoInput(true);
-                       //
-                       // Send the request
-                       //
-                       try (OutputStream os = connection.getOutputStream()) {
-                               IOUtils.copy(is, os);
-                       }
-            //
-            // Do the connect
-            //
-            connection.connect();
-            if (connection.getResponseCode() == 200) {
-               //
-               // Read the response
-               //
-                       ContentType contentType = null;
-                       try {
-                               contentType = ContentType.parse(connection.getContentType());
-                               
-                               if (contentType.getMimeType().equalsIgnoreCase(ContentType.APPLICATION_JSON.getMimeType())) {
-                               response = JSONResponse.load(connection.getInputStream());
-                               } else if (contentType.getMimeType().equalsIgnoreCase(ContentType.APPLICATION_XML.getMimeType()) ||
-                                               contentType.getMimeType().equalsIgnoreCase("application/xacml+xml") ) {
-                               response = DOMResponse.load(connection.getInputStream());
-                               } else {
-                               logger.error("unknown content-type: " + contentType);
-                       }
-
-                } catch (Exception e) {
-                               String message = "Parsing Content-Type: " + connection.getContentType() + ", error=" + e.getMessage();
-                               logger.error(message, e);
-                       }
-
-            } else {
-               logger.error(connection.getResponseCode() + " " + connection.getResponseMessage());
-            }
-               } catch (Exception e) {
-                       logger.error(e);
-               }
-               
-               return response;
-       }
-       
-       /**
-        * This processes a response. Saves the response out to disk. If there is a corresponding response file for the request located
-        * in the "responses" sub-directory, then this method will compare that response file with what the engine returned to see if it
-        * matched.
-        * 
-        * @param requestFile
-        * @param request
-        * @param response
-        * @param group
-        * @param count
-        * @throws Exception
-        */
-       protected void processResponse(Path requestFile, Request request, Response response, String group, int count) throws Exception {
-               //
-               // Construct the output filename
-               //
-               Path responseFile = null;
-               Path resultFile = null;
-               int num = requestFile.getNameCount();
-               if (num < 2) {
-                       logger.error("Too few dir's in request filename.");
-                       throw new Exception("Too few dir's in request filename. Format should be Request.[0-9]+.{Permit|Deny|NA|Indeterminate}.{json|xml}");
-               }
-               String filename = requestFile.getFileName().toString();
-               if (group.equals("Generate")) {
-                       //
-                       // Using count variable, construct a filename
-                       //
-                       //              i.e. Response.03.Generate.{count}.json
-                       //
-                       filename = "Response" + filename.substring(filename.indexOf('.'), filename.lastIndexOf('.')) + String.format("%03d", count) + filename.substring(filename.lastIndexOf('.'));
-               } else {
-                       //
-                       // Construct filename
-                       //
-                       filename = "Response" + filename.substring(filename.indexOf('.'));
-               }
-               //
-               // Determine equivalent response file path
-               //
-               responseFile = Paths.get(requestFile.subpath(0, num - 2).toString(), "responses");
-               if (Files.notExists(responseFile)) {
-                       //
-                       // Create it
-                       //
-                       logger.warn(responseFile.toString() + " does NOT exist, creating...");
-                       try {
-                               Files.createDirectories(responseFile);
-                       } catch (IOException e) {
-                               logger.error(e);
-                               throw new Exception("Cannot proceed without an output directory.");
-                       }
-               }
-               responseFile = Paths.get(responseFile.toString(), filename);
-               //
-               // Determine path to write result file
-               //
-               if (this.output != null) {
-                       //
-                       // User specified an output path
-                       //
-                       resultFile = this.output;
-               } else {
-                       //
-                       // Default path
-                       //
-                       resultFile = Paths.get(requestFile.subpath(0, num - 2).toString(), "results");
-               }
-               //
-               // Check if the path exists
-               //
-               if (Files.notExists(resultFile)) {
-                       //
-                       // Create it
-                       //
-                       logger.warn(resultFile.toString() + " does NOT exist, creating...");
-                       try {
-                               Files.createDirectories(resultFile);
-                       } catch (IOException e) {
-                               logger.error(e);
-                               throw new Exception("Cannot proceed without an output directory.");
-                       }
-               }
-               //
-               // Add the filename to the path
-               //
-               resultFile = Paths.get(resultFile.toString(), filename);
-               //
-               // Check if there is an equivalent response in the response
-               // directory. If so, compare our response result with that one.
-               //
-               boolean succeeded = true;
-               if (responseFile != null && Files.exists(responseFile)) {
-                       //
-                       // Do comparison
-                       //
-                       Response expectedResponse = null;
-                       if (TestBase.isJSON(responseFile)) {
-                               expectedResponse = JSONResponse.load(responseFile);
-                       } else if (TestBase.isXML(responseFile)) {
-                               expectedResponse = DOMResponse.load(responseFile);
-                       }
-                       if (expectedResponse != null) {
-                               //
-                               // Do the compare
-                               //
-                               if (response == null) {
-                                       logger.error("NULL response returned.");
-                                       this.responseNotMatches++;
-                                       succeeded = false;
-                               } else {
-                                       if (response.equals(expectedResponse)) {
-                                               logger.info("Response matches expected response.");
-                                               this.responseMatches++;
-                                       } else {
-                                               logger.error("Response does not match expected response.");
-                                               logger.error("Expected: ");
-                                               logger.error(expectedResponse.toString());
-                                               this.responseNotMatches++;
-                                               succeeded = false;
-                                       }
-                               }
-                       }
-               }
-               //
-               // Write the response to the result file
-               //
-               logger.info("Request: " + requestFile.getFileName() + " response is: " + (response == null ? "null" : response.toString()));
-               if (resultFile != null && response != null) {
-                       if (TestBase.isJSON(resultFile)) {
-                               Files.write(resultFile, JSONResponse.toString(response, true).getBytes());
-                       } else if (TestBase.isXML(resultFile)) {
-                               Files.write(resultFile, DOMResponse.toString(response, true).getBytes());
-                       }
-               }
-               //
-               // Stats
-               //              
-               if (group.equals("Permit")) {
-                       this.expectedPermits++;
-               } else if (group.equals("Deny")) {
-                       this.expectedDenies++;
-               } else if (group.equals("NA")) {
-                       this.expectedNotApplicables++;
-               } else if (group.equals("Indeterminate")) {
-                       this.expectedIndeterminates++;
-               }
-               if (response != null) {
-                       for (Result result : response.getResults()) {
-                               Decision decision = result.getDecision();
-                               if (group.equals("Generate")) {
-                                       if (decision.equals(Decision.PERMIT)) {
-                                               this.generatedpermits++;
-                                       } else if (decision.equals(Decision.DENY)) {
-                                               this.generateddenies++;
-                                       } else if (decision.equals(Decision.NOTAPPLICABLE)) {
-                                               this.generatednotapplicables++;
-                                       } else if (decision.equals(Decision.INDETERMINATE)) {
-                                               this.generatedindeterminates++;
-                                       }
-                                       continue;
-                               }
-                               if (decision.equals(Decision.PERMIT)) {
-                                       this.permits++;
-                                       if (group.equals("Permit") == false) {
-                                               succeeded = false;
-                                               logger.error("Expected " + group + " got " + decision);
-                                       }
-                               } else if (decision.equals(Decision.DENY)) {
-                                       this.denies++;
-                                       if (group.equals("Deny") == false) {
-                                               succeeded = false;
-                                               logger.error("Expected " + group + " got " + decision);
-                                       }
-                               } else if (decision.equals(Decision.NOTAPPLICABLE)) {
-                                       this.notapplicables++;
-                                       if (group.equals("NA") == false) {
-                                               succeeded = false;
-                                               logger.error("Expected " + group + " got " + decision);
-                                       }
-                               } else if (decision.equals(Decision.INDETERMINATE)) {
-                                       this.indeterminates++;
-                                       if (group.equals("Indeterminate") == false) {
-                                               succeeded = false;
-                                               logger.error("Expected " + group + " got " + decision);
-                                       }
-                               }
-                       }
-               }
-               if (succeeded) {
-                       logger.info("REQUEST SUCCEEDED");
-               } else {
-                       logger.info("REQUEST FAILED");
-               }
-       }
-
-       protected void  dumpStats() {
-               StringBuilder dump = new StringBuilder();
-               dump.append(System.lineSeparator());
-               dump.append("Permits: " + this.permits + " Expected: " + this.expectedPermits);
-               dump.append(System.lineSeparator());
-               dump.append("Denies: " + this.denies + " Expected: " + this.expectedDenies);
-               dump.append(System.lineSeparator());
-               dump.append("NA: " + this.notapplicables + " Expected: " + this.expectedNotApplicables);
-               dump.append(System.lineSeparator());
-               dump.append("Indeterminates: " + this.indeterminates + " Expected: " + this.expectedIndeterminates);
-               dump.append(System.lineSeparator());
-               dump.append("Generated Permits: " + this.generatedpermits);
-               dump.append(System.lineSeparator());
-               dump.append("Generated Denies: " + this.generateddenies);
-               dump.append(System.lineSeparator());
-               dump.append("Generated NA: " + this.generatednotapplicables);
-               dump.append(System.lineSeparator());
-               dump.append("Generated Indeterminates: " + this.generatedindeterminates);
-               dump.append(System.lineSeparator());
-               dump.append("Responses Matched: " + this.responseMatches);
-               dump.append(System.lineSeparator());
-               dump.append("Responses NOT Matched: " + this.responseNotMatches);
-               
-               if (this.permits != this.expectedPermits ||
-                       this.denies != this.expectedDenies ||
-                       this.notapplicables != this.expectedNotApplicables ||
-                       this.indeterminates != this.expectedIndeterminates ||
-                       this.responseNotMatches > 0) {
-                       logger.fatal(dump.toString());
-               } else {
-                       logger.info(dump.toString());
-               }
-       }
-       
-       protected void  resetStats() {
-               this.permits = 0;
-               this.denies = 0;
-               this.notapplicables = 0;
-               this.indeterminates = 0;
-               this.generatedpermits = 0;
-               this.generateddenies = 0;
-               this.generatednotapplicables = 0;
-               this.generatedindeterminates = 0;
-               this.responseMatches = 0;
-               this.responseNotMatches = 0;
-       }
-
-       public static void main(String[] args) {
-               try {
-                       new TestBase(args).run();
-               } catch (ParseException | IOException | FactoryException e) {
-                       logger.error(e);
-               } catch (HelpException e) {
-               }               
-       }
-}
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestPolicy.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestPolicy.java
deleted file mode 100644 (file)
index 11601f2..0000000
+++ /dev/null
@@ -1,792 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ECOMP-XACML
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.policy.xacml.test;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.Marshaller;
-
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributesType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObjectFactory;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicySetType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.RequestType;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.GnuParser;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import com.att.research.xacml.api.AttributeValue;
-import com.att.research.xacml.api.DataType;
-import com.att.research.xacml.api.DataTypeException;
-import com.att.research.xacml.api.DataTypeFactory;
-import com.att.research.xacml.api.Identifier;
-import com.att.research.xacml.api.XACML3;
-import com.att.research.xacml.std.IdentifierImpl;
-import com.att.research.xacml.util.FactoryException;
-import com.att.research.xacml.util.XACMLObjectCopy;
-import com.att.research.xacml.util.XACMLPolicyAggregator;
-import com.att.research.xacml.util.XACMLPolicyScanner;
-import com.att.research.xacml.util.XACMLProperties;
-
-/**
- * This class reads the policy in and extracts all the attributes and their values that is contained
- * in the Policy. It then generates a request every single combination of attributes found.
- * 
- * The attributes mostly come from the Target Match elements, since they have both an attribute designator/selector
- * matched with an attribute value.
- * 
- *
- */
-public class TestPolicy extends TestBase {
-       private static Log logger       = LogFactory.getLog(TestPolicy.class);
-
-       private boolean skip;
-       private Path policy;
-       private XACMLPolicyAggregator aggregator = new XACMLPolicyAggregator();
-       private long index;
-       
-       //
-       // Our command line parameters
-       //
-       public static final String OPTION_POLICY = "policy";
-       public static final String OPTION_SKIP_GENERATE = "skip";
-
-       static {
-               options.addOption(new Option(OPTION_POLICY, true, "Path to the policy file."));
-               options.addOption(new Option(OPTION_SKIP_GENERATE, false, "Skip generating requests."));
-       }
-       
-       public class FlattenerObject {
-               Identifier category;
-               Identifier datatype;
-               Identifier attribute;
-               Set<AttributeValue<?>> values;
-       }
-       
-       /**
-        * This application exercises a policy by producing ALL the possible request combinations for a policy.
-        * 
-        * -policy Path to a policy file
-        * 
-        * @param args
-        * @throws HelpException 
-        * @throws ParseException 
-        * @throws MalformedURLException 
-        */
-
-       public TestPolicy(String[] args) throws MalformedURLException, ParseException, HelpException {
-               super(args);
-       }
-
-       /* 
-        * Look for the -policy command line argument. This application needs a pointer to a specific policy
-        * in order to run.
-        * 
-        * 
-        * (non-Javadoc)
-        * @see com.att.research.xacmlatt.pdp.test.TestBase#parseCommands(java.lang.String[])
-        */
-       @Override
-       protected void parseCommands(String[] args) throws ParseException, MalformedURLException, HelpException {
-               //
-               // Have our super do its job
-               //
-               super.parseCommands(args);
-               //
-               // Look for the policy option
-               //
-               CommandLine cl;
-               cl = new GnuParser().parse(options, args);
-               if (cl.hasOption(OPTION_POLICY)) {
-                       this.policy = Paths.get(cl.getOptionValue(OPTION_POLICY));
-                       //
-                       // Ensure it exists
-                       //
-                       if (Files.notExists(this.policy)) {
-                               throw new ParseException("Policy file does not exist.");
-                       }
-               } else {
-                       throw new ParseException("You need to specify the policy file to be used.");
-               }
-               if (cl.hasOption(OPTION_SKIP_GENERATE)) {
-                       this.skip = true;
-               } else {
-                       this.skip = false;
-               }
-       }
-
-       /* 
-        * We override this method because here is where we want to scan the policy and aggregate all
-        * the attributes that are defined within the policy. This routine will then dump all the possible
-        * requests into the requests sub-directory. Thus, when this method returns the TestBase can proceed
-        * to iterate each generated request and run it against the PDP engine.
-        * 
-        * (non-Javadoc)
-        * @see com.att.research.xacmlatt.pdp.test.TestBase#configure()
-        */
-       @Override
-       protected void configure() throws FactoryException {
-               //
-               // Have our base class do its thing
-               //
-               super.configure();
-               //
-               // Setup where the PDP can find the policy
-               //
-               System.setProperty(XACMLProperties.PROP_ROOTPOLICIES, "policy");
-               System.setProperty("policy.file", this.policy.toString());
-               //
-               // Determine if they want us to skip generation. This helps when a huge number of
-               // requests will get generated for a policy and can take some time to do so. The user
-               // can generate the requests once and then start testing a policy against the requests. Thus,
-               // the attributes never changed but the policy logic did (saves time).
-               //
-               if (this.skip) {
-                       return;
-               }
-               //
-               // Now we will scan the policy and get all the attributes.
-               //
-               XACMLPolicyScanner scanner = new XACMLPolicyScanner(this.policy, this.aggregator);
-               //
-               // The scanner returns us a policy object
-               //
-               Object policyObject = scanner.scan();
-               //
-               // Just dump some info
-               //
-               if (policyObject instanceof PolicySetType) {
-                       logger.info("Creating requests for policyset: " + ((PolicySetType)policyObject).getDescription());
-               } else if (policyObject instanceof PolicyType) {
-                       logger.info("Creating requests for policy: " + ((PolicyType)policyObject).getDescription());
-               }
-               //
-               // Call the function to create the requests
-               //
-               if (policyObject != null) {
-                       this.createRequests();
-               }
-
-               logger.info("Completed Generating requests.");
-       }
-
-       @SuppressWarnings("unchecked")
-       protected void createRequests() {
-               //
-               // Clear out our request directory
-               //
-               this.removeRequests();
-               //
-               // Get our map
-               //
-               Map<Identifier, Map<Identifier, Map<Identifier, Set<AttributeValue<?>>>>> attributeMap = this.aggregator.getAttributeMap();
-               //
-               // We're going to create an initial flat list of requests for each unique attribute ID. Unique being the
-               // category, datatype and attribute id.
-               //
-               // By flattening the list, it makes it easier to then generate all the combinations of possible requests.
-               //
-               List<FlattenerObject> attributes = new ArrayList<FlattenerObject>();
-               //
-               // Iterate through all the maps, we are going to flatten it
-               // out into an array list.
-               //
-               for (Map.Entry<Identifier, Map<Identifier, Map<Identifier, Set<AttributeValue<?>>>>> categoryEntry : attributeMap.entrySet()) {
-                       String category = categoryEntry.getKey().toString();
-                       if (logger.isDebugEnabled()) {
-                               logger.debug("Category: " + category);
-                       }
-                       Map<Identifier, Map<Identifier, Set<AttributeValue<?>>>> datatypeMap = categoryEntry.getValue();
-                       for (Map.Entry<Identifier, Map<Identifier, Set<AttributeValue<?>>>> datatypeEntry : datatypeMap.entrySet()) {
-                               String datatype = datatypeEntry.getKey().toString();
-                               if (logger.isDebugEnabled()) {
-                                       logger.debug("\tData Type: " + datatype);
-                               }
-                               Map<Identifier, Set<AttributeValue<?>>> attributeIDMap = datatypeEntry.getValue();
-                               for (Map.Entry<Identifier, Set<AttributeValue<?>>> attributeIDEntry : attributeIDMap.entrySet()) {
-                                       String attributeID = attributeIDEntry.getKey().toString();
-                                       if (logger.isDebugEnabled()) {
-                                               logger.debug("\t\tAttribute ID: " + attributeID);
-                                       }
-                                       Set<AttributeValue<?>> attributeValueSet = attributeIDEntry.getValue();
-                                       //
-                                       // Sanity check to see if there are any values. Sometimes there isn't if an attribute
-                                       // is a designator that is part of a condition or variable.
-                                       //
-                                       if (attributeValueSet.isEmpty()) {
-                                               if (logger.isDebugEnabled()) {
-                                                       logger.debug("No values for attribute " + attributeIDEntry.getKey().stringValue());
-                                               }
-                                               //
-                                               // Check for the boolean datatype, in that case we can safely
-                                               // assume the true/false are ALL the possible values.
-                                               //
-                                               if (datatypeEntry.getKey().equals(XACML3.ID_DATATYPE_BOOLEAN) == false) {
-                                                       //
-                                                       // Not boolean, so skip it
-                                                       //
-                                                       continue;
-                                               }
-                                               if (logger.isDebugEnabled()) {
-                                                       logger.debug("No values but its a boolean datatype, we will include it anyway.");
-                                               }
-                                       }
-                                       //
-                                       // Create our flattener object
-                                       //
-                                       FlattenerObject flat = new FlattenerObject();
-                                       flat.category = categoryEntry.getKey();
-                                       flat.datatype = datatypeEntry.getKey();
-                                       flat.attribute = attributeIDEntry.getKey();
-                                       flat.values = new HashSet<AttributeValue<?>>();
-                                       if (datatypeEntry.getKey().equals(XACML3.ID_DATATYPE_BOOLEAN)) {
-                                               //
-                                               // There are only 2 possible values, true or false
-                                               //
-                                               flat.values.add(this.createAttributeValue(flat.datatype, true));
-                                               flat.values.add(this.createAttributeValue(flat.datatype, false));
-                                       } else {
-                                               flat.values.addAll(attributeValueSet);
-                                       }
-                                       attributes.add(flat);
-                               }
-                       }
-               }
-               if (attributes.size() <= 1) {
-                       //
-                       // Only one attribute, why bother
-                       //
-                       logger.info("Not enough attributes in policy: " + attributes.size());
-                       return;
-               }
-               /*
-                * PLD work more on this later. This combinatorial formula is only accurate if each
-                * attribute has one value.
-                * 
-                */
-               if (logger.isDebugEnabled()) {
-                       //
-                       // This isn't really accurate, if an attribute has more than one value
-                       //
-                       logger.debug(attributes.size() + " will generate " + computePossibleCombinations(attributes.size()));
-               }
-               this.index = 1;
-               for (int i = 0; i < attributes.size(); i++) {
-                       FlattenerObject flat = attributes.get(i);
-                       for (AttributeValue<?> value : flat.values) {
-                               //
-                               // Create a basic request object for just that attribute value.
-                               //
-                               RequestType request = new RequestType();
-                               //
-                               AttributesType attrs = new AttributesType();
-                               attrs.setCategory(flat.category.stringValue());
-                               request.getAttributes().add(attrs);
-                               //
-                               AttributeType attr = new AttributeType();
-                               attr.setAttributeId(flat.attribute.stringValue());
-                               attrs.getAttribute().add(attr);
-                               //
-                               AttributeValueType val = new AttributeValueType();
-                               val.setDataType(flat.datatype.stringValue());
-                               if (value.getValue() instanceof Collection) {
-                                       val.getContent().addAll((Collection<? extends Object>) value.getValue());
-                               } else {
-                                       val.getContent().add(value.getValue().toString());
-                               }
-                               //
-                               attr.getAttributeValue().add(val);
-                               //
-                               // Dump it out
-                               //
-                               this.writeRequest(request);
-                               //
-                               // Initiate recursive call to add other attributes to the request
-                               //
-                               this.recursivelyGenerateRequests(request, i + 1, attributes);
-                       }
-               }
-       }
-       
-       protected void recursivelyGenerateRequests(RequestType request, int i, List<FlattenerObject> attributes) {
-               if (logger.isTraceEnabled()) {
-                       logger.trace("recursiveGenerate index: " + index + " i: " + i);
-               }
-               for ( ; i < attributes.size(); i++) {
-                       FlattenerObject flat = attributes.get(i);
-                       for (AttributeValue<?> value : flat.values) {
-                               //
-                               // Make a copy of the request
-                               //
-                               RequestType copyRequest = XACMLObjectCopy.deepCopy(request);
-                               //
-                               // Create the value object
-                               //
-                               AttributeValueType newValue = new AttributeValueType();
-                               newValue.setDataType(flat.datatype.stringValue());
-                               if (value.getValue() instanceof Collection) {
-                                       for (Object v : (Collection<?>) value.getValue()) {
-                                               newValue.getContent().add(v.toString());
-                                       }
-                               } else {
-                                       newValue.getContent().add(value.getValue().toString());
-                               }
-                               //
-                               // Add the value to the request
-                               //
-                               this.addAttribute(copyRequest, flat.category.stringValue(), flat.attribute.stringValue(), newValue);
-                               //
-                               // Now write it out
-                               //
-                               this.writeRequest(copyRequest);
-                               //
-                               // Recursively go through the rest of the attributes
-                               //
-                               this.recursivelyGenerateRequests(copyRequest, i + 1, attributes);
-                       }
-               }
-       }
-       
-       public static long      computePossibleCombinations(long numberOfAttributes) {
-               long num = 0;
-               for (long i = numberOfAttributes; i > 0; i--) {
-                       num += computeCombinations(numberOfAttributes, i);
-               }
-               return num;
-       }
-       
-       public static long      computeFactorial(long n) {
-               long fact = 1;
-               for (long i = 1; i <= n; i++) {
-                       fact *= i;
-               }
-               return fact;
-       }
-
-       public static long      computePermutationsWithoutRepetition(long n, long r) {
-               //
-               //      n!
-               //      ---------
-               //   (n - r)!
-               //
-               long nPrime = 1;
-               long n_rPrime = 1;
-               for (long i = n; i > 1; i--) {
-                       nPrime *= i; 
-               }
-               
-               for (long i = (n - r); i > 1; i--) {
-                       n_rPrime *= i; 
-               }
-               return nPrime / n_rPrime;
-       }
-       
-       public static long      computeCombinations(long n, long r) {
-               //
-               //               n!
-               //      -----------
-               //  r! * (n-r)!
-               //
-               long nPrime = 1;
-               long rPrime = 1;
-               long n_rPrime = 1;
-               
-               for (long i = n; i > 1; i--) {
-                       nPrime *= i; 
-               }
-               
-               for (long i = r; i > 1; i--) {
-                       rPrime *= i; 
-               }
-               
-               for (long i = (n - r); i > 1; i--) {
-                       n_rPrime *= i; 
-               }
-               
-               return nPrime / (rPrime * n_rPrime);
-       }
-
-       protected Set<AttributeValue<?>> getAttributeValues(RequestType request) {
-               //
-               // Get our map
-               //
-               Map<Identifier, Map<Identifier, Map<Identifier, Set<AttributeValue<?>>>>> attributeMap = this.aggregator.getAttributeMap();
-               //
-               // Find the attribute
-               //
-               AttributesType attrs = request.getAttributes().get(0);
-               Map<Identifier, Map<Identifier, Set<AttributeValue<?>>>> categoryMap = attributeMap.get(new IdentifierImpl(attrs.getCategory()));
-               if (categoryMap != null) {
-                       AttributeType a = attrs.getAttribute().get(0);
-                       Map<Identifier, Set<AttributeValue<?>>> datatypeMap = categoryMap.get(new IdentifierImpl(a.getAttributeValue().get(0).getDataType()));
-                       if (datatypeMap != null) {
-                               Set<AttributeValue<?>> values = datatypeMap.get(new IdentifierImpl(a.getAttributeId()));
-                               if (values != null) {
-                                       return values;
-                               }
-                       }
-               }
-               return Collections.emptySet();
-       }
-       
-       protected AttributeValue<?> createAttributeValue(Identifier datatype, Object value) {
-               DataTypeFactory dataTypeFactory         = null;
-               try {
-                       dataTypeFactory = DataTypeFactory.newInstance();
-                       if (dataTypeFactory == null) {
-                               logger.error("Could not create data type factory");
-                               return null;
-                       }
-               } catch (FactoryException e) {
-                       logger.error("Can't get Data type Factory: " + e.getLocalizedMessage());
-                       return null;
-               }               
-               DataType<?> dataTypeExtended    = dataTypeFactory.getDataType(datatype);
-               if (dataTypeExtended == null) {
-                       logger.error("Unknown datatype: " + datatype);
-                       return null;
-               }
-               try {
-                       return dataTypeExtended.createAttributeValue(value);
-               } catch (DataTypeException e) {
-                       logger.error(e);
-               }
-               return null;
-       }
-       
-       protected void removeRequests() {
-               //
-               // Delete any existing request files that we generate. i.e. Have the Unknown in the file name.
-               //
-               try {
-                       Files.walkFileTree(Paths.get(this.directory.toString(), "requests"), new SimpleFileVisitor<Path>() {
-
-                               @Override
-                               public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
-                                       //
-                                       // Sanity check the file name
-                                       //
-                                       Matcher matcher = pattern.matcher(file.getFileName().toString());
-                                       if (matcher.matches()) {
-                                               try {
-                                                       //
-                                                       // Pull what this request is supposed to be
-                                                       //
-                                                       String group = null;
-                                                       int count = matcher.groupCount();
-                                                       if (count >= 1) {
-                                                               group = matcher.group(count-1);
-                                                       }
-                                                       //
-                                                       // Send it
-                                                       //
-                                                       if (group.equals("Unknown")) {
-                                                               //
-                                                               // Remove the file
-                                                               //
-                                                               Files.delete(file);
-                                                       }
-                                               } catch (Exception e) {
-                                                       logger.error(e);
-                                                       logger.error("Exception Occured"+e);
-                                               }
-                                       }
-                                       return super.visitFile(file, attrs);
-                               }                               
-                       });
-               } catch (IOException e) {
-                       logger.error("Failed to removeRequests from " + this.directory + " " + e);
-               }
-       }
-
-       protected void addRequests(RequestType request, List<RequestType> requests, int index) {
-               for (RequestType req : requests) {
-                       //
-                       // There really should only be one attribute
-                       //
-                       for (AttributesType attrs : req.getAttributes()) {
-                               for (AttributeType attr : attrs.getAttribute()) {
-                                       for (AttributeValueType value : attr.getAttributeValue()) {
-                                               if (this.addAttribute(request, attrs.getCategory(), attr.getAttributeId(), value)) {
-                                                       this.writeRequest(request);
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-
-       /**
-        * Writes the request into the "requests" sub-directory, relative to the value of the "directory" setup
-        * during initialization.
-        * 
-        * Writing the requests out allows one to go back and easily refer to the request when analyzing the responses
-        * generated after the PDP decide() call. Also, one can then use the generated requests into any test tools
-        * they wish to build.
-        * 
-        * @param request - The request to be written.
-        */
-       protected void writeRequest(RequestType request) {
-               if (logger.isTraceEnabled()) {
-                       logger.trace("writeRequest: " + index);
-               }
-               try {
-                       ObjectFactory of = new ObjectFactory();
-                       JAXBElement<RequestType> requestElement = of.createRequest(request);
-                       JAXBContext context = JAXBContext.newInstance(RequestType.class);
-                       Marshaller m = context.createMarshaller();
-                       m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
-                       Path outFile = Paths.get(this.directory, "requests", String.format("Request.%06d.Unknown.xml", this.index));
-                       m.marshal(requestElement, outFile.toFile());
-               } catch (Exception e) {
-                       logger.error("Failed to write request: " + e.getMessage());
-               }
-               this.index++;
-       }
-
-       protected boolean       addAttribute(RequestType request, String category, String id, AttributeValueType value) {
-               //
-               // See if the category exists
-               //
-               for (AttributesType attrs : request.getAttributes()) {
-                       if (attrs.getCategory().equals(category)) {
-                               //
-                               // It does have the category. But does it have the attribute ID?
-                               //
-                               for (AttributeType attr : attrs.getAttribute()) {
-                                       if (attr.getAttributeId().equals(id)) {
-                                               //
-                                               // Yes, check for the same datatype
-                                               //
-                                               for (AttributeValueType val : attr.getAttributeValue()) {
-                                                       if (val.getDataType().equals(value.getDataType())) {
-                                                               //
-                                                               // We have something already there
-                                                               //
-                                                               return false;
-                                                       }
-                                               }
-                                               //
-                                               // The ID exists, but not the datatype
-                                               //
-                                               attr.getAttributeValue().add(value);
-                                               return true;
-                                       }
-                               }
-                               //
-                               // If we get here, the ID does not exist
-                               //
-                               AttributeType attr = new AttributeType();
-                               attr.setAttributeId(id);
-                               attr.getAttributeValue().add(value);
-                               attrs.getAttribute().add(attr);
-                               return true;
-                       }
-               }
-               //
-               // If we get here, the category does not exist. So add it in.
-               //
-               AttributesType attrs = new AttributesType();
-               attrs.setCategory(category);
-               AttributeType attr = new AttributeType();
-               attr.setAttributeId(id);
-               attr.getAttributeValue().add(value);
-               attrs.getAttribute().add(attr);
-               request.getAttributes().add(attrs);
-               return true;
-       }
-
-       public static void main(String[] args) {
-               try {
-                       new TestPolicy(args).run();
-               } catch (ParseException | IOException | FactoryException e) {
-                       logger.error(e);
-               } catch (HelpException e) {
-               }
-       }
-
-       /*
-       // Map<CATEGORY, MAP<DATATYPE, MAP<ATTRIBUTEID, SET<VALUES>>>
-       @SuppressWarnings("unchecked")
-       private void generateRequests(Map<Identifier, Map<Identifier, Map<Identifier, Set<AttributeValue<?>>>>> categoryMap) {
-               meta = new ArrayList<>();
-               
-               for (Map.Entry<Identifier, Map<Identifier, Map<Identifier, Set<AttributeValue<?>>>>> categoryEntry : categoryMap.entrySet()) {
-                       String category = categoryEntry.getKey().toString();
-                       logger.debug("Category: " + category);
-                       Map<Identifier, Map<Identifier, Set<AttributeValue<?>>>> datatypeMap = categoryEntry.getValue();
-                       for (Map.Entry<Identifier, Map<Identifier, Set<AttributeValue<?>>>> datatypeEntry : datatypeMap.entrySet()) {
-                               String datatype = datatypeEntry.getKey().toString();
-                               logger.debug("\tData Type: " + datatype);
-                               Map<Identifier, Set<AttributeValue<?>>> attributeIDMap = datatypeEntry.getValue();
-                               for (Map.Entry<Identifier, Set<AttributeValue<?>>> attributeIDEntry : attributeIDMap.entrySet()) {
-                                       String attributeID = attributeIDEntry.getKey().toString();
-                                       logger.debug("\t\tAttribute ID: " + attributeID);
-                                       Set<AttributeValue<?>> attributeValueSet = attributeIDEntry.getValue();
-                                       for (AttributeValue<?> value : attributeValueSet) {
-                                               logger.debug("\t\t\tAttribute Value: " + value);                                                
-                                       }
-                                       Iterator<AttributeValue<?>> iterator = attributeValueSet.iterator();
-                                       logger.debug("\t\t\t# of Attribute values: " + attributeValueSet.size());
-                                       meta.add(new Object[] {category, datatype, attributeID, iterator.next(), iterator, attributeValueSet});
-                               }
-                       }
-               }
-               
-               int count = 0;
-               for (File file : output.toFile().listFiles()) {
-                       file.delete();
-               }
-                       
-               do {
-                       RequestType request = new RequestType();
-                       request.setCombinedDecision(false);
-                       request.setReturnPolicyIdList(false);
-                       List<AttributesType> attributesList = request.getAttributes();
-                       
-                       Map<String, AttributesType> category2Attribute= new HashMap<>();
-                       for (int i = 0; i < meta.size(); i++) {
-                               Object[] record = meta.get(i);
-                               
-                               AttributesType attributes = null;
-                               if (category2Attribute.containsKey(record[0].toString()))
-                                       attributes = category2Attribute.get(record[0].toString());
-                               else {
-                                       attributes = new AttributesType();
-                                       attributes.setCategory(record[0].toString());
-                                       category2Attribute.put(record[0].toString(), attributes);
-                                       attributesList.add(attributes);                         
-                               }
-//                             attributes.setId(record[2].toString());
-                               List<AttributeType> attrList = attributes.getAttribute();
-                               
-                               AttributeType attribute = new AttributeType();
-                               attribute.setAttributeId(record[2].toString());
-                               List<AttributeValueType> valueList = attribute.getAttributeValue();
-
-                               AttributeValue<?> attributeValue = (AttributeValue<?>) record[3];
-
-                               AttributeValueType value = new AttributeValueType();
-                               value.setDataType(attributeValue.getDataTypeId().toString());
-                               List<Object> content = value.getContent();
-                               content.addAll((Collection<? extends Object>) attributeValue.getValue());
-                               valueList.add(value);
-
-                               attrList.add(attribute);
-                       }
-                       
-                       try {
-                               ObjectFactory of = new ObjectFactory();
-                               JAXBElement<RequestType> requestElement = of.createRequest(request);
-                               JAXBContext context = JAXBContext.newInstance(RequestType.class);
-                               Marshaller m = context.createMarshaller();
-                               m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
-                               m.marshal(requestElement, output.resolve("request" + count + ".xml").toFile());
-                               
-//                             if (count == 0) {//Just send the first request to the engine
-                                       StringWriter sw = new StringWriter();
-                                       m.marshal(requestElement, sw);
-                                       logger.info(sw.toString());
-                                       EngineCaller engine = new LocalEngineCaller();
-                                       if (engine.startEngine("")) {
-                                               String response = engine.decide(sw.toString(), "xml");
-                                               FileWriter writer = new FileWriter(output.resolve("response" + count + ".xml").toFile());
-                                               writer.write(response);
-                                               writer.close();
-                                               logger.info("Response received: \n" + response);                                        
-                                       }
-//                             }
-                       } catch (Exception e) {
-                               logger.error("Exception Occured"+e);
-                       }
-                       
-                       count++;
-               } while (hasNextRequest());
-                       
-               logger.info("# of requests generated: " + count);
-       }
-       
-       private boolean hasNextRequest() {
-               int i = meta.size() - 1;
-               Object[] record = meta.get(i);
-               
-               @SuppressWarnings("unchecked")
-               Iterator<AttributeValue<?>> iterator = (Iterator<AttributeValue<?>>) record[4];
-               if (iterator.hasNext()) {
-                       record[3] = iterator.next();
-               } else {
-                       return recycleAttributeValue(i);
-               }
-               
-               return true;
-       }
-       
-       @SuppressWarnings("unchecked")
-       private boolean recycleAttributeValue(int position) {
-               boolean rc = true;
-               
-               if (position == 0)
-                       return false;
-               
-               Object[] record = meta.get(position);
-               Set<AttributeValue<?>> attributeValueSet = (Set<AttributeValue<?>>) record[5];
-               Iterator<AttributeValue<?>> newIt = attributeValueSet.iterator();
-               record[4] = newIt;
-               record[3] = newIt.next();
-               int i = position - 1;
-               Object[] previous = meta.get(i);
-               Iterator<AttributeValue<?>> preIt = (Iterator<AttributeValue<?>>) previous[4];
-               if (preIt.hasNext()) {
-                       previous[3] = preIt.next();
-               } else {
-                       rc = recycleAttributeValue(i);
-               }
-               
-               return rc;
-       }
-       
-       */
-       
-}
-       
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/XACMLEngineTest.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/XACMLEngineTest.java
deleted file mode 100644 (file)
index d2198a1..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ECOMP-XACML
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-/*package org.openecomp.policy.xacml.test;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import junit.framework.TestCase;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.springframework.mock.web.MockHttpServletResponse;
-import org.springframework.mock.web.MockServletConfig;
-
-public class XACMLEngineTest extends TestCase{
-       
-       private List<String> headers = new ArrayList<String>();
-       
-       private HttpServletRequest httpServletRequest;
-       private HttpServletResponse httpServletResponse;
-       private ServletOutputStream mockOutput;
-       private ServletConfig servletConfig; 
-
-    @Before
-   
-    public void setUp() throws IOException {
-       httpServletRequest = Mockito.mock(HttpServletRequest.class);
-       Mockito.when(httpServletRequest.getMethod()).thenReturn("POST");
-       Mockito.when(httpServletRequest.getParameter("groupId")).thenReturn(null);
-       Mockito.when(httpServletRequest.getHeaderNames()).thenReturn(Collections.enumeration(headers));
-       Mockito.when(httpServletRequest.getAttributeNames()).thenReturn(Collections.enumeration(headers));
-       
-       
-       mockOutput = Mockito.mock(ServletOutputStream.class);
-       
-       httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
-       
-       Mockito.when(httpServletResponse.getOutputStream()).thenReturn(mockOutput);
-
-       servletConfig = Mockito.mock(MockServletConfig.class);
-
-       Mockito.when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(headers));
-       
-       
-             
-    }
-       
-    @Test
-       public void testDummy() throws Exception{
-               try {   
-                       assertTrue(true);
-               } catch (Exception e) {
-                       fail();
-               }
-
-       }
-       
-}
-*/
\ No newline at end of file
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/RequestCategoryTest.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/RequestCategoryTest.java
deleted file mode 100644 (file)
index 905c1a1..0000000
+++ /dev/null
@@ -1,4168 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ECOMP-XACML
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.policy.xacml.test.json;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import org.junit.Test;
-
-import com.att.research.xacml.api.Request;
-import com.att.research.xacml.std.json.JSONRequest;
-import com.att.research.xacml.std.json.JSONStructureException;
-
-/**
- * Test JSON Request convert to object - Category sub-component.  Does not include "Default" Categories (Subject, Action, Resource, Environment).
- * Basic existance/absence of Category is tested in RequestMainTest.
- * 
- * TO RUN - use jUnit
- * In Eclipse select this file or the enclosing directory, right-click and select Run As/JUnit Test
- * 
- * NOTE:
- * The "correct" way to verify that each JSON string gets translated into our internal Objects correctly is to look explicitly at each of the child objects
- * and verify that they are correct.  This would involve a lot of coding to get child of child of child and individually verify each property of each element.
- * To simplify testing we assume that request.toString() correctly includes a complete text representation of every sub-component of the Request object
- * and we compare the resulting String to our expected String.
- * This has two possible sources of error:
- *     - toString might not include some sub-component, and
- *     - the initial verification of the resulting string is done by hand and may have been incorrect.
- * 
- *
- */
-public class RequestCategoryTest {
-       
-       // The request object output from each test conversion from JSON string
-       Request request;
-
-       
-       /*
-        * Request that uses all fields with both single and multiple  entries
-        */
-       String allFieldsRequest = 
-                       "{\"Request\": {" +
-                                       "\"ReturnPolicyIdList\" : true ," +
-                                       "\"CombinedDecision\" : true ," +
-                                       "\"XPathVersion\" : \"http://www.w3.org/TR/1999/REC-xpath-19991116\"," +
-                                       "\"MultiRequests\" : {" +
-                                   "\"RequestReference\": [" +
-                                       "{ " +
-                                               "\"ReferenceId\" : [\"foo1\",\"bar1\"]" +
-                                       "}," +
-                                       "{" +
-                                               "\"ReferenceId\" : [\"foo2\",\"bar1\"]" +
-                                       "}]" +   
-                                 "}," +
-
-                                       "\"Category\": [" +
-                                               "{ " +
-                                               "\"CategoryId\": \"custom-category\", " +
-                                               "\"Id\" : \"customId\", " +
-                                               "\"Attribute\" : [" +
-                                                       "{" +
-                                                               "\"AttributeId\"                : \"document-id\", " +
-                                                               "\"DataType\"   : \"integer\", " +
-                                                               "\"Value\"      : 123 " +
-                                                               "}, " +
-                                                               "{" +
-                                                               "\"AttributeId\"                : \"document-url\", " +
-                                                               "\"DataType\"   : \"anyURI\", " +
-                                                               "\"Value\"      : \"http://somewhere.over.the.com/rainbow\" " +
-                                                       "}, " +
-                                                               "{" +
-                                                               "\"AttributeId\"                : \"page-list\", " +
-                                                               "\"Value\"      : [1, 2, 3, 4.5, 3, 2, 1] " +
-                                                       "} " +
-                                               "]" +
-                                           "}, " +
-                                           "{ " +
-                                               "\"CategoryId\": \"another-custom-cat\", " +
-                                               "\"Id\" : \"anotherXmlId\", " +
-                                               "\"Attribute\" : []" +
-                                           "} " +
-                                       "], " +
-                                           
-                                       "\"AccessSubject\":{ " +
-                                               "\"Content\" : \"<?xml version=\\\"1.0\\\"?><catalog>" + 
-                                                       "<book id=\\\"bk101\\\"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre>" +
-                                                       "<price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description>"+
-                                                       "</book></catalog>\"," +
-                                               "\"Attribute\" : []" +
-                                       "}, " +
-                                       
-                                       "\"Resource\" : {" +
-                                               "\"Content\" : \"PD94bWwgdmVyc2lvbj0iMS4wIj8+PGNhdGFsb2c+PGJvb2sgaWQ9ImJrMTAxIj48YXV0aG9yPkdhbWJhcmRlbGxhLCBNYXR0aGV3PC9hdXRob3I+PHRpdGxlPlhNT" +
-                                                       "CBEZXZlbG9wZXIncyBHdWlkZTwvdGl0bGU+PGdlbnJlPkNvbXB1dGVyPC9nZW5yZT48cHJpY2U+NDQuOTU8L3ByaWNlPjxwdWJsaXNoX2RhdGU+MjAwMC0xMC0wMTwvcHVibGlzaF"+
-                                                       "9kYXRlPjxkZXNjcmlwdGlvbj5BbiBpbi1kZXB0aCBsb29rIGF0IGNyZWF0aW5nIGFwcGxpY2F0aW9ucyB3aXRoIFhNTC48L2Rlc2NyaXB0aW9uPjwvYm9vaz48L2NhdGFsb2c+\"" +
-
-
-                                       "} " +
-
-                                 
-                       "}}";
-       
-       /*
-        * The following example comes directly from the JSON Profile Spec
-        */
-       String exampleFromSpec = "{ " +
-                       "\"Request\" : { " +
-                               "\"AccessSubject\" : { " +
-                                       "\"Attribute\": [ " +
-                                               "{ " +
-                                                       "\"Id\" : \"subject-id\", " +
-                                                       "\"Value\" : \"Andreas\" " +
-                                               "}, " +
-                                               "{ " +
-                                                       "\"Id\" : \"location\", " +
-                                                       "\"Value\" : \"Gamla Stan\" " +
-                                               "} " +
-                                       "] " +
-                               "}, " +
-                               "\"Action\" : { " +
-                                       "\"Attribute\":  " +
-                                               "{ " +
-                                                       "\"Id\" : \"action-id\", " +
-                                                       "\"Value\" : \"http://www.xacml.eu/buy\", " +
-                                                       "\"DataType\" : \"anyURI\" " +
-                                               "} " +
-                               "}, " +
-                               "\"Resource\" : { " +
-                                       "\"Attribute\": [ " +
-                                               "{ " +
-                                                       "\"Id\" : \"book-title\", " +
-                                                       "\"Value\" : \"Learn German in 90 days\" " +
-                                               "}, " +
-                                               "{ " +
-                                                       "\"Id\" : \"currency\", " +
-                                                       "\"Value\" : \"SEK\" " +
-                                               "}, " +
-                                               "{ " +
-                                                       "\"Id\" : \"price\", " +
-                                                       "\"Value\" : 123.34 " +
-                                               "} " +
-                                               "] " +
-                                       "} " +
-                               "} " +
-                       "} ";
-
-       
-       /*
-        * The following example comes directly from the JSON Profile Spec (modified to include a "</Catalog>" missing from both examples).
-        * It shows the two ways of handling XPath content, as escaped XML and as Base64 encoding.
-        */
-       String xPathExampleFromSpec = "{ " +
-                       "\"Request\" : { " +
-                               "\"Resource\" : { " +
-                                       "\"Attribute\": [ " +
-                                               "{ " +
-                                                       "\"Id\" : \"urn:oasis:names:tc:xacml:3.0:content-selector\", " +
-                                           "\"DataType\" : \"xpathExpression\", " +
-                                           "\"Value\" : { " +
-                                               "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\", " +
-                                               "\"Namespaces\" : [{ " +
-                                                       "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                                       "}, " +
-                                                   "{ " +
-                                                       "\"Prefix\" : \"md\", " +
-                                                       "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                                   "} " +
-                                               "], " +
-                                               "\"XPath\" : \"md:record/md:patient/md:patientDoB\" " +
-                                           "} " +
-                                       "} " +
-                                       "] " +
-                               "} " +
-                       "} " +
-               "} ";
-
-
-       
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-       // Top-level of Category
-       @Test
-       public void testCategoryTopLevel() {    
-               
-               // empty Category
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Missing value
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\" }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\" : }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category without CategoryId
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{}] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category with CategoryId value missing or =""
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\"] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"\" ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // CategoryId wrong type
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : true } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : 123 } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category with Id
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Id\" : \"customId\" } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category},xmlId=customId}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category with Id - wrong type
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Id\" : true } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Id\" : 123 } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // Category without Id  
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\" } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // Category with standard CategoryId
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category with extra unknown field
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", unknown } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"unknown\" : 123 } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category with multiple sub-Category objects using same CategoryId
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"category1\" }, {\"CategoryId\" : \"category1\" } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=category1}}{super={category=category1}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-       }
-
-       
-       
-       // Tests related to Attributes
-       @Test
-       public void testCategoryAttributes() {  
-       
-               // Category with Attribute but none given ("Attribute" : [] )           
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-
-               // Category Attribute with empty attribute (missing both AttributeId and Id)
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with AttributeId and no Value
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"AttributeId\" : \"document-id\" " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute missing AttributeId but with Id           
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"AttributeId\" : \"document-id\", " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute missing AttributeId but with Id
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute including both AttributeId and Id with same value
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"AttributeId\" : \"document-id\", " +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute missing both AttributeId and Id
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute AttributeId not string
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"AttributeId\" : true, " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"AttributeId\" : 123, " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute Id not string
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : true, " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : 123, " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // Category Attribute with DataType
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"integer\", " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with DataType not string (e.g. "DataType" : 55.5 )
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : true, " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with unknown DataType
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"no such data type\", " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : 321, " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with multiple value array
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"dayTimeDuration\", " +
-                               "\"Value\"      : [\"P3D\", \"P2DT12H34M\", \"PT15M\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=3hours=0minutes=0seconds=0millis=0},factionalSeconds=0.0}}{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=2hours=12minutes=34seconds=0millis=0},factionalSeconds=0.0}}{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=0hours=0minutes=15seconds=0millis=0},factionalSeconds=0.0}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute multiple value with null in array
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"dayTimeDuration\", " +
-                               "\"Value\"      : [\"P3D\", , \"P15M\"] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with array value with no values ("Attribute": [ {"AttributeId" :"a", Value:[] } ] }  )
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"dayTimeDuration\", " +
-                               "\"Value\"      : [ ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with no DataType and array with no values
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with Issuer
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                                       "\"Issuer\" : \"University Press\", " +
-                               "\"DataType\"   : \"integer\", " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],issuer=University Press,includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with Issuer not string
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                                       "\"Issuer\" : true, " +
-                               "\"DataType\"   : \"integer\", " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                                       "\"Issuer\" : 4.56, " +
-                               "\"DataType\"   : \"integer\", " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with includeInResult=true
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : 123, " +
-                               "\"IncludeInResult\" : true " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],includeInResults=true}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with includeInResult = false
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : 123, " +
-                               "\"IncludeInResult\" : false " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with includeInResult not boolean
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : 123, " +
-                               "\"IncludeInResult\" : \"abc\" " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : 123, " +
-                               "\"IncludeInResult\" : 123.45 " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-       }
-
-       
-       
-       // Tests related to DataTypes within Attributes
-       @Test
-       public void testCategoryAttributesDataTypesSimple() {   
-               
-               // Category Attribute using full Identifier for each data type
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
-                               "\"Value\"      : \"abc\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#boolean\", " +
-                               "\"Value\"      : true " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#double\", " +
-                               "\"Value\"      : 123.34 " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.34}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#time\", " +
-                               "\"Value\"      : \"12:00:00Z\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#time,value=12:00:00Z}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#date\", " +
-                               "\"Value\"      : \"2002-10-10\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#date,value=2002-10-10}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dateTime\", " +
-                               "\"Value\"      : \"2002-10-10T12:00:00Z\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#dateTime,value=2002-10-10T12:00:00Z}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dayTimeDuration\", " +
-                               "\"Value\"      : \"P23DT7H12M54S\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=23hours=7minutes=12seconds=54millis=0},factionalSeconds=54.0}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#yearMonthDuration\", " +
-                               "\"Value\"      : \"P165Y8M\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#yearMonthDuration,value={super={durationSign=1years=165months=8days=0hours=0minutes=0seconds=0millis=0},monthsDuration=1988}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#anyURI\", " +
-                               "\"Value\"      : \"aValue\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#hexBinary\", " +
-                               "\"Value\"      : \"FA027B7D12CC34DDD20012AEEF\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#hexBinary,value={data=[-6,2,123,125,18,-52,52,-35,-46,0,18,-82,-17]}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#base64Binary\", " +
-                               "\"Value\"      : \"lvbj0iMS4wIj8+PGNhdGFsb2c+PGJvb2sgaWQ9ImJrMTAxIj48YXV0aG9y\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-106,-10,-29,-46,35,18,-29,2,35,-13,-29,-58,54,23,70,22,-58,-10,115,-29,-58,38,-10,-10,-78,6,-106,67,-46,38,38,-77,19,3,18,35,-29,-58,23,87,70,-122,-9]}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name\", " +
-                               "\"Value\"      : \"someone.else@A.COMPANY.com\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name,value={localName=someone.else,domainName=A.COMPANY.com}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:x500Name\", " +
-                               "\"Value\"      : \"cn=Julius Hibbert, o=Medi Corporation, c=US\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:x500Name,value=CN=Julius Hibbert, O=Medi Corporation, C=US}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:ipAddress\", " +
-                               "\"Value\"      : \"121.221.43.58:12345\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=121.221.43.58:12345-12345}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:dnsName\", " +
-                               "\"Value\"      : \"aValue\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\", " +
-                               "\"Value\"      : {" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"Namespaces\" : ["
-                                               + "{ "+
-                                                       "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                                       "}," +
-                                                       "{" +
-                                                               "\"Prefix\" : \"md\", " +
-                                                               "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                                       "}], "+
-                                       "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                       "}" +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression,value={path=md:record/md:patient/md:patientDoB,Namespace={[{md,urn:example:med:schemas:record}{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}]},status=null,xpathExpressionWrapped=null},xpathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}],includeInResults=false}]}}]}", request.toString());
-
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-
-               
-               // Category Attribute shorthand notation for each data type
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"string\", " +
-                               "\"Value\"      : \"abc\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"boolean\", " +
-                               "\"Value\"      : true " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"integer\", " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"double\", " +
-                               "\"Value\"      : 123.34 " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.34}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"time\", " +
-                               "\"Value\"      : \"12:00:00Z\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#time,value=12:00:00Z}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"date\", " +
-                               "\"Value\"      : \"2002-10-10\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#date,value=2002-10-10}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"dateTime\", " +
-                               "\"Value\"      : \"2002-10-10T12:00:00Z\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#dateTime,value=2002-10-10T12:00:00Z}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"dayTimeDuration\", " +
-                               "\"Value\"      : \"P23DT7H12M54S\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=23hours=7minutes=12seconds=54millis=0},factionalSeconds=54.0}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"yearMonthDuration\", " +
-                               "\"Value\"      : \"P165Y8M\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#yearMonthDuration,value={super={durationSign=1years=165months=8days=0hours=0minutes=0seconds=0millis=0},monthsDuration=1988}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"anyURI\", " +
-                               "\"Value\"      : \"aValue\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"hexBinary\", " +
-                               "\"Value\"      : \"FA027B7D12CC34DDD20012AEEF\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#hexBinary,value={data=[-6,2,123,125,18,-52,52,-35,-46,0,18,-82,-17]}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"base64Binary\", " +
-                               "\"Value\"      : \"lvbj0iMS4wIj8+PGNhdGFsb2c+PGJvb2sgaWQ9ImJrMTAxIj48YXV0aG9y\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-106,-10,-29,-46,35,18,-29,2,35,-13,-29,-58,54,23,70,22,-58,-10,115,-29,-58,38,-10,-10,-78,6,-106,67,-46,38,38,-77,19,3,18,35,-29,-58,23,87,70,-122,-9]}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"rfc822Name\", " +
-                               "\"Value\"      : \"someone.else@A.COMPANY.com\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name,value={localName=someone.else,domainName=A.COMPANY.com}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"x500Name\", " +
-                               "\"Value\"      : \"cn=Julius Hibbert, o=Medi Corporation, c=US\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:x500Name,value=CN=Julius Hibbert, O=Medi Corporation, C=US}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"ipAddress\", " +
-                               "\"Value\"      : \"121.221.43.58:12345\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=121.221.43.58:12345-12345}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"dnsName\", " +
-                               "\"Value\"      : \"aValue\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"xpathExpression\", " +
-                               "\"Value\"      : {" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"Namespaces\" : ["
-                                               + "{ "+
-                                                       "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                                       "}," +
-                                                       "{" +
-                                                               "\"Prefix\" : \"md\", " +
-                                                               "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                                       "}], "+
-                                       "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                       "}" +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression,value={path=md:record/md:patient/md:patientDoB,Namespace={[{md,urn:example:med:schemas:record}{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}]},status=null,xpathExpressionWrapped=null},xpathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}],includeInResults=false}]}}]}", request.toString());
-
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-
-               
-               
-               // infer data type - only integer, boolean and double are distinguishable from strings; everything else is treated as a string
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : \"abc\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : true " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : 123.34 " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.34}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : \"12:00:00Z\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : \"2002-10-10\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : \"2002-10-10T12:00:00Z\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : \"P23DT7H12M54S\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : \"P165Y8M\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : \"aValue\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : \"FA027B7D12CC34DDD20012AEEF\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=FA027B7D12CC34DDD20012AEEF}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : \"lvbj0iMS4wIj8+PGNhdGFsb2c+PGJvb2sgaWQ9ImJrMTAxIj48YXV0aG9y\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lvbj0iMS4wIj8+PGNhdGFsb2c+PGJvb2sgaWQ9ImJrMTAxIj48YXV0aG9y}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : \"someone.else@A.COMPANY.com\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=someone.else@A.COMPANY.com}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:x500Name\", " +
-                               "\"Value\"      : \"cn=Julius Hibbert, o=Medi Corporation, c=US\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:x500Name,value=CN=Julius Hibbert, O=Medi Corporation, C=US}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : \"121.221.43.58:12345\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=121.221.43.58:12345}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : \"aValue\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : \"aValue\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : {" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"Namespaces\" : ["
-                                               + "{ "+
-                                                       "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                                       "}," +
-                                                       "{" +
-                                                               "\"Prefix\" : \"md\", " +
-                                                               "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                                       "}], "+
-                                       "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                       "}" +
-                                       "}] } ] }}");
-                       // gets inferred to a String containing the whole structure under Value as a String
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value={XPathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource, Namespaces=[{Namespace=urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}, {Prefix=md, Namespace=urn:example:med:schemas:record}], XPath=md:record/md:patient/md:patientDoB}}],includeInResults=false}]}}]}", request.toString());
-
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-       }
-       
-       
-       
-       @Test
-       public void testCategoryAttributesDataTypesNotMatchValue() {    
-
-               // Category Attribute with DataType not matching value type (JSON type derived from syntax)
-               // AUTO-CONVERSION from Boolean to String!
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
-                               "\"Value\"      : true " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // SUCCESSFUL AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // SUCCESSFUL AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
-                               "\"Value\"      : 123.34 " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123.34}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#boolean\", " +
-                               "\"Value\"      : \"abc\" " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#boolean\", " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#boolean\", " +
-                               "\"Value\"      : 123.45 " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // SUCCESSFUL AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
-                               "\"Value\"      : \"123\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
-                               "\"Value\"      : true " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
-                               "\"Value\"      : 123.45 " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-
-               // SUCCESSFUL AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#double\", " +
-                               "\"Value\"      : \"123.34\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.34}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#double\", " +
-                               "\"Value\"      : true " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // allow integer to auto-convert to double when DataType is given
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#double\", " +
-                               "\"Value\"      : 123 " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.0}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // special JavaScript values not allowed except for -0 (inappropriate requirement in spec - check it anyway)
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
-                               "\"Value\"      : \"NaN\" " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
-                               "\"Value\"      : \"INF\" " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
-                               "\"Value\"      : \"-INF\" " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // JavaScript 0 and -0 are ok
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
-                               "\"Value\"      : 0 " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=0}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
-                               "\"Value\"      : -0 " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=0}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // All other data types are checked when we convert internally, so value must be syntactically correct
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#time\", " +
-                               "\"Value\"      : \"syntactically incorrect value\" " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#date\", " +
-                               "\"Value\"      : \"syntactically incorrect value\" " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dateTime\", " +
-                               "\"Value\"      : \"syntactically incorrect value\" " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dayTimeDuration\", " +
-                               "\"Value\"      : \"syntactically incorrect value\" " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#yearMonthDuration\", " +
-                               "\"Value\"      : \"syntactically incorrect value\" " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#anyURI\", " +
-                               "\"Value\"      : \"syntactically incorrect value\" " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#hexBinary\", " +
-                               "\"Value\"      : \"syntactically incorrect value\" " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Base64 convert does not throw an exception if the contents are not Base64, so cannot test for this.
-               // Any problem with the data will have to be discovered later when the data is used.
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name\", " +
-                               "\"Value\"      : \"syntactically incorrect value\" " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:x500Name\", " +
-                               "\"Value\"      : \"syntactically incorrect value\" " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:ipAddress\", " +
-                               "\"Value\"      : \"syntactically incorrect value\" " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:dnsName\", " +
-                               "\"Value\"      : \"syntactically incorrect value\" " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-
-               // Cannot test XPathExpressions here.  The XPathExpression gets converted into a simple String value within the XPathExpression object,
-               // but it is not evaluated or compiled at that time.  Therefore we do not know whether or not the value is valid until it is used in a computation.
-
-       }
-       
-       
-       @Test
-       public void testArrayDataTypes() {
-               
-               // array of size 0
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
-                               "\"Value\"      : [] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // Category Attribute value array DataType given (repeat for all data types)
-               // Category Attribute using full Identifier for each data type
-               // Category Attribute shorthand notation for each data type
-               // Also tests for mixes of different JSON types (trying incorrect strings for XACML data types whenever possible)
-               // string
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
-                               "\"Value\"      : [\"abc\", \"def\", \"hig\", \"lmn\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=def}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=hig}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lmn}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"string\", " +
-                               "\"Value\"      : [\"abc\", \"def\", \"hig\", \"lmn\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=def}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=hig}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lmn}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // SUCCESSFUL AUTO-CONVERT to DataType
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
-                               "\"Value\"      : [\"abc\", true, \"hig\", \"lmn\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=hig}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lmn}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // SUCCESSFUL AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
-                               "\"Value\"      : [\"abc\",123, \"hig\", \"lmn\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=hig}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lmn}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // SUCCESSFUL AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
-                               "\"Value\"      : [\"abc\", 34.34, \"hig\", \"lmn\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=34.34}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=hig}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lmn}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // boolean
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#boolean\", " +
-                               "\"Value\"      : [true, true, false, true, false ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=false}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=false}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"boolean\", " +
-                               "\"Value\"      : [true, true, false, true, false ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=false}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=false}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#boolean\", " +
-                               "\"Value\"      : [true, \"abc\", false, true, false ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#boolean\", " +
-                               "\"Value\"      : [true, 123, false, true, false ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#boolean\", " +
-                               "\"Value\"      : [true, 12.34, false, true, false ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               
-               // integer
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
-                               "\"Value\"      : [123, 456, 765, 234] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=456}{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=765}{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=234}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"integer\", " +
-                               "\"Value\"      : [123, 456, 765, 234] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=456}{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=765}{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=234}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
-                               "\"Value\"      : [123, \"abc\", 765, 234] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
-                               "\"Value\"      : [123, true, 765, 234] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
-                               "\"Value\"      : [123, 34.56, 765, 234] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // double
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#double\", " +
-                               "\"Value\"      : [ 123.34, 543.54, 3445.455, 4543,543 ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.34}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=543.54}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=3445.455}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=4543.0}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=543.0}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"double\", " +
-                               "\"Value\"      : [ 123.34, 543.54, 3445.455, 4543,543 ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.34}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=543.54}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=3445.455}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=4543.0}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=543.0}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // special case - auto-convert integer to boolean
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#double\", " +
-                               "\"Value\"      : [ 123.34, 111122, 3445.455, 4543,543 ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.34}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=111122.0}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=3445.455}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=4543.0}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=543.0}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#double\", " +
-                               "\"Value\"      : [ 123.34, true, 3445.455, 4543,543 ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#double\", " +
-                               "\"Value\"      : [ 123.34, \"abb\", 3445.455, 4543,543 ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // time
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#time\", " +
-                               "\"Value\"      : [ \"12:00:00Z\", \"12:00:00Z\", \"12:00:00Z\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#time,value=12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#time,value=12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#time,value=12:00:00Z}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"time\", " +
-                               "\"Value\"      : [ \"12:00:00Z\", \"12:00:00Z\", \"12:00:00Z\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#time,value=12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#time,value=12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#time,value=12:00:00Z}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#time\", " +
-                               "\"Value\"      : [ \"12:00:00Z\", \"not a time\", \"12:00:00Z\"] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#time\", " +
-                               "\"Value\"      : [ \"12:00:00Z\", true, \"12:00:00Z\"] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#time\", " +
-                               "\"Value\"      : [ \"12:00:00Z\", 123, \"12:00:00Z\"] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#time\", " +
-                               "\"Value\"      : [ \"12:00:00Z\", 12.34, \"12:00:00Z\"] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // date
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#date\", " +
-                               "\"Value\"      : [\"2002-10-10\",\"2002-10-10\",\"2002-10-10\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#date,value=2002-10-10}{dataTypeId=http://www.w3.org/2001/XMLSchema#date,value=2002-10-10}{dataTypeId=http://www.w3.org/2001/XMLSchema#date,value=2002-10-10}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"date\", " +
-                               "\"Value\"      : [\"2002-10-10\",\"2002-10-10\",\"2002-10-10\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#date,value=2002-10-10}{dataTypeId=http://www.w3.org/2001/XMLSchema#date,value=2002-10-10}{dataTypeId=http://www.w3.org/2001/XMLSchema#date,value=2002-10-10}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#date\", " +
-                               "\"Value\"      : [\"2002-10-10\",\"not a date\",\"2002-10-10\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#date\", " +
-                               "\"Value\"      : [\"2002-10-10\",true,\"2002-10-10\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#date\", " +
-                               "\"Value\"      : [\"2002-10-10\",123,\"2002-10-10\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#date\", " +
-                               "\"Value\"      : [\"2002-10-10\",123.45,\"2002-10-10\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // dateTime
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dateTime\", " +
-                               "\"Value\"      : [ \"2002-10-10T12:00:00Z\",\"2002-10-10T12:00:00Z\",\"2002-10-10T12:00:00Z\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#dateTime,value=2002-10-10T12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#dateTime,value=2002-10-10T12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#dateTime,value=2002-10-10T12:00:00Z}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"dateTime\", " +
-                               "\"Value\"      : [ \"2002-10-10T12:00:00Z\",\"2002-10-10T12:00:00Z\",\"2002-10-10T12:00:00Z\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#dateTime,value=2002-10-10T12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#dateTime,value=2002-10-10T12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#dateTime,value=2002-10-10T12:00:00Z}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dateTime\", " +
-                               "\"Value\"      : [ \"2002-10-10T12:00:00Z\",\"not a dateTime\",\"2002-10-10T12:00:00Z\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dateTime\", " +
-                               "\"Value\"      : [ \"2002-10-10T12:00:00Z\",true,\"2002-10-10T12:00:00Z\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dateTime\", " +
-                               "\"Value\"      : [ \"2002-10-10T12:00:00Z\",123,\"2002-10-10T12:00:00Z\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dateTime\", " +
-                               "\"Value\"      : [ \"2002-10-10T12:00:00Z\",12.34,\"2002-10-10T12:00:00Z\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // dayTimeDuration
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dayTimeDuration\", " +
-                               "\"Value\"      : [ \"P23DT7H12M54S\",\"P23DT7H12M54S\",\"P23DT7H12M54S\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=23hours=7minutes=12seconds=54millis=0},factionalSeconds=54.0}}{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=23hours=7minutes=12seconds=54millis=0},factionalSeconds=54.0}}{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=23hours=7minutes=12seconds=54millis=0},factionalSeconds=54.0}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"dayTimeDuration\", " +
-                               "\"Value\"      : [ \"P23DT7H12M54S\",\"P23DT7H12M54S\",\"P23DT7H12M54S\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=23hours=7minutes=12seconds=54millis=0},factionalSeconds=54.0}}{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=23hours=7minutes=12seconds=54millis=0},factionalSeconds=54.0}}{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=23hours=7minutes=12seconds=54millis=0},factionalSeconds=54.0}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dayTimeDuration\", " +
-                               "\"Value\"      : [ \"P23DT7H12M54S\",\"not a duration\",\"P23DT7H12M54S\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dayTimeDuration\", " +
-                               "\"Value\"      : [ \"P23DT7H12M54S\",true,\"P23DT7H12M54S\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dayTimeDuration\", " +
-                               "\"Value\"      : [ \"P23DT7H12M54S\",123,\"P23DT7H12M54S\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dayTimeDuration\", " +
-                               "\"Value\"      : [ \"P23DT7H12M54S\",11.22,\"P23DT7H12M54S\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // yearMonth duration
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#yearMonthDuration\", " +
-                               "\"Value\"      : [ \"P165Y8M\",\"P165Y8M\",\"P165Y8M\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#yearMonthDuration,value={super={durationSign=1years=165months=8days=0hours=0minutes=0seconds=0millis=0},monthsDuration=1988}}{dataTypeId=http://www.w3.org/2001/XMLSchema#yearMonthDuration,value={super={durationSign=1years=165months=8days=0hours=0minutes=0seconds=0millis=0},monthsDuration=1988}}{dataTypeId=http://www.w3.org/2001/XMLSchema#yearMonthDuration,value={super={durationSign=1years=165months=8days=0hours=0minutes=0seconds=0millis=0},monthsDuration=1988}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"yearMonthDuration\", " +
-                               "\"Value\"      : [ \"P165Y8M\",\"P165Y8M\",\"P165Y8M\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#yearMonthDuration,value={super={durationSign=1years=165months=8days=0hours=0minutes=0seconds=0millis=0},monthsDuration=1988}}{dataTypeId=http://www.w3.org/2001/XMLSchema#yearMonthDuration,value={super={durationSign=1years=165months=8days=0hours=0minutes=0seconds=0millis=0},monthsDuration=1988}}{dataTypeId=http://www.w3.org/2001/XMLSchema#yearMonthDuration,value={super={durationSign=1years=165months=8days=0hours=0minutes=0seconds=0millis=0},monthsDuration=1988}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#yearMonthDuration\", " +
-                               "\"Value\"      : [ \"P165Y8M\",\"not a duration\",\"P165Y8M\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#yearMonthDuration\", " +
-                               "\"Value\"      : [ \"P165Y8M\",true,\"P165Y8M\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#yearMonthDuration\", " +
-                               "\"Value\"      : [ \"P165Y8M\",123,\"P165Y8M\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#yearMonthDuration\", " +
-                               "\"Value\"      : [ \"P165Y8M\",11.22,\"P165Y8M\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // anyURI
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#anyURI\", " +
-                               "\"Value\"      : [ \"aValue\",\"aValue\",\"aValue\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"anyURI\", " +
-                               "\"Value\"      : [ \"aValue\",\"aValue\",\"aValue\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // SUCCESSFUL AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#anyURI\", " +
-                               "\"Value\"      : [ \"aValue\",true,\"aValue\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // SUCCESSFUL AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#anyURI\", " +
-                               "\"Value\"      : [ \"aValue\",123,\"aValue\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#anyURI\", " +
-                               "\"Value\"      : [ \"aValue\",11.111,\"aValue\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=11.111}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // hexBinary
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#hexBinary\", " +
-                               "\"Value\"      : [ \"FA027B7D12CC34DDD20012AEEF\",\"FA027B7D12CC34DDD20012AEEF\",\"FA027B7D12CC34DDD20012AEEF\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#hexBinary,value={data=[-6,2,123,125,18,-52,52,-35,-46,0,18,-82,-17]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#hexBinary,value={data=[-6,2,123,125,18,-52,52,-35,-46,0,18,-82,-17]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#hexBinary,value={data=[-6,2,123,125,18,-52,52,-35,-46,0,18,-82,-17]}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"hexBinary\", " +
-                               "\"Value\"      : [ \"FA027B7D12CC34DDD20012AEEF\",\"FA027B7D12CC34DDD20012AEEF\",\"FA027B7D12CC34DDD20012AEEF\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#hexBinary,value={data=[-6,2,123,125,18,-52,52,-35,-46,0,18,-82,-17]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#hexBinary,value={data=[-6,2,123,125,18,-52,52,-35,-46,0,18,-82,-17]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#hexBinary,value={data=[-6,2,123,125,18,-52,52,-35,-46,0,18,-82,-17]}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#hexBinary\", " +
-                               "\"Value\"      : [ \"FA027B7D12CC34DDD20012AEEF\",true,\"012AEEF\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#hexBinary\", " +
-                               "\"Value\"      : [ \"FA027B7D12CC34DDD20012AEEF\",123,\"012AEEF\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#hexBinary\", " +
-                               "\"Value\"      : [ \"FA027B7D12CC34DDD20012AEEF\",11.44,\"012AEEF\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // base64Binary
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#base64Binary\", " +
-                               "\"Value\"      : [ \"aG9y\",\"lvbj0iMS4xIj48YXV0aG9y\",\"lvbjIj48YXV0aG9y\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[104,111,114]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-106,-10,-29,-46,35,18,-29,18,35,-29,-58,23,87,70,-122,-9]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-106,-10,-29,34,62,60,97,117,116,104,111,114]}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"base64Binary\", " +
-                               "\"Value\"      : [ \"aG9y\",\"lvbj0iMS4xIj48YXV0aG9y\",\"lvbjIj48YXV0aG9y\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[104,111,114]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-106,-10,-29,-46,35,18,-29,18,35,-29,-58,23,87,70,-122,-9]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-106,-10,-29,34,62,60,97,117,116,104,111,114]}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#base64Binary\", " +
-                               "\"Value\"      : [ \"aG9y\",true,\"lvbjIj48YXV0aG9y\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[104,111,114]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-74,-69,-98]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-106,-10,-29,34,62,60,97,117,116,104,111,114]}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#base64Binary\", " +
-                               "\"Value\"      : [ \"aG9y\",1123,\"lvbjIj48YXV0aG9y\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[104,111,114]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-41,93,-73]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-106,-10,-29,34,62,60,97,117,116,104,111,114]}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#base64Binary\", " +
-                               "\"Value\"      : [ \"aG9y\",11.22,\"lvbjIj48YXV0aG9y\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[104,111,114]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-41,93,-74]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-106,-10,-29,34,62,60,97,117,116,104,111,114]}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // RFC822 name
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name\", " +
-                               "\"Value\"      : [ \"sne.else@A.COMPANY.com\",\"one.else@A.COMPANY.com\",\"someone.else@A.CONY.com\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name,value={localName=sne.else,domainName=A.COMPANY.com}}{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name,value={localName=one.else,domainName=A.COMPANY.com}}{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name,value={localName=someone.else,domainName=A.CONY.com}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"rfc822Name\", " +
-                               "\"Value\"      : [ \"sne.else@A.COMPANY.com\",\"one.else@A.COMPANY.com\",\"someone.else@A.CONY.com\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name,value={localName=sne.else,domainName=A.COMPANY.com}}{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name,value={localName=one.else,domainName=A.COMPANY.com}}{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name,value={localName=someone.else,domainName=A.CONY.com}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name\", " +
-                               "\"Value\"      : [ \"sne.else@A.COMPANY.com\",\"not a dns\",\"someone.else@A.CONY.com\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name\", " +
-                               "\"Value\"      : [ \"sne.else@A.COMPANY.com\",true,\"someone.else@A.CONY.com\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name\", " +
-                               "\"Value\"      : [ \"sne.else@A.COMPANY.com\",111,\"someone.else@A.CONY.com\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name\", " +
-                               "\"Value\"      : [ \"sne.else@A.COMPANY.com\",11.22,\"someone.else@A.CONY.com\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // x500
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:x500Name\", " +
-                               "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", \"cn=Julius Hibbert, o=Medi Corporation, c=US\", \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:x500Name,value=CN=Julius Hibbert, O=Medi Corporation, C=US}{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:x500Name,value=CN=Julius Hibbert, O=Medi Corporation, C=US}{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:x500Name,value=CN=Julius Hibbert, O=Medi Corporation, C=US}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"x500Name\", " +
-                               "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", \"cn=Julius Hibbert, o=Medi Corporation, c=US\", \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:x500Name,value=CN=Julius Hibbert, O=Medi Corporation, C=US}{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:x500Name,value=CN=Julius Hibbert, O=Medi Corporation, C=US}{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:x500Name,value=CN=Julius Hibbert, O=Medi Corporation, C=US}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:x500Name\", " +
-                               "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", \"non-x500 string\", \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:x500Name\", " +
-                               "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", true, \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:x500Name\", " +
-                               "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", 1111, \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:x500Name\", " +
-                               "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", 11.22, \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // ipAddress
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:ipAddress\", " +
-                               "\"Value\"      : [ \"121.221.43.58:12345\",\"121.221.43.58:12345\",\"121.221.43.58:12345\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=121.221.43.58:12345-12345}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=121.221.43.58:12345-12345}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=121.221.43.58:12345-12345}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"ipAddress\", " +
-                               "\"Value\"      : [ \"121.221.43.58:12345\",\"121.221.43.58:12345\",\"121.221.43.58:12345\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=121.221.43.58:12345-12345}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=121.221.43.58:12345-12345}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=121.221.43.58:12345-12345}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:ipAddress\", " +
-                               "\"Value\"      : [ \"121.221.43.58:12345\",\"not an ip address\",\"121.221.43.58:12345\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:ipAddress\", " +
-                               "\"Value\"      : [ \"121.221.43.58:12345\",true,\"121.221.43.58:12345\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:ipAddress\", " +
-                               "\"Value\"      : [ \"121.221.43.58:12345\",1111,\"121.221.43.58:12345\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:ipAddress\", " +
-                               "\"Value\"      : [ \"121.221.43.58:12345\",11.22,\"121.221.43.58:12345\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // dnsName
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:dnsName\", " +
-                               "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"dnsName\", " +
-                               "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:dnsName\", " +
-                               "\"Value\"      : [ \"aValue\", true, \"aValue\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=true}}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:dnsName\", " +
-                               "\"Value\"      : [ \"aValue\", 1111, \"aValue\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:dnsName\", " +
-                               "\"Value\"      : [ \"aValue\", 11.22, \"aValue\" ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // xPathExpression
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\", " +
-                               "\"Value\"      : [ "
-                               + "{" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"Namespaces\" : ["
-                                               + "{ "+
-                                                       "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                                       "}," +
-                                                       "{" +
-                                                               "\"Prefix\" : \"md\", " +
-                                                               "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                                       "}], "+
-                                       "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                       "}," +
-                       "{" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"Namespaces\" : ["
-                                               + "{ "+
-                                                               "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                                               "}," +
-                                                               "{" +
-                                                                       "\"Prefix\" : \"md\", " +
-                                                                       "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                                               "}], "+
-                                               "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                               "}," +
-                               "{" +
-                                               "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                               "\"Namespaces\" : ["
-                                                       + "{ "+
-                                                               "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                                               "}," +
-                                                               "{" +
-                                                                       "\"Prefix\" : \"md\", " +
-                                                                       "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                                               "}], "+
-                                               "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                               "}"
-                               + "] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression,value={path=md:record/md:patient/md:patientDoB,Namespace={[{md,urn:example:med:schemas:record}{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}]},status=null,xpathExpressionWrapped=null},xpathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}{dataTypeId=urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression,value={path=md:record/md:patient/md:patientDoB,Namespace={[{md,urn:example:med:schemas:record}{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}]},status=null,xpathExpressionWrapped=null},xpathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}{dataTypeId=urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression,value={path=md:record/md:patient/md:patientDoB,Namespace={[{md,urn:example:med:schemas:record}{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}]},status=null,xpathExpressionWrapped=null},xpathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\", " +
-                               "\"Value\"      : [ "
-                               + "{" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"Namespaces\" : ["
-                                               + "{ "+
-                                                       "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                                       "}," +
-                                                       "{" +
-                                                               "\"Prefix\" : \"md\", " +
-                                                               "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                                       "}], "+
-                                       "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                       "}," +
-                       "\"simpleString\"," +
-                               "{" +
-                                               "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                               "\"Namespaces\" : ["
-                                                       + "{ "+
-                                                               "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                                               "}," +
-                                                               "{" +
-                                                                       "\"Prefix\" : \"md\", " +
-                                                                       "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                                               "}], "+
-                                               "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                               "}"
-                               + "] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\", " +
-                               "\"Value\"      : [ "
-                               + "{" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"Namespaces\" : ["
-                                               + "{ "+
-                                                       "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                                       "}," +
-                                                       "{" +
-                                                               "\"Prefix\" : \"md\", " +
-                                                               "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                                       "}], "+
-                                       "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                       "}," +
-                       "true," +
-                               "{" +
-                                               "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                               "\"Namespaces\" : ["
-                                                       + "{ "+
-                                                               "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                                               "}," +
-                                                               "{" +
-                                                                       "\"Prefix\" : \"md\", " +
-                                                                       "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                                               "}], "+
-                                               "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                               "}"
-                               + "] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\", " +
-                               "\"Value\"      : [ "
-                               + "{" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"Namespaces\" : ["
-                                               + "{ "+
-                                                       "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                                       "}," +
-                                                       "{" +
-                                                               "\"Prefix\" : \"md\", " +
-                                                               "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                                       "}], "+
-                                       "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                       "}," +
-                       "123," +
-                               "{" +
-                                               "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                               "\"Namespaces\" : ["
-                                                       + "{ "+
-                                                               "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                                               "}," +
-                                                               "{" +
-                                                                       "\"Prefix\" : \"md\", " +
-                                                                       "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                                               "}], "+
-                                               "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                               "}"
-                               + "] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\", " +
-                               "\"Value\"      : [ "
-                               + "{" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"Namespaces\" : ["
-                                               + "{ "+
-                                                       "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                                       "}," +
-                                                       "{" +
-                                                               "\"Prefix\" : \"md\", " +
-                                                               "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                                       "}], "+
-                                       "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                       "}," +
-                       "12.34," +
-                               "{" +
-                                               "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                               "\"Namespaces\" : ["
-                                                       + "{ "+
-                                                               "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                                               "}," +
-                                                               "{" +
-                                                                       "\"Prefix\" : \"md\", " +
-                                                                       "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                                               "}], "+
-                                               "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                               "}"
-                               + "] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-
-       }
-       
-
-       
-       
-       
-       
-       
-       @Test
-       public void testArrayNoDataTypes() {
-               
-               // array of size 0
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // Category Attribute value array DataType Not given (repeat for all data types)
-               // Also tests for mixes of different JSON types (trying incorrect strings for XACML data types whenever possible)
-               // string
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [\"abc\", \"def\", \"hig\", \"lmn\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=def}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=hig}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lmn}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // SUCCESSFUL AUTO-CONVERT to DataType
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [\"abc\", true, \"hig\", \"lmn\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=hig}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lmn}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // SUCCESSFUL AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [\"abc\",123, \"hig\", \"lmn\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=hig}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lmn}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // SUCCESSFUL AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [\"abc\", 34.34, \"hig\", \"lmn\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=34.34}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=hig}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lmn}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // boolean
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [true, true, false, true, false ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=false}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=false}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [true, \"abc\", false, true, false ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [true, 123, false, true, false ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [true, 12.34, false, true, false ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               
-               // integer
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [123, 456, 765, 234] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=456}{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=765}{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=234}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [123, \"abc\", 765, 234] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [123, true, 765, 234] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-
-               
-               
-               // double
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ 123.34, 543.54, 3445.455, 4543,543 ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.34}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=543.54}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=3445.455}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=4543.0}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=543.0}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // special case - auto-convert integer to boolean
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ 123.34, 111122, 3445.455, 4543,543 ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.34}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=111122.0}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=3445.455}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=4543.0}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=543.0}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ 123.34, true, 3445.455, 4543,543 ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ 123.34, \"abb\", 3445.455, 4543,543 ] " +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // time - defaults to String
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"12:00:00Z\", \"12:00:00Z\", \"12:00:00Z\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // SUCCESSFUL AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"12:00:00Z\", true, \"12:00:00Z\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // SUCCESSFUL AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"12:00:00Z\", 123, \"12:00:00Z\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"12:00:00Z\", 12.34, \"12:00:00Z\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12.34}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // date - defaults to String
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [\"2002-10-10\",\"2002-10-10\",\"2002-10-10\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [\"2002-10-10\",true,\"2002-10-10\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [\"2002-10-10\",123,\"2002-10-10\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [\"2002-10-10\",123.45,\"2002-10-10\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123.45}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // dateTime - defaults to String
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"2002-10-10T12:00:00Z\",\"2002-10-10T12:00:00Z\",\"2002-10-10T12:00:00Z\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"2002-10-10T12:00:00Z\",true,\"2002-10-10T12:00:00Z\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"2002-10-10T12:00:00Z\",123,\"2002-10-10T12:00:00Z\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"2002-10-10T12:00:00Z\",12.34,\"2002-10-10T12:00:00Z\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12.34}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // dayTimeDuration - defaults to String
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"P23DT7H12M54S\",\"P23DT7H12M54S\",\"P23DT7H12M54S\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               //AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"P23DT7H12M54S\",true,\"P23DT7H12M54S\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"P23DT7H12M54S\",123,\"P23DT7H12M54S\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"P23DT7H12M54S\",11.22,\"P23DT7H12M54S\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.22}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // yearMonth duration - defaults to String
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"P165Y8M\",\"P165Y8M\",\"P165Y8M\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"P165Y8M\",true,\"P165Y8M\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"P165Y8M\",123,\"P165Y8M\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"P165Y8M\",11.22,\"P165Y8M\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.22}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // anyURI - defaults to String
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\",\"aValue\",\"aValue\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\",true,\"aValue\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\",123,\"aValue\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\",11.111,\"aValue\"] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.111}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // hexBinary - defaults to String
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"FA027B7D12CC34DDD20012AEEF\",\"FA027B7D12CC34DDD20012AEEF\",\"FA027B7D12CC34DDD20012AEEF\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=FA027B7D12CC34DDD20012AEEF}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=FA027B7D12CC34DDD20012AEEF}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=FA027B7D12CC34DDD20012AEEF}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"FA027B7D12CC34DDD20012AEEF\",true,\"012AEEF\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=FA027B7D12CC34DDD20012AEEF}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=012AEEF}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"FA027B7D12CC34DDD20012AEEF\",123,\"012AEEF\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=FA027B7D12CC34DDD20012AEEF}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=012AEEF}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"FA027B7D12CC34DDD20012AEEF\",11.44,\"012AEEF\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=FA027B7D12CC34DDD20012AEEF}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.44}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=012AEEF}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // base64Binary - defaults to String
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aG9y\",\"lvbj0iMS4xIj48YXV0aG9y\",\"lvbjIj48YXV0aG9y\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aG9y}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lvbj0iMS4xIj48YXV0aG9y}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lvbjIj48YXV0aG9y}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aG9y\",true,\"lvbjIj48YXV0aG9y\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aG9y}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lvbjIj48YXV0aG9y}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aG9y\",1123,\"lvbjIj48YXV0aG9y\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aG9y}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=1123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lvbjIj48YXV0aG9y}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aG9y\",11.22,\"lvbjIj48YXV0aG9y\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aG9y}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.22}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lvbjIj48YXV0aG9y}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // RFC822 name - defaults to String
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"sne.else@A.COMPANY.com\",\"one.else@A.COMPANY.com\",\"someone.else@A.CONY.com\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=sne.else@A.COMPANY.com}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=one.else@A.COMPANY.com}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=someone.else@A.CONY.com}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"sne.else@A.COMPANY.com\",true,\"someone.else@A.CONY.com\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=sne.else@A.COMPANY.com}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=someone.else@A.CONY.com}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"sne.else@A.COMPANY.com\",111,\"someone.else@A.CONY.com\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=sne.else@A.COMPANY.com}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=111}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=someone.else@A.CONY.com}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"sne.else@A.COMPANY.com\",11.22,\"someone.else@A.CONY.com\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=sne.else@A.COMPANY.com}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.22}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=someone.else@A.CONY.com}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // x500 - defaults to String
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", \"cn=Julius Hibbert, o=Medi Corporation, c=US\", \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=cn=Julius Hibbert, o=Medi Corporation, c=US}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=cn=Julius Hibbert, o=Medi Corporation, c=US}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=cn=Julius Hibbert, o=Medi Corporation, c=US}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", true, \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=cn=Julius Hibbert, o=Medi Corporation, c=US}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=cn=Julius Hibbert, o=Medi Corporation, c=US}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", 1111, \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=cn=Julius Hibbert, o=Medi Corporation, c=US}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=1111}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=cn=Julius Hibbert, o=Medi Corporation, c=US}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", 11.22, \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=cn=Julius Hibbert, o=Medi Corporation, c=US}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.22}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=cn=Julius Hibbert, o=Medi Corporation, c=US}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // ipAddress - defaults to String
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"121.221.43.58:12345\",\"121.221.43.58:12345\",\"121.221.43.58:12345\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=121.221.43.58:12345}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=121.221.43.58:12345}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=121.221.43.58:12345}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"121.221.43.58:12345\",true,\"121.221.43.58:12345\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=121.221.43.58:12345}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=121.221.43.58:12345}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"121.221.43.58:12345\",1111,\"121.221.43.58:12345\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=121.221.43.58:12345}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=1111}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=121.221.43.58:12345}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"121.221.43.58:12345\",11.22,\"121.221.43.58:12345\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=121.221.43.58:12345}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.22}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=121.221.43.58:12345}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // dnsName - defaults to String
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\", true, \"aValue\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\", 1111, \"aValue\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=1111}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\", 11.22, \"aValue\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.22}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // xPathExpression - defaults to String
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\", true, \"aValue\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\", 1111, \"aValue\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=1111}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               // AUTO-CONVERT
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\", 11.22, \"aValue\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.22}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-       }
-       
-       
-
-       
-       @Test
-       public void testXPathExpression() {
-               // Category Attribute with XPathExpression including XPathCategory and XPath
-               // Category Attribute with XPathExpression with Namespaces with/without Prefix
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"xpathExpression\", " +
-                               "\"Value\"      : {" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"Namespaces\" : ["
-                                         + "{ "+
-                                                       "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                               "}," +
-                                               "{ "+
-                                                       "\"Prefix\" : \"lab\", " +
-                                                       "\"Namespace\" : \"http://somewhere/uri.html\" " +
-                                               "}," +
-                                               "{" +
-                                                       "\"Prefix\" : \"md\", " +
-                                                       "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                               "}], "+
-                                       "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                       "}" +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression,value={path=md:record/md:patient/md:patientDoB,Namespace={[{md,urn:example:med:schemas:record}{lab,http://somewhere/uri.html}{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}]},status=null,xpathExpressionWrapped=null},xpathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with XPathExpression missing XPathCategory
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"xpathExpression\", " +
-                               "\"Value\"      : {" +
-                                       "\"Namespaces\" : [{ "+
-                                                       "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                               "}," +
-                                               "{" +
-                                                       "\"Prefix\" : \"md\", " +
-                                                       "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                               "}], "+
-                                       "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                       "}" +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with XPathExpression missing XPath
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"xpathExpression\", " +
-                               "\"Value\"      : {" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"Namespaces\" : [{ "+
-                                                       "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                               "}," +
-                                               "{" +
-                                                       "\"Prefix\" : \"md\", " +
-                                                       "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                               "}] "+
-                       "}" +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with XPathExpression without Namespaces
-               // (path does not contain namespace references)
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"xpathExpression\", " +
-                               "\"Value\"      : {" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"XPath\" : \"record/patient/patientDoB\" "+
-                       "}" +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression,value={path=record/patient/patientDoB,Namespace=null,status=null,xpathExpressionWrapped=null},xpathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with XPathExpression with 0 Namespaces
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"xpathExpression\", " +
-                               "\"Value\"      : {" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"Namespaces\" : [], "+
-                                       "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                       "}" +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression,value={path=md:record/md:patient/md:patientDoB,Namespace=null,status=null,xpathExpressionWrapped=null},xpathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // Category Attribute with XPathExpression with Namespaces without mandatory Namespace
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"xpathExpression\", " +
-                               "\"Value\"      : {" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"Namespaces\" : [{ "+
-                                                       "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                               "}," +
-                                               "{" +
-                                                       "\"Prefix\" : \"md\", " +
-                                               "}], "+
-                                       "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                       "}" +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"xpathExpression\", " +
-                               "\"Value\"      : {" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"Namespaces\" : [{ "+
-                                               "}," +
-                                               "{" +
-                                                       "\"Prefix\" : \"md\", " +
-                                                       "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                               "}], "+
-                                       "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                       "}" +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-                               
-               // Category Attribute with XPathExpression with Namespaces with 2 namespaces using same prefix
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"xpathExpression\", " +
-                               "\"Value\"      : {" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"Namespaces\" : [{ "+
-                                                       "\"Prefix\" : \"md\", " +
-                                                       "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                               "}," +
-                                               "{" +
-                                                       "\"Prefix\" : \"md\", " +
-                                                       "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                               "}], "+
-                                       "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                       "}" +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with XPathExpression without Namespaces which are used within the XPathExpression (NOTE: Error is not syntactic and is not found by converter)
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"xpathExpression\", " +
-                               "\"Value\"      : {" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                       "}" +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression,value={path=md:record/md:patient/md:patientDoB,Namespace=null,status=null,xpathExpressionWrapped=null},xpathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with XPathExpression containing simple value (must be object)
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"xpathExpression\", " +
-                               "\"Value\"      : \"simple Value\"" +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with Namespaces containing simple value (must be object)
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"xpathExpression\", " +
-                               "\"Value\"      : {" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"Namespaces\" : [ \"simpleValue\"," +
-                                               "{" +
-                                                       "\"Prefix\" : \"md\", " +
-                                                       "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                               "}], "+
-                                       "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                       "}" +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // Category Attribute with Namespaces non-string Namespace
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"xpathExpression\", " +
-                               "\"Value\"      : {" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"Namespaces\" : [ {" +
-                                                       "\"Prefix\" : \"md\", " +
-                                                       "\"Namespace\" : 123 " +
-                                               "}], "+
-                                       "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                       "}" +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with Namespaces non-string prefix
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"xpathExpression\", " +
-                               "\"Value\"      : {" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"Namespaces\" : [ {" +
-                                                       "\"Prefix\" : 123, " +
-                                                       "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                               "}], "+
-                                       "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                       "}" +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with Namespaces non-string XPathCategory
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"xpathExpression\", " +
-                               "\"Value\"      : {" +
-                                       "\"XPathCategory\" : 123," +
-                                       "\"Namespaces\" : [ {" +
-                                                       "\"Prefix\" : \"md\", " +
-                                                       "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                               "}], "+
-                                       "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
-                       "}" +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category Attribute with Namespaces non-string XPath
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"xpathExpression\", " +
-                               "\"Value\"      : {" +
-                                       "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
-                                       "\"Namespaces\" : [ {" +
-                                                       "\"Prefix\" : \"md\", " +
-                                                       "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                               "}], "+
-                                       "\"XPath\" : 123 "+
-                       "}" +
-                                       "}] } ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-       }
-
-
-       
-       @Test
-       public void testContent() {
-
-               // Category with Content in XML, escaped properly
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\",\"aValue\",\"aValue\"] " +
-                               "}]," +
-                                       "\"Content\" : \"<?xml version=\\\"1.0\\\"?><catalog>" + 
-                                               "<book id=\\\"bk101\\\"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre>" +
-                                               "<price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description>"+
-                                               "</book></catalog>\"" +
-                                       "} ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]},contentRoot=[catalog: null]}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category with Content in XML, double quotes and back-slashes NOT escaped properly?
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\",\"aValue\",\"aValue\"] " +
-                               "}]," +
-                                       "\"Content\" : \"<?xml version=\\\"1.0\\\"?><catalog>" + 
-                                               "<book id=\"bk101\\\"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre>" +
-                                               "<price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description>"+
-                                               "</book></catalog>\"" +
-                                       "} ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category with Content in Base64
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\",\"aValue\",\"aValue\"] " +
-                               "}]," +
-                                       "\"Content\" :  \"PD94bWwgdmVyc2lvbj0iMS4wIj8+PGNhdGFsb2c+PGJvb2sgaWQ9ImJrMTAxIj48YXV0aG9yPkdhbWJhcmRlbGxhLCBNYXR0aGV3PC9hdXRob3I+PHRpdGxlPlhNT" +
-                                                       "CBEZXZlbG9wZXIncyBHdWlkZTwvdGl0bGU+PGdlbnJlPkNvbXB1dGVyPC9nZW5yZT48cHJpY2U+NDQuOTU8L3ByaWNlPjxwdWJsaXNoX2RhdGU+MjAwMC0xMC0wMTwvcHVibGlzaF"+
-                                                       "9kYXRlPjxkZXNjcmlwdGlvbj5BbiBpbi1kZXB0aCBsb29rIGF0IGNyZWF0aW5nIGFwcGxpY2F0aW9ucyB3aXRoIFhNTC48L2Rlc2NyaXB0aW9uPjwvYm9vaz48L2NhdGFsb2c+\"" +
-                                       "} ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]},contentRoot=[catalog: null]}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Category with Bad Content in Base64
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\",\"aValue\",\"aValue\"] " +
-                               "}]," +
-                                       "\"Content\" :  \"PD94bWwgdmV\"" +
-                                       "} ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-       }
-       
-
-       
-       
-       @Test
-       public void testDuplicates() {
-               // duplicate of same element within Category array is ok
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
-                               "\"Value\"      : \"abc\" " +
-                                       "}] }, " +
-                                       "{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
-                                               "\"Value\"      : \"abc\" " +
-                                                       "}] } "
-                                       + "] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}],includeInResults=false}]}}{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // duplicate Attribute
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [" +
-                                       "{\"CategoryId\" : \"custom-category\","
-                                       + " \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
-                                               "\"Value\"      : \"abc\" " +
-                                                       "}], "
-                                       + " \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
-                                               "\"Value\"      : \"abc\" " +
-                                                       "}] "
-                                                       + "} "
-                                       + " }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // dup id
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
-                               "\"Value\"      : \"abc\" " +
-                                       "}] } " 
-                                       + "] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // dup DataType
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
-                               "\"Value\"      : \"abc\" " +
-                                       "}] } " 
-                                       + "] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // dup Value
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
-                               "\"Value\"      : \"abc\" " +
-                               "\"Value\"      : \"abc\" " +
-                                       "}] } " 
-                                       + "] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // duplicate Content
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{"
-                                       + "\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                                       "\"Id\" : \"document-id\", " +
-                                       "\"Value\"      : [ \"aValue\",\"aValue\",\"aValue\"] " +
-                                       "}]," +
-                                       "\"Content\" : \"<?xml version=\\\"1.0\\\"?><catalog>" + 
-                                                       "<book id=\\\"bk101\\\"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre>" +
-                                                       "<price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description>"+
-                                                       "</book></catalog>\" , " +
-                                               "\"Content\" : \"<?xml version=\\\"1.0\\\"?><catalog>" + 
-                                                       "<book id=\\\"bk101\\\"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre>" +
-                                                       "<price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description>"+
-                                                       "</book></catalog>\"" +
-                                       "} ] }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-       }
-}
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/RequestConformanceTest.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/RequestConformanceTest.java
deleted file mode 100644 (file)
index 7319da4..0000000
+++ /dev/null
@@ -1,358 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ECOMP-XACML
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.policy.xacml.test.json;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.junit.Test;
-
-import com.att.research.xacml.api.Request;
-import com.att.research.xacml.api.RequestAttributes;
-import com.att.research.xacml.api.RequestReference;
-import com.att.research.xacml.std.dom.DOMRequest;
-import com.att.research.xacml.std.json.JSONRequest;
-import com.att.research.xacml.std.json.JSONStructureException;
-/**
- * Test JSON Request convert to object - Conformance tests
- * 
- * TO RUN - use jUnit
- * In Eclipse select this file or the enclosing directory, right-click and select Run As/JUnit Test
- * 
- * NOTE:
- * The "correct" way to verify that each JSON string gets translated into our internal Objects correctly is to look explicitly at each of the child objects
- * and verify that they are correct.  This would involve a lot of coding to get child of child of child and individually verify each property of each element.
- * To simplify testing we assume that request.toString() correctly includes a complete text representation of every sub-component of the Request object
- * and we compare the resulting String to our expected String.
- * This has two possible sources of error:
- *     - toString might not include some sub-component, and
- *     - the initial verification of the resulting string is done by hand and may have been incorrect.
- * 
- *
- */
-public class RequestConformanceTest {
-       
-       // where to find the conformance test XML files
-       private final String CONFORMANCE_DIRECTORY_PATH = "testsets/conformance/xacml3.0-ct-v.0.4";
-       
-       // The request object output from each test conversion from JSON string
-       Request request;
-
-
-       
-       
-       
-       // test just one of each top-level element.
-       // For simple elements also test for incorrect type
-       @Test
-       public void testConformanceRequests() {
-               
-               List<File> filesInDirectory = null;
-               
-               File conformanceDirectory = null;
-               
-               File currentFile = null;
-               
-               try {
-                       conformanceDirectory = new File(CONFORMANCE_DIRECTORY_PATH);
-                       filesInDirectory = getRequestsInDirectory(conformanceDirectory);
-               } catch (Exception e) {
-                       fail("Unable to set up Conformance tests for dir '" + conformanceDirectory.getAbsolutePath()+"' e="+ e);
-               }
-               
-               // run through each XML file
-               //      - load the file from XML into an internal Request object
-               //      - generate the JSON representation of that Request object
-               //      - load that JSON representation into a new Request object
-               //      - compare the 2 Request objects
-               Request xmlRequest = null;
-               Request jsonRequest = null;
-               try {
-                       for (File f : filesInDirectory) {
-                               currentFile = f;
-
-//// This is a simple way to select just one file for debugging - comment out when not being used
-//if ( ! f.getName().equals("IIA023Request.xml")) {   continue;  }
-
-// during debugging it is helpful to know what file it is starting to work on
-//                             System.out.println("starting file="+currentFile.getName());
-                               
-                               try {
-                                       // load XML into a Request object
-                                       xmlRequest = DOMRequest.load(f);
-                                       xmlRequest.getStatus();
-                               } catch (Exception e) {
-                                       // if XML does not load, just note it and continue with next file
-                                       System.out.println("XML file did not load: '" + f.getName() + "  e=" + e);
-                                       continue;
-                               }
-                               
-//System.out.println(JSONRequest.toString(xmlRequest, false));
-
-                               // generate JSON from the Request
-                               String jsonString = JSONRequest.toString(xmlRequest, false);
-                               
-
-// single-value elements
-//jsonString = "{\"Request\":{\"Category\":[{\"CategoryId\":\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\",\"Attribute\":["
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"Julius Hibbert\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"IncludeInResult\":\"true\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-id\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":123,\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-string\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"true\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#boolean\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-boolean\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"56\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-integer\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"27.5\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#double\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-double\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"2002-03-22\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#date\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-date\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"2002-03-22T08:23:47-05:00\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#dateTime\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-dateTime\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"P50DT5H4M3S\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#dayTimeDuration\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-dayTimeDuration\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"-P5Y3M\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#yearMonthDuration\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-yearMonthDuration\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"0bf7a9876cde\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#hexBinary\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-hexBinary\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"c3VyZS4=\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#base64Binary\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-rfc822Name\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"j_hibbert@medico.com\",\"DataType\":\"urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-rfc822Name\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"CN=Julius Hibbert, O=Medi Corporation, C=US\",\"DataType\":\"urn:oasis:names:tc:xacml:1.0:data-type:x500Name\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-x500Name\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"122.45.38.245/255.255.255.64:8080-8080\",\"DataType\":\"urn:oasis:names:tc:xacml:2.0:data-type:ipAddress\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-ipAddress\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"some.host.name:147-874\",\"DataType\":\"urn:oasis:names:tc:xacml:2.0:data-type:dnsName\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-dnsName\"}"
-//             + "]},"
-//             + "{\"CategoryId\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"Attribute\":["
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":{\"Namespaces\":[{\"Namespace\":\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\"},{\"Namespace\":\"http://www.medico.com/schemas/record\",\"Prefix\":\"md\"},{\"Namespace\":\"http://www.w3.org/2001/XMLSchema-instance\",\"Prefix\":\"xsi\"}],\"XPathCategory\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"XPath\":\"//md:records/md:record\"},\"DataType\":\"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:resource:xpathExpression\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"http://medico.com/record/patient/BartSimpson\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#anyURI\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:resource:resource-id\"}"
-//             + "]},"
-//             + "{\"CategoryId\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:action\",\"Attribute\":["
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"read\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:action:action-id\"}"
-//             + "]},"
-//             + "{\"CategoryId\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:environment\",\"Attribute\":["
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"08:23:47-05:00\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#time\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:environment:current-time\"}"
-//             + "]}],\"ReturnPolicyIdList\":false,\"CombinedDecision\":false}}";
-
-
-                               
-                               
-                               
-                               
-// array attributes WITH explicit data types
-                       
-                       
-                               
-                               
-// String for testing Arrays of Attribute values
-//jsonString = "{\"Request\":{\"Category\":[{\"CategoryId\":\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\",\"Attribute\":["
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":[\"test string\",\"Julius Hibbert\",\"Julius Hibbert as string\"],\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-id\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":[true, false],\"DataType\":\"http://www.w3.org/2001/XMLSchema#boolean\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-boolean\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":[56, 12],\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-integer\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":[27.12, 12112.344],\"DataType\":\"http://www.w3.org/2001/XMLSchema#double\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-double\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":[\"2002-03-22\",\"1256-11-11\"],\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-date\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":[\"2002-03-22T08:23:47-05:00\",\"1056-11-05T19:08:12-14:30\"],\"DataType\":\"http://www.w3.org/2001/XMLSchema#dateTime\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-dateTime\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":[\"P50DT5H4M3S\",\"P12DT148H18M21S\"],\"DataType\":\"http://www.w3.org/2001/XMLSchema#dayTimeDuration\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-dayTimeDuration\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"-P5Y3M\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#yearMonthDuration\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-yearMonthDuration\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"-P28Y7M\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#yearMonthDuration\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-yearMonthDuration\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"0bf7a9876cde\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#hexBinary\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-hexBinary\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"0fb8\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#hexBinary\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-hexBinary\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"c3VyZS4=\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#base64Binary\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-rfc822Name\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"YXN1cmUu\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#base64Binary\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-rfc822Name\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"j_hibbert@medico.com\",\"DataType\":\"urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-rfc822Name\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"c_clown@nose_medico.com\",\"DataType\":\"urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-rfc822Name\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"CN=Julius Hibbert, O=Medi Corporation, C=US\",\"DataType\":\"urn:oasis:names:tc:xacml:1.0:data-type:x500Name\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-x500Name\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"CN=Crusty Clown, O=Red Nose Corporation, C=US\",\"DataType\":\"urn:oasis:names:tc:xacml:1.0:data-type:x500Name\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-x500Name\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"122.45.38.245/255.255.255.64:8080-8080\",\"DataType\":\"urn:oasis:names:tc:xacml:2.0:data-type:ipAddress\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-ipAddress\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"35.123.111.56/255.64.32.255:9999-9999\",\"DataType\":\"urn:oasis:names:tc:xacml:2.0:data-type:ipAddress\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-ipAddress\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"some.host.name:147-874\",\"DataType\":\"urn:oasis:names:tc:xacml:2.0:data-type:dnsName\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-dnsName\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"a.different.host:-45\",\"DataType\":\"urn:oasis:names:tc:xacml:2.0:data-type:dnsName\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject:subject-dnsName\"}"
-//             + "]},"
-//             + "{\"CategoryId\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"Attribute\":["
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":{\"Namespaces\":[{\"Namespace\":\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\"},{\"Namespace\":\"http://www.medico.com/schemas/record\",\"Prefix\":\"md\"},{\"Namespace\":\"http://www.w3.org/2001/XMLSchema-instance\",\"Prefix\":\"xsi\"}],\"XPathCategory\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"XPath\":\"//md:records/md:record\"},\"DataType\":\"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:resource:xpathExpression\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":{\"Namespaces\":[{\"Namespace\":\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\"},{\"Namespace\":\"http://www.medico.com/schemas/record\",\"Prefix\":\"md\"},{\"Namespace\":\"http://www.w3.org/2001/XMLSchema-instance\",\"Prefix\":\"xsi\"}],\"XPathCategory\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"XPath\":\"//md:records/md:diagnosis_info\"},\"DataType\":\"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:resource:xpathExpression\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"http://medico.com/record/patient/BartSimpson\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#anyURI\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:resource:resource-id\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"http://medico.com/record/patient/HomerSimpson\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#anyURI\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:resource:resource-id\"}"
-//             + "],"
-//             + "\"Content\":\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?><md:records xmlns:md=\\\"http://www.medico.com/schemas/record\\\">\\r\\n            \\t<md:record>\\r\\n                \\t<md:patient_info>\\r\\n                    \\t<md:name>Bart Simpson</md:name>\\r\\n                    \\t<md:age>60</md:age>\\r\\n                    \\t<md:sex>male</md:sex>\\r\\n                    \\t<md:health_insurance>123456</md:health_insurance>\\r\\n                \\t</md:patient_info>\\r\\n                \\t<md:diagnosis_info>\\r\\n                    \\t<md:diagnosis>\\r\\n                        \\t<md:item type=\\\"primary\\\">Gastric Cancer</md:item>\\r\\n                        \\t<md:item type=\\\"secondary\\\">Hyper tension</md:item>\\r\\n                    \\t</md:diagnosis>\\r\\n                    \\t<md:pathological_diagnosis>\\r\\n                        \\t<md:diagnosis>\\r\\n                            \\t<md:item type=\\\"primary\\\">Well differentiated adeno carcinoma</md:item>\\r\\n                        \\t</md:diagnosis>\\r\\n                        \\t<md:date>2000-10-05</md:date>\\r\\n                        \\t<md:malignancy type=\\\"yes\\\"/>\\r\\n                    \\t</md:pathological_diagnosis>\\r\\n                \\t</md:diagnosis_info>                \\r\\n            \\t</md:record>\\r\\n            \\t<md:record>\\r\\n                \\t<md:patient_info>\\r\\n                    \\t<md:name>Homer Simpson</md:name>\\r\\n                    \\t<md:age>80</md:age>\\r\\n                    \\t<md:sex>male</md:sex>\\r\\n                    \\t<md:health_insurance>123456</md:health_insurance>\\r\\n                \\t</md:patient_info>\\r\\n                \\t<md:diagnosis_info>\\r\\n                    \\t<md:diagnosis>\\r\\n                        \\t<md:item type=\\\"primary\\\">Gastric Cancer</md:item>\\r\\n                        \\t<md:item type=\\\"secondary\\\">Hyper tension</md:item>\\r\\n                    \\t</md:diagnosis>\\r\\n                    \\t<md:pathological_diagnosis>\\r\\n                        \\t<md:diagnosis>\\r\\n                            \\t<md:item type=\\\"primary\\\">Well differentiated adeno carcinoma</md:item>\\r\\n                        \\t</md:diagnosis>\\r\\n                        \\t<md:date>2000-10-05</md:date>\\r\\n                        \\t<md:malignancy type=\\\"yes\\\"/>\\r\\n                    \\t</md:pathological_diagnosis>\\r\\n                \\t</md:diagnosis_info>                \\r\\n            \\t</md:record>\\r\\n\\t    </md:records>\"},"
-//             + "{\"CategoryId\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:action\",\"Attribute\":["
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"read\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:action:action-id\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"write\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:action:action-id\"}"
-//             + "]},"
-//             + "{\"CategoryId\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:environment\",\"Attribute\":["
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"08:23:47-05:00\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#time\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:environment:current-time\"},"
-//             + "{\"Issuer\":\"ConformanceTester\",\"Value\":\"22:12:10Z\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#time\",\"IncludeInResult\":true,\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:environment:current-time\"}]}]"
-//             + ",\"ReturnPolicyIdList\":false,\"CombinedDecision\":false}}";
-
-       
-                               
-                               
-                               // load JSON into a Request
-                               jsonRequest = JSONRequest.load(jsonString);
-                               
-                               // compare the two Request objects
-                               
-                               // check simple things first
-                               assertEquals("File '" + currentFile.getName() + "' CombinedDecision", xmlRequest.getCombinedDecision(), jsonRequest.getCombinedDecision());
-                               assertEquals("File '" + currentFile.getName() + "' getReturnPolicyIdList", xmlRequest.getReturnPolicyIdList(), jsonRequest.getReturnPolicyIdList());
-                               assertEquals("File '" + currentFile.getName() + "' requestDefaults", xmlRequest.getRequestDefaults(), jsonRequest.getRequestDefaults());
-
-                               // multiRequests (guaranteed to not be null)
-                               // We do NOT care about ordering, so compare the two collections inefficiently
-                               Collection<RequestReference> xmlCollection = xmlRequest.getMultiRequests();
-                               Collection<RequestReference> jsonCollection = jsonRequest.getMultiRequests();
-                               String errorMessage = null;
-                               if (jsonCollection.size() != xmlCollection.size()) {
-                                       errorMessage = "File '" + currentFile.getName() + "' MultiRequests not same size.  ";
-                               } else if (! jsonCollection.containsAll(xmlCollection)) {
-                                       errorMessage = "File '" + currentFile.getName() + "' MultiRequests have different contents.  ";
-                               }
-                               if (errorMessage != null) {
-                                       String xmlContents = "";
-                                       String jsonContents = "";
-                                       Iterator<RequestReference> rrIt = xmlCollection.iterator();
-                                       while (rrIt.hasNext()) {
-                                               xmlContents += "\n   " + rrIt.next().toString(); 
-                                       }
-                                       rrIt = jsonCollection.iterator();
-                                       while (rrIt.hasNext()) { 
-                                               jsonContents += "\n  " + rrIt.next().toString(); 
-                                       }
-                                       fail(errorMessage + "\nXML(" + xmlCollection.size() + ")='" + xmlContents + 
-                                                       "'  \nJSON(" + jsonCollection.size() + ")='" + jsonContents +
-                                                       "'" +
-                                                       "\njson='" + jsonString + "'");
-                               }
-                               
-                               // attributes (guaranteed to not be null)
-                               // We do NOT care about ordering, so compare the two collections inefficiently
-                               Collection<RequestAttributes> xmlAttrCollection = xmlRequest.getRequestAttributes();
-                               Collection<RequestAttributes> jsonAttrCollection = jsonRequest.getRequestAttributes();
-                               errorMessage = null;
-                               if (jsonAttrCollection.size() != xmlAttrCollection.size()) {
-                                       errorMessage = "File '" + currentFile.getName() + "' RequestAttributes not same size.  ";
-                               } else if (! jsonAttrCollection.containsAll(xmlAttrCollection)) {
-                                       String attrName = "";
-                                       Iterator<RequestAttributes> rait = xmlAttrCollection.iterator();
-                                       while (rait.hasNext()) {
-                                               RequestAttributes ra = rait.next();
-                                               if (jsonAttrCollection.contains(ra) == false) {
-                                                       attrName = ra.toString();
-                                               }
-                                       }
-                                       errorMessage = "File '" + currentFile.getName() + "' RequestAttributes have different contents.  JSON is missing attr=" + attrName;
-                               }
-                               if (errorMessage != null) {
-                                       String xmlContents = "";
-                                       String jsonContents = "";
-                                       Iterator<RequestAttributes> rrIt = xmlAttrCollection.iterator();
-                                       while (rrIt.hasNext()) {
-                                               RequestAttributes ras = rrIt.next();
-                                               xmlContents += "\n   " + ras.toString();
-                                               if (ras.getContentRoot() != null) {
-                                                       StringWriter writer = new StringWriter();
-                                                       Transformer transformer = null;
-                                                       try {
-                                                               transformer = TransformerFactory.newInstance().newTransformer();
-                                                               transformer.transform(new DOMSource(ras.getContentRoot()), new StreamResult(writer));
-                                                       } catch (Exception e) {
-                                                               throw new JSONStructureException("Unable to Content node to string; e="+e);
-                                                       }
-
-                                                       xmlContents += "\n        Content: " + writer.toString();
-                                               }
-                                       }
-                                       rrIt = jsonAttrCollection.iterator();
-                                       while (rrIt.hasNext()) { 
-                                               RequestAttributes ras = rrIt.next();
-                                               jsonContents += "\n   " + ras.toString();       
-                                               if (ras.getContentRoot() != null) {
-                                                       StringWriter writer = new StringWriter();
-                                                       Transformer transformer = null;
-                                                       try {
-                                                               transformer = TransformerFactory.newInstance().newTransformer();
-                                                               transformer.transform(new DOMSource(ras.getContentRoot()), new StreamResult(writer));
-                                                       } catch (Exception e) {
-                                                               throw new JSONStructureException("Unable to Content node to string; e="+e);
-                                                       }
-
-                                                       jsonContents += "\n        Content: " + writer.toString();
-                                               }
-                                       }
-                                       fail(errorMessage + "\nXML(" + xmlAttrCollection.size() + ")='" + xmlContents + 
-                                                       "'  \nJSON(" + jsonAttrCollection.size() + ")='" + jsonContents +
-                                                       "\njson='" + jsonString + "'");
-                               }
-                               
-
-                       }                       
-
-               } catch (Exception e) {
-                       fail ("Failed test with '" + currentFile.getName() + "', e=" + e);
-               }
-
-               
-       }
-       
-       //
-       // HELPER to get list of all Request files in the given directory
-       //
-       
-       private List<File> getRequestsInDirectory(File directory) {
-               List<File> fileList = new ArrayList<File>();
-               
-               File[] fileArray = directory.listFiles();
-               for (File f : fileArray) {
-                       if (f.isDirectory()) {
-                               List<File> subDirList = getRequestsInDirectory(f);
-                               fileList.addAll(subDirList);
-                       }
-                       if (f.getName().endsWith("Request.xml")) {
-                               fileList.add(f);
-                       }
-               }
-               return fileList;
-               
-       }
-       
-}
-
-
-
-
-/*
-Place to dump very long trace/exception strings that need manual editing to understand
-
-
-
-
-
-
- */
-
-
-
-
-
-
-
-
-
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/RequestDefaultCategoryTest.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/RequestDefaultCategoryTest.java
deleted file mode 100644 (file)
index a5929a4..0000000
+++ /dev/null
@@ -1,1427 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ECOMP-XACML
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.policy.xacml.test.json;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import org.junit.Test;
-
-import com.att.research.xacml.api.Request;
-import com.att.research.xacml.std.json.JSONRequest;
-import com.att.research.xacml.std.json.JSONStructureException;
-/**
- * Test JSON Request convert to object - Default Category object tests
- * 
- * TO RUN - use jUnit
- * In Eclipse select this file or the enclosing directory, right-click and select Run As/JUnit Test
- * 
- * NOTE:
- * The "correct" way to verify that each JSON string gets translated into our internal Objects correctly is to look explicitly at each of the child objects
- * and verify that they are correct.  This would involve a lot of coding to get child of child of child and individually verify each property of each element.
- * To simplify testing we assume that request.toString() correctly includes a complete text representation of every sub-component of the Request object
- * and we compare the resulting String to our expected String.
- * This has two possible sources of error:
- *     - toString might not include some sub-component, and
- *     - the initial verification of the resulting string is done by hand and may have been incorrect.
- * 
- *
- */
-public class RequestDefaultCategoryTest {
-       
-       // The request object output from each test conversion from JSON string
-       Request request;
-
-       
-       /*
-        * Request that uses all fields with both single and multiple  entries
-        */
-       String allFieldsRequest = 
-                       "{\"Request\": {" +
-                                       "\"ReturnPolicyIdList\" : true ," +
-                                       "\"CombinedDecision\" : true ," +
-                                       "\"XPathVersion\" : \"http://www.w3.org/TR/1999/REC-xpath-19991116\"," +
-                                       "\"MultiRequests\" : {" +
-                                   "\"RequestReference\": [" +
-                                       "{ " +
-                                               "\"ReferenceId\" : [\"foo1\",\"bar1\"]" +
-                                       "}," +
-                                       "{" +
-                                               "\"ReferenceId\" : [\"foo2\",\"bar1\"]" +
-                                       "}]" +   
-                                 "}," +
-
-                                       "\"Category\": [" +
-                                               "{ " +
-                                               "\"CategoryId\": \"custom-category\", " +
-                                               "\"Id\" : \"customId\", " +
-                                               "\"Attribute\" : [" +
-                                                       "{" +
-                                                               "\"AttributeId\"                : \"document-id\", " +
-                                                               "\"DataType\"   : \"integer\", " +
-                                                               "\"Value\"      : 123 " +
-                                                               "}, " +
-                                                               "{" +
-                                                               "\"AttributeId\"                : \"document-url\", " +
-                                                               "\"DataType\"   : \"anyURI\", " +
-                                                               "\"Value\"      : \"http://somewhere.over.the.com/rainbow\" " +
-                                                       "}, " +
-                                                               "{" +
-                                                               "\"AttributeId\"                : \"page-list\", " +
-                                                               "\"Value\"      : [1, 2, 3, 4.5, 3, 2, 1] " +
-                                                       "} " +
-                                               "]" +
-                                           "}, " +
-                                           "{ " +
-                                               "\"CategoryId\": \"another-custom-cat\", " +
-                                               "\"Id\" : \"anotherXmlId\", " +
-                                               "\"Attribute\" : []" +
-                                           "} " +
-                                       "], " +
-                                           
-                                       "\"AccessSubject\":{ " +
-                                               "\"Content\" : \"<?xml version=\\\"1.0\\\"?><catalog>" + 
-                                                       "<book id=\\\"bk101\\\"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre>" +
-                                                       "<price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description>"+
-                                                       "</book></catalog>\"," +
-                                               "\"Attribute\" : []" +
-                                       "}, " +
-                                       
-                                       "\"Resource\" : {" +
-                                               "\"Content\" : \"PD94bWwgdmVyc2lvbj0iMS4wIj8+PGNhdGFsb2c+PGJvb2sgaWQ9ImJrMTAxIj48YXV0aG9yPkdhbWJhcmRlbGxhLCBNYXR0aGV3PC9hdXRob3I+PHRpdGxlPlhNT" +
-                                                       "CBEZXZlbG9wZXIncyBHdWlkZTwvdGl0bGU+PGdlbnJlPkNvbXB1dGVyPC9nZW5yZT48cHJpY2U+NDQuOTU8L3ByaWNlPjxwdWJsaXNoX2RhdGU+MjAwMC0xMC0wMTwvcHVibGlzaF"+
-                                                       "9kYXRlPjxkZXNjcmlwdGlvbj5BbiBpbi1kZXB0aCBsb29rIGF0IGNyZWF0aW5nIGFwcGxpY2F0aW9ucyB3aXRoIFhNTC48L2Rlc2NyaXB0aW9uPjwvYm9vaz48L2NhdGFsb2c+\"" +
-
-
-                                       "} " +
-
-                                 
-                       "}}";
-       
-       /*
-        * The following example comes directly from the JSON Profile Spec
-        */
-       String exampleFromSpec = "{ " +
-                       "\"Request\" : { " +
-                               "\"AccessSubject\" : { " +
-                                       "\"Attribute\": [ " +
-                                               "{ " +
-                                                       "\"Id\" : \"subject-id\", " +
-                                                       "\"Value\" : \"Andreas\" " +
-                                               "}, " +
-                                               "{ " +
-                                                       "\"Id\" : \"location\", " +
-                                                       "\"Value\" : \"Gamla Stan\" " +
-                                               "} " +
-                                       "] " +
-                               "}, " +
-                               "\"Action\" : { " +
-                                       "\"Attribute\":  " +
-                                               "{ " +
-                                                       "\"Id\" : \"action-id\", " +
-                                                       "\"Value\" : \"http://www.xacml.eu/buy\", " +
-                                                       "\"DataType\" : \"anyURI\" " +
-                                               "} " +
-                               "}, " +
-                               "\"Resource\" : { " +
-                                       "\"Attribute\": [ " +
-                                               "{ " +
-                                                       "\"Id\" : \"book-title\", " +
-                                                       "\"Value\" : \"Learn German in 90 days\" " +
-                                               "}, " +
-                                               "{ " +
-                                                       "\"Id\" : \"currency\", " +
-                                                       "\"Value\" : \"SEK\" " +
-                                               "}, " +
-                                               "{ " +
-                                                       "\"Id\" : \"price\", " +
-                                                       "\"Value\" : 123.34 " +
-                                               "} " +
-                                               "] " +
-                                       "} " +
-                               "} " +
-                       "} ";
-
-       
-       /*
-        * The following example comes directly from the JSON Profile Spec (modified to include a "</Catalog>" missing from both examples).
-        * It shows the two ways of handling XPath content, as escaped XML and as Base64 encoding.
-        */
-       String xPathExampleFromSpec = "{ " +
-                       "\"Request\" : { " +
-                               "\"Resource\" : { " +
-                                       "\"Attribute\": [ " +
-                                               "{ " +
-                                                       "\"Id\" : \"urn:oasis:names:tc:xacml:3.0:content-selector\", " +
-                                           "\"DataType\" : \"xpathExpression\", " +
-                                           "\"Value\" : { " +
-                                               "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\", " +
-                                               "\"Namespaces\" : [{ " +
-                                                       "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                                       "}, " +
-                                                   "{ " +
-                                                       "\"Prefix\" : \"md\", " +
-                                                       "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                                   "} " +
-                                               "], " +
-                                               "\"XPath\" : \"md:record/md:patient/md:patientDoB\" " +
-                                           "} " +
-                                       "} " +
-                                       "] " +
-                               "} " +
-                       "} " +
-               "} ";
-
-       
-       // test Shorthand Category notation for elements not tested in their own section below.
-       // Categories that are more commonly used are fully tested. 
-       // Given that the functions within the categories are the same irrespective of the name of the category, 
-       // we assume that the contents of the category will work ok once the Shorthand notation is recognized, so all we need to test is the shorthand
-       // The ones that are tested in their own sections are:
-       //              AccessSubject
-       //              Action
-       //              Resource
-       //              Environment 
-       // test Subject
-       @Test
-       public void testCategoryShorthand() {
-       
-               // RecipientSubject present both as element within Category and as separate RecipientSubject element at same level as Category
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + "\"Category\": ["
-                                               + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                               "}] }, "
-                                               + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : \"aValue\"" +
-                                               "}] } "
-                                               + "]," +
-                                       "\"RecipientSubject\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // IntermediarySubject present both as element within Category and as separate IntermediarySubject element at same level as Category
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + "\"Category\": ["
-                                               + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                               "}] }, "
-                                               + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : \"aValue\"" +
-                                               "}] } "
-                                               + "]," +
-                                       "\"IntermediarySubject\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // Codebase present both as element within Category and as separate Codebase element at same level as Category
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + "\"Category\": ["
-                                               + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:1.0:subject-category:codebase\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                               "}] }, "
-                                               + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:1.0:subject-category:codebase\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : \"aValue\"" +
-                                               "}] } "
-                                               + "]," +
-                                       "\"Codebase\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:codebase,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:codebase,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:codebase,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:codebase,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:codebase,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:codebase,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:1.0:subject-category:codebase,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               
-               // RequestingMachine present both as element within Category and as separate RequestingMachine element at same level as Category
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + "\"Category\": ["
-                                               + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:1.0:subject-category:requesting-machine\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                               "}] }, "
-                                               + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:1.0:subject-category:requesting-machine\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : \"aValue\"" +
-                                               "}] } "
-                                               + "]," +
-                                       "\"RequestingMachine\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:requesting-machine,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:requesting-machine,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:requesting-machine,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:requesting-machine,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:requesting-machine,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:requesting-machine,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:1.0:subject-category:requesting-machine,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-       }
-
-
-
-
-
-       
-
-
-       
-
-
-       
-       
-       
-       
-       
-       // test AccessSubject
-       // Include test for backward compatibility with "Subject"
-       @Test
-       public void testAccessSubjectRequest() {
-               
-               // AccessSubject absent
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // AccessSubject as normal element under Category (with CategoryId==subject category id)
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : \"aValue\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // multiple AccessSubjects under Category
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": ["
-                                       + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\", \"Attribute\" : [{" +
-                                       "\"Id\" : \"document-id\", " +
-                                       "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                       "}] }, "
-                                       + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\", \"Attribute\" : [{" +
-                                       "\"Id\" : \"document-id\", " +
-                                       "\"Value\"      : \"aValue\"" +
-                                       "}] } "
-                                       + "] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // AccessSubject present both as element within Category and as separate AccessSubject element at same level as Category
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + "\"Category\": ["
-                                               + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                               "}] }, "
-                                               + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : \"aValue\"" +
-                                               "}] } "
-                                               + "]," +
-                                       "\"AccessSubject\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // AccessSubject present, no other Category element
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"AccessSubject\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // Subject present, no other Category element (Backward Compatibility
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"Subject\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // AccessSubject present, 1/multiple other Category element also present
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + "\"Category\": ["
-                                               + "{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : \"aValue\"" +
-                                               "}] } "
-                                               + "]," +
-                                       "\"AccessSubject\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // 2 AccessSubjects - duplicates fail
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"AccessSubject\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                                       + 
-                                       "\"AccessSubject\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // AccessSubject with correct Category value
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"AccessSubject\" : { " +
-                                               "\"CategoryId\" : \"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" ," +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // AccessSubject with wrong Category value
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"AccessSubject\" : { " +
-                                               "\"CategoryId\" : \"notthesubject\" ," +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // AccessSubject with array of sub-object AccessSubjects (Multi Decision)
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"AccessSubject\" : ["
-                                       + "{ " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "}, "
-                                       + "{ " +
-                                       "\"Attribute\": [ " +
-                                               "{ " +
-                                                       "\"Id\" : \"subject-id\", " +
-                                                       "\"Value\" : \"Arless\" " +
-                                               "}, " +
-                                               "{ " +
-                                                       "\"Id\" : \"location\", " +
-                                                       "\"Value\" : \"Somewhere\" " +
-                                               "} " +
-                                       "] " +
-                                       "}, "
-                                       + "{ " +
-                                       "\"Attribute\": [ " +
-                                               "{ " +
-                                                       "\"Id\" : \"subject-id\", " +
-                                                       "\"Value\" : \"Barry\" " +
-                                               "}, " +
-                                               "{ " +
-                                                       "\"Id\" : \"location\", " +
-                                                       "\"Value\" : \"Elsewhere\" " +
-                                               "} " +
-                                       "] " +
-                                       "} "
-                               + "]"
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Arless}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Somewhere}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Barry}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Elsewhere}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-
-       }
-       
-       
-       
-       
-       
-       
-       
-       
-       
-       // Action ... duplicate all AccessSubject tests...
-       // test Action
-       @Test
-       public void testActionRequest() {
-               
-               // Action absent
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Action as normal element under Category (with CategoryId==subject category id)
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:environment\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : \"aValue\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // multiple Actions under Category
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": ["
-                                       + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:environment\", \"Attribute\" : [{" +
-                                       "\"Id\" : \"document-id\", " +
-                                       "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                       "}] }, "
-                                       + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:environment\", \"Attribute\" : [{" +
-                                       "\"Id\" : \"document-id\", " +
-                                       "\"Value\"      : \"aValue\"" +
-                                       "}] } "
-                                       + "] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Action present both as element within Category and as separate Action element at same level as Category
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + "\"Category\": ["
-                                               + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:environment\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                               "}] }, "
-                                               + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:environment\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : \"aValue\"" +
-                                               "}] } "
-                                               + "]," +
-                                       "\"Action\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Action present, no other Category element
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"Action\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Action present, 1/multiple other Category element also present
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + "\"Category\": ["
-                                               + "{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : \"aValue\"" +
-                                               "}] } "
-                                               + "]," +
-                                       "\"Action\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // 2 Actions - duplicates fail
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"Action\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                                       + 
-                                       "\"Action\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Action with correct Category value
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"Action\" : { " +
-                                               "\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:action\" ," +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Action with wrong Category value
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"Action\" : { " +
-                                               "\"CategoryId\" : \"notthesubject\" ," +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Action with array of sub-object Actions (Multi Decision)
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"Action\" : ["
-                                       + "{ " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "}, "
-                                       + "{ " +
-                                       "\"Attribute\": [ " +
-                                               "{ " +
-                                                       "\"Id\" : \"subject-id\", " +
-                                                       "\"Value\" : \"Arless\" " +
-                                               "}, " +
-                                               "{ " +
-                                                       "\"Id\" : \"location\", " +
-                                                       "\"Value\" : \"Somewhere\" " +
-                                               "} " +
-                                       "] " +
-                                       "}, "
-                                       + "{ " +
-                                       "\"Attribute\": [ " +
-                                               "{ " +
-                                                       "\"Id\" : \"subject-id\", " +
-                                                       "\"Value\" : \"Barry\" " +
-                                               "}, " +
-                                               "{ " +
-                                                       "\"Id\" : \"location\", " +
-                                                       "\"Value\" : \"Elsewhere\" " +
-                                               "} " +
-                                       "] " +
-                                       "} "
-                               + "]"
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Arless}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Somewhere}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Barry}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Elsewhere}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-
-       }
-       
-       
-       
-       
-       // Resource ... duplicate all AccessSubject tests...
-       // test Resource
-       @Test
-       public void testResourceRequest() {
-               
-               // Resource absent
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Resource as normal element under Category (with CategoryId==subject category id)
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:environment\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : \"aValue\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // multiple Resources under Category
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": ["
-                                       + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:environment\", \"Attribute\" : [{" +
-                                       "\"Id\" : \"document-id\", " +
-                                       "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                       "}] }, "
-                                       + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:environment\", \"Attribute\" : [{" +
-                                       "\"Id\" : \"document-id\", " +
-                                       "\"Value\"      : \"aValue\"" +
-                                       "}] } "
-                                       + "] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Resource present both as element within Category and as separate Resource element at same level as Category
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + "\"Category\": ["
-                                               + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:environment\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                               "}] }, "
-                                               + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:environment\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : \"aValue\"" +
-                                               "}] } "
-                                               + "]," +
-                                       "\"Resource\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Resource present, no other Category element
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"Resource\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Resource present, 1/multiple other Category element also present
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + "\"Category\": ["
-                                               + "{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : \"aValue\"" +
-                                               "}] } "
-                                               + "]," +
-                                       "\"Resource\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // 2 Resources - duplicates fail
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"Resource\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                                       + 
-                                       "\"Resource\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Resource with correct Category value
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"Resource\" : { " +
-                                               "\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" ," +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Resource with wrong Category value
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"Resource\" : { " +
-                                               "\"CategoryId\" : \"notthesubject\" ," +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Resource with array of sub-object Resources (Multi Decision)
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"Resource\" : ["
-                                       + "{ " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "}, "
-                                       + "{ " +
-                                       "\"Attribute\": [ " +
-                                               "{ " +
-                                                       "\"Id\" : \"subject-id\", " +
-                                                       "\"Value\" : \"Arless\" " +
-                                               "}, " +
-                                               "{ " +
-                                                       "\"Id\" : \"location\", " +
-                                                       "\"Value\" : \"Somewhere\" " +
-                                               "} " +
-                                       "] " +
-                                       "}, "
-                                       + "{ " +
-                                       "\"Attribute\": [ " +
-                                               "{ " +
-                                                       "\"Id\" : \"subject-id\", " +
-                                                       "\"Value\" : \"Barry\" " +
-                                               "}, " +
-                                               "{ " +
-                                                       "\"Id\" : \"location\", " +
-                                                       "\"Value\" : \"Elsewhere\" " +
-                                               "} " +
-                                       "] " +
-                                       "} "
-                               + "]"
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Arless}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Somewhere}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Barry}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Elsewhere}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-
-       }
-       
-       
-       
-       
-       
-       
-       // Environment ... duplicate all AccessSubject tests ...
-       // test Environment
-       @Test
-       public void testEnvironmentRequest() {
-               
-               // Environment absent
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Environment as normal element under Category (with CategoryId==subject category id)
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:environment\", \"Attribute\" : [{" +
-                               "\"Id\" : \"document-id\", " +
-                               "\"Value\"      : \"aValue\" " +
-                                       "}] } ] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // multiple Environments under Category
-               try {
-                       request = JSONRequest.load("{\"Request\" : {\"Category\": ["
-                                       + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:environment\", \"Attribute\" : [{" +
-                                       "\"Id\" : \"document-id\", " +
-                                       "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                       "}] }, "
-                                       + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:environment\", \"Attribute\" : [{" +
-                                       "\"Id\" : \"document-id\", " +
-                                       "\"Value\"      : \"aValue\"" +
-                                       "}] } "
-                                       + "] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Environment present both as element within Category and as separate Environment element at same level as Category
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + "\"Category\": ["
-                                               + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:environment\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
-                                               "}] }, "
-                                               + "{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:environment\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : \"aValue\"" +
-                                               "}] } "
-                                               + "]," +
-                                       "\"Environment\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Environment present, no other Category element
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"Environment\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Environment present, 1/multiple other Category element also present
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + "\"Category\": ["
-                                               + "{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
-                                               "\"Id\" : \"document-id\", " +
-                                               "\"Value\"      : \"aValue\"" +
-                                               "}] } "
-                                               + "]," +
-                                       "\"Environment\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // 2 Environments - duplicates fail
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"Environment\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                                       + 
-                                       "\"Environment\" : { " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Environment with correct Category value
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"Environment\" : { " +
-                                               "\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:environment\" ," +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Environment with wrong Category value
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"Environment\" : { " +
-                                               "\"CategoryId\" : \"notthesubject\" ," +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "} " 
-                               + " }}");
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Environment with array of sub-object Environments (Multi Decision)
-               try {
-                       request = JSONRequest.load("{\"Request\" : {"
-                                       + 
-                                       "\"Environment\" : ["
-                                       + "{ " +
-                                               "\"Attribute\": [ " +
-                                                       "{ " +
-                                                               "\"Id\" : \"subject-id\", " +
-                                                               "\"Value\" : \"Andreas\" " +
-                                                       "}, " +
-                                                       "{ " +
-                                                               "\"Id\" : \"location\", " +
-                                                               "\"Value\" : \"Gamla Stan\" " +
-                                                       "} " +
-                                               "] " +
-                                       "}, "
-                                       + "{ " +
-                                       "\"Attribute\": [ " +
-                                               "{ " +
-                                                       "\"Id\" : \"subject-id\", " +
-                                                       "\"Value\" : \"Arless\" " +
-                                               "}, " +
-                                               "{ " +
-                                                       "\"Id\" : \"location\", " +
-                                                       "\"Value\" : \"Somewhere\" " +
-                                               "} " +
-                                       "] " +
-                                       "}, "
-                                       + "{ " +
-                                       "\"Attribute\": [ " +
-                                               "{ " +
-                                                       "\"Id\" : \"subject-id\", " +
-                                                       "\"Value\" : \"Barry\" " +
-                                               "}, " +
-                                               "{ " +
-                                                       "\"Id\" : \"location\", " +
-                                                       "\"Value\" : \"Elsewhere\" " +
-                                               "} " +
-                                       "] " +
-                                       "} "
-                               + "]"
-                               + " }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Arless}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Somewhere}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Barry}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Elsewhere}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-
-       }
-
-       
-}
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/RequestMainTest.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/RequestMainTest.java
deleted file mode 100644 (file)
index 198ba3a..0000000
+++ /dev/null
@@ -1,1076 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ECOMP-XACML
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.policy.xacml.test.json;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import org.junit.Test;
-
-import com.att.research.xacml.api.Request;
-import com.att.research.xacml.std.json.JSONRequest;
-import com.att.research.xacml.std.json.JSONStructureException;
-/**
- * Test JSON Request convert to object - High-level Request-as-a-whole tests including test that fills in all fields with multiple values (where appropriate)
- * 
- * TO RUN - use jUnit
- * In Eclipse select this file or the enclosing directory, right-click and select Run As/JUnit Test
- * 
- * NOTE:
- * The "correct" way to verify that each JSON string gets translated into our internal Objects correctly is to look explicitly at each of the child objects
- * and verify that they are correct.  This would involve a lot of coding to get child of child of child and individually verify each property of each element.
- * To simplify testing we assume that request.toString() correctly includes a complete text representation of every sub-component of the Request object
- * and we compare the resulting String to our expected String.
- * This has two possible sources of error:
- *     - toString might not include some sub-component, and
- *     - the initial verification of the resulting string is done by hand and may have been incorrect.
- * 
- *
- */
-public class RequestMainTest {
-       
-       // The request object output from each test conversion from JSON string
-       Request request;
-
-       
-       /*
-        * Request that uses all fields with both single and multiple  entries
-        */
-       String allFieldsRequest = 
-                       "{\"Request\": {" +
-                                       "\"ReturnPolicyIdList\" : true ," +
-                                       "\"CombinedDecision\" : true ," +
-                                       "\"XPathVersion\" : \"http://www.w3.org/TR/1999/REC-xpath-19991116\"," +
-                                       "\"MultiRequests\" : {" +
-                                   "\"RequestReference\": [" +
-                                       "{ " +
-                                               "\"ReferenceId\" : [\"foo1\",\"bar1\"]" +
-                                       "}," +
-                                       "{" +
-                                               "\"ReferenceId\" : [\"foo2\",\"bar1\"]" +
-                                       "}]" +   
-                                 "}," +
-
-                                       "\"Category\": [" +
-                                               "{ " +
-                                               "\"CategoryId\": \"custom-category\", " +
-                                               "\"Id\" : \"customId\", " +
-                                               "\"Attribute\" : [" +
-                                                       "{" +
-                                                               "\"AttributeId\"                : \"document-id\", " +
-                                                               "\"DataType\"   : \"integer\", " +
-                                                               "\"Value\"      : 123 " +
-                                                               "}, " +
-                                                               "{" +
-                                                               "\"AttributeId\"                : \"document-url\", " +
-                                                               "\"DataType\"   : \"anyURI\", " +
-                                                               "\"Value\"      : \"http://somewhere.over.the.com/rainbow\" " +
-                                                       "}, " +
-                                                               "{" +
-                                                               "\"AttributeId\"                : \"page-list\", " +
-                                                               "\"Value\"      : [1, 2, 3, 4.5, 3, 2, 1] " +
-                                                       "} " +
-                                               "]" +
-                                           "}, " +
-                                           "{ " +
-                                               "\"CategoryId\": \"another-custom-cat\", " +
-                                               "\"Id\" : \"anotherXmlId\", " +
-                                               "\"Attribute\" : []" +
-                                           "} " +
-                                       "], " +
-                                           
-                                       "\"AccessSubject\":{ " +
-                                               "\"Content\" : \"<?xml version=\\\"1.0\\\"?><catalog>" + 
-                                                       "<book id=\\\"bk101\\\"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre>" +
-                                                       "<price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description>"+
-                                                       "</book></catalog>\"," +
-                                               "\"Attribute\" : []" +
-                                       "}, " +
-                                       
-                                       "\"Resource\" : {" +
-                                               "\"Content\" : \"PD94bWwgdmVyc2lvbj0iMS4wIj8+PGNhdGFsb2c+PGJvb2sgaWQ9ImJrMTAxIj48YXV0aG9yPkdhbWJhcmRlbGxhLCBNYXR0aGV3PC9hdXRob3I+PHRpdGxlPlhNT" +
-                                                       "CBEZXZlbG9wZXIncyBHdWlkZTwvdGl0bGU+PGdlbnJlPkNvbXB1dGVyPC9nZW5yZT48cHJpY2U+NDQuOTU8L3ByaWNlPjxwdWJsaXNoX2RhdGU+MjAwMC0xMC0wMTwvcHVibGlzaF"+
-                                                       "9kYXRlPjxkZXNjcmlwdGlvbj5BbiBpbi1kZXB0aCBsb29rIGF0IGNyZWF0aW5nIGFwcGxpY2F0aW9ucyB3aXRoIFhNTC48L2Rlc2NyaXB0aW9uPjwvYm9vaz48L2NhdGFsb2c+\"" +
-
-
-                                       "} " +
-
-                                 
-                       "}}";
-       
-       /*
-        * The following example comes directly from the JSON Profile Spec
-        */
-       String exampleFromSpec = "{ " +
-                       "\"Request\" : { " +
-                               "\"AccessSubject\" : { " +
-                                       "\"Attribute\": [ " +
-                                               "{ " +
-                                                       "\"Id\" : \"subject-id\", " +
-                                                       "\"Value\" : \"Andreas\" " +
-                                               "}, " +
-                                               "{ " +
-                                                       "\"Id\" : \"location\", " +
-                                                       "\"Value\" : \"Gamla Stan\" " +
-                                               "} " +
-                                       "] " +
-                               "}, " +
-                               "\"Action\" : { " +
-                                       "\"Attribute\":  " +
-                                               "{ " +
-                                                       "\"Id\" : \"action-id\", " +
-                                                       "\"Value\" : \"http://www.xacml.eu/buy\", " +
-                                                       "\"DataType\" : \"anyURI\" " +
-                                               "} " +
-                               "}, " +
-                               "\"Resource\" : { " +
-                                       "\"Attribute\": [ " +
-                                               "{ " +
-                                                       "\"Id\" : \"book-title\", " +
-                                                       "\"Value\" : \"Learn German in 90 days\" " +
-                                               "}, " +
-                                               "{ " +
-                                                       "\"Id\" : \"currency\", " +
-                                                       "\"Value\" : \"SEK\" " +
-                                               "}, " +
-                                               "{ " +
-                                                       "\"Id\" : \"price\", " +
-                                                       "\"Value\" : 123.34 " +
-                                               "} " +
-                                               "] " +
-                                       "} " +
-                               "} " +
-                       "} ";
-
-       
-       /*
-        * The following example comes directly from the JSON Profile Spec (modified to include a "</Catalog>" missing from both examples).
-        * It shows the two ways of handling XPath content, as escaped XML and as Base64 encoding.
-        */
-       String xPathExampleFromSpec = "{ " +
-                       "\"Request\" : { " +
-                               "\"Resource\" : { " +
-                                       "\"Attribute\": [ " +
-                                               "{ " +
-                                                       "\"Id\" : \"urn:oasis:names:tc:xacml:3.0:content-selector\", " +
-                                           "\"DataType\" : \"xpathExpression\", " +
-                                           "\"Value\" : { " +
-                                               "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\", " +
-                                               "\"Namespaces\" : [{ " +
-                                                       "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                                       "}, " +
-                                                   "{ " +
-                                                       "\"Prefix\" : \"md\", " +
-                                                       "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                                   "} " +
-                                               "], " +
-                                               "\"XPath\" : \"md:record/md:patient/md:patientDoB\" " +
-                                           "} " +
-                                       "} " +
-                                       "] " +
-                               "} " +
-                       "} " +
-               "} ";
-
-       
-       
-       // test various ways that request might be empty
-       @Test
-       public void testEmptyRequest() {
-               // null request
-               try {
-                       request = JSONRequest.load((String)null);
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // empty request
-               try {
-                       request = JSONRequest.load((String)"");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load((String)" ");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // empty JSON request
-               try {
-                       request = JSONRequest.load((String)"{}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load((String)"{{}}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // garbage input
-               try {
-                       request = JSONRequest.load((String)"Some non-JSON string");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load((String)"{something non-JSON}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // bad syntax (Request with no content)
-               try {
-                       request = JSONRequest.load((String)"{\"Request\"}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // bad syntax (no :field after Request)
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : }");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // bad syntax (no " around Request)
-               try {
-                       request = JSONRequest.load((String)"{Request}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // empty content in Request
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : \"\"}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // content is not an object
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : \"CombinedDecision\" : true }");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // too many } at end
-               // Jackson parser does not treat this as an error
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"XPathVersion\" : \"http://www.w3.org/TR/1999/REC-xpath-19991116\"}}}}}");
-                       assertEquals("{requestDefaults={xpatherVersion=http://www.w3.org/TR/1999/REC-xpath-19991116},returnPolicyIdList=false,combinedDecision=false}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // too few } at end
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"XPathVersion\" : \"http://www.w3.org/TR/1999/REC-xpath-19991116\" }");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // misplaced } in middle
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"XPathVersion\" : } \"http://www.w3.org/TR/1999/REC-xpath-19991116\"}}}}}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-
-       }
-       
-
-       
-       // Test double braces around request
-       @Test
-       public void testDoubleBraces() {
-               
-               try {
-                       request = JSONRequest.load((String)"{{\"Request\" }");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load((String)"{{\"Request\" : }");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load((String)"{{\"Request\" : {\"CombinedDecision\" : true }}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-       }
-       
-       
-       
-       // test elements missing from top-level Request and arrays where single elements should be
-       @Test
-       public void testMissingFields() {
-               
-               // Request containing empty array
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : []}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // array of one element
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : [{\"CombinedDecision\" : true }]}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // correctly formatted empty request gives request with defaults set
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : { }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // space in front of name (inside quotes)
-               try {
-                       request = JSONRequest.load((String)"{\" Request\" : {\"XPathVersion\" : \"http://some/other/default/uri\" }}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // space at end of name (inside quotes)
-               try {
-                       request = JSONRequest.load((String)"{\"Request \" : {\"XPathVersion\" : \"http://some/other/default/uri\" }}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // space in front of value (inside quotes) - valid String but not valid URI
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"XPathVersion\" : \" http://some/other/default/uri\" }}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // space at end of value (inside quotes) - valid String but not valid URI
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"XPathVersion\" : \"http://some/other/default/uri \" }}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-       }
-       
-       
-       
-       // test just one of each top-level element.
-       // For simple elements also test for incorrect type
-       @Test
-       public void testTopLevelElements() {
-               
-               // empty request
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {}}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-
-               
-               // ReturnPolicyIdList
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"ReturnPolicyIdList\" : true  }}");
-                       assertEquals("{returnPolicyIdList=true,combinedDecision=false}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"ReturnPolicyIdList\" : \"abc\"  }}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"ReturnPolicyIdList\" : 123  }}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // CombinedDecision
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : { \"CombinedDecision\" : true }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=true}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"CombinedDecision\" : \"abc\"  }}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"CombinedDecision\" : 123  }}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // XPathVersion
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"XPathVersion\" : \"http://some/other/default/uri\" }}");
-                       assertEquals("{requestDefaults={xpatherVersion=http://some/other/default/uri},returnPolicyIdList=false,combinedDecision=false}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"XPathVersion\" : true  }}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"XPathVersion\" : 123  }}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"XPathVersion\" : \"not a uri\" }}");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // Category
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"Category\": [{ " +
-                                               "\"CategoryId\": \"another-custom-cat\", " +
-                                               "\"Id\" : \"anotherXmlId\", " +
-                                               "\"Attribute\" : []" +
-                                           "} " +
-                                       "] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=another-custom-cat},xmlId=anotherXmlId}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // AccessSubject
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : { \"AccessSubject\":{ }}}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Action
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : { \"Action\":{ }}}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:action}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Resource
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"Resource\":{ }}}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Environment
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"Environment\":{ } }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:environment}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // MultiRequests
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"MultiRequests\" : {" +
-                                   "\"RequestReference\": [" +
-                                       "{ " +
-                                               "\"ReferenceId\" : [\"foo1\",\"bar1\"]" +
-                                       "}," +
-                                       "{" +
-                                               "\"ReferenceId\" : [\"foo2\",\"bar2\"]" +
-                                       "}]" +   
-                                 "} } }");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,multiRequests=[{requestAttributesReferences=[{referenceId=foo1}{referenceId=bar1}]}{requestAttributesReferences=[{referenceId=foo2}{referenceId=bar2}]}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // MultiRequest with 1
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"MultiRequests\" : {" +
-                                   "\"RequestReference\": [" +
-                                       "{" +
-                                               "\"ReferenceId\" : [\"bar2\"]" +
-                                       "}]" +   
-                                 "} } }");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,multiRequests=[{requestAttributesReferences=[{referenceId=bar2}]}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // MultiRequest with RequestReferences with no ReferenceId
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"MultiRequests\" : {" +
-                                   "\"RequestReference\": [" +
-                                       "{" +
-                                               "\"ReferenceId\" : []" +
-                                       "}]" +   
-                                 "} } }");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-
-               // MultiRequests with no RequestReference
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"MultiRequests\" : {" +
-                                   "\"RequestReference\": []" +   
-                                 "} } }");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // MultiRequests with something other than RequestReference
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"MultiRequests\" : {" +
-                                   "\"SomeOtherAttribute\": 123" +   
-                                 "} } }");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // MultiRequests with single RequestReference rather than array
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"MultiRequests\" : {" +
-                                   "\"RequestReference\": " +
-                                       "{" +
-                                               "\"ReferenceId\" : []" +
-                                       "}" +   
-                                 "} } }");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // MultiRequests with RequestReference containing single element instead of array
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"MultiRequests\" : {" +
-                                   "\"RequestReference\": [" +
-                                       "{" +
-                                               "\"ReferenceId\" : \"foo1\"" +
-                                       "}]" +   
-                                 "} } }");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"MultiRequests\" : {" +
-                                   "\"RequestReference\": [" +
-                                       "{" +
-                                               "\"ReferenceId\" : {\"foo1\"}" +
-                                       "}]" +   
-                                 "} } }");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // MultiRequests with component that is not a RequestReference
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"MultiRequests\" : {" +
-                                   "\"RequestReference\": [" +
-                                       "{ " +
-                                               "\"SomeOtherAttribute\" : [\"foo1\",\"bar1\"]" +
-                                       "}," +
-                                       "{" +
-                                               "\"ReferenceId\" : [\"foo2\",\"bar2\"]" +
-                                       "}]" +   
-                                 "} } }");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // MultiRequests with component that is not a RequestReference
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"MultiRequests\" : {" +
-                                   "\"RequestReference\": [" +
-                                       "{ " +
-                                               "\"ReferenceId\" : [\"foo2\",\"bar2\"]," +
-                                               "\"SomeOtherAttribute\" : [\"foo1\",\"bar1\"]" +
-                                       "}," +
-                                       "{" +
-                                               "\"ReferenceId\" : [\"foo2\",\"bar2\"]" +
-                                       "}]" +   
-                                 "} } }");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // MultiRequest with unknown elements (in addition to RequestReference)
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"MultiRequests\" : {" +
-                               "\"SomeOtherAttribute\": 123," +   
-                                   "\"RequestReference\": [" +
-                                       "{ " +
-                                               "\"ReferenceId\" : [\"foo1\",\"bar1\"]" +
-                                       "}," +
-                                       "{" +
-                                               "\"ReferenceId\" : [\"foo2\",\"bar2\"]" +
-                                       "}]" +   
-                                 "} } }");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // MultiRequest with RequestReferences with  ReferenceId NOT a string
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"MultiRequests\" : {" +
-                                   "\"RequestReference\": [" +
-                                       "{" +
-                                               "\"ReferenceId\" : [ true ]" +
-                                       "}]" +   
-                                 "} } }");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"MultiRequests\" : {" +
-                                   "\"RequestReference\": [" +
-                                       "{" +
-                                               "\"ReferenceId\" : [ 123 ]" +
-                                       "}]" +   
-                                 "} } }");
-                       fail("Request should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // Cannot test with ReferenceId that is NOT referring to a Category object Id property because we may not have read the Category objects yet.
-               // Need to leave this up to the PDP.
-
-               
-               // extra elements in top-level
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {}, \"unknownElement\" : false, \"unk2\" : \"abc\", \"unk3\" : 123 }}");
-                       fail("Unknown element should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // extra elements in Request
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"XPathVersion\" : \"http://www.w3.org/TR/1999/REC-xpath-19991116\", \"unknownElement\" : false }}");
-                       fail("Unknown element should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-       }
-       
-       
-       // Test with every field filled in with multiple values where appropriate
-       @Test
-       public void testAllFieldsRequest() {    
-       
-               // convert Response to JSON
-               try {
-                       request = JSONRequest.load(allFieldsRequest);
-                       assertEquals("{requestDefaults={xpatherVersion=http://www.w3.org/TR/1999/REC-xpath-19991116},returnPolicyIdList=true,combinedDecision=true,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],includeInResults=false}{attributeId=document-url,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=http://somewhere.over.the.com/rainbow}],includeInResults=false}{attributeId=page-list,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=1.0}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=2.0}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=3.0}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=4.5}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=3.0}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=2.0}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=1.0}],includeInResults=false}]},xmlId=customId}{super={category=another-custom-cat},xmlId=anotherXmlId}{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject},contentRoot=[catalog: null]}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource},contentRoot=[catalog: null]}],multiRequests=[{requestAttributesReferences=[{referenceId=foo1}{referenceId=bar1}]}{requestAttributesReferences=[{referenceId=foo2}{referenceId=bar1}]}]}"
-                                       , request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // convert example request from spec
-               try {
-                       request = JSONRequest.load(exampleFromSpec);
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,attributes=[{attributeId=subject-id,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Andreas}],includeInResults=false}{attributeId=location,category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Gamla Stan}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,attributes=[{attributeId=action-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:action,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=http://www.xacml.eu/buy}],includeInResults=false}]}}{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,attributes=[{attributeId=book-title,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=Learn German in 90 days}],includeInResults=false}{attributeId=currency,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=SEK}],includeInResults=false}{attributeId=price,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.34}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // convert example request from spec containing XPAthExpression
-               try {
-                       request = JSONRequest.load(xPathExampleFromSpec);
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,attributes=[{attributeId=urn:oasis:names:tc:xacml:3.0:content-selector,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression,value={path=md:record/md:patient/md:patientDoB,Namespace={[{md,urn:example:med:schemas:record}{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}]},status=null,xpathExpressionWrapped=null},xpathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}],includeInResults=false}]}}]}", request.toString());
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-       
-       }
-       
-       
-       
-       // Duplicates - Each element duplicated
-       @Test
-       public void testDuplicates() {
-               // duplicate Request
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {}, \"Request\" : {}}");
-                       fail("Unknown element should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"ReturnPolicyIdList\" : true, \"ReturnPolicyIdList\" : true   }}");
-                       fail("Unknown element should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : { \"CombinedDecision\" : true, \"CombinedDecision\" : true }}");
-                       fail("Unknown element should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"Category\": [{ " +
-                                               "\"CategoryId\": \"another-custom-cat\", " +
-                                               "\"Id\" : \"anotherXmlId\", " +
-                                               "\"Attribute\" : []" +
-                                           "} " +
-                                       "],"
-                                       + "\"Category\": [{ " +
-                                               "\"CategoryId\": \"another-custom-cat\", " +
-                                               "\"Id\" : \"anotherXmlId\", " +
-                                               "\"Attribute\" : []" +
-                                           "} " +
-                                       "] }}");
-                       assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=another-custom-cat},xmlId=anotherXmlId}]}", request.toString());
-                       fail("Unknown element should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"Category\": [{ " +
-                                               "\"CategoryId\": \"another-custom-cat\", " +
-                                               "\"CategoryId\": \"another-custom-cat\", " +
-                                               "\"Id\" : \"anotherXmlId\", " +
-                                               "\"Attribute\" : []" +
-                                           "} " +
-                                       "] }}");
-                       fail("Unknown element should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"Category\": [{ " +
-                                               "\"CategoryId\": \"another-custom-cat\", " +
-                                               "\"Id\" : \"anotherXmlId\", " +
-                                               "\"Id\" : \"anotherXmlId\", " +
-                                               "\"Attribute\" : []" +
-                                           "} " +
-                                       "] }}");
-                       fail("Unknown element should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"Category\": [{ " +
-                                               "\"CategoryId\": \"another-custom-cat\", " +
-                                               "\"Id\" : \"anotherXmlId\", " +
-                                               "\"Attribute\" : []" +
-                                               "\"Attribute\" : []" +
-                                           "} " +
-                                       "] }}");
-                       fail("Unknown element should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // AccessSubject
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : { \"AccessSubject\":{ }, \"AccessSubject\":{ }}}");
-                       fail("Unknown element should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Action
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : { \"Action\":{ }, \"Action\":{ }}}");
-                       fail("Unknown element should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Resource
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"Resource\":{ }, \"Resource\":{ }}}");
-                       fail("Unknown element should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Environment
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"Environment\":{ }, \"Environment\":{ } }}");
-                       fail("Unknown element should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // MultiRequests
-
-               
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"MultiRequests\" : {" +
-                                   "\"RequestReference\": [" +
-                                       "{ " +
-                                               "\"ReferenceId\" : [\"foo1\",\"bar1\"]" +
-                                       "}," +
-                                       "{" +
-                                               "\"ReferenceId\" : [\"foo2\",\"bar2\"]" +
-                                       "}]" +   
-                                 "},"
-                                 + "\"MultiRequests\" : {" +
-                                   "\"RequestReference\": [" +
-                                       "{ " +
-                                               "\"ReferenceId\" : [\"foo1\",\"bar1\"]" +
-                                       "}," +
-                                       "{" +
-                                               "\"ReferenceId\" : [\"foo2\",\"bar2\"]" +
-                                       "}]" +   
-                                 "}  } }");
-                       fail("Unknown element should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"MultiRequests\" : {" +
-                                   "\"RequestReference\": [" +
-                                       "{ " +
-                                               "\"ReferenceId\" : [\"foo1\",\"bar1\"]" +
-                                       "}," +
-                                       "{" +
-                                               "\"ReferenceId\" : [\"foo2\",\"bar2\"]" +
-                                       "}]," + 
-                                       "\"RequestReference\": [" +
-                                       "{ " +
-                                               "\"ReferenceId\" : [\"foo1\",\"bar1\"]" +
-                                       "}," +
-                                       "{" +
-                                               "\"ReferenceId\" : [\"foo2\",\"bar2\"]" +
-                                       "}]" +
-                                 "} } }");
-                       fail("Unknown element should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               try {
-                       request = JSONRequest.load((String)"{\"Request\" : {\"MultiRequests\" : {" +
-                                   "\"RequestReference\": [" +
-                                       "{ " +
-                                               "\"ReferenceId\" : [\"foo1\",\"bar1\"]" +
-                                               "\"ReferenceId\" : [\"foo1\",\"bar1\"]" +
-                                       "}," +
-                                       "{" +
-                                               "\"ReferenceId\" : [\"foo2\",\"bar2\"]" +
-                                       "}]" +   
-                                 "} } }");
-                       fail("Unknown element should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-       }
-       
-
-}
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/ResponseConformanceTest.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/ResponseConformanceTest.java
deleted file mode 100644 (file)
index 735fa46..0000000
+++ /dev/null
@@ -1,357 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ECOMP-XACML
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.policy.xacml.test.json;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.junit.Test;
-
-import com.att.research.xacml.api.Advice;
-import com.att.research.xacml.api.Attribute;
-import com.att.research.xacml.api.AttributeCategory;
-import com.att.research.xacml.api.IdReference;
-import com.att.research.xacml.api.Obligation;
-import com.att.research.xacml.api.Response;
-import com.att.research.xacml.api.Result;
-import com.att.research.xacml.std.dom.DOMResponse;
-import com.att.research.xacml.std.json.JSONResponse;
-import com.att.research.xacml.util.ListUtil;
-/**
- * Test JSON Response convert to object - Conformance tests
- * 
- * TO RUN - use jUnit
- * In Eclipse select this file or the enclosing directory, right-click and select Run As/JUnit Test
- * 
- * Note: some of the validation tests comparing the XML-derived Results to the JSON-derived Results are high-level comparisons of Collections.
- *             When this class was first created that was sufficient to pass all Conformance tests.
- *             However if this sees a failure in a Conformance test, those validations may need to be upgraded to look at the individual data elements to see what is wrong.
- * 
- *
- */
-public class ResponseConformanceTest {
-
-       // where to find the conformance test XML files
-       private final String CONFORMANCE_DIRECTORY_PATH = "testsets/conformance/xacml3.0-ct-v.0.4";
-
-       // The request object output from each test conversion from JSON string
-       Response response;
-
-       // test just one of each top-level element.
-       // For simple elements also test for incorrect type
-       @Test
-       public void testConformanceResponses() {
-
-               List<File> filesInDirectory = null;
-
-               File conformanceDirectory = null;
-
-               File currentFile = null;
-
-               try {
-                       conformanceDirectory = new File(CONFORMANCE_DIRECTORY_PATH);
-                       filesInDirectory = getRequestsInDirectory(conformanceDirectory);
-               } catch (Exception e) {
-                       fail("Unable to set up Conformance tests for dir '" + conformanceDirectory.getAbsolutePath()+"' e="+ e);
-               }
-
-               // run through each XML file
-               //      - load the file from XML into an internal Response object
-               //      - generate the JSON representation of that Response object
-               //      - load that JSON representation into a new Response object
-               //      - compare the 2 Request objects
-               Response xmlResponse = null;
-               Response jsonResponse = null;
-               try {
-                       for (File f : filesInDirectory) {
-                               currentFile = f;
-
-                               //// This is a simple way to select just one file for debugging - comment out when not being used
-                               //if ( ! f.getName().equals("IIIA030Response.xml") && ! f.getName().equals("IIIA330Response.xml")) {   continue;  }
-
-                               // during debugging it is helpful to know what file it is starting to work on
-                               //                              System.out.println("starting file="+currentFile.getName());
-
-                               try {
-                                       // load XML into a Response object
-                                       xmlResponse = DOMResponse.load(f);
-                               } catch (Exception e) {
-                                       // if XML does not load, just note it and continue with next file
-                                       System.out.println("XML file did not load: '" + f.getName() + "  e=" + e);
-                                       continue;
-                               }
-
-                               // some tests have JSON response files to load, most do not
-                               String jsonFileName = f.getName().replace(".xml", ".json");
-                               File jsonFile = new File(conformanceDirectory, jsonFileName);
-
-                               if (jsonFile.exists()) {
-                                       //System.out.println("found file "+jsonFile.getName());
-                                       // json version exists in file, so load it
-                                       jsonResponse = JSONResponse.load(jsonFile);
-                               } else {
-                                       // json does not exist in file, so create it from the XML response using a String intermediate version
-                                       String jsonResponseString = JSONResponse.toString(xmlResponse, false);
-                                       //System.out.println(jsonResponseString);       
-                                       //System.out.println(JSONResponse.toString(xmlResponse, true));
-
-                                       jsonResponse = JSONResponse.load(jsonResponseString);
-                               }                       
-
-
-                               //System.out.println(JSONResponse.toString(xmlResponse, true));
-
-
-
-
-                               // compare the two Response objects
-
-                               // compare results
-                               assertEquals(xmlResponse.getResults().size(), jsonResponse.getResults().size());
-
-                               if (xmlResponse.getResults().size() == 0) {
-                                       fail("neither XML nor JSON response have any Results");
-                               }
-
-
-                               // Results are an un-ordered Collection.
-                               // There is no identifying information that is unique to a specific Result.
-                               // If there are more than one we cannot be sure which one corresponds with which.
-                               // The best we can do is say that one or more in the first list do not match any in the second list
-                               if (xmlResponse.getResults().size() > 1) {
-                                       for (Result xmlResult : xmlResponse.getResults()) {
-                                               boolean found = false;
-                                               for (Result jsonResult : jsonResponse.getResults()) {
-                                                       if (xmlResult.equals(jsonResult)) {
-                                                               found = true;
-                                                               break;
-                                                       }
-                                               }
-                                               if (found) {
-                                                       continue;
-                                               }
-                                               // no match found
-                                               System.out.println("No match for XML in " + f.getName());
-                                               System.out.println("XML =" + xmlResult.toString());
-                                               for (Result jsonResult : jsonResponse.getResults()) {
-                                                       System.out.println("JSON="+ jsonResult.toString());
-                                               }
-                                               fail("JSON Response has no match for XML Result: " + xmlResult.toString());
-                                       }
-                                       // we've done the best we can for multiple decisions, so go to next file
-                                       continue;
-                               }
-
-                               // single Result in each
-                               Result xmlResult = xmlResponse.getResults().iterator().next();
-                               Result jsonResult = jsonResponse.getResults().iterator().next();
-
-                               // The following sections have not given us trouble, so checking is very high-level.
-                               // If we see a problem in one of these elements, the single line will need to be replaced with detailed examination of the objects.
-                               assertEquals(f.getName() + " Decision", xmlResult.getDecision(), jsonResult.getDecision());
-                               assertEquals(f.getName() + " Status", xmlResult.getStatus(), jsonResult.getStatus());
-
-                               // Obligations
-                               if (xmlResult.getObligations() != jsonResult.getObligations()) {
-                                       Collection<Obligation> xmlObligations = xmlResult.getObligations();
-                                       Collection<Obligation> jsonObligations = jsonResult.getObligations();
-                                       // if both are null we do not get here
-                                       if (xmlObligations == null || jsonObligations == null) {
-                                               fail(f.getName() + " Obligations has null \nXML="+xmlObligations + "\nJSON="+jsonObligations);
-                                       }
-                                       if (ListUtil.equalsAllowNulls(xmlObligations, jsonObligations) == false) {
-                                               // collections are not equal, so need to examine further
-                                               fail(f.getName() + " Obligation collections not equal\nXML="+xmlObligations + "\nJSON="+jsonObligations);
-                                       }
-                               }
-
-                               // AssociatedAdvice
-                               if (xmlResult.getAssociatedAdvice() != jsonResult.getAssociatedAdvice()) {
-                                       Collection<Advice> xmlAdvice = xmlResult.getAssociatedAdvice();
-                                       Collection<Advice> jsonAdvice = jsonResult.getAssociatedAdvice();
-                                       // if both are null we do not get here
-                                       if (xmlAdvice == null || jsonAdvice == null) {
-                                               fail(f.getName() + " Advice has null \nXML="+xmlAdvice + "\nJSON="+jsonAdvice);
-                                       }
-                                       if (ListUtil.equalsAllowNulls(xmlAdvice, jsonAdvice) == false) {
-                                               // collections are not equal, so need to examine further
-                                               fail(f.getName() + " Advice collections not equal\nXML="+xmlAdvice + "\nJSON="+jsonAdvice);
-                                       }
-                               }
-
-
-
-                               // check Attributes in more detail
-                               Collection<AttributeCategory> xmlAttributes = xmlResult.getAttributes();
-                               Collection<AttributeCategory> jsonAttributes = jsonResult.getAttributes();
-                               if (xmlAttributes == null && jsonAttributes != null || 
-                                               xmlAttributes != null && jsonAttributes == null) {
-                                       fail(f.getName() + " XML Attributes="+xmlAttributes + "  but JSON Attributes=" + jsonAttributes);
-                               }
-                               if (xmlAttributes != null) {
-                                       // both are non-null
-                                       if (xmlAttributes.size() != jsonAttributes.size()) {
-                                               String xmlAttributesString = "XML categorys=";
-                                               for (AttributeCategory ac : xmlAttributes) {
-                                                       xmlAttributesString += " " + ac.getCategory().stringValue();
-                                               }
-                                               String jsonAttributesString = "JSON categorys=";
-                                               for (AttributeCategory ac : jsonAttributes) {
-                                                       jsonAttributesString += " " + ac.getCategory().stringValue();
-                                               }
-                                               fail(f.getName() + " XML and JSON have different number of Category elements: " + xmlAttributesString + ", " + jsonAttributesString);
-                                       }
-
-                                       // Attribute collections are the same size but may be in different orders.
-                                       // for each XML category try to find the corresponding JSON category.
-                                       // ASSUME that each category only shows up once!!!!
-                                       for (AttributeCategory xmlAttributeCategory : xmlAttributes) {
-                                               boolean attributeCategoryFound = false;
-                                               for (AttributeCategory jsonAttributeCategory : jsonAttributes) {
-                                                       if (xmlAttributeCategory.equals(jsonAttributeCategory)) {
-                                                               attributeCategoryFound = true;
-                                                               break;
-                                                       }
-                                                       // not an exact match, but if same CategoryId then need to check individual Attribute objects
-                                                       if (xmlAttributeCategory.getCategory().equals(jsonAttributeCategory.getCategory())) {
-                                                               // same category
-                                                               if (xmlAttributeCategory.getAttributes().size() != jsonAttributeCategory.getAttributes().size()) {
-                                                                       System.out.println("XML =" + xmlAttributeCategory.getAttributes());
-                                                                       System.out.println("JSON=" + jsonAttributeCategory.getAttributes());
-                                                                       fail(f.getName() + " Attributes Category '" + xmlAttributeCategory.getCategory().stringValue() + "' size mismatch; XML="+
-                                                                                       xmlAttributeCategory.getAttributes().size() +", JSON=" + jsonAttributeCategory.getAttributes().size());
-                                                               }
-                                                               for (Attribute xmlAttr : xmlAttributeCategory.getAttributes()) {
-                                                                       boolean attributeFound = false;
-                                                                       for (Attribute jsonAttr : jsonAttributeCategory.getAttributes()) {
-                                                                               if (xmlAttr.equals(jsonAttr)) {
-                                                                                       attributeFound = true;
-                                                                                       break;
-                                                                               }
-                                                                       }
-
-                                                                       if (attributeFound) {
-                                                                               // check next XML attribute
-                                                                               continue;
-                                                                       }
-                                                                       System.out.println("Attribute not found in JSON, Category="+xmlAttributeCategory.getCategory());
-                                                                       System.out.println("XML Attribute ="+ xmlAttr);
-                                                                       System.out.println("JSON Attributes=" + jsonAttributeCategory.toString());
-                                                                       fail(f.getName() + " Attribute not found in JSON, Category=" + xmlAttributeCategory.getCategory() +
-                                                                                       "/nXML Attribute="+xmlAttr+
-                                                                                       "\nJSON Category Attributes="+jsonAttributeCategory.toString());
-                                                               }
-
-
-
-                                                       }
-                                               }
-                                               if (attributeCategoryFound) {
-                                                       continue;
-                                               }
-                                               fail("XML Category not found in JSON; xml="+xmlAttributeCategory.toString());
-                                       }
-
-                               }
-
-                               // PolicyIdentifiers
-                               if (xmlResult.getPolicyIdentifiers() != jsonResult.getPolicyIdentifiers()) {
-                                       Collection<IdReference> xmlIdReferences = xmlResult.getPolicyIdentifiers();
-                                       Collection<IdReference> jsonIdReferences = jsonResult.getPolicyIdentifiers();
-                                       // if both are null we do not get here
-                                       if (xmlIdReferences == null || jsonIdReferences == null) {
-                                               fail(f.getName() + " PolicyIdentifiers has null \nXML="+xmlIdReferences + "\nJSON="+jsonIdReferences);
-                                       }
-                                       if (ListUtil.equalsAllowNulls(xmlIdReferences, jsonIdReferences) == false) {
-                                               // collections are not equal, so need to examine further
-                                               fail(f.getName() + " PolicyIdentifiers collections not equal\nXML="+xmlIdReferences+ "\nJSON="+jsonIdReferences);
-                                       }
-                               }
-
-                               // PolicySetIdentifiers
-                               if (xmlResult.getPolicySetIdentifiers() != jsonResult.getPolicySetIdentifiers()) {
-                                       Collection<IdReference> xmlIdReferences = xmlResult.getPolicySetIdentifiers();
-                                       Collection<IdReference> jsonIdReferences = jsonResult.getPolicySetIdentifiers();
-                                       // if both are null we do not get here
-                                       if (xmlIdReferences == null || jsonIdReferences == null) {
-                                               fail(f.getName() + " PolicySetIdentifiers has null \nXML="+xmlIdReferences + "\nJSON="+jsonIdReferences);
-                                       }
-                                       if (ListUtil.equalsAllowNulls(xmlIdReferences, jsonIdReferences) == false) {
-                                               // collections are not equal, so need to examine further
-                                               fail(f.getName() + " PolicySetIdentifiers collections not equal\nXML="+xmlIdReferences + "\nJSON="+jsonIdReferences);
-                                       }
-                               }
-
-
-                       }                       
-
-               } catch (Exception e) {
-                       fail ("Failed test with '" + currentFile.getName() + "', e=" + e);
-               }
-
-
-       }
-
-       //
-       // HELPER to get list of all Request files in the given directory
-       //
-
-       private List<File> getRequestsInDirectory(File directory) {
-               List<File> fileList = new ArrayList<>();
-
-               File[] fileArray = directory.listFiles();
-               for (File f : fileArray) {
-                       if (f.isDirectory()) {
-                               List<File> subDirList = getRequestsInDirectory(f);
-                               fileList.addAll(subDirList);
-                       }
-                       if (f.getName().endsWith("Response.xml")) {
-                               fileList.add(f);
-                       }
-               }
-               return fileList;
-
-       }
-
-}
-
-
-/*
- * 
-This is a place to copy the really long output from test rigs that need to be manually edited for readability....
-
-
-{"Response":[{"Status":{"StatusCode":{"Value":"urn:oasis:names:tc:xacml:1.0:status:ok"}},"Obligations":[{"Id":"urn:oasis:names:tc:xacml:2.0:conformance-test:IIIA030:obligation-1","AttributeAssignment":[
-{"Value":"assignment1","DataType":"string","AttributeId":"urn:oasis:names:tc:xacml:2.0:conformance-test:IIIA030:assignment1"},
-{"Value":{"Namespaces":[{"Namespace":"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"},{"Namespace":"http://www.w3.org/2001/XMLSchema-instance","Prefix":"xsi"}],
-               "XPathCategory":"urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
-               "XPath":"//md:records/md:record"},
-       "DataType":"xpathExpression",
-       "AttributeId":"urn:oasis:names:tc:xacml:2.0:conformance-test:IIIA030:assignment2"}]}],"Decision":"Permit"}]}
-
-
-
- */
\ No newline at end of file
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/ResponseTest.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/ResponseTest.java
deleted file mode 100644 (file)
index a950c39..0000000
+++ /dev/null
@@ -1,2272 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ECOMP-XACML
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.policy.xacml.test.json;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.math.BigInteger;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-import com.att.research.xacml.api.Attribute;
-import com.att.research.xacml.api.AttributeValue;
-import com.att.research.xacml.api.Decision;
-import com.att.research.xacml.api.Identifier;
-import com.att.research.xacml.api.XACML3;
-import com.att.research.xacml.std.IdentifierImpl;
-import com.att.research.xacml.std.StdAttribute;
-import com.att.research.xacml.std.StdAttributeCategory;
-import com.att.research.xacml.std.StdAttributeValue;
-import com.att.research.xacml.std.StdIdReference;
-import com.att.research.xacml.std.StdMutableAdvice;
-import com.att.research.xacml.std.StdMutableAttribute;
-import com.att.research.xacml.std.StdMutableAttributeAssignment;
-import com.att.research.xacml.std.StdMutableMissingAttributeDetail;
-import com.att.research.xacml.std.StdMutableObligation;
-import com.att.research.xacml.std.StdMutableResponse;
-import com.att.research.xacml.std.StdMutableResult;
-import com.att.research.xacml.std.StdMutableStatus;
-import com.att.research.xacml.std.StdMutableStatusDetail;
-import com.att.research.xacml.std.StdStatusCode;
-import com.att.research.xacml.std.StdVersion;
-import com.att.research.xacml.std.datatypes.DataTypes;
-import com.att.research.xacml.std.datatypes.StringNamespaceContext;
-import com.att.research.xacml.std.datatypes.XPathExpressionWrapper;
-import com.att.research.xacml.std.json.JSONResponse;
-import com.att.research.xacml.std.json.JSONStructureException;
-
-/**
- * Test JSON Responses
- * 
- * TO RUN - use jUnit
- * In Eclipse select this file or the enclosing directory, right-click and select Run As/JUnit Test
- * 
- *
- */
-public class ResponseTest {
-
-       String jsonResponse;
-       
-       StdMutableResponse response;
-       
-       StdMutableResult result;
-       
-       StdMutableStatus status;
-       
-       
-       // Note: Initially test responses without Obligations, Associated Advice, Attributes, or PolicyIdentifier
-       
-       
-       @Test
-       public void testEmptyAndDecisions() {
-               // null response
-               try {
-                       jsonResponse = JSONResponse.toString(null, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // empty response (no Result object)
-               response = new StdMutableResponse();
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // just decision, no status
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // just status (empty), no decision
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();                
-               result.setStatus(status);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // just status (non-empty), no decision
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_OK);
-               result.setStatus(status);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // test other decisions without Status
-               
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.DENY);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Deny\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.NOTAPPLICABLE);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"NotApplicable\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Indeterminate\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.INDETERMINATE_DENY);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Indeterminate{D}\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.INDETERMINATE_DENYPERMIT);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Indeterminate{DP}\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.INDETERMINATE_PERMIT);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Indeterminate{P}\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-
-               
-               // test Multiple Decisions - success
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               response.add(result);
-               StdMutableResult result2 = new StdMutableResult();
-               result2.setDecision(Decision.DENY);
-               response.add(result2);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Permit\"},{\"Decision\":\"Deny\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // test Multiple Decisions - one success and one error
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               response.add(result);
-               result2 = new StdMutableResult();
-               result2.setDecision(Decision.INDETERMINATE);
-               response.add(result2);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Permit\"},{\"Decision\":\"Indeterminate\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-       }
-               
-
-       
-       
-       // Test with every field filled in with multiple values where appropriate
-       @Ignore //@Test
-       public void testAllFieldsResponse() {   
-               
-               // fully-loaded multiple response
-               
-               StdMutableResponse response = new StdMutableResponse();
-               // create a Status object
-               StdMutableStatus status = new StdMutableStatus(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               status.setStatusMessage("some status message");
-               StdMutableStatusDetail statusDetailIn = new StdMutableStatusDetail();
-               StdMutableMissingAttributeDetail mad = new StdMutableMissingAttributeDetail();
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "doh"));
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_INTEGER.getId(), "5432"));
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "meh"));
-               mad.setAttributeId(XACML3.ID_ACTION_PURPOSE);
-               mad.setCategory(XACML3.ID_ATTRIBUTE_CATEGORY_ACTION);
-               mad.setDataTypeId(XACML3.ID_DATATYPE_STRING);
-               mad.setIssuer("an Issuer");
-               statusDetailIn.addMissingAttributeDetail(mad);
-               status.setStatusDetail(statusDetailIn);
-               // create a single result object
-               StdMutableResult result = new StdMutableResult(status);
-               // set the decision
-               result.setDecision(Decision.INDETERMINATE);
-               // put the Result into the Response
-               response.add(result);
-
-               
-               // create a new Result with a different Decision
-               status = new StdMutableStatus(StdStatusCode.STATUS_CODE_OK);
-               result = new StdMutableResult(status);
-               result.setDecision(Decision.DENY);
-               
-               StdMutableObligation obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer2", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Ned")));
-               result.addObligation(obligation);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_SUBJECT_CATEGORY_INTERMEDIARY_SUBJECT);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer3", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Maggie")));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer4", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Homer")));
-               result.addObligation(obligation);
-               
-               
-               StdMutableAdvice advice = new StdMutableAdvice();
-               advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "advice-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu")));
-               advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               null, 
-                               XACML3.ID_SUBJECT, 
-                               "advice-issuerNoCategory", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Crusty")));
-               result.addAdvice(advice);
-               
-               
-               response.add(result);
-               
-               
-               // create a new Result with a different Decision
-               // add Child/minor status codes within the main status
-               StdStatusCode childChildChildStatusCode = new StdStatusCode(new IdentifierImpl("childChildChildStatusCode"));
-               StdStatusCode childChildStatusCode = new StdStatusCode(new IdentifierImpl("childChildStatusCode"), childChildChildStatusCode);
-               StdStatusCode child1StatusCode = new StdStatusCode(new IdentifierImpl("child1StatusCode"), childChildStatusCode);
-               StdStatusCode statusCode = new StdStatusCode(XACML3.ID_STATUS_OK, child1StatusCode);
-               
-               status = new StdMutableStatus(statusCode);
-               
-               
-               result = new StdMutableResult(status);
-               result.setDecision(Decision.PERMIT);
-               
-               
-               
-               
-               // add attribute list in result
-               Identifier categoryIdentifier = new IdentifierImpl("firstCategory");
-               Attribute[] attrList = {
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true),
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent2"), new StdAttributeValue<String>(DataTypes.DT_YEARMONTHDURATION.getId(), "P10Y4M"), "BIssue", false),
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent3"), new StdAttributeValue<Double>(DataTypes.DT_DOUBLE.getId(), 765.432), "CIssue", true),
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent4"), new StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), true), "DIssue", true),
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent5"), new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(4567)), "EIssue", true),
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrNoIssuer"), new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(4567)), null, true) };
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, Arrays.asList(attrList)));
-               categoryIdentifier = new IdentifierImpl("secondCategory");
-               Attribute[] secondAttrList = {
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent12"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu2"), "AIssue2", true),
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent22"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Abc2"), "BIssue2", false),
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent32"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Der2"), "CIssue2", true) };
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, Arrays.asList(secondAttrList)));
-               
-               
-               // add PolicyIdentifierList to result
-               StdIdReference policyIdentifier1 = null;
-               StdIdReference policyIdentifier2 = null;
-               StdIdReference policySetIdentifier1 = null;
-               StdIdReference policySetIdentifier2 = null;
-               try {
-                       policyIdentifier1 = new StdIdReference(new IdentifierImpl("idRef1"), StdVersion.newInstance("1.2.3"));
-                       policyIdentifier2 = new StdIdReference(new IdentifierImpl("idRef2_NoVersion"));
-                       policySetIdentifier1 = new StdIdReference(new IdentifierImpl("idSetRef1"), StdVersion.newInstance("4.5.6.7.8.9.0"));
-                       policySetIdentifier2 = new StdIdReference(new IdentifierImpl("idSetRef2_NoVersion"));
-               } catch (ParseException e1) {
-                       fail("creating policyIds, e="+e1);
-               }
-               
-               result.addPolicyIdentifier(policyIdentifier1);
-               result.addPolicyIdentifier(policyIdentifier2);
-       
-               result.addPolicySetIdentifier(policySetIdentifier1);
-               result.addPolicySetIdentifier(policySetIdentifier2);
-               
-               response.add(result);
-       
-               // convert Response to JSON
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-System.out.println(jsonResponse);
-//System.out.println(JSONResponse.toString(response, true));
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"},\"StatusMessage\":\"some status message\",\"StatusDetail\":\"<MissingAttributeDetail Category=\\\\\\\"urn:oasis:names:tc:xacml:3.0:attribute-category:action\\\\\\\" AttributeId=\\\\\\\"urn:oasis:names:tc:xacml:2.0:action:purpose\\\\\\\" DataType=\\\\\\\"http://www.w3.org/2001/XMLSchema#string\\\\\\\" Issuer=\\\\\\\"an Issuer\\\\\\\"><AttributeValue DataType=\\\\\\\"http://www.w3.org/2001/XMLSchema#string\\\\\\\">doh</AttributeValue><AttributeValue DataType=\\\\\\\"http://www.w3.org/2001/XMLSchema#integer\\\\\\\">5432</AttributeValue><AttributeValue DataType=\\\\\\\"http://www.w3.org/2001/XMLSchema#string\\\\\\\">meh</AttributeValue></MissingAttributeDetail>\"},\"Decision\":\"Indeterminate\"},{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:ok\"}},\"Obligations\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Issuer\":\"obligation-issuer1\",\"Value\":\"Bart\",\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"},{\"Issuer\":\"obligation-issuer2\",\"Value\":\"Ned\",\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]},{\"Id\":\"urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject\",\"AttributeAssignment\":[{\"Issuer\":\"obligation-issuer3\",\"Value\":\"Maggie\",\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"},{\"Issuer\":\"obligation-issuer4\",\"Value\":\"Homer\",\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}],\"Decision\":\"Deny\",\"AssociatedAdvice\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Issuer\":\"advice-issuer1\",\"Value\":\"Apu\",\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"},{\"Issuer\":\"advice-issuerNoCategory\",\"Value\":\"Crusty\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}]},{\"Status\":{\"StatusCode\":{\"StatusCode\":{\"StatusCode\":{\"StatusCode\":{\"Value\":\"childChildChildStatusCode\"},\"Value\":\"childChildStatusCode\"},\"Value\":\"child1StatusCode\"},\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:ok\"}},\"Category\":[{\"CategoryId\":\"firstCategory\",\"Attribute\":[{\"Issuer\":\"AIssue\",\"Value\":\"Apu\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"attrIdent1\"},{\"Issuer\":\"CIssue\",\"Value\":765.432,\"DataType\":\"http://www.w3.org/2001/XMLSchema#double\",\"AttributeId\":\"attrIdent3\"},{\"Issuer\":\"DIssue\",\"Value\":true,\"DataType\":\"http://www.w3.org/2001/XMLSchema#boolean\",\"AttributeId\":\"attrIdent4\"},{\"Issuer\":\"EIssue\",\"Value\":4567,\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"AttributeId\":\"attrIdent5\"},{\"Value\":4567,\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"AttributeId\":\"attrNoIssuer\"}]},{\"CategoryId\":\"secondCategory\",\"Attribute\":[{\"Issuer\":\"AIssue2\",\"Value\":\"Apu2\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"attrIdent12\"},{\"Issuer\":\"CIssue2\",\"Value\":\"Der2\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"attrIdent32\"}]}],\"Decision\":\"Permit\",\"PolicyIdentifier\":{\"PolicyIdReference\":[{\"Id\":\"idRef1\",\"Version\":\"1.2.3\"},{\"Id\":\"idRef2_NoVersion\"}],\"PolicySetIdReference\":[{\"Id\":\"idSetRef1\",\"Version\":\"4.5.6.7.8.9.0\"},{\"Id\":\"idSetRef2_NoVersion\"}]}}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-       }
-       
-       
-       
-       
-       // combinations of Status values with Decision values
-       @Test
-       public void testDecisionStatusMatch() {
-               // the tests in this method use different values and do not change structures, so we can re-use the objects
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               result.setStatus(status);
-               response.add(result);
-               
-               // StatusCode = OK
-               status.setStatusCode(StdStatusCode.STATUS_CODE_OK);
-               result.setDecision(Decision.PERMIT);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:ok\"}},\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.DENY);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:ok\"}},\"Decision\":\"Deny\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.NOTAPPLICABLE);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:ok\"}},\"Decision\":\"NotApplicable\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               result.setDecision(Decision.INDETERMINATE_DENY);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               result.setDecision(Decision.INDETERMINATE_DENYPERMIT);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               result.setDecision(Decision.INDETERMINATE_PERMIT);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               
-               
-               
-               
-               // StatusCode = SyntaxError
-               status.setStatusCode(StdStatusCode.STATUS_CODE_SYNTAX_ERROR);
-               result.setDecision(Decision.PERMIT);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               result.setDecision(Decision.DENY);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               result.setDecision(Decision.NOTAPPLICABLE);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               result.setDecision(Decision.INDETERMINATE);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:syntax-error\"}},\"Decision\":\"Indeterminate\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE_DENY);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:syntax-error\"}},\"Decision\":\"Indeterminate{D}\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE_DENYPERMIT);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:syntax-error\"}},\"Decision\":\"Indeterminate{DP}\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE_PERMIT);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:syntax-error\"}},\"Decision\":\"Indeterminate{P}\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // StatusCode = ProcessingError
-               status.setStatusCode(StdStatusCode.STATUS_CODE_PROCESSING_ERROR);
-               result.setDecision(Decision.PERMIT);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               result.setDecision(Decision.DENY);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               result.setDecision(Decision.NOTAPPLICABLE);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               result.setDecision(Decision.INDETERMINATE);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:processing-error\"}},\"Decision\":\"Indeterminate\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE_DENY);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:processing-error\"}},\"Decision\":\"Indeterminate{D}\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE_DENYPERMIT);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:processing-error\"}},\"Decision\":\"Indeterminate{DP}\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE_PERMIT);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:processing-error\"}},\"Decision\":\"Indeterminate{P}\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               
-               // StatusCode = MissingAttribute
-               status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               result.setDecision(Decision.PERMIT);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               result.setDecision(Decision.DENY);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               result.setDecision(Decision.NOTAPPLICABLE);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               result.setDecision(Decision.INDETERMINATE);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"}},\"Decision\":\"Indeterminate\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE_DENY);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"}},\"Decision\":\"Indeterminate{D}\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE_DENYPERMIT);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"}},\"Decision\":\"Indeterminate{DP}\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               result.setDecision(Decision.INDETERMINATE_PERMIT);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"}},\"Decision\":\"Indeterminate{P}\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-       }
-
-       
-       
-
-       // tests related to Status and its components
-       @Ignore //@Test
-       public void testStatus() {
-               // Status with no StatusCode - error
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               result.setStatus(status);
-               result.setDecision(Decision.PERMIT);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Status with StatusMessage when OK
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_OK);
-               status.setStatusMessage("I'm ok, you're ok");
-               result.setStatus(status);
-               result.setDecision(Decision.PERMIT);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:ok\"},\"StatusMessage\":\"I'm ok, you're ok\"},\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // Status with StatusDetail when OK
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_OK);
-               StdMutableStatusDetail statusDetail = new StdMutableStatusDetail();
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.PERMIT);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Status with StatusMessage when SyntaxError
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_SYNTAX_ERROR);
-               status.setStatusMessage("I'm ok, you're ok");
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:syntax-error\"},\"StatusMessage\":\"I'm ok, you're ok\"},\"Decision\":\"Indeterminate\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // Status with empty StatusDetail when SyntaxError
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_SYNTAX_ERROR);
-               statusDetail = new StdMutableStatusDetail();
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               // Status with StatusMessage when ProcessingError
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_PROCESSING_ERROR);
-               status.setStatusMessage("I'm ok, you're ok");
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:processing-error\"},\"StatusMessage\":\"I'm ok, you're ok\"},\"Decision\":\"Indeterminate\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // Status with empty StatusDetail when ProcessingError
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_PROCESSING_ERROR);
-               statusDetail = new StdMutableStatusDetail();
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-
-               
-               // Status with StatusMessage when MissingAttribute
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               status.setStatusMessage("I'm ok, you're ok");
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"},\"StatusMessage\":\"I'm ok, you're ok\"},\"Decision\":\"Indeterminate\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // Status with empty StatusDetail when MissingAttribute
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               statusDetail = new StdMutableStatusDetail();
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"}},\"Decision\":\"Indeterminate\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               
-               // Status with StatusDetail with empty detail when MissingAttribute
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               statusDetail = new StdMutableStatusDetail();
-               StdMutableMissingAttributeDetail mad = new StdMutableMissingAttributeDetail();
-               statusDetail.addMissingAttributeDetail(mad);
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Status with StatusDetail with valid detail with no value when MissingAttribute
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               statusDetail = new StdMutableStatusDetail();
-               mad = new StdMutableMissingAttributeDetail();
-               mad.setAttributeId(new IdentifierImpl("mad"));
-               mad.setCategory(XACML3.ID_ACTION);
-               mad.setDataTypeId(DataTypes.DT_STRING.getId());
-               statusDetail.addMissingAttributeDetail(mad);
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"},\"StatusDetail\":\"<MissingAttributeDetail Category=\\\\\\\"urn:oasis:names:tc:xacml:1.0:action\\\\\\\" AttributeId=\\\\\\\"mad\\\\\\\" DataType=\\\\\\\"http://www.w3.org/2001/XMLSchema#string\\\\\\\"></MissingAttributeDetail>\"},\"Decision\":\"Indeterminate\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // Status with StatusDetail with valid detail with value when MissingAttribute
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               statusDetail = new StdMutableStatusDetail();
-               mad = new StdMutableMissingAttributeDetail();
-               mad.setAttributeId(new IdentifierImpl("mad"));
-               mad.setCategory(XACML3.ID_ACTION);
-               mad.setDataTypeId(DataTypes.DT_STRING.getId()); 
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "meh"));
-               statusDetail.addMissingAttributeDetail(mad);
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"},\"StatusDetail\":\"<MissingAttributeDetail Category=\\\\\\\"urn:oasis:names:tc:xacml:1.0:action\\\\\\\" AttributeId=\\\\\\\"mad\\\\\\\" DataType=\\\\\\\"http://www.w3.org/2001/XMLSchema#string\\\\\\\"><AttributeValue DataType=\\\\\\\"http://www.w3.org/2001/XMLSchema#string\\\\\\\">meh</AttributeValue></MissingAttributeDetail>\"},\"Decision\":\"Indeterminate\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // Status with StatusDetail with array valid detail with value when MissingAttribute
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               statusDetail = new StdMutableStatusDetail();
-               mad = new StdMutableMissingAttributeDetail();
-               mad.setAttributeId(new IdentifierImpl("mad"));
-               mad.setCategory(XACML3.ID_ACTION);
-               mad.setDataTypeId(DataTypes.DT_STRING.getId()); 
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "meh"));
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "nu?"));
-               statusDetail.addMissingAttributeDetail(mad);
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"},\"StatusDetail\":\"<MissingAttributeDetail Category=\\\\\\\"urn:oasis:names:tc:xacml:1.0:action\\\\\\\" AttributeId=\\\\\\\"mad\\\\\\\" DataType=\\\\\\\"http://www.w3.org/2001/XMLSchema#string\\\\\\\"><AttributeValue DataType=\\\\\\\"http://www.w3.org/2001/XMLSchema#string\\\\\\\">meh</AttributeValue><AttributeValue DataType=\\\\\\\"http://www.w3.org/2001/XMLSchema#string\\\\\\\">nu?</AttributeValue></MissingAttributeDetail>\"},\"Decision\":\"Indeterminate\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // Status with StatusDetail with valid detail with Integer value when MissingAttribute
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               statusDetail = new StdMutableStatusDetail();
-               mad = new StdMutableMissingAttributeDetail();
-               mad.setAttributeId(new IdentifierImpl("mad"));
-               mad.setCategory(XACML3.ID_ACTION);
-               mad.setDataTypeId(DataTypes.DT_INTEGER.getId());        
-               mad.addAttributeValue(new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(1111)));
-               statusDetail.addMissingAttributeDetail(mad);
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-//                     assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"},\"StatusDetail\":\"<MissingAttributeDetail Category=\\\\\\\"urn:oasis:names:tc:xacml:1.0:action\\\\\\\" AttributeId=\\\\\\\"mad\\\\\\\" DataType=\\\\\\\"http://www.w3.org/2001/XMLSchema#string\\\\\\\"><AttributeValue DataType=\\\\\\\"http://www.w3.org/2001/XMLSchema#integer\\\\\\\">1111</AttributeValue></MissingAttributeDetail>\"},\"Decision\":\"Indeterminate\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       java.io.StringWriter sw = new java.io.StringWriter();
-                       java.io.PrintWriter pw = new java.io.PrintWriter(sw);
-                       e.printStackTrace(pw);
-
-
-                       fail("operation failed, e="+e + sw.toString());
-               }
-               
-               // Status with StatusDetail with array valid detail with Integer value when MissingAttribute
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               statusDetail = new StdMutableStatusDetail();
-               mad = new StdMutableMissingAttributeDetail();
-               mad.setAttributeId(new IdentifierImpl("mad"));
-               mad.setCategory(XACML3.ID_ACTION);
-               mad.setDataTypeId(DataTypes.DT_STRING.getId()); 
-               mad.addAttributeValue(new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(1111)));
-               mad.addAttributeValue(new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(2222)));
-               statusDetail.addMissingAttributeDetail(mad);
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"},\"StatusDetail\":\"<MissingAttributeDetail Category=\\\\\\\"urn:oasis:names:tc:xacml:1.0:action\\\\\\\" AttributeId=\\\\\\\"mad\\\\\\\" DataType=\\\\\\\"http://www.w3.org/2001/XMLSchema#string\\\\\\\"><AttributeValue DataType=\\\\\\\"http://www.w3.org/2001/XMLSchema#integer\\\\\\\">1111</AttributeValue><AttributeValue DataType=\\\\\\\"http://www.w3.org/2001/XMLSchema#integer\\\\\\\">2222</AttributeValue></MissingAttributeDetail>\"},\"Decision\":\"Indeterminate\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-//             StringNamespaceContext snc = new StringNamespaceContext();
-//             try {
-//                     snc.add("defaultURI");
-//                     snc.add("md", "referenceForMD");
-//             } catch (Exception e) {
-//                     fail("unable to create NamespaceContext e="+e);
-//             }
-//             XPathExpressionWrapper xpathExpressionWrapper = new XPathExpressionWrapper(snc, "//md:record");
-//
-//TODO - assume that we will never try to pass back an XPathExpression in a MissingAttributeDetail - it doesn't make sense and is unclear how to put into XML
-//             // Status with StatusDetail with valid detail with XPathExpression value when MissingAttribute
-//             response = new StdMutableResponse();
-//             result = new StdMutableResult();
-//             status = new StdMutableStatus();
-//             status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-//             statusDetail = new StdMutableStatusDetail();
-//             mad = new StdMutableMissingAttributeDetail();
-//             mad.setAttributeId(new IdentifierImpl("mad"));
-//             mad.setCategory(XACML3.ID_ACTION);
-//             mad.setDataTypeId(DataTypes.DT_STRING.getId()); 
-//             mad.addAttributeValue(new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper, new IdentifierImpl("xpathCategoryId")));
-//             statusDetail.addMissingAttributeDetail(mad);
-//             status.setStatusDetail(statusDetail);
-//             result.setStatus(status);
-//             result.setDecision(Decision.INDETERMINATE);
-//             response.add(result);
-//             try {
-//                     jsonResponse = JSONResponse.toString(response, false);
-//                     assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"},\"StatusDetail\":\"<AttributeValue>1111</AttributeValue><Category>urn:oasis:names:tc:xacml:1.0:action</Category><AttributeId>mad</AttributeId><DataType>http://www.w3.org/2001/XMLSchema#string</DataType></MissingAttributeDetail>\"},\"Decision\":\"Indeterminate\"}]}", jsonResponse);
-//             } catch (Exception e) {
-//                     fail("operation failed, e="+e);
-//             }
-//             
-//             // Status with StatusDetail with array valid detail with XPathExpression value when MissingAttribute
-//             response = new StdMutableResponse();
-//             result = new StdMutableResult();
-//             status = new StdMutableStatus();
-//             status.setStatusCode(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-//             statusDetail = new StdMutableStatusDetail();
-//             mad = new StdMutableMissingAttributeDetail();
-//             mad.setAttributeId(new IdentifierImpl("mad"));
-//             mad.setCategory(XACML3.ID_ACTION);
-//             mad.setDataTypeId(DataTypes.DT_STRING.getId()); 
-//             mad.addAttributeValue(new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper, new IdentifierImpl("xpathCategoryId1")));
-//             mad.addAttributeValue(new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper, new IdentifierImpl("xpathCategoryId2")));
-//             statusDetail.addMissingAttributeDetail(mad);
-//             status.setStatusDetail(statusDetail);
-//             result.setStatus(status);
-//             result.setDecision(Decision.INDETERMINATE);
-//             response.add(result);
-//             try {
-//                     jsonResponse = JSONResponse.toString(response, false);
-//                     assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:missing-attribute\"},\"StatusDetail\":\"<AttributeValue>1111</AttributeValue><AttributeValue>2222</AttributeValue><Category>urn:oasis:names:tc:xacml:1.0:action</Category><AttributeId>mad</AttributeId><DataType>http://www.w3.org/2001/XMLSchema#string</DataType></MissingAttributeDetail>\"},\"Decision\":\"Indeterminate\"}]}", jsonResponse);
-//             } catch (Exception e) {
-//                     fail("operation failed, e="+e);
-//             }
-               
-//TODO - try with other data types, esp XPathExpression                
-               
-               // Status with StatusDetail with array valid detail with value when SyntaxError
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_SYNTAX_ERROR);
-               statusDetail = new StdMutableStatusDetail();
-               mad = new StdMutableMissingAttributeDetail();
-               mad.setAttributeId(new IdentifierImpl("mad"));
-               mad.setCategory(XACML3.ID_ACTION);
-               mad.setDataTypeId(DataTypes.DT_STRING.getId()); 
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "meh"));
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "nu?"));
-               statusDetail.addMissingAttributeDetail(mad);
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Status with StatusDetail with array valid detail with value when ProcessingError
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               status.setStatusCode(StdStatusCode.STATUS_CODE_PROCESSING_ERROR);
-               statusDetail = new StdMutableStatusDetail();
-               mad = new StdMutableMissingAttributeDetail();
-               mad.setAttributeId(new IdentifierImpl("mad"));
-               mad.setCategory(XACML3.ID_ACTION);
-               mad.setDataTypeId(DataTypes.DT_STRING.getId()); 
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "meh"));
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "nu?"));
-               statusDetail.addMissingAttributeDetail(mad);
-               status.setStatusDetail(statusDetail);
-               result.setStatus(status);
-               result.setDecision(Decision.INDETERMINATE);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               
-               // Status with nested child StatusCodes (child status containing child status containing...)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               StdStatusCode child1StatusCode = new StdStatusCode(new IdentifierImpl("child1StatusCode"));
-               StdStatusCode statusCode = new StdStatusCode(XACML3.ID_STATUS_OK, child1StatusCode);
-               status = new StdMutableStatus(statusCode);
-               status.setStatusMessage("I'm ok, you're ok");
-               result.setStatus(status);
-               result.setDecision(Decision.PERMIT);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"StatusCode\":{\"Value\":\"child1StatusCode\"},\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:ok\"},\"StatusMessage\":\"I'm ok, you're ok\"},\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               status = new StdMutableStatus();
-               StdStatusCode childChildChildStatusCode = new StdStatusCode(new IdentifierImpl("childChildChildStatusCode"));
-               StdStatusCode childChildStatusCode = new StdStatusCode(new IdentifierImpl("childChildStatusCode"), childChildChildStatusCode);
-               child1StatusCode = new StdStatusCode(new IdentifierImpl("child1StatusCode"), childChildStatusCode);
-               statusCode = new StdStatusCode(XACML3.ID_STATUS_OK, child1StatusCode);
-               status = new StdMutableStatus(statusCode);
-               status.setStatusMessage("I'm ok, you're ok");
-               result.setStatus(status);
-               result.setDecision(Decision.PERMIT);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Status\":{\"StatusCode\":{\"StatusCode\":{\"StatusCode\":{\"StatusCode\":{\"Value\":\"childChildChildStatusCode\"},\"Value\":\"childChildStatusCode\"},\"Value\":\"child1StatusCode\"},\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:ok\"},\"StatusMessage\":\"I'm ok, you're ok\"},\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-
-       }
-
-
-       
-       @Ignore //@Test
-       public void testObligations() {
-               
-               // create an XPathExpression for use later
-               StringNamespaceContext snc = new StringNamespaceContext();
-               try {
-                       snc.add("defaultURI");
-                       snc.add("md", "referenceForMD");
-               } catch (Exception e) {
-                       fail("unable to create NamespaceContext e="+e);
-               }
-               XPathExpressionWrapper xpathExpressionWrapper = new XPathExpressionWrapper(snc, "//md:record");
-               XPathExpressionWrapper xpathExpressionWrapper2 = new XPathExpressionWrapper(snc, "//md:hospital");
-               
-               StdMutableObligation obligation;
-
-               // test Obligation single decision no attributes
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Obligations\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // obligation missing Id
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               
-               //      AttributeAssignment     - with AttributeId, Value,  Category, DataType, Issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Obligations\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Issuer\":\"obligation-issuer1\",\"Value\":\"Bart\",\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               //      AttributeAssignment     - with AttributeId, Value, no Category, DataType, Issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               null, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Obligations\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Issuer\":\"obligation-issuer1\",\"Value\":\"Bart\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               //      AttributeAssignment     - Missing AttributeId
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               null, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               //      AttributeAssignment     - Missing Value
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               null));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Obligations\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Issuer\":\"obligation-issuer1\",\"Value\":\"\",\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // AttributeAssignment - missing DataType
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<String>(null, "Bart")));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Obligations\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Issuer\":\"obligation-issuer1\",\"Value\":\"Bart\",\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // AttributeAssignment - missing issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Obligations\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Value\":\"Bart\",\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // AttributeAssignment - Integer type
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(1111))));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Obligations\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Value\":1111,\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // AttributeAssignment - XPathExpression type
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper, new IdentifierImpl("SimpleXPathCategory"))));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Obligations\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Value\":{\"Namespaces\":[{\"Namespace\":\"referenceForMD\",\"Prefix\":\"md\"},{\"Namespace\":\"defaultURI\"}],\"XPathCategory\":\"SimpleXPathCategory\",\"XPath\":\"//md:record\"},\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               
-
-               //
-               // Technically arrays cannot occur in Obligations and Advice elements.  The XML spec boils down to the following definition:
-               //              <Obligation (attributes of the obligation) >
-               //                      <AttributeAssignment (attributes of this assignment) >value</AttributeAssignment>
-               //                      <AttributeAssignment (attributes of this assignment) >value</AttributeAssignment>
-               //                      :
-               //              </Obligation
-               //      which means that there may be multiple AttributeAssignments but each one has only one value.
-               //      This differs from the Attributes section in which each <Attribute> may have multiple <AttributeValue> elements.
-               // For Obligations and Advice we can simulate an array by having multiple AttributeAssignment elements with the same Category, Id and Issuer.
-               //
-
-               
-               //      AttributeAssignment     - Multiple values with same Category and Id (one way of doing array)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Lisa")));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Maggie")));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Obligations\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Issuer\":\"obligation-issuer1\",\"Value\":\"Bart\",\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"},{\"Issuer\":\"obligation-issuer1\",\"Value\":\"Lisa\",\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"},{\"Issuer\":\"obligation-issuer1\",\"Value\":\"Maggie\",\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               //      AttributeAssignment     - Multiple Integer values with same Category and Id (one way of doing array)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(1111))));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(2222))));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(3333))));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Obligations\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Issuer\":\"obligation-issuer1\",\"Value\":1111,\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"},{\"Issuer\":\"obligation-issuer1\",\"Value\":2222,\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"},{\"Issuer\":\"obligation-issuer1\",\"Value\":3333,\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // Multiple XPathExpression values with same Category and Id (one way of doing array)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper, new IdentifierImpl("SimpleXPathCategory"))));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper2, new IdentifierImpl("SimpleXPathCategory"))));
-               result.addObligation(obligation);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Obligations\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Value\":{\"Namespaces\":[{\"Namespace\":\"referenceForMD\",\"Prefix\":\"md\"},{\"Namespace\":\"defaultURI\"}],\"XPathCategory\":\"SimpleXPathCategory\",\"XPath\":\"//md:record\"},\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"},{\"Value\":{\"Namespaces\":[{\"Namespace\":\"referenceForMD\",\"Prefix\":\"md\"},{\"Namespace\":\"defaultURI\"}],\"XPathCategory\":\"SimpleXPathCategory\",\"XPath\":\"//md:hospital\"},\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }       
-               
-       }
-       
-       
-       
-       
-       @Ignore //@Test
-       public void testAdvice() {
-               
-               // create an XPathExpression for use later
-               StringNamespaceContext snc = new StringNamespaceContext();
-               try {
-                       snc.add("defaultURI");
-                       snc.add("md", "referenceForMD");
-               } catch (Exception e) {
-                       fail("unable to create NamespaceContext e="+e);
-               }
-               XPathExpressionWrapper xpathExpressionWrapper = new XPathExpressionWrapper(snc, "//md:record");
-               XPathExpressionWrapper xpathExpressionWrapper2 = new XPathExpressionWrapper(snc, "//md:hospital");
-               
-               StdMutableAdvice Advice;
-
-               // test Advice single decision no attributes
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Permit\",\"AssociatedAdvice\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\"}]}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // Advice missing Id
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               
-               
-               //      AttributeAssignment     - with AttributeId, Value,  Category, DataType, Issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Permit\",\"AssociatedAdvice\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Issuer\":\"Advice-issuer1\",\"Value\":\"Bart\",\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}]}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               //      AttributeAssignment     - with AttributeId, Value, no Category, DataType, Issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               null, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Permit\",\"AssociatedAdvice\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Issuer\":\"Advice-issuer1\",\"Value\":\"Bart\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}]}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               //      AttributeAssignment     - Missing AttributeId
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               null, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               //      AttributeAssignment     - Missing Value
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               null));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Permit\",\"AssociatedAdvice\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Issuer\":\"Advice-issuer1\",\"Value\":\"\",\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}]}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // AttributeAssignment - missing DataType
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<String>(null, "Bart")));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Permit\",\"AssociatedAdvice\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Issuer\":\"Advice-issuer1\",\"Value\":\"Bart\",\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}]}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // AttributeAssignment - missing issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Permit\",\"AssociatedAdvice\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Value\":\"Bart\",\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}]}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // AttributeAssignment - Integer type
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(1111))));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Permit\",\"AssociatedAdvice\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Value\":1111,\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}]}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // AttributeAssignment - XPathExpression type
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper, new IdentifierImpl("SimpleXPathCategory"))));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Permit\",\"AssociatedAdvice\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Value\":{\"Namespaces\":[{\"Namespace\":\"referenceForMD\",\"Prefix\":\"md\"},{\"Namespace\":\"defaultURI\"}],\"XPathCategory\":\"SimpleXPathCategory\",\"XPath\":\"//md:record\"},\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}]}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               
-
-               //
-               // Technically arrays cannot occur in Obligations and Advice elements.  The XML spec boils down to the following definition:
-               //              <Obligation (attributes of the obligation) >
-               //                      <AttributeAssignment (attributes of this assignment) >value</AttributeAssignment>
-               //                      <AttributeAssignment (attributes of this assignment) >value</AttributeAssignment>
-               //                      :
-               //              </Obligation
-               //      which means that there may be multiple AttributeAssignments but each one has only one value.
-               //      This differs from the Attributes section in which each <Attribute> may have multiple <AttributeValue> elements.
-               // For Obligations and Advice we can simulate an array by having multiple AttributeAssignment elements with the same Category, Id and Issuer.
-               //
-               
-               //      AttributeAssignment     - Multiple values with same Category and Id (one way of doing array)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart")));
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Lisa")));
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Maggie")));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Permit\",\"AssociatedAdvice\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Issuer\":\"Advice-issuer1\",\"Value\":\"Bart\",\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"},{\"Issuer\":\"Advice-issuer1\",\"Value\":\"Lisa\",\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"},{\"Issuer\":\"Advice-issuer1\",\"Value\":\"Maggie\",\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}]}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               //      AttributeAssignment     - Multiple Integer values with same Category and Id (one way of doing array)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(1111))));
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(2222))));
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "Advice-issuer1", 
-                               new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(3333))));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Permit\",\"AssociatedAdvice\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Issuer\":\"Advice-issuer1\",\"Value\":1111,\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"},{\"Issuer\":\"Advice-issuer1\",\"Value\":2222,\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"},{\"Issuer\":\"Advice-issuer1\",\"Value\":3333,\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}]}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // Multiple XPathExpression values with same Category and Id (one way of doing array)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               Advice = new StdMutableAdvice();
-               Advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper, new IdentifierImpl("SimpleXPathCategory"))));
-               Advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               null, 
-                               new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper2, new IdentifierImpl("SimpleXPathCategory"))));
-               result.addAdvice(Advice);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Permit\",\"AssociatedAdvice\":[{\"Id\":\"urn:oasis:names:tc:xacml:1.0:action:implied-action\",\"AttributeAssignment\":[{\"Value\":{\"Namespaces\":[{\"Namespace\":\"referenceForMD\",\"Prefix\":\"md\"},{\"Namespace\":\"defaultURI\"}],\"XPathCategory\":\"SimpleXPathCategory\",\"XPath\":\"//md:record\"},\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"},{\"Value\":{\"Namespaces\":[{\"Namespace\":\"referenceForMD\",\"Prefix\":\"md\"},{\"Namespace\":\"defaultURI\"}],\"XPathCategory\":\"SimpleXPathCategory\",\"XPath\":\"//md:hospital\"},\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"DataType\":\"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\",\"AttributeId\":\"urn:oasis:names:tc:xacml:1.0:subject\"}]}]}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-       }
-       
-       
-       
-       
-       
-
-       
-       
-
-       
-       // Attributes tests
-       @Ignore //@Test
-       public void testAttributes() {
-               
-               // create an XPathExpression for use later
-               StringNamespaceContext snc = new StringNamespaceContext();
-               try {
-                       snc.add("defaultURI");
-                       snc.add("md", "referenceForMD");
-               } catch (Exception e) {
-                       fail("unable to create NamespaceContext e="+e);
-               }
-               XPathExpressionWrapper xpathExpressionWrapper = new XPathExpressionWrapper(snc, "//md:record");
-               
-               
-               Identifier categoryIdentifier;
-               List<Attribute> attrList = new ArrayList<Attribute>();
-               StdMutableAttribute mutableAttribute;
-               
-               // Attr list with no entries
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Category\":[{\"CategoryId\":\"firstCategory\",\"Attribute\":[]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // one Attribute
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Category\":[{\"CategoryId\":\"firstCategory\",\"Attribute\":[{\"Issuer\":\"AIssue\",\"Value\":\"Apu\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"attrIdent1\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // multiple attributes
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent2"), new StdAttributeValue<String>(DataTypes.DT_YEARMONTHDURATION.getId(), "P10Y4M"), "BIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent3"), new StdAttributeValue<Double>(DataTypes.DT_DOUBLE.getId(), 765.432), "CIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent4"), new StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), true), "DIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent5"), new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(4567)), "EIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Category\":[{\"CategoryId\":\"firstCategory\",\"Attribute\":[{\"Issuer\":\"AIssue\",\"Value\":\"Apu\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"attrIdent1\"},{\"Issuer\":\"BIssue\",\"Value\":\"P10Y4M\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#yearMonthDuration\",\"AttributeId\":\"attrIdent2\"},{\"Issuer\":\"CIssue\",\"Value\":765.432,\"DataType\":\"http://www.w3.org/2001/XMLSchema#double\",\"AttributeId\":\"attrIdent3\"},{\"Issuer\":\"DIssue\",\"Value\":true,\"DataType\":\"http://www.w3.org/2001/XMLSchema#boolean\",\"AttributeId\":\"attrIdent4\"},{\"Issuer\":\"EIssue\",\"Value\":4567,\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"AttributeId\":\"attrIdent5\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // IncludeInResult=false/true
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", false));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Category\":[{\"CategoryId\":\"firstCategory\",\"Attribute\":[]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // Missing AttributeId (mandatory)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                               attrList.add(new StdAttribute(categoryIdentifier, null, new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Missing mandatory Value
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), null), "AIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // Missing optional Issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), null, true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Category\":[{\"CategoryId\":\"firstCategory\",\"Attribute\":[{\"Value\":\"Apu\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"attrIdent1\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // missing optional DataType
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(null, "Apu"), "AIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Category\":[{\"CategoryId\":\"firstCategory\",\"Attribute\":[{\"Issuer\":\"AIssue\",\"Value\":\"Apu\",\"AttributeId\":\"attrIdent1\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // same id, same type different issuer
-               // (This is not an array of values because issuer is different)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart"), "BIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Simpson"), "CIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Category\":[{\"CategoryId\":\"firstCategory\",\"Attribute\":[{\"Issuer\":\"AIssue\",\"Value\":\"Apu\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"attrIdent1\"},{\"Issuer\":\"BIssue\",\"Value\":\"Bart\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"attrIdent1\"},{\"Issuer\":\"CIssue\",\"Value\":\"Simpson\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"attrIdent1\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // same id, same type different issuer
-               // (This is effectively an array of values, but we return them as separate values to the client)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart"), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Simpson"), "AIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Category\":[{\"CategoryId\":\"firstCategory\",\"Attribute\":[{\"Issuer\":\"AIssue\",\"Value\":\"Apu\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"attrIdent1\"},{\"Issuer\":\"AIssue\",\"Value\":\"Bart\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"attrIdent1\"},{\"Issuer\":\"AIssue\",\"Value\":\"Simpson\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"attrIdent1\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // same Id, different types, same issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_YEARMONTHDURATION.getId(), "P10Y4M"), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<Double>(DataTypes.DT_DOUBLE.getId(), 765.432), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), true), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(4567)), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(4567)), "AIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Category\":[{\"CategoryId\":\"firstCategory\",\"Attribute\":[{\"Issuer\":\"AIssue\",\"Value\":\"Apu\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"attrIdent1\"},{\"Issuer\":\"AIssue\",\"Value\":\"P10Y4M\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#yearMonthDuration\",\"AttributeId\":\"attrIdent1\"},{\"Issuer\":\"AIssue\",\"Value\":765.432,\"DataType\":\"http://www.w3.org/2001/XMLSchema#double\",\"AttributeId\":\"attrIdent1\"},{\"Issuer\":\"AIssue\",\"Value\":true,\"DataType\":\"http://www.w3.org/2001/XMLSchema#boolean\",\"AttributeId\":\"attrIdent1\"},{\"Issuer\":\"AIssue\",\"Value\":4567,\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"AttributeId\":\"attrIdent1\"},{\"Issuer\":\"AIssue\",\"Value\":4567,\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"AttributeId\":\"attrIdent1\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               // same Id, different types, different issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_YEARMONTHDURATION.getId(), "P10Y4M"), "BIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<Double>(DataTypes.DT_DOUBLE.getId(), 765.432), "CIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), true), "DIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(4567)), "EIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(4567)), null, true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Category\":[{\"CategoryId\":\"firstCategory\",\"Attribute\":[{\"Issuer\":\"AIssue\",\"Value\":\"Apu\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"attrIdent1\"},{\"Issuer\":\"BIssue\",\"Value\":\"P10Y4M\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#yearMonthDuration\",\"AttributeId\":\"attrIdent1\"},{\"Issuer\":\"CIssue\",\"Value\":765.432,\"DataType\":\"http://www.w3.org/2001/XMLSchema#double\",\"AttributeId\":\"attrIdent1\"},{\"Issuer\":\"DIssue\",\"Value\":true,\"DataType\":\"http://www.w3.org/2001/XMLSchema#boolean\",\"AttributeId\":\"attrIdent1\"},{\"Issuer\":\"EIssue\",\"Value\":4567,\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"AttributeId\":\"attrIdent1\"},{\"Value\":4567,\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"AttributeId\":\"attrIdent1\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-
-               // different Id, different types, same issuer
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent2"), new StdAttributeValue<String>(DataTypes.DT_YEARMONTHDURATION.getId(), "AIssue"), "BIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent3"), new StdAttributeValue<Double>(DataTypes.DT_DOUBLE.getId(), 765.432), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent4"), new StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), true), "AIssue", true));
-                       attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent5"), new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(4567)), "AIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Category\":[{\"CategoryId\":\"firstCategory\",\"Attribute\":[{\"Issuer\":\"AIssue\",\"Value\":\"Apu\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"attrIdent1\"},{\"Issuer\":\"BIssue\",\"Value\":\"AIssue\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#yearMonthDuration\",\"AttributeId\":\"attrIdent2\"},{\"Issuer\":\"AIssue\",\"Value\":765.432,\"DataType\":\"http://www.w3.org/2001/XMLSchema#double\",\"AttributeId\":\"attrIdent3\"},{\"Issuer\":\"AIssue\",\"Value\":true,\"DataType\":\"http://www.w3.org/2001/XMLSchema#boolean\",\"AttributeId\":\"attrIdent4\"},{\"Issuer\":\"AIssue\",\"Value\":4567,\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"AttributeId\":\"attrIdent5\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // one Attribute of type XPathExpression (the only complex data type)
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-                               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<XPathExpressionWrapper>(DataTypes.DT_XPATHEXPRESSION.getId(), xpathExpressionWrapper, new IdentifierImpl("xpathCategory")), "AIssue", true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Category\":[{\"CategoryId\":\"firstCategory\",\"Attribute\":[{\"Issuer\":\"AIssue\",\"Value\":{\"Namespaces\":[{\"Namespace\":\"referenceForMD\",\"Prefix\":\"md\"},{\"Namespace\":\"defaultURI\"}],\"XPathCategory\":\"xpathCategory\",\"XPath\":\"//md:record\"},\"DataType\":\"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\",\"AttributeId\":\"attrIdent1\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // multiple sets of values
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               attrList.clear();
-               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"), "AIssue", true));
-               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent2"), new StdAttributeValue<String>(DataTypes.DT_YEARMONTHDURATION.getId(), "P10Y4M"), "BIssue", false));
-               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent3"), new StdAttributeValue<Double>(DataTypes.DT_DOUBLE.getId(), 765.432), "CIssue", true));
-               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent4"), new StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), true), "DIssue", true));
-               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent5"), new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(4567)), "EIssue", true));
-               attrList.add(new StdAttribute(categoryIdentifier, new IdentifierImpl("attrNoIssuer"), new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(4567)), null, true));
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               categoryIdentifier = new IdentifierImpl("secondCategory");
-               Attribute[] secondAttrList = {
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent12"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu2"), "AIssue2", true),
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent22"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Abc2"), "BIssue2", false),
-                               new StdAttribute(categoryIdentifier, new IdentifierImpl("attrIdent32"), new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Der2"), "CIssue2", true) };
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, Arrays.asList(secondAttrList)));
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Category\":[{\"CategoryId\":\"firstCategory\",\"Attribute\":[{\"Issuer\":\"AIssue\",\"Value\":\"Apu\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"attrIdent1\"},{\"Issuer\":\"CIssue\",\"Value\":765.432,\"DataType\":\"http://www.w3.org/2001/XMLSchema#double\",\"AttributeId\":\"attrIdent3\"},{\"Issuer\":\"DIssue\",\"Value\":true,\"DataType\":\"http://www.w3.org/2001/XMLSchema#boolean\",\"AttributeId\":\"attrIdent4\"},{\"Issuer\":\"EIssue\",\"Value\":4567,\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"AttributeId\":\"attrIdent5\"},{\"Value\":4567,\"DataType\":\"http://www.w3.org/2001/XMLSchema#integer\",\"AttributeId\":\"attrNoIssuer\"}]},{\"CategoryId\":\"secondCategory\",\"Attribute\":[{\"Issuer\":\"AIssue2\",\"Value\":\"Apu2\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"attrIdent12\"},{\"Issuer\":\"CIssue2\",\"Value\":\"Der2\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"attrIdent32\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // array of values - same type
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               attrList.clear();
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               mutableAttribute = new StdMutableAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), (Collection<AttributeValue<?>>)null, "AIssue", true);
-
-                       mutableAttribute.addValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"));
-                       mutableAttribute.addValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Bart"));
-                       mutableAttribute.addValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Homer"));
-                       mutableAttribute.addValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Ned"));
-                       
-               attrList.add(mutableAttribute);
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Category\":[{\"CategoryId\":\"firstCategory\",\"Attribute\":[{\"Issuer\":\"AIssue\",\"Value\":[\"Apu\",\"Bart\",\"Homer\",\"Ned\"],\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\",\"AttributeId\":\"attrIdent1\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // array of values - compatible different types
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               attrList.clear();
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               mutableAttribute = new StdMutableAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), (Collection<AttributeValue<?>>)null, "AIssue", true);
-
-                       mutableAttribute.addValue(new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(4567)));
-                       mutableAttribute.addValue(new StdAttributeValue<Double>(DataTypes.DT_DOUBLE.getId(), 765.432));
-                       mutableAttribute.addValue(new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(4567)));
-               attrList.add(mutableAttribute);
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Category\":[{\"CategoryId\":\"firstCategory\",\"Attribute\":[{\"Issuer\":\"AIssue\",\"Value\":[4567,765.432,4567],\"DataType\":\"http://www.w3.org/2001/XMLSchema#double\",\"AttributeId\":\"attrIdent1\"}]}],\"Decision\":\"Permit\"}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // array of values - incompatible different types
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               attrList.clear();
-               categoryIdentifier = new IdentifierImpl("firstCategory");
-               mutableAttribute = new StdMutableAttribute(categoryIdentifier, new IdentifierImpl("attrIdent1"), (Collection<AttributeValue<?>>)null, "AIssue", true);
-
-                       mutableAttribute.addValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Apu"));
-                       mutableAttribute.addValue(new StdAttributeValue<String>(DataTypes.DT_YEARMONTHDURATION.getId(), "P10Y4M"));
-                       mutableAttribute.addValue(new StdAttributeValue<Double>(DataTypes.DT_DOUBLE.getId(), 765.432));
-                       mutableAttribute.addValue(new StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), true));
-                       mutableAttribute.addValue(new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(4567)));
-                       mutableAttribute.addValue(new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), BigInteger.valueOf(4567)));
-               attrList.add(mutableAttribute);
-               result.addAttributeCategory(new StdAttributeCategory(categoryIdentifier, attrList));
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-       }
-       
-       
-       
-       
-       
-       // PolicyIdentifier tests
-       @Ignore //@Test
-       public void testPolicyIdentifier() {
-               
-               StdIdReference policyIdentifier1 = null;
-               StdIdReference policyIdentifier2 = null;
-               StdIdReference policySetIdentifier1 = null;
-               StdIdReference policySetIdentifier2 = null;
-               
-               // multiple PolicyIdentifiers of both types
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               try {
-                       policyIdentifier1 = new StdIdReference(new IdentifierImpl("idRef1"), StdVersion.newInstance("1.2.3"));
-                       policyIdentifier2 = new StdIdReference(new IdentifierImpl("idRef2_NoVersion"));
-                       policySetIdentifier1 = new StdIdReference(new IdentifierImpl("idSetRef1"), StdVersion.newInstance("4.5.6.7.8.9.0"));
-                       policySetIdentifier2 = new StdIdReference(new IdentifierImpl("idSetRef2_NoVersion"));
-               } catch (ParseException e1) {
-                       fail("creating policyIds, e="+e1);
-               }
-               result.addPolicyIdentifier(policyIdentifier1);
-               result.addPolicyIdentifier(policyIdentifier2);
-               result.addPolicySetIdentifier(policySetIdentifier1);
-               result.addPolicySetIdentifier(policySetIdentifier2);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Permit\",\"PolicyIdentifier\":{\"PolicyIdReference\":[{\"Id\":\"idRef1\",\"Version\":\"1.2.3\"},{\"Id\":\"idRef2_NoVersion\"}],\"PolicySetIdReference\":[{\"Id\":\"idSetRef1\",\"Version\":\"4.5.6.7.8.9.0\"},{\"Id\":\"idSetRef2_NoVersion\"}]}}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // PolicyIdentifier exists but has no IdReferences
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               policyIdentifier1 = null;
-               result.addPolicyIdentifier(policyIdentifier1);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // PolicySetIdentifier exists but has not IdReferences
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               policySetIdentifier1 = null;
-               result.addPolicyIdentifier(policySetIdentifier1);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       fail("Operation should throw exception");
-               } catch (JSONStructureException e) {
-                       // correct response
-               } catch (Exception e) {
-                       fail ("Failed convert from JSON to object: " + e);
-               }
-               
-               // PolicyIdentifier with PolicyIdReference and no PolicySetIdReference
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               try {
-                       policyIdentifier1 = new StdIdReference(new IdentifierImpl("idRef1"), StdVersion.newInstance("1.2.3"));
-               } catch (ParseException e1) {
-                       fail("creating policyIds, e="+e1);
-               }
-               result.addPolicyIdentifier(policyIdentifier1);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Permit\",\"PolicyIdentifier\":{\"PolicyIdReference\":[{\"Id\":\"idRef1\",\"Version\":\"1.2.3\"}]}}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               
-               // PolicyIdentifier with no PolicyIdReference and with PolicySetIdReference
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-               try {
-                       policySetIdentifier1 = new StdIdReference(new IdentifierImpl("idSetRef1"), StdVersion.newInstance("4.5.6.7.8.9.0"));
-               } catch (ParseException e1) {
-                       fail("creating policyIds, e="+e1);
-               }
-               result.addPolicySetIdentifier(policySetIdentifier1);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Permit\",\"PolicyIdentifier\":{\"PolicySetIdReference\":[{\"Id\":\"idSetRef1\",\"Version\":\"4.5.6.7.8.9.0\"}]}}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-               
-               
-               // IdReferences without version
-               response = new StdMutableResponse();
-               result = new StdMutableResult();
-               result.setDecision(Decision.PERMIT);
-
-                       policyIdentifier1 = new StdIdReference(new IdentifierImpl("idRef1"), null);
-                       policyIdentifier2 = new StdIdReference(new IdentifierImpl("idRef2_NoVersion"));
-                       policySetIdentifier1 = new StdIdReference(new IdentifierImpl("idSetRef1"));
-                       policySetIdentifier2 = new StdIdReference(new IdentifierImpl("idSetRef2_NoVersion"));
-
-               result.addPolicyIdentifier(policyIdentifier1);
-               result.addPolicyIdentifier(policyIdentifier2);
-               result.addPolicySetIdentifier(policySetIdentifier1);
-               result.addPolicySetIdentifier(policySetIdentifier2);
-               response.add(result);
-               try {
-                       jsonResponse = JSONResponse.toString(response, false);
-                       assertEquals("{\"Response\":[{\"Decision\":\"Permit\",\"PolicyIdentifier\":{\"PolicyIdReference\":[{\"Id\":\"idRef1\"},{\"Id\":\"idRef2_NoVersion\"}],\"PolicySetIdReference\":[{\"Id\":\"idSetRef1\"},{\"Id\":\"idSetRef2_NoVersion\"}]}}]}", jsonResponse);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-       }       
-}
\ No newline at end of file
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/std/pap/StdEngineFactoryTest.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/std/pap/StdEngineFactoryTest.java
new file mode 100644 (file)
index 0000000..3c1a338
--- /dev/null
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP-XACML
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.policy.xacml.test.std.pap;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.openecomp.policy.xacml.std.pap.StdEngineFactory;
+
+import com.att.research.xacml.api.pap.PAPException;
+import com.att.research.xacml.util.FactoryException;
+
+public class StdEngineFactoryTest {
+
+
+       @Test
+       public void testStdEngineFactory() throws FactoryException, PAPException, IOException{
+               
+               StdEngineFactory stdFactory = new StdEngineFactory();
+               System.setProperty("xacml.pap.pdps", "src/test/resources/pdps");
+               assertTrue(stdFactory.newEngine() != null);
+               Properties properties = new Properties();
+               properties.setProperty("xacml.pap.pdps", "src/test/resources/pdps");
+               assertTrue(stdFactory.newEngine(properties) != null);
+               
+               StdEngineFactory stdFactoryNew = new StdEngineFactory();
+               System.setProperty("xacml.pap.pdps", "src/test/resources/pdpstest");
+               assertTrue(stdFactoryNew.newEngine() != null);
+
+       }
+}
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/util/AAFEngineTest.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/util/AAFEngineTest.java
new file mode 100644 (file)
index 0000000..a7f7817
--- /dev/null
@@ -0,0 +1,24 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP-XACML
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.policy.xacml.test.util;
+
+public class AAFEngineTest {
+
+}
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/util/MetricsUtilTest.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/util/MetricsUtilTest.java
new file mode 100644 (file)
index 0000000..1c48d0c
--- /dev/null
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP-XACML
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.policy.xacml.test.util;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.openecomp.policy.xacml.util.MetricsUtil;
+
+public class MetricsUtilTest {
+       
+       @Test
+       public void metricsUtilTest(){
+               MetricsUtil.AvgLatency avgLatency = new MetricsUtil.AvgLatency();
+               avgLatency.compute(0);
+               assertTrue(avgLatency.avg() == 0);
+               avgLatency.compute(2);
+               assertTrue(avgLatency.avg() == 1);
+               avgLatency.reset();
+               assertTrue(avgLatency.avg() == 0);
+               
+               MetricsUtil.MaxLatency maxLatency = new MetricsUtil.MaxLatency();
+               maxLatency.compute(2);
+               assertTrue(maxLatency.max() == 2);
+               maxLatency.reset();
+               assertTrue(maxLatency.max() < 0);
+               
+               MetricsUtil.MinLatency minLatency = new MetricsUtil.MinLatency();
+               minLatency.compute(2);
+               assertTrue(minLatency.min() == 2);
+               minLatency.reset();
+               assertTrue(minLatency.min() > 0);
+       }
+
+}
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/util/XACMLPolicyScannerTest.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/util/XACMLPolicyScannerTest.java
new file mode 100644 (file)
index 0000000..b7a12da
--- /dev/null
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP-XACML
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.policy.xacml.test.util;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.policy.xacml.util.XACMLPolicyScanner;
+
+import com.att.research.xacml.util.XACMLPolicyScanner.Callback;
+
+public class XACMLPolicyScannerTest {
+
+       private static final Log logger                         = LogFactory.getLog(XACMLPolicyScannerTest.class);
+       private static Path configPolicyPathValue;
+       private static Path actionPolicyPathValue;
+       
+       @Before
+       public void setUp() {
+               File templateFile;
+               ClassLoader classLoader = getClass().getClassLoader();
+        try {
+               templateFile = new File(classLoader.getResource("Config_SampleTest1206.1.xml").getFile());
+               configPolicyPathValue = templateFile.toPath();
+               templateFile = new File(classLoader.getResource("Action_TestActionPolicy.1.xml").getFile());
+               actionPolicyPathValue = templateFile.toPath();
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+               }
+       }
+       
+       @Test
+       public void xacmlPolicyScannerTest() throws IOException{
+               Callback callback = null;
+               try{
+                       XACMLPolicyScanner actionScanner = new XACMLPolicyScanner(actionPolicyPathValue, callback);
+                       assertTrue(actionScanner.getPolicyObject() != null);
+                       Object actionObject = actionScanner.scan();
+                       assertTrue(actionObject != null);
+                       
+                       XACMLPolicyScanner scanner = new XACMLPolicyScanner(configPolicyPathValue, callback);
+                       assertTrue(scanner.getPolicyObject() != null);
+                       Object object = scanner.scan();
+                       assertTrue(object != null);
+                       String id = XACMLPolicyScanner.getID(scanner.getPolicyObject());
+                       assertTrue(id.equals("urn:com:xacml:policy:id:0b67998b-57e2-4e25-9ea9-f9154bf18df1"));
+                       String version = XACMLPolicyScanner.getVersion(scanner.getPolicyObject());
+                       assertTrue(version.equals("1"));
+                       String versionFromPath = XACMLPolicyScanner.getVersion(configPolicyPathValue);
+                       assertTrue(versionFromPath.equals("1"));
+                       List<String> returnValue = XACMLPolicyScanner.getCreatedByModifiedBy(configPolicyPathValue);
+                       assertTrue(returnValue.get(0).equals("test"));
+                       String createdBy = XACMLPolicyScanner.getCreatedBy(configPolicyPathValue);
+                       assertTrue(createdBy.equals("test"));
+                       String modifiedBy = XACMLPolicyScanner.getModifiedBy(configPolicyPathValue);
+                       assertTrue(modifiedBy.equals("test"));
+               }catch(Exception e){
+                       fail();
+                       logger.error("Exception Occured"+e);
+               }
+       }
+}
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/util/XACMLPolicyWriterTest.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/util/XACMLPolicyWriterTest.java
new file mode 100644 (file)
index 0000000..0a6fbf5
--- /dev/null
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP-XACML
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.policy.xacml.test.util;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.policy.xacml.util.XACMLPolicyWriter;
+
+public class XACMLPolicyWriterTest {
+       private static final Log logger                         = LogFactory.getLog(XACMLPolicyWriterTest.class);
+       private static Path configPolicyPathValue;
+       private static Path actionPolicyPathValue;
+       
+       @Before
+       public void setUp() {
+               File templateFile;
+               ClassLoader classLoader = getClass().getClassLoader();
+        try {
+               templateFile = new File(classLoader.getResource("Config_SampleTest1206.1.xml").getFile());
+               configPolicyPathValue = templateFile.toPath();
+               templateFile = new File(classLoader.getResource("Action_TestActionPolicy.1.xml").getFile());
+               actionPolicyPathValue = templateFile.toPath();
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+               }
+       }
+       
+       @SuppressWarnings("static-access")
+       @Test
+       public void xacmlPolicyWriterTest() throws IOException{
+               XACMLPolicyWriter writer = new XACMLPolicyWriter();
+               String configResponseValue = writer.changeFileNameInXmlWhenRenamePolicy(configPolicyPathValue);
+               assertTrue(configResponseValue.equals("txt"));
+               String actionResponseValue = writer.changeFileNameInXmlWhenRenamePolicy(actionPolicyPathValue);
+               assertTrue(actionResponseValue.equals("json"));
+       }
+}
diff --git a/ECOMP-XACML/src/test/resources/Action_TestActionPolicy.1.xml b/ECOMP-XACML/src/test/resources/Action_TestActionPolicy.1.xml
new file mode 100644 (file)
index 0000000..56f843c
--- /dev/null
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:xacml:policy:id:b8e180de-3dcc-4b5b-814d-925e674e573c" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+     <Description>TestActionPolicy@CreatedBy:test@CreatedBy:@ModifiedBy:test@ModifiedBy:</Description>
+     <Target>
+         <AnyOf>
+             <AllOf>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">12</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="SamplTest" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+             </AllOf>
+         </AnyOf>
+     </Target>
+     <Rule RuleId="" Effect="Permit">
+         <Target/>
+         <Condition>
+             <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
+                 <Apply FunctionId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                     <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
+                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="SamplTest" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                     </Apply>
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">test</AttributeValue>
+                 </Apply>
+                 <Apply FunctionId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                     <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
+                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="SamplTest" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                     </Apply>
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Sample</AttributeValue>
+                 </Apply>
+             </Apply>
+         </Condition>
+         <ObligationExpressions>
+             <ObligationExpression ObligationId="Test" FulfillOn="Permit">
+                 <AttributeAssignmentExpression AttributeId="performer" Category="urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">PEPAction</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="type" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">REST</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="url" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">http://localhost.com</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="method" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">GET</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="body" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">$URL/Action/com.Action_TestActionPolicy.1.xml.json</AttributeValue>
+                 </AttributeAssignmentExpression>
+             </ObligationExpression>
+         </ObligationExpressions>
+     </Rule>
+ </Policy>
\ No newline at end of file
diff --git a/ECOMP-XACML/src/test/resources/Config_SampleTest1206.1.xml b/ECOMP-XACML/src/test/resources/Config_SampleTest1206.1.xml
new file mode 100644 (file)
index 0000000..5390548
--- /dev/null
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:com:xacml:policy:id:0b67998b-57e2-4e25-9ea9-f9154bf18df1" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+    <Description>SampleTest1206@CreatedBy:test@CreatedBy:@ModifiedBy:test@ModifiedBy:</Description>
+    <Target>
+        <AnyOf>
+            <AllOf>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_SampleTest1206.1.xml</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="PolicyName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+            </AllOf>
+            <AllOf>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">success</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ECOMPName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">PROD</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskType" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskLevel" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="guard" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="TTLDate" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleTest1206</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ConfigName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+            </AllOf>
+        </AnyOf>
+    </Target>
+    <Rule RuleId="urn:com:xacml:rule:id:7e46d503-af54-4ea5-a86c-9eb6dd1f4f43" Effect="Permit">
+        <Target>
+            <AnyOf>
+                <AllOf>
+                    <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">ACCESS</AttributeValue>
+                        <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                    </Match>
+                    <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Config</AttributeValue>
+                        <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                    </Match>
+                </AllOf>
+            </AnyOf>
+        </Target>
+        <AdviceExpressions>
+            <AdviceExpression AdviceId="configID" AppliesTo="Permit">
+                <AttributeAssignmentExpression AttributeId="type" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Configuration</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="URLID" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">$URL/Config/com.Config_SampleTest1206.1.txt</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="PolicyName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_SampleTest1206.1.xml</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="VersionNumber" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="matching:ECOMPName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">success</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="matching:ConfigName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleTest1206</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="RiskType" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">PROD</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="RiskLevel" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="guard" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="TTLDate" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
+                </AttributeAssignmentExpression>
+            </AdviceExpression>
+        </AdviceExpressions>
+    </Rule>
+</Policy>
diff --git a/ECOMP-XACML/src/test/resources/pdps/default/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml b/ECOMP-XACML/src/test/resources/pdps/default/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml
new file mode 100644 (file)
index 0000000..33c0c4a
--- /dev/null
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:com:xacml:policy:id:0f246245-4e4e-4fb4-87f2-c95ebc0b6c30" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+    <Description>vFW Demo Policy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:</Description>
+    <Target>
+        <AnyOf>
+            <AllOf>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="PolicyName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+            </AllOf>
+            <AllOf>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DROOLS</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ECOMPName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">BRMS_PARAM_RULE</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ConfigName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskType" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskLevel" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">False</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="guard" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">NA</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="TTLDate" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+            </AllOf>
+        </AnyOf>
+    </Target>
+    <Rule RuleId="urn:com:xacml:rule:id:d4281b8e-698f-4860-b96f-aa85f70710a6" Effect="Permit">
+        <Target>
+            <AnyOf>
+                <AllOf>
+                    <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">ACCESS</AttributeValue>
+                        <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                    </Match>
+                    <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Config</AttributeValue>
+                        <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                    </Match>
+                </AllOf>
+            </AnyOf>
+        </Target>
+        <AdviceExpressions>
+            <AdviceExpression AdviceId="BRMSPARAMID" AppliesTo="Permit">
+                <AttributeAssignmentExpression AttributeId="type" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Configuration</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="URLID" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">$URL/Config/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="PolicyName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="VersionNumber" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="matching:ECOMPName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DROOLS</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="matching:ConfigName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">BRMS_PARAM_RULE</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="key:controller" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">vFW</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="RiskType" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="RiskLevel" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="guard" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">False</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="TTLDate" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">NA</AttributeValue>
+                </AttributeAssignmentExpression>
+            </AdviceExpression>
+        </AdviceExpressions>
+    </Rule>
+</Policy>
\ No newline at end of file
diff --git a/ECOMP-XACML/src/test/resources/pdps/default/xacml.pip.properties b/ECOMP-XACML/src/test/resources/pdps/default/xacml.pip.properties
new file mode 100644 (file)
index 0000000..4dba1f5
--- /dev/null
@@ -0,0 +1,6 @@
+#
+#Tue Feb 07 10:35:08 EST 2017
+AAF.description=AAFEngine to communicate with AAF to take decisions
+AAF.classname=org.openecomp.policy.xacml.std.pip.engines.aaf.AAFEngine
+AAF.name=AAFEngine
+xacml.pip.engines=AAF
\ No newline at end of file
diff --git a/ECOMP-XACML/src/test/resources/pdps/default/xacml.policy.properties b/ECOMP-XACML/src/test/resources/pdps/default/xacml.policy.properties
new file mode 100644 (file)
index 0000000..1dc2aab
--- /dev/null
@@ -0,0 +1,5 @@
+#
+#Tue Feb 07 10:35:08 EST 2017
+com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml.name=Config_BRMS_Param_BRMSParamvFWDemoPolicy
+xacml.referencedPolicies=
+xacml.rootPolicies=com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml
\ No newline at end of file
diff --git a/ECOMP-XACML/src/test/resources/pdps/xacml.properties b/ECOMP-XACML/src/test/resources/pdps/xacml.properties
new file mode 100644 (file)
index 0000000..aa1ece0
--- /dev/null
@@ -0,0 +1,7 @@
+#
+#Tue Feb 07 10:37:51 EST 2017
+default.description=The default group where new PDP's are put.
+default.name=default
+default.pdps=
+xacml.pap.groups=default
+xacml.pap.groups.default=default
\ No newline at end of file
diff --git a/POLICY-SDK-APP/config/policyLogger.properties b/POLICY-SDK-APP/config/policyLogger.properties
new file mode 100644 (file)
index 0000000..030c5ee
--- /dev/null
@@ -0,0 +1,24 @@
+################################### Set concurrentHashMap and timer info  #######################
+#Timer initial delay and the delay between in milliseconds before task is to be execute.
+timer.delay.time=1000
+#Timer scheduleAtFixedRate period - time in milliseconds between successive task executions.
+check.interval= 30000
+#Longest time an event info can be stored in the concurrentHashMap for logging - in seconds. 
+event.expired.time=86400
+#Size of the concurrentHashMap which stores the event starting time, etc - when its size reaches this limit, the Timer gets executed 
+#to remove all expired records from this concurrentHashMap.
+concurrentHashMap.limit=5000
+#Size of the concurrentHashMap - when its size drops to this point, stop the Timer
+stop.check.point=2500
+################################### Set logging format #############################################
+# set EELF for EELF logging format, set LOG4J for using log4j, set SYSTEMOUT for using system.out.println
+logger.type=SYSTEMOUT
+#################################### Set level for EELF or SYSTEMOUT logging ##################################
+# Set level for debug file. Set DEBUG to enable .info, .warn and .debug; set INFO for enable .info and .warn; set OFF to disable all 
+debugLogger.level=INFO
+# Set level for metrics file. Set OFF to disable; set ON to enable
+metricsLogger.level=ON
+# Set level for error file. Set OFF to disable; set ON to enable
+error.level=ON
+# Set level for audit file. Set OFF to disable; set ON to enable
+audit.level=ON
index 639e29e..1821e10 100644 (file)
@@ -95,13 +95,13 @@ public class PolicyManagerServlet extends HttpServlet {
                LIST, RENAME, COPY, DELETE, EDITFILE, ADDFOLDER, DESCRIBEPOLICYFILE, VIEWPOLICY, ADDSUBSCOPE, SWITCHVERSION, EXPORT, SEARCHLIST
        }
 
-       private PolicyController policyController;
-       public PolicyController getPolicyController() {
+       private static PolicyController policyController;
+       public synchronized PolicyController getPolicyController() {
                return policyController;
        }
 
-       public void setPolicyController(PolicyController policyController) {
-               this.policyController = policyController;
+       public synchronized static void setPolicyController(PolicyController policyController) {
+               PolicyManagerServlet.policyController = policyController;
        }
 
        private static String CONTENTTYPE = "application/json";
@@ -115,7 +115,7 @@ public class PolicyManagerServlet extends HttpServlet {
        
        private static Path closedLoopJsonLocation;
        private static JsonArray policyNames;
-       private String testUserId = null;
+       private static String testUserId = null;
        
        public static JsonArray getPolicyNames() {
                return policyNames;
@@ -126,7 +126,6 @@ public class PolicyManagerServlet extends HttpServlet {
        }
 
        private static List<String> serviceTypeNamesList = new ArrayList<>();
-       private List<Object> policyData;
 
        public static List<String> getServiceTypeNamesList() {
                return serviceTypeNamesList;
@@ -192,7 +191,11 @@ public class PolicyManagerServlet extends HttpServlet {
                                fileOperation(request, response);
                        }
                } catch (Exception e) {
-                       setError(e, response);
+                       try {
+                               setError(e, response);
+                       }catch(Exception e1){
+                               LOGGER.error("Exception Occured"+e1);
+                       }
                }
        }
 
@@ -270,6 +273,7 @@ public class PolicyManagerServlet extends HttpServlet {
                        Mode mode = Mode.valueOf(params.getString("mode"));
                        switch (mode) {
                        case ADDFOLDER:
+                       case ADDSUBSCOPE:
                                responseJsonObject = addFolder(params, request);
                                break;
                        case COPY:
@@ -278,12 +282,10 @@ public class PolicyManagerServlet extends HttpServlet {
                        case DELETE:
                                responseJsonObject = delete(params, request);
                                break;
-                       case EDITFILE: 
+                       case EDITFILE:
+                       case VIEWPOLICY:
                                responseJsonObject = editFile(params);
                                break;
-                       case VIEWPOLICY: 
-                               responseJsonObject = editFile(params);
-                               break;  
                        case LIST:
                                responseJsonObject = list(params, request);
                                break;
@@ -293,9 +295,6 @@ public class PolicyManagerServlet extends HttpServlet {
                        case DESCRIBEPOLICYFILE:
                                responseJsonObject = describePolicy(params);
                                break;
-                       case ADDSUBSCOPE:
-                               responseJsonObject = addFolder(params, request);
-                               break;
                        case SWITCHVERSION:
                                responseJsonObject = switchVersion(params, request);
                                break;
@@ -321,7 +320,7 @@ public class PolicyManagerServlet extends HttpServlet {
        private JSONObject searchPolicyList(JSONObject params, HttpServletRequest request) {
                Set<String> scopes = null;
                List<String> roles = null;
-               policyData = new ArrayList<>();
+               List<Object> policyData = new ArrayList<>();
                JSONArray policyList = null;
                if(params.has("policyList")){
                        policyList = (JSONArray) params.get("policyList");
@@ -1230,7 +1229,7 @@ public class PolicyManagerServlet extends HttpServlet {
                                                                                policyEntity = (PolicyEntity) object;
                                                                                String policyEntityName = policyEntity.getPolicyName().replace(".xml", "");
                                                                                int policyEntityVersion = Integer.parseInt(policyEntityName.substring(policyEntityName.lastIndexOf(".")+1));
-                                                                               if(policyEntityVersion > highestVersion){
+                                                                               if(policyEntityVersion > highestVersion && policyEntityVersion != version){
                                                                                        highestVersion = policyEntityVersion;
                                                                                }
                                                                        }
@@ -1472,7 +1471,7 @@ public class PolicyManagerServlet extends HttpServlet {
                return testUserId;
        }
 
-       public void setTestUserId(String testUserId) {
-               this.testUserId = testUserId;
+       public static void setTestUserId(String testUserId) {
+               PolicyManagerServlet.testUserId = testUserId;
        }
 }
\ No newline at end of file
index 9bd6e4f..1a535dc 100644 (file)
@@ -106,7 +106,7 @@ public class PolicyNotificationMail{
                                         + '\n'  + '\n' + "Moved By : " +entityItem.getModifiedBy() + '\n' + "Moved Time  : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + "Policy Notification System  (please don't respond to this email)";
                }
                String policyFileName = entityItem.getPolicyName();
-               String checkPolicyName = policyFileName;
+               String checkPolicyName = policyName;
                if(policyFileName.contains("/")){
                        policyFileName = policyFileName.substring(0, policyFileName.indexOf("/"));
                        policyFileName = policyFileName.replace("/", File.separator);
@@ -119,40 +119,41 @@ public class PolicyNotificationMail{
                String query = "from WatchPolicyNotificationTable where policyName like'" +policyFileName+"%'";
                boolean sendFlag = false;
                List<Object> watchList = policyNotificationDao.getDataByQuery(query);
-               if(watchList != null){
-                       if(watchList.isEmpty()){
-                               for(Object watch : watchList){
-                                       WatchPolicyNotificationTable list = (WatchPolicyNotificationTable) watch;
-                                       String watchPolicyName = list.getPolicyName();
-                                       if(watchPolicyName.contains("Config_") || watchPolicyName.contains("Action_") || watchPolicyName.contains("Decision_")){
-                                               if(watchPolicyName.equals(checkPolicyName)){
-                                                       sendFlag = true;
-                                               }else{
-                                                       sendFlag = false;
-                                               }
+               if(watchList != null && !watchList.isEmpty()){
+                       for(Object watch : watchList){
+                               WatchPolicyNotificationTable list = (WatchPolicyNotificationTable) watch;
+                               String watchPolicyName = list.getPolicyName();
+                               if(watchPolicyName.contains("Config_") || watchPolicyName.contains("Action_") || watchPolicyName.contains("Decision_")){
+                                       if(watchPolicyName.equals(checkPolicyName)){
+                                               sendFlag = true;
+                                       }else{
+                                               sendFlag = false;
                                        }
-                                       if(sendFlag){
-                                               AnnotationConfigApplicationContext ctx = null;
-                                               try {
-                                                       to = list.getLoginIds()+"@"+PolicyController.getSmtpApplicationName();
-                                                       to = to.trim();
-                                                       ctx = new AnnotationConfigApplicationContext();
-                                                       ctx.register(PolicyNotificationMail.class);
-                                                       ctx.refresh();
-                                                       JavaMailSenderImpl mailSender = ctx.getBean(JavaMailSenderImpl.class);
-                                                       MimeMessage mimeMessage = mailSender.createMimeMessage();
-                                                       MimeMessageHelper mailMsg = new MimeMessageHelper(mimeMessage);
-                                                       mailMsg.setFrom(new InternetAddress(from, "Policy Notification System"));
-                                                       mailMsg.setTo(to);
-                                                       mailMsg.setSubject(subject);
-                                                       mailMsg.setText(message);
-                                                       mailSender.send(mimeMessage);
-                                               } catch (Exception e) {
-                                                       policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW+"Exception Occured in Policy Notification" +e);
-                                               }finally{
-                                                       if(ctx != null){
-                                                               ctx.close();
-                                                       }
+                               }
+                               if(sendFlag){
+                                       AnnotationConfigApplicationContext ctx = null;
+                                       try {
+                                               to = list.getLoginIds()+"@"+PolicyController.getSmtpEmailExtension();
+                                               to = to.trim();
+                                               ctx = new AnnotationConfigApplicationContext();
+                                               ctx.register(PolicyNotificationMail.class);
+                                               ctx.refresh();
+                                               JavaMailSenderImpl mailSender = ctx.getBean(JavaMailSenderImpl.class);
+                                               MimeMessage mimeMessage = mailSender.createMimeMessage();
+                                               MimeMessageHelper mailMsg = new MimeMessageHelper(mimeMessage);
+                                               mailMsg.setFrom(new InternetAddress(from, "Policy Notification System"));
+                                               mailMsg.setTo(to);
+                                               mailMsg.setSubject(subject);
+                                               mailMsg.setText(message);
+                                               mailSender.send(mimeMessage);
+                                               if(mode.equalsIgnoreCase("Rename") || mode.contains("Delete") || mode.contains("Move")){
+                                                       policyNotificationDao.delete(watch);
+                                               }
+                                       } catch (Exception e) {
+                                               policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW+"Exception Occured in Policy Notification" +e);
+                                       }finally{
+                                               if(ctx != null){
+                                                       ctx.close();
                                                }
                                        }
                                }
index 2c04bc6..08ef99f 100644 (file)
@@ -86,90 +86,90 @@ public class PolicyRestController extends RestrictedBaseController{
        CommonClassDao commonClassDao;
 
        @RequestMapping(value={"/policycreation/save_policy"}, method={RequestMethod.POST})
-       public ModelAndView policyCreationController(HttpServletRequest request, HttpServletResponse response) throws Exception{
-               
+       public void policyCreationController(HttpServletRequest request, HttpServletResponse response) {
                String userId = UserUtils.getUserSession(request).getOrgUserId();
                ObjectMapper mapper = new ObjectMapper();
                mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-               JsonNode root = mapper.readTree(request.getReader());
-               
-               PolicyRestAdapter policyData = mapper.readValue(root.get(PolicyController.getPolicydata()).get("policy").toString(), PolicyRestAdapter.class);
-       
-               if("file".equals(root.get(PolicyController.getPolicydata()).get(modal).get("type").toString().replace("\"", ""))){
-                       policyData.setEditPolicy(true);
-               }
-               if(root.get(PolicyController.getPolicydata()).get(modal).get("path").size() != 0){
-                       String dirName = "";
-                       for(int i = 0; i < root.get(PolicyController.getPolicydata()).get(modal).get("path").size(); i++){
-                               dirName = dirName.replace("\"", "") + root.get(PolicyController.getPolicydata()).get(modal).get("path").get(i).toString().replace("\"", "") + File.separator;
+               try{
+                       JsonNode root = mapper.readTree(request.getReader());
+
+                       PolicyRestAdapter policyData = mapper.readValue(root.get(PolicyController.getPolicydata()).get("policy").toString(), PolicyRestAdapter.class);
+
+                       if("file".equals(root.get(PolicyController.getPolicydata()).get(modal).get("type").toString().replace("\"", ""))){
+                               policyData.setEditPolicy(true);
                        }
-                       if(policyData.isEditPolicy()){
-                               policyData.setDomainDir(dirName.substring(0, dirName.lastIndexOf(File.separator)));
+                       if(root.get(PolicyController.getPolicydata()).get(modal).get("path").size() != 0){
+                               String dirName = "";
+                               for(int i = 0; i < root.get(PolicyController.getPolicydata()).get(modal).get("path").size(); i++){
+                                       dirName = dirName.replace("\"", "") + root.get(PolicyController.getPolicydata()).get(modal).get("path").get(i).toString().replace("\"", "") + File.separator;
+                               }
+                               if(policyData.isEditPolicy()){
+                                       policyData.setDomainDir(dirName.substring(0, dirName.lastIndexOf(File.separator)));
+                               }else{
+                                       policyData.setDomainDir(dirName + root.get(PolicyController.getPolicydata()).get(modal).get("name").toString().replace("\"", ""));
+                               }
                        }else{
-                               policyData.setDomainDir(dirName + root.get(PolicyController.getPolicydata()).get(modal).get("name").toString().replace("\"", ""));
-                       }
-               }else{
-                       String domain = root.get(PolicyController.getPolicydata()).get("model").get("name").toString();
-                       if(domain.contains("/")){
-                               domain = domain.substring(0, domain.lastIndexOf('/')).replace("/", File.separator);
+                               String domain = root.get(PolicyController.getPolicydata()).get("model").get("name").toString();
+                               if(domain.contains("/")){
+                                       domain = domain.substring(0, domain.lastIndexOf('/')).replace("/", File.separator);
+                               }
+                               domain = domain.replace("\"", "");
+                               policyData.setDomainDir(domain);
                        }
-                       domain = domain.replace("\"", "");
-                       policyData.setDomainDir(domain);
-               }
-               
-               if(policyData.getConfigPolicyType() != null){
-                       if("ClosedLoop_Fault".equalsIgnoreCase(policyData.getConfigPolicyType())){
-                               CreateClosedLoopFaultController faultController = new CreateClosedLoopFaultController();
-                               policyData = faultController.setDataToPolicyRestAdapter(policyData, root);
-                       }else if("Firewall Config".equalsIgnoreCase(policyData.getConfigPolicyType())){
-                               CreateFirewallController fwController = new CreateFirewallController();
-                               policyData = fwController.setDataToPolicyRestAdapter(policyData);
-                       }else if("Micro Service".equalsIgnoreCase(policyData.getConfigPolicyType())){
-                               CreateDcaeMicroServiceController msController = new CreateDcaeMicroServiceController();
-                               policyData = msController.setDataToPolicyRestAdapter(policyData, root);
+
+                       if(policyData.getConfigPolicyType() != null){
+                               if("ClosedLoop_Fault".equalsIgnoreCase(policyData.getConfigPolicyType())){
+                                       CreateClosedLoopFaultController faultController = new CreateClosedLoopFaultController();
+                                       policyData = faultController.setDataToPolicyRestAdapter(policyData, root);
+                               }else if("Firewall Config".equalsIgnoreCase(policyData.getConfigPolicyType())){
+                                       CreateFirewallController fwController = new CreateFirewallController();
+                                       policyData = fwController.setDataToPolicyRestAdapter(policyData);
+                               }else if("Micro Service".equalsIgnoreCase(policyData.getConfigPolicyType())){
+                                       CreateDcaeMicroServiceController msController = new CreateDcaeMicroServiceController();
+                                       policyData = msController.setDataToPolicyRestAdapter(policyData, root);
+                               }
                        }
-               }
-               
-               policyData.setUserId(userId);
-               
-               String result;
-               String body = PolicyUtils.objectToJsonString(policyData);
-               String uri = request.getRequestURI();
-               ResponseEntity<?> responseEntity = sendToPAP(body, uri, HttpMethod.POST);
-               if(responseEntity != null && responseEntity.getBody().equals(HttpServletResponse.SC_CONFLICT)){
-                       result = "PolicyExists";
-               }else if(responseEntity != null){
-                       result =  responseEntity.getBody().toString();
-                       String policyName = responseEntity.getHeaders().get("policyName").get(0);
-                       if(policyData.isEditPolicy() && "success".equalsIgnoreCase(result)){
-                               PolicyNotificationMail email = new PolicyNotificationMail();
-                               String mode = "EditPolicy";
-                               String watchPolicyName = policyName.replace(".xml", "");
-                               String version = watchPolicyName.substring(watchPolicyName.lastIndexOf('.')+1);
-                               watchPolicyName = watchPolicyName.substring(0, watchPolicyName.lastIndexOf('.')).replace(".", File.separator);
-                               String policyVersionName = watchPolicyName.replace(".", File.separator);
-                               watchPolicyName = watchPolicyName + "." + version + ".xml";
-                               PolicyVersion entityItem = new PolicyVersion();
-                               entityItem.setPolicyName(policyVersionName);
-                               entityItem.setActiveVersion(Integer.parseInt(version));
-                               entityItem.setModifiedBy(userId);
-                               email.sendMail(entityItem, watchPolicyName, mode, commonClassDao);
+
+                       policyData.setUserId(userId);
+
+                       String result;
+                       String body = PolicyUtils.objectToJsonString(policyData);
+                       String uri = request.getRequestURI();
+                       ResponseEntity<?> responseEntity = sendToPAP(body, uri, HttpMethod.POST);
+                       if(responseEntity != null && responseEntity.getBody().equals(HttpServletResponse.SC_CONFLICT)){
+                               result = "PolicyExists";
+                       }else if(responseEntity != null){
+                               result =  responseEntity.getBody().toString();
+                               String policyName = responseEntity.getHeaders().get("policyName").get(0);
+                               if(policyData.isEditPolicy() && "success".equalsIgnoreCase(result)){
+                                       PolicyNotificationMail email = new PolicyNotificationMail();
+                                       String mode = "EditPolicy";
+                                       String watchPolicyName = policyName.replace(".xml", "");
+                                       String version = watchPolicyName.substring(watchPolicyName.lastIndexOf('.')+1);
+                                       watchPolicyName = watchPolicyName.substring(0, watchPolicyName.lastIndexOf('.')).replace(".", File.separator);
+                                       String policyVersionName = watchPolicyName.replace(".", File.separator);
+                                       watchPolicyName = watchPolicyName + "." + version + ".xml";
+                                       PolicyVersion entityItem = new PolicyVersion();
+                                       entityItem.setPolicyName(policyVersionName);
+                                       entityItem.setActiveVersion(Integer.parseInt(version));
+                                       entityItem.setModifiedBy(userId);
+                                       email.sendMail(entityItem, watchPolicyName, mode, commonClassDao);
+                               }
+                       }else{
+                               result =  "Response is null from PAP";
                        }
-               }else{
-                       result =  "Response is null from PAP";
-               }
-               
-       
-               response.setCharacterEncoding(PolicyController.getCharacterencoding());
-               response.setContentType(PolicyController.getContenttype());
-               request.setCharacterEncoding(PolicyController.getCharacterencoding());
 
-               PrintWriter out = response.getWriter();
-               String responseString = mapper.writeValueAsString(result);
-               JSONObject j = new JSONObject("{policyData: " + responseString + "}");
-               out.write(j.toString());
-               return null;
+                       response.setCharacterEncoding(PolicyController.getCharacterencoding());
+                       response.setContentType(PolicyController.getContenttype());
+                       request.setCharacterEncoding(PolicyController.getCharacterencoding());
 
+                       PrintWriter out = response.getWriter();
+                       String responseString = mapper.writeValueAsString(result);
+                       JSONObject j = new JSONObject("{policyData: " + responseString + "}");
+                       out.write(j.toString());
+               }catch(Exception e){
+                       policyLogger.error("Exception Occured while saving policy" , e);
+               }
        }
        
        
@@ -344,7 +344,7 @@ public class PolicyRestController extends RestrictedBaseController{
        }
        
        @RequestMapping(value={"/getDictionary/*"}, method={RequestMethod.GET})
-       public void getDictionaryController(HttpServletRequest request, HttpServletResponse response) throws Exception{
+       public void getDictionaryController(HttpServletRequest request, HttpServletResponse response){
                String uri = request.getRequestURI().replace("/getDictionary", "");
                String body = null;
                ResponseEntity<?> responseEntity = sendToPAP(null, uri, HttpMethod.GET);
@@ -353,7 +353,11 @@ public class PolicyRestController extends RestrictedBaseController{
                }else{
                        body = "";
                }
-               response.getWriter().write(body);
+               try {
+                       response.getWriter().write(body);
+               } catch (IOException e) {
+                       policyLogger.error("Exception occured while getting Dictionary entries", e);
+               }
        }
        
        @RequestMapping(value={"/saveDictionary/*/*"}, method={RequestMethod.POST})
index 2c68df6..c88412b 100644 (file)
@@ -58,7 +58,9 @@ import org.openecomp.policy.common.logging.flexlogger.Logger;
 public class ActionPolicyController extends RestrictedBaseController{
        private static final Logger LOGGER = FlexLogger.getLogger(ActionPolicyController.class);
        
-       public ActionPolicyController(){}
+       public ActionPolicyController(){
+               //Default Constructor
+       }
 
        private ArrayList<Object> attributeList;
        protected  LinkedList<Integer> ruleAlgoirthmTracker;
index 8258b8b..4f4838d 100644 (file)
@@ -42,17 +42,19 @@ import javax.servlet.http.HttpServletResponse;
 import javax.xml.bind.JAXBElement;
 
 import org.json.JSONObject;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
 import org.openecomp.policy.rest.adapter.PolicyRestAdapter;
 import org.openecomp.policy.rest.dao.CommonClassDao;
 import org.openecomp.policy.rest.jpa.BRMSParamTemplate;
 import org.openecomp.policy.rest.jpa.PolicyEntity;
+import org.openecomp.policy.xacml.api.XACMLErrorConstants;
 import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.servlet.ModelAndView;
 
-import org.openecomp.policy.xacml.api.XACMLErrorConstants;
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -69,9 +71,6 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
 
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger; 
-import org.openecomp.policy.common.logging.flexlogger.Logger;
-
 @Controller
 @RequestMapping("/")
 public class CreateBRMSParamController extends RestrictedBaseController {
@@ -79,6 +78,14 @@ public class CreateBRMSParamController extends RestrictedBaseController {
 
        private static CommonClassDao commonClassDao;
 
+       public static CommonClassDao getCommonClassDao() {
+               return commonClassDao;
+       }
+
+       public static void setCommonClassDao(CommonClassDao commonClassDao) {
+               CreateBRMSParamController.commonClassDao = commonClassDao;
+       }
+       
        @Autowired
        private CreateBRMSParamController(CommonClassDao commonClassDao){
                CreateBRMSParamController.commonClassDao = commonClassDao;
@@ -90,35 +97,36 @@ public class CreateBRMSParamController extends RestrictedBaseController {
        private HashMap<String, String> dynamicLayoutMap;
        
        private static String brmsTemplateVlaue = "<$%BRMSParamTemplate=";
-       private static String String = "String";
+       private static String string = "String";
 
 
        @RequestMapping(value={"/policyController/getBRMSTemplateData.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView getBRMSParamPolicyRuleData(HttpServletRequest request, HttpServletResponse response) throws Exception{
-               dynamicLayoutMap = new HashMap<>();
-               ObjectMapper mapper = new ObjectMapper();
-               mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-               JsonNode root = mapper.readTree(request.getReader());
-               String rule = findRule(root.get(PolicyController.getPolicydata()).toString().replaceAll("^\"|\"$", ""));
-               generateUI(rule);
-               response.setCharacterEncoding(PolicyController.getCharacterencoding());
-               response.setContentType(PolicyController.getContenttype());
-               request.setCharacterEncoding(PolicyController.getCharacterencoding());
+       public void getBRMSParamPolicyRuleData(HttpServletRequest request, HttpServletResponse response){
+               try{
+                       dynamicLayoutMap = new HashMap<>();
+                       ObjectMapper mapper = new ObjectMapper();
+                       mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+                       JsonNode root = mapper.readTree(request.getReader());
+                       String rule = findRule(root.get(PolicyController.getPolicydata()).toString().replaceAll("^\"|\"$", ""));
+                       generateUI(rule);
+                       response.setCharacterEncoding(PolicyController.getCharacterencoding());
+                       response.setContentType(PolicyController.getContenttype());
+                       request.setCharacterEncoding(PolicyController.getCharacterencoding());
 
-               PrintWriter out = response.getWriter();
-               String responseString = mapper.writeValueAsString(dynamicLayoutMap);
-               JSONObject j = new JSONObject("{policyData: " + responseString + "}");
-               out.write(j.toString());
-               return null;
+                       PrintWriter out = response.getWriter();
+                       String responseString = mapper.writeValueAsString(dynamicLayoutMap);
+                       JSONObject j = new JSONObject("{policyData: " + responseString + "}");
+                       out.write(j.toString());
+               }catch(Exception e){
+                       policyLogger.error("Exception Occured while getting BRMS Rule data" , e);
+               }
        }
 
        protected String findRule(String ruleTemplate) {
-               List<Object> datas = commonClassDao.getData(BRMSParamTemplate.class);
-               for (Object data: datas){
-                       BRMSParamTemplate  bRMSParamTemplate = (BRMSParamTemplate) data;
-                       if(bRMSParamTemplate.getRuleName().equals(ruleTemplate)){
-                               return bRMSParamTemplate.getRule();
-                       }
+               List<Object> datas = commonClassDao.getDataById(BRMSParamTemplate.class, "ruleName", ruleTemplate);
+               if(datas != null && !datas.isEmpty()){
+                       BRMSParamTemplate  bRMSParamTemplate = (BRMSParamTemplate) datas.get(0);
+                       return bRMSParamTemplate.getRule();
                }
                return null;
        }
@@ -197,10 +205,10 @@ public class CreateBRMSParamController extends RestrictedBaseController {
                                                policyLogger.info("Just for Logging"+e);
                                                nextComponent = components[i];
                                        }
-                                       if (nextComponent.startsWith(String)) {
+                                       if (nextComponent.startsWith(string)) {
                                                type = "String";
                                                createField(caption, type);
-                                               caption = nextComponent.replace(String, "");
+                                               caption = nextComponent.replace(string, "");
                                        } else if (nextComponent.startsWith("int")) {
                                                type = "int";
                                                createField(caption, type);
@@ -357,7 +365,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
                return formateDate;
        }
        // This method generates the UI from rule configuration
-       private void paramUIGenerate(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
+       public void paramUIGenerate(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
                String data = entity.getConfigurationData().getConfigBody();
                if(data != null){
                        File file = new File(PolicyController.getConfigHome() +File.separator+ entity.getConfigurationData().getConfigurationName());
@@ -471,7 +479,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
        // set View Rule
        @SuppressWarnings("unchecked")
        @RequestMapping(value={"/policyController/ViewBRMSParamPolicyRule.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView setViewRule(HttpServletRequest request, HttpServletResponse response) throws Exception{
+       public void setViewRule(HttpServletRequest request, HttpServletResponse response){
                try {
                        ObjectMapper mapper = new ObjectMapper();
                        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
@@ -493,7 +501,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
                        if(policyData.getRuleData().size() > 0){ 
                                for(Object keyValue: policyData.getRuleData().keySet()){ 
                                        String key = keyValue.toString().substring(0, 1).toUpperCase() + keyValue.toString().substring(1); 
-                                       if (String.equals(keyValue)) { 
+                                       if (string.equals(keyValue)) { 
                                                generatedRule.append("\n\t\tparams.set" 
                                                                + key + "(\"" 
                                                                + policyData.getRuleData().get(keyValue).toString() + "\");"); 
@@ -537,10 +545,8 @@ public class CreateBRMSParamController extends RestrictedBaseController {
                        String responseString = mapper.writeValueAsString(body);
                        JSONObject j = new JSONObject("{policyData: " + responseString + "}");
                        out.write(j.toString());
-                       return null;
                } catch (Exception e) {
                        policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
-               }
-               return null;    
+               }       
        }
 }
index 67945e1..c5b97ad 100644 (file)
@@ -72,6 +72,7 @@ public class CreateBRMSRawController{
                        try{
                                description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:"));
                        }catch(Exception e){
+                               logger.info("Not able to see the createdby in description. So, add generic description", e);
                                description = policy.getDescription();
                        }
                        policyAdapter.setPolicyDescription(description);
index ccecf5d..08c0c38 100644 (file)
@@ -61,7 +61,7 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
 @RequestMapping("/")
 public class CreateClosedLoopFaultController extends RestrictedBaseController{
 
-       private static final Logger LOGGER      = FlexLogger.getLogger(CreateClosedLoopFaultController.class);
+       private static final Logger policyLogger        = FlexLogger.getLogger(CreateClosedLoopFaultController.class);
        
        protected PolicyRestAdapter policyAdapter = null;
        
@@ -75,86 +75,91 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
        
        public CreateClosedLoopFaultController(){}
        
-       public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root) throws Exception{
-               ObjectMapper mapper = new ObjectMapper();
-               mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-               TrapDatas trapDatas = mapper.readValue(root.get("trapData").toString(), TrapDatas.class);
-               TrapDatas faultDatas = mapper.readValue(root.get("faultData").toString(), TrapDatas.class);
-               ClosedLoopGridJSONData policyJsonData = mapper.readValue(root.get("policyData").get("policy").toString(), ClosedLoopGridJSONData.class);
-               ClosedLoopFaultBody jsonBody = mapper.readValue(root.get("policyData").get("policy").get("jsonBodyData").toString(), ClosedLoopFaultBody.class);
-               
-               ArrayList<Object> trapSignatureDatas = new ArrayList<>();
-               if(trapDatas.getTrap1() != null){
-                       trapSignatureDatas.add(trapDatas);
-               }
-               ArrayList<Object> faultSignatureDatas = new ArrayList<>();
-               if(faultDatas.getTrap1() != null){
-                       faultSignatureDatas.add(faultDatas);
-               }
-               
-               String resultBody = "";
-               if(!policyJsonData.getConnecttriggerSignatures().isEmpty()){
-                       resultBody = resultBody + "(";
-                       for(int i = policyJsonData.getConnecttriggerSignatures().size()-1; i>=0 ; i--){
-                               String connectBody = connectTriggerSignature(i, policyJsonData.getConnecttriggerSignatures(), trapSignatureDatas.get(0));
-                               resultBody = resultBody  + connectBody;
+       public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root){
+               try{
+                       ObjectMapper mapper = new ObjectMapper();
+                       mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+                       TrapDatas trapDatas = mapper.readValue(root.get("trapData").toString(), TrapDatas.class);
+                       TrapDatas faultDatas = mapper.readValue(root.get("faultData").toString(), TrapDatas.class);
+                       ClosedLoopGridJSONData policyJsonData = mapper.readValue(root.get("policyData").get("policy").toString(), ClosedLoopGridJSONData.class);
+                       ClosedLoopFaultBody jsonBody = mapper.readValue(root.get("policyData").get("policy").get("jsonBodyData").toString(), ClosedLoopFaultBody.class);
+
+                       ArrayList<Object> trapSignatureDatas = new ArrayList<>();
+                       if(trapDatas.getTrap1() != null){
+                               trapSignatureDatas.add(trapDatas);
                        }
-                       resultBody = resultBody + ")";
-               }else{
-                       if(!trapSignatureDatas.isEmpty()){
-                               resultBody = callTrap("nill", trapSignatureDatas.get(0));
+                       ArrayList<Object> faultSignatureDatas = new ArrayList<>();
+                       if(faultDatas.getTrap1() != null){
+                               faultSignatureDatas.add(faultDatas);
                        }
-               }
-               ClosedLoopSignatures triggerSignatures = new ClosedLoopSignatures();
-               triggerSignatures.setSignatures(resultBody);
-               if(policyData.getClearTimeOut() != null){
-                       triggerSignatures.setTimeWindow(Integer.parseInt(policyData.getClearTimeOut()));        
-                       triggerSignatures.setTrapMaxAge(Integer.parseInt(policyData.getTrapMaxAge()));
-                       ClosedLoopFaultTriggerUISignatures uiTriggerSignatures = new ClosedLoopFaultTriggerUISignatures();
-                       if(!trapSignatureDatas.isEmpty()){
-                               uiTriggerSignatures.setSignatures(getUITriggerSignature("Trap", trapSignatureDatas.get(0)));
-                               if(!policyJsonData.getConnecttriggerSignatures().isEmpty()){
-                                       uiTriggerSignatures.setConnectSignatures(getUIConnectTraps(policyJsonData.getConnecttriggerSignatures()));
-                               }                               
-                       }                       
-                       jsonBody.setTriggerSignaturesUsedForUI(uiTriggerSignatures);
-                       jsonBody.setTriggerTimeWindowUsedForUI(Integer.parseInt(policyData.getClearTimeOut()));
-                       jsonBody.setTrapMaxAgeUsedForUI(Integer.parseInt(policyData.getTrapMaxAge()));
-               }
-               
-               jsonBody.setTriggerSignatures(triggerSignatures);
-               String faultBody = "";
-               if(!policyJsonData.getConnectVerificationSignatures().isEmpty()){
-                       faultBody = faultBody + "(";
-                       for(int i = policyJsonData.getConnectVerificationSignatures().size()-1; i>=0 ; i--){
-                               String connectBody = connectTriggerSignature(i, policyJsonData.getConnectVerificationSignatures(), faultSignatureDatas.get(0));
-                               faultBody = faultBody  + connectBody;
+
+                       String resultBody = "";
+                       if(!policyJsonData.getConnecttriggerSignatures().isEmpty()){
+                               resultBody = resultBody + "(";
+                               for(int i = policyJsonData.getConnecttriggerSignatures().size()-1; i>=0 ; i--){
+                                       String connectBody = connectTriggerSignature(i, policyJsonData.getConnecttriggerSignatures(), trapSignatureDatas.get(0));
+                                       resultBody = resultBody  + connectBody;
+                               }
+                               resultBody = resultBody + ")";
+                       }else{
+                               if(!trapSignatureDatas.isEmpty()){
+                                       resultBody = callTrap("nill", trapSignatureDatas.get(0));
+                               }
                        }
-                       faultBody = faultBody + ")";
-               }else{
-                       if(!faultSignatureDatas.isEmpty()){
-                               faultBody = callTrap("nill", faultSignatureDatas.get(0));
+                       ClosedLoopSignatures triggerSignatures = new ClosedLoopSignatures();
+                       triggerSignatures.setSignatures(resultBody);
+                       if(policyData.getClearTimeOut() != null){
+                               triggerSignatures.setTimeWindow(Integer.parseInt(policyData.getClearTimeOut()));        
+                               triggerSignatures.setTrapMaxAge(Integer.parseInt(policyData.getTrapMaxAge()));
+                               ClosedLoopFaultTriggerUISignatures uiTriggerSignatures = new ClosedLoopFaultTriggerUISignatures();
+                               if(!trapSignatureDatas.isEmpty()){
+                                       uiTriggerSignatures.setSignatures(getUITriggerSignature("Trap", trapSignatureDatas.get(0)));
+                                       if(!policyJsonData.getConnecttriggerSignatures().isEmpty()){
+                                               uiTriggerSignatures.setConnectSignatures(getUIConnectTraps(policyJsonData.getConnecttriggerSignatures()));
+                                       }                               
+                               }                       
+                               jsonBody.setTriggerSignaturesUsedForUI(uiTriggerSignatures);
+                               jsonBody.setTriggerTimeWindowUsedForUI(Integer.parseInt(policyData.getClearTimeOut()));
+                               jsonBody.setTrapMaxAgeUsedForUI(Integer.parseInt(policyData.getTrapMaxAge()));
                        }
-               }
-               ClosedLoopSignatures faultSignatures = new ClosedLoopSignatures();
-               faultSignatures.setSignatures(faultBody);
-               if(policyData.getVerificationclearTimeOut() != null){
-                       faultSignatures.setTimeWindow(Integer.parseInt(policyData.getVerificationclearTimeOut()));
-                       ClosedLoopFaultTriggerUISignatures uifaultSignatures = new ClosedLoopFaultTriggerUISignatures();
-                       if(!faultSignatureDatas.isEmpty()){
-                               uifaultSignatures.setSignatures(getUITriggerSignature("Fault", faultSignatureDatas.get(0)));
-                               if(!policyJsonData.getConnectVerificationSignatures().isEmpty()){
-                                       uifaultSignatures.setConnectSignatures(getUIConnectTraps(policyJsonData.getConnectVerificationSignatures()));
-                               }               
+
+                       jsonBody.setTriggerSignatures(triggerSignatures);
+                       String faultBody = "";
+                       if(!policyJsonData.getConnectVerificationSignatures().isEmpty()){
+                               faultBody = faultBody + "(";
+                               for(int i = policyJsonData.getConnectVerificationSignatures().size()-1; i>=0 ; i--){
+                                       String connectBody = connectTriggerSignature(i, policyJsonData.getConnectVerificationSignatures(), faultSignatureDatas.get(0));
+                                       faultBody = faultBody  + connectBody;
+                               }
+                               faultBody = faultBody + ")";
+                       }else{
+                               if(!faultSignatureDatas.isEmpty()){
+                                       faultBody = callTrap("nill", faultSignatureDatas.get(0));
+                               }
                        }
-                       
-                       jsonBody.setVerificationSignaturesUsedForUI(uifaultSignatures);
-                       jsonBody.setVerfificationTimeWindowUsedForUI(Integer.parseInt(policyData.getVerificationclearTimeOut()));
-               }               
-               jsonBody.setVerificationSignatures(faultSignatures);
-               ObjectWriter om = new ObjectMapper().writer();
-               String json = om.writeValueAsString(jsonBody);
-               policyData.setJsonBody(json);
+                       ClosedLoopSignatures faultSignatures = new ClosedLoopSignatures();
+                       faultSignatures.setSignatures(faultBody);
+                       if(policyData.getVerificationclearTimeOut() != null){
+                               faultSignatures.setTimeWindow(Integer.parseInt(policyData.getVerificationclearTimeOut()));
+                               ClosedLoopFaultTriggerUISignatures uifaultSignatures = new ClosedLoopFaultTriggerUISignatures();
+                               if(!faultSignatureDatas.isEmpty()){
+                                       uifaultSignatures.setSignatures(getUITriggerSignature("Fault", faultSignatureDatas.get(0)));
+                                       if(!policyJsonData.getConnectVerificationSignatures().isEmpty()){
+                                               uifaultSignatures.setConnectSignatures(getUIConnectTraps(policyJsonData.getConnectVerificationSignatures()));
+                                       }               
+                               }
+
+                               jsonBody.setVerificationSignaturesUsedForUI(uifaultSignatures);
+                               jsonBody.setVerfificationTimeWindowUsedForUI(Integer.parseInt(policyData.getVerificationclearTimeOut()));
+                       }               
+                       jsonBody.setVerificationSignatures(faultSignatures);
+                       ObjectWriter om = new ObjectMapper().writer();
+                       String json = om.writeValueAsString(jsonBody);
+                       policyData.setJsonBody(json);
+
+               }catch(Exception e){
+                       policyLogger.error("Exception Occured while setting data to Adapter" , e);
+               }
                return policyData;
        }
        
@@ -170,6 +175,7 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
                        }
                        resultBody = resultBody + "(" + notBox;
                }catch(NullPointerException e){
+                       policyLogger.info("General error" , e);
                        resultBody = resultBody + "(";
                }
                String connectTrap1 = connectTraps.get("connectTrap1");
@@ -194,11 +200,13 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
                        String trapCount1 = connectTraps.get("trapCount1");
                        resultBody = resultBody + ", Time = " + trapCount1 + ")";
                }catch(NullPointerException e){
+                       policyLogger.info("General error" , e);
                }
                try{
                        String operatorBox = connectTraps.get("operatorBox");
                        resultBody = resultBody + operatorBox +"(";
                }catch (NullPointerException e){
+                       policyLogger.info("General error" , e);
                }
                try{
                        String connectTrap2 = connectTraps.get("connectTrap2");
@@ -220,11 +228,13 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
                                }
                        }
                }catch(NullPointerException e){
+                       policyLogger.info("General error" , e);
                }
                try{
                        String trapCount2 = connectTraps.get("trapCount2");
                        resultBody = resultBody + ", Time = " + trapCount2 + ")";
                }catch(NullPointerException e){
+                       policyLogger.info("General error" , e);
                }
                return resultBody;
        }
@@ -603,7 +613,7 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
                        }
 
                } catch (Exception e) {
-                       LOGGER.error("Exception Occured"+e);
+                       policyLogger.error("Exception Occured"+e);
                }
 
                return null;    
index 385ca15..39850d9 100644 (file)
@@ -63,6 +63,7 @@ public class CreateClosedLoopPMController{
                        try{
                                description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:"));
                        }catch(Exception e){
+                               LOGGER.info("General error" , e);
                                description = policy.getDescription();
                        }
                        policyAdapter.setPolicyDescription(description);
index e156002..777fb89 100644 (file)
@@ -35,6 +35,7 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -160,7 +161,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
                        jsonContent = decodeContent(root.get("policyJSON")).toString();
                        constructJson(policyData, jsonContent);
                }catch(Exception e){
-                       LOGGER.error("Error while decoding microservice content");
+                       LOGGER.error("Error while decoding microservice content", e);
                }
                
                return policyData;
@@ -224,7 +225,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
                try {
                        json = om.writeValueAsString(microServiceObject);
                } catch (JsonProcessingException e) {
-                       LOGGER.error("Error writing out the object");
+                       LOGGER.error("Error writing out the object", e);
                }
                LOGGER.info(json);
                String cleanJson = cleanUPJson(json);
@@ -254,7 +255,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
                                cleanJson = returnNode.toString();
                        }
                } catch (IOException e) {
-                       LOGGER.error("Error writing out the JsonNode");
+                       LOGGER.error("Error writing out the JsonNode",e);
                }
                return cleanJson;
        }
@@ -311,7 +312,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
        public Map<String, String> load(byte[] source) throws IOException { 
                Yaml yaml = new Yaml(); 
                @SuppressWarnings("unchecked")
-               Map<Object, Object> yamlMap = (Map<Object, Object>) yaml.load(source.toString()); 
+               Map<Object, Object> yamlMap = (Map<Object, Object>) yaml.load(Arrays.toString(source)); 
                StringBuilder sb = new StringBuilder(); 
                Map<String, String> settings = new HashMap <>(); 
                if (yamlMap == null) { 
@@ -397,10 +398,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
                HashMap<String,String> dataMapForJson=new HashMap <>(); 
                for(String uniqueDataKey: uniqueDataKeys){
                        if(uniqueDataKey.contains("%")){
-                               String[] uniqueDataKeySplit= uniqueDataKey.split("%",2);
-                               if (uniqueDataKeySplit.length < 2) {
-                                       continue;
-                               }
+                               String[] uniqueDataKeySplit= uniqueDataKey.split("%");
                                String findType=DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+TYPE;
                                String typeValue=map.get(findType);
                                LOGGER.info(typeValue);
@@ -476,10 +474,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
                HashMap<String,String> hmSub;
                for(Map.Entry<String, String> entry: dataMapForJson.entrySet()){
                        String uniqueDataKey= entry.getKey();
-                       String[] uniqueDataKeySplit=uniqueDataKey.split("%",2);
-                       if (uniqueDataKeySplit.length < 2) {
-                               continue;
-                       }
+                       String[] uniqueDataKeySplit=uniqueDataKey.split("%");
                        String value= dataMapForJson.get(uniqueDataKey);
                        if(dataMapKey.containsKey(uniqueDataKeySplit[0])){
                                hmSub = dataMapKey.get(uniqueDataKeySplit[0]);
@@ -743,10 +738,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
                                                        if(jsonArray != null && arryKey.equals(nodeKey.substring(0,nodeKey.indexOf("@")))){
                                                                jsonArray.put(decodeContent(node));
                                                        } 
-                                                       if(key.contains("@") && !arryKey.equals(key.substring(0,nodeKey.indexOf("@")))){
-                                                               jsonResult.put(arryKey, jsonArray);
-                                                               jsonArray = new JSONArray();
-                                                       }else if(!key.contains("@")){
+                                                       if((key.contains("@") && !arryKey.equals(key.substring(0,nodeKey.indexOf("@")))) || !key.contains("@")){
                                                                jsonResult.put(arryKey, jsonArray);
                                                                jsonArray = new JSONArray();
                                                        }
@@ -1231,18 +1223,13 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
                }
        }
 
-       private String getPolicyScope(String value) {   
-               GroupPolicyScopeList pScope = new GroupPolicyScopeList();
-               List<Object> groupList= commonClassDao.getData(GroupPolicyScopeList.class);
-               if(groupList.size() > 0){
-                       for(int i = 0 ; i < groupList.size() ; i ++){
-                               pScope = (GroupPolicyScopeList) groupList.get(i);
-                               if (pScope.getGroupList().equals(value)){
-                                       break;
-                               }               
-                       }
+       private String getPolicyScope(String value) {
+               List<Object> groupList= commonClassDao.getDataById(GroupPolicyScopeList.class, "groupList", value);
+               if(groupList != null && !groupList.isEmpty()){
+                       GroupPolicyScopeList pScope = (GroupPolicyScopeList) groupList.get(0);
+                       return pScope.getGroupName();           
                }
-               return pScope.getGroupName();
+               return null;
        }
 
        //Convert the map values and set into JSON body
index 4aea637..2232da6 100644 (file)
@@ -19,7 +19,6 @@
  */
 
 package org.openecomp.policy.controller;
-import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -67,11 +66,8 @@ import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.servlet.ModelAndView;
 
-import com.fasterxml.jackson.core.JsonGenerationException;
 import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.ObjectWriter;
@@ -87,7 +83,7 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
 @Controller
 @RequestMapping("/")
 public class CreateFirewallController extends RestrictedBaseController {
-       private static Logger logger    = FlexLogger.getLogger(CreateFirewallController.class);
+       private static Logger policyLogger      = FlexLogger.getLogger(CreateFirewallController.class);
 
        @Autowired
        SessionFactory sessionFactory;
@@ -110,9 +106,9 @@ public class CreateFirewallController extends RestrictedBaseController {
 
        public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData){
                
-               termCollectorList = new ArrayList<String>();
-               tagCollectorList = new ArrayList<String>();
-               if(policyData.getAttributes().size() > 0){
+               termCollectorList = new ArrayList<>();
+               tagCollectorList = new ArrayList<>();
+               if(!policyData.getAttributes().isEmpty()){
                        for(Object attribute : policyData.getAttributes()){
                                if(attribute instanceof LinkedHashMap<?, ?>){
                                        String key = ((LinkedHashMap<?, ?>) attribute).get("key").toString();
@@ -135,16 +131,14 @@ public class CreateFirewallController extends RestrictedBaseController {
        }
 
        private List<String> mapping(String expandableList) {
-               String value = new String();
-               String desc =  new String();
                List <String> valueDesc= new ArrayList<>();
                List<Object> prefixListData = commonClassDao.getData(PrefixList.class);
                for (int i = 0; i< prefixListData.size(); i++) {
                        PrefixList prefixList = (PrefixList) prefixListData.get(i);
                        if (prefixList.getPrefixListName().equals(expandableList)) {
-                               value = prefixList.getPrefixListValue();
+                               String value = prefixList.getPrefixListValue();
                                valueDesc.add(value);
-                               desc= prefixList.getDescription();
+                               String desc= prefixList.getDescription();
                                valueDesc.add(desc);
                                break;
                        }
@@ -198,14 +192,15 @@ public class CreateFirewallController extends RestrictedBaseController {
                        // policy name value is the policy name without any prefix and Extensions.
                        policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName());
                        String policyNameValue = policyAdapter.getPolicyName().substring(policyAdapter.getPolicyName().indexOf("FW_") +3);
-                       if (logger.isDebugEnabled()) {
-                               logger.debug("Prepopulating form data for Config Policy selected:"+ policyAdapter.getPolicyName());
+                       if (policyLogger.isDebugEnabled()) {
+                               policyLogger.debug("Prepopulating form data for Config Policy selected:"+ policyAdapter.getPolicyName());
                        }
                        policyAdapter.setPolicyName(policyNameValue);
                        String description = "";
                        try{
                                description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:"));
                        }catch(Exception e){
+                               policyLogger.info("General error", e);
                                description = policy.getDescription();
                        }
                        policyAdapter.setPolicyDescription(description);
@@ -229,7 +224,7 @@ public class CreateFirewallController extends RestrictedBaseController {
                                }
                        }
                        catch(Exception e) {
-                               logger.error("Exception Caused while Retriving the JSON body data" +e);
+                               policyLogger.error("Exception Caused while Retriving the JSON body data" +e);
                        }
                        
                        Map<String, String> termTagMap=null;
@@ -317,14 +312,14 @@ public class CreateFirewallController extends RestrictedBaseController {
        }
        
        @RequestMapping(value={"/policyController/ViewFWPolicyRule.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView setFWViewRule(HttpServletRequest request, HttpServletResponse response) throws Exception{
+       public void setFWViewRule(HttpServletRequest request, HttpServletResponse response){
                try {
                        termCollectorList = new ArrayList<>();
                        ObjectMapper mapper = new ObjectMapper();
                        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                        JsonNode root = mapper.readTree(request.getReader());
                        PolicyRestAdapter policyData = (PolicyRestAdapter)mapper.readValue(root.get("policyData").toString(), PolicyRestAdapter.class);
-                       if(policyData.getAttributes().size() > 0){
+                       if(!policyData.getAttributes().isEmpty()){
                                for(Object attribute : policyData.getAttributes()){
                                        if(attribute instanceof LinkedHashMap<?, ?>){
                                                String key = ((LinkedHashMap<?, ?>) attribute).get("key").toString();
@@ -450,7 +445,7 @@ public class CreateFirewallController extends RestrictedBaseController {
                                                                }
                                                        }
                                                }
-                                               displayString.append("\n");
+                                               displayString.append("\n");     
                                        }
 
                                        ruleAction=(jpaTermList).getAction();
@@ -469,11 +464,9 @@ public class CreateFirewallController extends RestrictedBaseController {
                        String responseString = mapper.writeValueAsString(displayString);
                        JSONObject j = new JSONObject("{policyData: " + responseString + "}");
                        out.write(j.toString());
-                       return null;
                } catch (Exception e) {
-                       logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
+                       policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                }
-               return null;    
        }
 
        private String constructJson(PolicyRestAdapter policyData) {
@@ -847,10 +840,10 @@ public class CreateFirewallController extends RestrictedBaseController {
                                                        PrefixIPList targetAddressList = new PrefixIPList();
                                                        AddressMembers addressMembers= new AddressMembers();
                                                        targetAddressList.setName(prefixIP);
-                                                       logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "PrefixList value:"+prefixIP);
+                                                       policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "PrefixList value:"+prefixIP);
                                                        valueDesc = mapping(prefixIP);
                                                        if(!valueDesc.isEmpty()){
-                                                               logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "PrefixList description:"+valueDesc.get(1));
+                                                               policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "PrefixList description:"+valueDesc.get(1));
                                                                targetAddressList.setDescription(valueDesc.get(1));
                                                        }
                                                        
@@ -922,16 +915,12 @@ public class CreateFirewallController extends RestrictedBaseController {
                        ObjectWriter om = new ObjectMapper().writer();
                        try {
                                json = om.writeValueAsString(tc);
-                       } catch (JsonGenerationException e) {
-                               logger.error("Exception Occured"+e);
-                       } catch (JsonMappingException e) {
-                               logger.error("Exception Occured"+e);
-                       } catch (IOException e) {
-                               logger.error("Exception Occured"+e);
+                       } catch (Exception e) {
+                               policyLogger.error("Exception Occured"+e);
                        }       
 
                }catch (Exception e) {
-                       logger.error("Exception Occured"+e);
+                       policyLogger.error("Exception Occured"+e);
                }
 
                return json;
index 56ff637..0894706 100644 (file)
@@ -73,7 +73,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 @Controller
 @RequestMapping({"/"})
 public class DashboardController  extends RestrictedBaseController{
-       private static final Logger logger = FlexLogger.getLogger(DashboardController.class);
+       private static final Logger policyLogger = FlexLogger.getLogger(DashboardController.class);
        @Autowired
        SystemLogDbDao systemDAO;
        
@@ -110,7 +110,7 @@ public class DashboardController  extends RestrictedBaseController{
                        response.getWriter().write(j.toString());
                }
                catch (Exception e){
-                       logger.error("Exception Occured"+e);
+                       policyLogger.error("Exception Occured"+e);
                }
        }
        
@@ -125,7 +125,7 @@ public class DashboardController  extends RestrictedBaseController{
                        response.getWriter().write(j.toString());
                }
                catch (Exception e){
-                       logger.error("Exception Occured"+e);
+                       policyLogger.error("Exception Occured"+e);
                }
        }
        
@@ -142,7 +142,7 @@ public class DashboardController  extends RestrictedBaseController{
                        response.getWriter().write(j.toString());
                }
                catch (Exception e){
-                       logger.error("Exception Occured"+e);
+                       policyLogger.error("Exception Occured"+e);
                }
        }
        
@@ -161,7 +161,7 @@ public class DashboardController  extends RestrictedBaseController{
                        response.getWriter().write(j.toString());
                }
                catch (Exception e){
-                       logger.error("Exception Occured"+e);
+                       policyLogger.error("Exception Occured"+e);
                }
        }
        
@@ -180,7 +180,7 @@ public class DashboardController  extends RestrictedBaseController{
                        response.getWriter().write(j.toString());
                }
                catch (Exception e){
-                       logger.error("Exception Occured"+e);
+                       policyLogger.error("Exception Occured"+e);
                }
        }
        
@@ -201,7 +201,7 @@ public class DashboardController  extends RestrictedBaseController{
                        }
                } catch (PAPException | NullPointerException e1) {
                        papStatus = "CANNOT_CONNECT";
-                       logger.error("Error getting PAP status, PAP not responding to requests");
+                       policyLogger.error("Error getting PAP status, PAP not responding to requests", e1);
                }
                String papURL = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL);
                JSONObject object = new JSONObject();
@@ -229,11 +229,12 @@ public class DashboardController  extends RestrictedBaseController{
                                if (pdp.getStatus().getStatus().toString() == "UP_TO_DATE" && ((EcompPDP) pdp).getJmxPort() != 0){
                                        String pdpIpAddress = parseIPSystem(pdp.getId());
                                        int port = ((EcompPDP) pdp).getJmxPort();
-                                       if (port != 0)
-                                       logger.debug("Getting JMX Response Counts from " + pdpIpAddress + " at JMX port " + port);
-                                       naCount = getRequestCounts(pdpIpAddress, port, "pdpEvaluationNA");
-                                       permitCount = getRequestCounts(pdpIpAddress, port, "PdpEvaluationPermit");
-                                       denyCount = getRequestCounts(pdpIpAddress, port, "PdpEvaluationDeny");
+                                       if (port != 0){
+                                               policyLogger.debug("Getting JMX Response Counts from " + pdpIpAddress + " at JMX port " + port);
+                                               naCount = getRequestCounts(pdpIpAddress, port, "pdpEvaluationNA");
+                                               permitCount = getRequestCounts(pdpIpAddress, port, "PdpEvaluationPermit");
+                                               denyCount = getRequestCounts(pdpIpAddress, port, "PdpEvaluationDeny");
+                                       }
                                }
                                if (naCount == -1){
                                        JSONObject object = new JSONObject();
@@ -279,7 +280,7 @@ public class DashboardController  extends RestrictedBaseController{
        @SuppressWarnings({ "rawtypes", "unchecked" })
        private long getRequestCounts(String host, int port, String jmxAttribute) {
                
-               logger.debug("Create an RMI connector client and connect it to the JMX connector server");
+               policyLogger.debug("Create an RMI connector client and connect it to the JMX connector server");
                HashMap map = new HashMap();
                map = null;
                JMXConnector jmxConnection;
@@ -288,23 +289,23 @@ public class DashboardController  extends RestrictedBaseController{
                        jmxConnection.connect();
                        Object o = jmxConnection.getMBeanServerConnection().getAttribute(new ObjectName("PdpRest:type=PdpRestMonitor"), jmxAttribute);
                        jmxConnection.close();
-                       logger.debug("pdpEvaluationNA value retreived: " + o);
+                       policyLogger.debug("pdpEvaluationNA value retreived: " + o);
                        return (long) o;
                } catch (MalformedURLException e) {
-                       logger.error("MalformedURLException for JMX connection");
+                       policyLogger.error("MalformedURLException for JMX connection" , e);
                } catch (IOException e) {
-                       logger.error("Error in reteriving" + jmxAttribute + " from JMX connection");
+                       policyLogger.error("Error in reteriving" + jmxAttribute + " from JMX connection", e);
                } catch (AttributeNotFoundException e) {                
-                       logger.error("AttributeNotFoundException  " + jmxAttribute +  " for JMX connection");
+                       policyLogger.error("AttributeNotFoundException  " + jmxAttribute +  " for JMX connection", e);
                } catch (InstanceNotFoundException e) {
-                       logger.error("InstanceNotFoundException " + host + " for JMX connection");
+                       policyLogger.error("InstanceNotFoundException " + host + " for JMX connection", e);
                } catch (MalformedObjectNameException e) {
-                       logger.error("MalformedObjectNameException for JMX connection");
+                       policyLogger.error("MalformedObjectNameException for JMX connection", e);
                } catch (MBeanException e) {
-                       logger.error("MBeanException for JMX connection");
-                       logger.error("Exception Occured"+e);
+                       policyLogger.error("MBeanException for JMX connection");
+                       policyLogger.error("Exception Occured"+e);
                } catch (ReflectionException e) {
-                       logger.error("ReflectionException for JMX connection");
+                       policyLogger.error("ReflectionException for JMX connection", e);
                }
                
                return -1;
@@ -332,7 +333,7 @@ public class DashboardController  extends RestrictedBaseController{
                                try{
                                        policyMap.put(policy.getPolicyId().replace(" ", ""), policy.getId());
                                }catch(Exception e){
-                                       logger.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID+policy.getName() +e);
+                                       policyLogger.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID+policy.getName() +e);
                                }
                        }
                        
@@ -386,7 +387,7 @@ public class DashboardController  extends RestrictedBaseController{
         */
        @SuppressWarnings({ "rawtypes", "unchecked" })
        private Object getPolicy(String host, int port, String jmxAttribute){
-               logger.debug("Create an RMI connector client and connect it to the JMX connector server for Policy: " + host);
+               policyLogger.debug("Create an RMI connector client and connect it to the JMX connector server for Policy: " + host);
                HashMap map = new HashMap();
                map = null;
                JMXConnector jmxConnection;
@@ -395,23 +396,23 @@ public class DashboardController  extends RestrictedBaseController{
                        jmxConnection.connect();
                        Object o = jmxConnection.getMBeanServerConnection().getAttribute(new ObjectName("PdpRest:type=PdpRestMonitor"), "policyMap");
                        jmxConnection.close();
-                       logger.debug("policyMap value retreived: " + o);
+                       policyLogger.debug("policyMap value retreived: " + o);
                        return  o;
                } catch (MalformedURLException e) {
-                       logger.error("MalformedURLException for JMX connection");
+                       policyLogger.error("MalformedURLException for JMX connection");
                } catch (IOException e) {
-                       logger.error("AttributeNotFoundException for policyMap" );
+                       policyLogger.error("AttributeNotFoundException for policyMap" );
                } catch (AttributeNotFoundException e) {                
-                       logger.error("AttributeNotFoundException for JMX connection");
+                       policyLogger.error("AttributeNotFoundException for JMX connection");
                } catch (InstanceNotFoundException e) {
-                       logger.error("InstanceNotFoundException " + host + " for JMX connection");
+                       policyLogger.error("InstanceNotFoundException " + host + " for JMX connection");
                } catch (MalformedObjectNameException e) {
-                       logger.error("MalformedObjectNameException for JMX connection");
+                       policyLogger.error("MalformedObjectNameException for JMX connection");
                } catch (MBeanException e) {
-                       logger.error("MBeanException for JMX connection");
-                       logger.error("Exception Occured"+e);
+                       policyLogger.error("MBeanException for JMX connection");
+                       policyLogger.error("Exception Occured"+e);
                } catch (ReflectionException e) {
-                       logger.error("ReflectionException for JMX connection");
+                       policyLogger.error("ReflectionException for JMX connection");
                }
                
                return null;
index ef43135..f959495 100644 (file)
@@ -21,6 +21,7 @@
 package org.openecomp.policy.controller;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -39,7 +40,6 @@ import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionsType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
@@ -58,7 +58,7 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableReferenceType;
 @Controller
 @RequestMapping("/")
 public class DecisionPolicyController extends RestrictedBaseController {
-       private static final Logger logger = FlexLogger.getLogger(DecisionPolicyController.class);
+       private static final Logger policyLogger = FlexLogger.getLogger(DecisionPolicyController.class);
        
        public DecisionPolicyController(){}
 
@@ -88,6 +88,7 @@ public class DecisionPolicyController extends RestrictedBaseController {
                        try{
                                description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:"));
                        }catch(Exception e){
+                               policyLogger.info("General error", e);
                                description = policy.getDescription();
                        }
                        policyAdapter.setPolicyDescription(description);
@@ -141,23 +142,28 @@ public class DecisionPolicyController extends RestrictedBaseController {
                                                }
                                        }
                                        // Setting rainy day attributes to the parameters object if they exist 
+                                       boolean rainy = false;
                                        if(!attributeList.isEmpty()) {
                                                for(int i=0; i<attributeList.size() ; i++){
                                                        Map<String, String> map = (Map<String,String>)attributeList.get(i);
                                                        if(map.get("key").equals("WorkStep")){
                                                                rainydayParams.setWorkstep(map.get("value"));
+                                                               rainy=true;
                                                        }else if(map.get("key").equals("BB_ID")){
                                                                rainydayParams.setBbid(map.get("value"));
+                                                               rainy=true;
                                                        }else if(map.get("key").equals("ServiceType")){
                                                                rainydayParams.setServiceType(map.get("value"));
+                                                               rainy=true;
                                                        }else if(map.get("key").equals("VNFType")){
                                                                rainydayParams.setVnfType(map.get("value"));
+                                                               rainy=true;
                                                        }
                                                }       
                                        }
-                                       
-                                       policyAdapter.setRuleProvider("Rainy_Day");
-
+                                       if(rainy){
+                                               policyAdapter.setRuleProvider("Rainy_Day");
+                                       }
                                }
 
                                List<Object> ruleList = policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition();
@@ -165,7 +171,7 @@ public class DecisionPolicyController extends RestrictedBaseController {
                                for (Object object : ruleList) {
                                        if (object instanceof VariableDefinitionType) {
                                                VariableDefinitionType variableDefinitionType = (VariableDefinitionType) object;
-                                               Map<String, String> settings = new HashMap<String, String>();
+                                               Map<String, String> settings = new HashMap<>();
                                                settings.put("key", variableDefinitionType.getVariableId());
                                                JAXBElement<AttributeValueType> attributeValueTypeElement = (JAXBElement<AttributeValueType>) variableDefinitionType.getExpression();
                                                if (attributeValueTypeElement != null) {
@@ -201,6 +207,10 @@ public class DecisionPolicyController extends RestrictedBaseController {
                                                                                        yamlParams.setActor(map.get("value"));
                                                                                }else if(map.get("key").equals("recipe")){
                                                                                        yamlParams.setRecipe(map.get("value"));
+                                                                               }else if(map.get("key").equals("targets")){
+                                                                                       yamlParams.setTargets(Arrays.asList(map.get("value").split("\\|")));
+                                                                               }else if(map.get("key").equals("clname")){
+                                                                                       yamlParams.setClname(map.get("value"));
                                                                                }
                                                                        }
                                                                        ApplyType apply = ((ApplyType)((ApplyType)decisionApply.getExpression().get(0).getValue()).getExpression().get(0).getValue());
@@ -215,9 +225,11 @@ public class DecisionPolicyController extends RestrictedBaseController {
                                                                                }
                                                                                yamlParams.setBlackList(blackList);
                                                                        }else{
-                                                                               yamlParams.setLimit(((AttributeValueType)((ApplyType)decisionApply.getExpression().get(1).getValue()).getExpression().get(1).getValue()).getContent().get(0).toString());
-                                                                               String timeWindow = ((AttributeDesignatorType)((ApplyType)((ApplyType)decisionApply.getExpression().get(1).getValue()).getExpression().get(0).getValue()).getExpression().get(0).getValue()).getIssuer();
-                                                                               yamlParams.setTimeWindow(timeWindow.substring(timeWindow.lastIndexOf(":")+1));
+                                                                               ApplyType timeWindowSection = (ApplyType)((ApplyType)decisionApply.getExpression().get(0).getValue()).getExpression().get(1).getValue();
+                                                                               yamlParams.setLimit(((AttributeValueType)timeWindowSection.getExpression().get(1).getValue()).getContent().get(0).toString());
+                                                                               String timeWindow = ((AttributeDesignatorType)((ApplyType)timeWindowSection.getExpression().get(0).getValue()).getExpression().get(0).getValue()).getIssuer();
+                                                                               yamlParams.setTimeUnits(timeWindow.substring(timeWindow.lastIndexOf(':')+1));
+                                                                               yamlParams.setTimeWindow(timeWindow.substring(timeWindow.indexOf(":tw:")+4,timeWindow.lastIndexOf(':')));
                                                                        }
                                                                        policyAdapter.setYamlparams(yamlParams);
                                                                        policyAdapter.setAttributes(new ArrayList<Object>());
@@ -228,7 +240,7 @@ public class DecisionPolicyController extends RestrictedBaseController {
                                                                prePopulateDecisionCompoundRuleAlgorithm(index, decisionApply);
                                                                policyAdapter.setRuleAlgorithmschoices(ruleAlgorithmList);
                                                        }
-                                               } else if (((RuleType) object).getEffect().equals(EffectType.PERMIT)) {
+                                               } else if(policyAdapter.getRuleProvider()!=null && policyAdapter.getRuleProvider().equals("Rainy_Day")&& ((RuleType) object).getEffect().equals(EffectType.PERMIT)) {
                                                        
                                                        TargetType ruleTarget = ((RuleType) object).getTarget();
                                                        AdviceExpressionsType adviceExpression = ((RuleType) object).getAdviceExpressions();
@@ -303,8 +315,8 @@ public class DecisionPolicyController extends RestrictedBaseController {
                List<JAXBElement<?>> jaxbDecisionTypes = decisionApply.getExpression();
                for (JAXBElement<?> jaxbElement : jaxbDecisionTypes) {
                        // If There is Attribute Value under Decision Type that means we came to the final child
-                       if (logger.isDebugEnabled()) {
-                               logger.debug("Prepopulating rule algoirthm: " + index);
+                       if (policyLogger.isDebugEnabled()) {
+                               policyLogger.debug("Prepopulating rule algoirthm: " + index);
                        }
                        // Check to see if Attribute Value exists, if yes then it is not a compound rule
                        if(jaxbElement.getValue() instanceof AttributeValueType) {
@@ -321,8 +333,8 @@ public class DecisionPolicyController extends RestrictedBaseController {
                                index = prePopulateDecisionCompoundRuleAlgorithm(index, innerDecisionApply);
                        }
                        // Populate combo box
-                       if (logger.isDebugEnabled()) {
-                               logger.debug("Prepopulating Compound rule algorithm: " + index);
+                       if (policyLogger.isDebugEnabled()) {
+                               policyLogger.debug("Prepopulating Compound rule algorithm: " + index);
                        }
                        Map<String, String> rule = new HashMap<>();
                        for (String key : PolicyController.getDropDownMap().keySet()) {
index 2e9771e..6ef7165 100644 (file)
@@ -59,7 +59,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 @Controller
 @RequestMapping({"/"})
 public class PDPController extends RestrictedBaseController {
-       private static final  Logger logger = FlexLogger.getLogger(PDPController.class);
+       private static final  Logger policyLogger = FlexLogger.getLogger(PDPController.class);
 
        protected List<EcompPDPGroup> groups = Collections.synchronizedList(new ArrayList<EcompPDPGroup>());
        private PDPGroupContainer container;
@@ -152,7 +152,7 @@ public class PDPController extends RestrictedBaseController {
                                }
                        } catch (PAPException e) {
                                String message = "Unable to retrieve Groups from server: " + e;
-                               logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR+"Pap Engine is Null" + message);
+                               policyLogger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR+"Pap Engine is Null" + message);
                        }
                }
        }
@@ -167,12 +167,12 @@ public class PDPController extends RestrictedBaseController {
                        response.getWriter().write(j.toString());
                }
                catch (Exception e){
-                       logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while retrieving the PDP Group data" + e);
+                       policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while retrieving the PDP Group data" + e);
                }
        }
 
        @RequestMapping(value={"/pdp_Group/save_pdp_group"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView savePDPGroup(HttpServletRequest request, HttpServletResponse response) throws Exception{
+       public void savePDPGroup(HttpServletRequest request, HttpServletResponse response){
                try {
                        ObjectMapper mapper = new ObjectMapper();
                        PolicyController controller = getPolicyControllerInstance();
@@ -189,7 +189,7 @@ public class PDPController extends RestrictedBaseController {
 
                        } catch (Exception e) {
                                String message = "Unable to create Group.  Reason:\n" + e.getMessage();
-                               logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while creating the PDP Group" + message);
+                               policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while creating the PDP Group" + message + e);
                        }
 
 
@@ -202,21 +202,23 @@ public class PDPController extends RestrictedBaseController {
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups));
                        JSONObject j = new JSONObject(msg);
                        out.write(j.toString());
-
-                       return null;
                }
                catch (Exception e){
-                       logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Saving the PDP Group" + e);
+                       policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Saving the PDP Group" + e);
                        response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
-                       PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       PrintWriter out = null;
+                       try {
+                               request.setCharacterEncoding("UTF-8");
+                               out = response.getWriter();
+                               out.write(e.getMessage());
+                       } catch (Exception e1) {
+                               policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Saving the PDP Group" + e1);
+                       }
                }
-               return null;
        }
 
        @RequestMapping(value={"/pdp_Group/remove_pdp_group"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removePDPGroup(HttpServletRequest request, HttpServletResponse response) throws Exception {
+       public void removePDPGroup(HttpServletRequest request, HttpServletResponse response){
                try{
                        ObjectMapper mapper = new ObjectMapper();
                        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
@@ -240,21 +242,23 @@ public class PDPController extends RestrictedBaseController {
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups));
                        JSONObject j = new JSONObject(msg);
                        out.write(j.toString());
-
-                       return null;
                }
                catch (Exception e){
-                       logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Removing the PDP Group" + e);
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
-                       PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Removing the PDP Group" + e);
+                       PrintWriter out;
+                       try {
+                               response.setCharacterEncoding("UTF-8");
+                               request.setCharacterEncoding("UTF-8");
+                               out = response.getWriter();
+                               out.write(e.getMessage());
+                       } catch (Exception e1) {
+                               policyLogger.error("Exception Occured"+ e1);
+                       }
                }
-               return null;
        }
 
        @RequestMapping(value={"/pdp_Group/save_pdpTogroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView savePDPToGroup(HttpServletRequest request, HttpServletResponse response) throws Exception{
+       public void savePDPToGroup(HttpServletRequest request, HttpServletResponse response){
                try {
                        ObjectMapper mapper = new ObjectMapper();
                        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
@@ -273,7 +277,7 @@ public class PDPController extends RestrictedBaseController {
                                }
                        } catch (Exception e) {
                                String message = "Unable to create Group.  Reason:\n" + e.getMessage();
-                               logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Creating Pdp in PDP Group" + message);
+                               policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Creating Pdp in PDP Group" + message + e);
                        }
 
 
@@ -286,21 +290,23 @@ public class PDPController extends RestrictedBaseController {
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups));
                        JSONObject j = new JSONObject(msg);
                        out.write(j.toString());
-
-                       return null;
                }
                catch (Exception e){
-                       logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Creating Pdp in PDP Group" + e);
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
-                       PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Creating Pdp in PDP Group" + e);
+                       PrintWriter out;
+                       try {
+                               response.setCharacterEncoding("UTF-8");
+                               request.setCharacterEncoding("UTF-8");
+                               out = response.getWriter();
+                               out.write(e.getMessage());
+                       } catch (Exception e1) {
+                               policyLogger.error("Exception Occured"+ e1);
+                       }
                }
-               return null;
        }
 
        @RequestMapping(value={"/pdp_Group/remove_pdpFromGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removePDPFromGroup(HttpServletRequest request, HttpServletResponse response) throws Exception {
+       public void removePDPFromGroup(HttpServletRequest request, HttpServletResponse response){
                try{
                        ObjectMapper mapper = new ObjectMapper();
                        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
@@ -320,17 +326,19 @@ public class PDPController extends RestrictedBaseController {
                        String responseString = mapper.writeValueAsString(groups);
                        JSONObject j = new JSONObject("{pdpEntityDatas: " + responseString + "}");
                        out.write(j.toString());
-
-                       return null;
                }
                catch (Exception e){
-                       logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Removing Pdp from PDP Group" + e);
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
-                       PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Removing Pdp from PDP Group" + e);
+                       PrintWriter out;
+                       try {
+                               response.setCharacterEncoding("UTF-8");
+                               request.setCharacterEncoding("UTF-8");
+                               out = response.getWriter();
+                               out.write(e.getMessage());
+                       } catch (Exception e1) {
+                               policyLogger.error("Exception Occured"+ e1);
+                       }
                }
-               return null;
        }
 
        private PolicyController getPolicyControllerInstance(){
index bf2a148..8fe2d49 100644 (file)
@@ -99,6 +99,14 @@ public class PolicyExportAndImportController extends RestrictedBaseController {
                this.policyController = policyController;
        }
 
+       public static CommonClassDao getCommonClassDao() {
+               return commonClassDao;
+       }
+
+       public static void setCommonClassDao(CommonClassDao commonClassDao) {
+               PolicyExportAndImportController.commonClassDao = commonClassDao;
+       }
+
        @Autowired
        private PolicyExportAndImportController(CommonClassDao commonClassDao){
                PolicyExportAndImportController.commonClassDao = commonClassDao;
@@ -107,7 +115,7 @@ public class PolicyExportAndImportController extends RestrictedBaseController {
        public PolicyExportAndImportController(){}
 
        @RequestMapping(value={"/policy_download/exportPolicy.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public void ExportPolicy(HttpServletRequest request, HttpServletResponse response) throws Exception{
+       public void exportPolicy(HttpServletRequest request, HttpServletResponse response) throws Exception{
                try{
                        String file = null;
                        selectedPolicy = new ArrayList<>();
index cc6903b..0f8b379 100644 (file)
@@ -401,10 +401,8 @@ public class PolicyValidationController extends RestrictedBaseController {
                                                                        int endNum = Integer.parseInt(tempString[1]);
                                                                        String returnString = "Invalid Range:" + rMap.getKey() + " must be between " 
                                                                                        + startNum + " - "  + endNum + ",";
-                                                                       if (isInteger(value.replace("\"", ""))){
+                                                                       if (PolicyUtils.isInteger(value.replace("\"", ""))){
                                                                                int result = Integer.parseInt(value.replace("\"", ""));
-
-
                                                                                if (result < startNum || result > endNum){
                                                                                        responseString.append(returnString);                                                                    
                                                                                        valid = false;
@@ -492,13 +490,20 @@ public class PolicyValidationController extends RestrictedBaseController {
                                                        if(policyData.getYamlparams().getLimit()==null){
                                                                responseString.append(" Guard Params <b>Limit</b> is Required " + "<br>");
                                                                valid = false;
-                                                       }else if(!isInteger(policyData.getYamlparams().getLimit())){
+                                                       }else if(!PolicyUtils.isInteger(policyData.getYamlparams().getLimit())){
                                                                responseString.append(" Guard Params <b>Limit</b> Should be Integer " + "<br>");
                                                                valid = false;
                                                        }
                                                        if(policyData.getYamlparams().getTimeWindow()==null){
                                                                responseString.append("Guard Params <b>Time Window</b> is Required" + "<br>");
                                                                valid = false;
+                                                       }else if(!PolicyUtils.isInteger(policyData.getYamlparams().getTimeWindow())){
+                                                               responseString.append(" Guard Params <b>Time Window</b> Should be Integer " + "<br>");
+                                                               valid = false;
+                                                       }
+                                                       if(policyData.getYamlparams().getTimeUnits()==null){
+                                                               responseString.append("Guard Params <b>Time Units</b> is Required" + "<br>");
+                                                               valid = false;
                                                        }
                                                }else if("GUARD_BL_YAML".equals(policyData.getRuleProvider())){
                                                        if(policyData.getYamlparams().getBlackList()==null || policyData.getYamlparams().getBlackList().isEmpty()){
@@ -623,15 +628,6 @@ public class PolicyValidationController extends RestrictedBaseController {
                return null;
        }
 
-       protected boolean isInteger(String number) {
-               try{
-                       Integer.parseInt(number);
-               }catch(NumberFormatException e){
-                       return false;
-               }
-               return true;
-       }
-
        protected String  emptyValidator(String field){
                String error;
                if ("".equals(field) || field.contains(" ") || !field.matches("^[a-zA-Z0-9_]*$")) {
index 2919f5f..2cf57d3 100644 (file)
@@ -14778,7 +14778,7 @@ var _inherits = function (subClass, superClass) { if (typeof superClass !== "fun
 
 var Container = require("./container");
 
-// CSS at-rule like \93this.keyframes name { }\94.
+// CSS at-rule like ï¿½this.keyframes name { }�.
 //
 // Can contain declarations (like this.font-face or this.page) ot another rules.
 var AtRule = (function (Container) {
@@ -15486,7 +15486,7 @@ var _inherits = function (subClass, superClass) { if (typeof superClass !== "fun
 var Node = require("./node");
 var vendor = require("./vendor");
 
-// CSS declaration like \93color: black\94 in rules
+// CSS declaration like ï¿½color: black� in rules
 var Declaration = (function (Node) {
     function Declaration(defaults) {
         this.type = "decl";
@@ -17281,7 +17281,7 @@ var Container = require("./container");
 var Declaration = require("./declaration");
 var list = require("./list");
 
-// CSS rule like \93a { }\94
+// CSS rule like ï¿½a { }�
 var Rule = (function (Container) {
     function Rule(defaults) {
         this.type = "rule";
index 6ebda43..0cd3c52 100644 (file)
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */-->
 <script type="text/ng-template" id="remove_PDPGroupPolicies_popup.html">
-<div class="modal" style="margin-bottom: 20px; width: 100%; height:80%" data-backdrop="static"
+<div class="modal" style="margin-bottom: 20px; width: 100%" height:80%" data-backdrop="static"
        data-keyboard="false">
        <div class="modal-dialog-lg">
        <div class="modal-content">
index fb96643..94c1bc9 100644 (file)
@@ -163,10 +163,14 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
                                var addElement = parentElement.childElementCount + 1;
                                clone.id = ''+value+'@'+addElement;
                                clone.value = '';
+                               clone.className += ' child_single'; //here cloned is single element
                                document.getElementById("div."+value).appendChild(clone);
                                plainAttributeKeys.push(''+value+'@'+addElement);
                        }else{
                                div = document.getElementById("div."+value+"@0");
+                               
+                               div.className += ' children_group'; //here is div with a group of children.
+                               
                                var childElement = parentElement.firstElementChild;
                                var countParent = parentElement.childElementCount;
                                var childElementString = childElement.innerHTML;
@@ -295,9 +299,12 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
                        var plainAttributeKeys = [];
                        $scope.dcaeModelData = data[0].dcaeModelData;
                        $scope.dcaeJsonDate = data[0].jsonValue;
+                       console.log("$scope.dcaeJsonDate: " + $scope.dcaeJsonDate);     
                        var attributes = $scope.dcaeModelData.attributes;
                        var refAttributes = $scope.dcaeModelData.ref_attributes;
-                       var subAttributes =     $scope.dcaeModelData.sub_attributes;
+                       var subAttributes =     $scope.dcaeModelData.sub_attributes;                            
+                       console.log("subAttributes: " + subAttributes); 
+                       
                                var enumAttributes = $scope.dcaeModelData.enumValues;
                                var annotation = $scope.dcaeModelData.annotation;
                                var dictionary = $scope.microServiceAttributeDictionaryDatas;
@@ -442,11 +449,11 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
                return Object.prototype.toString.call(arrayTest) === '[object Array]';
            }
            var lableList = [];
-           
                function deconstructJSON(dataTest, level , name) {
                        var array = false;
                        var label = level;
                         var stringValue = "java.lang.String";
+                        var string = "string";
                         var intValue = "int";
                         var double = "double";
                         var boolean = "boolean";
@@ -459,6 +466,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
                    for (key in dataTest) {
                        array = isArray(dataTest[key]);
                        console.log(key , dataTest[key]);
+               
                        if (!!dataTest[key] && typeof(dataTest[key])=="object") {
                                if (array==false && key!=="0"){
                                        $scope.labelLayout(label, key, array );                         
@@ -500,11 +508,35 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
                                if (dataTest[key].includes('required-true')){
                                        isRequired = true;
                                }
-                               console.log("attirbuteLabel = " + attirbuteLabel);
+                               
+                               var subAttributes = $scope.dcaeModelData.sub_attributes;
+                               
+                               if(subAttributes){                                      
+                                       var jsonObject = JSON.parse(subAttributes);                                     
+                                       var allkeys = Object.keys(jsonObject);
+                                       if(allkeys){
+                                               for (var k = 0; k < allkeys.length; k++) {
+                                                       var keyValue = allkeys[k];
+                                                       console.log(" keyValue:jsonObject["+keyValue+ "]: " + jsonObject[keyValue]);
+                                                       if(jsonObject[keyValue]){
+                                                               var tempObject = jsonObject[keyValue];
+                                                               if(tempObject && tempObject[key]){
+                                                               if (tempObject[key].includes('required-true')){
+                                                                       isRequired = true;
+                                                               }       
+                                                               }
+                                                       }
+                                               }                                               
+                                       }                                       
+                               }
+                               
                                switch (dataTest[key].split(splitcolon)[0]){
                                        case stringValue:
                                                $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired);
                                                break;
+                                       case string:
+                                               $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired);
+                                               break;                                          
                                        case intValue: 
                                                $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired);
                                                break;
@@ -582,13 +614,13 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
                        var buttonaddLabel = document.createTextNode("+");       
                        addButton.appendChild(buttonaddLabel); 
                        addButton.setAttribute("id", labelValue + attibuteKey);
-                       addButton.setAttribute("class", "btn btn-default");
+                       addButton.setAttribute("class", "btn btn-add-remove");
                        addButton.setAttribute("ng-click" ,  'addNewChoice("'+labelValue + attibuteKey+'");');
                        addButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
                        var removeButton = document.createElement("BUTTON");
                        var buttonremoveLabel = document.createTextNode("-");       
                        removeButton.appendChild(buttonremoveLabel); 
-                       removeButton.setAttribute("class", "btn btn-default");
+                       removeButton.setAttribute("class", "btn btn-add-remove");
                        removeButton.setAttribute("ng-click" ,  'removeChoice("'+labelValue + attibuteKey+'");');
                        removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
                        document.getElementById(divID).appendChild(addButton); 
@@ -597,6 +629,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
                        document.getElementById(divID).appendChild(textField); 
                        document.getElementById(divID).appendChild(br); 
                        document.getElementById(divID).appendChild(divTag); 
+                       
                }else{
                        checkKey = labelValue + attibuteKey;
                        textField.setAttribute("id" , ''+labelValue +attibuteKey+'');
@@ -609,6 +642,16 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
 
                }
                
+               if(divID.includes("@0") && divID.includes("div.")){
+                       var firstChild_Id = divID.split("@0")[0];
+                       var firstChild_element = document.getElementById(firstChild_Id);
+                       if(firstChild_element){
+                               firstChild_element.className += ' children_group';  //here is a div with a group of children.
+                       }
+               }
+               console.log('firstChild_Id: ' + firstChild_Id);
+               console.log('divID: ' + divID);
+               
                if (defaultValue.length > 0){   
                        if(defaultValue.includes(":")){
                                defaultValue = defaultValue.split(":")[0];
@@ -661,18 +704,20 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
                var labeltext = document.createTextNode(lableName);
        
                label.appendChild(labeltext);
+               
+               var subAttributes = $scope.dcaeModelData.sub_attributes;
 
                if(labelManyKey){
                        var addButton = document.createElement("BUTTON");
                        var buttonLabel = document.createTextNode("+");       
                        addButton.appendChild(buttonLabel); 
-                       addButton.setAttribute("class", "btn btn-default");
+                       addButton.setAttribute("class", "btn btn-add-remove");
                        addButton.setAttribute("ng-click" ,  'addNewChoice("'+labelValue + lableName+'");');
                        addButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
                        var removeButton = document.createElement("BUTTON");
                        var buttonremoveLabel = document.createTextNode("-");       
                        removeButton.appendChild(buttonremoveLabel); 
-                       removeButton.setAttribute("class", "btn btn-default");
+                       removeButton.setAttribute("class", "btn btn-add-remove");
                        removeButton.setAttribute("ng-click" ,  'removeChoice("'+labelValue +lableName+'");');
                        removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly"); 
                        document.getElementById(divID).appendChild(addButton); 
@@ -685,12 +730,16 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
                        
                        var divTag = document.createElement("div");
                        divTag.setAttribute("id", id +'@0');
+                       
+                       divTag.className += ' children_group'; //here is div with a group of children.
+                       
                        document.getElementById(id).appendChild(divTag);
                }else{
                        var divTag = document.createElement("div");
                        divTag.setAttribute("id", "div."+labelValue+lableName);
+                       divTag.className += ' children_group'; //here is div with a group of children.
                        document.getElementById(divID).appendChild(label);  
-                       document.getElementById(divID).appendChild(divTag);
+                       document.getElementById(divID).appendChild(divTag);                     
                }
     };
 
@@ -801,7 +850,6 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
                                if (elumentLocation > 1){
                                        enumKey = keySplit[keySplit.length - 1];
                                }
-                               var aWhiteSpace = " ";
                                if (enumKeyList.indexOf(enumKey) != -1){
                                                if (splitPlainAttributeKey[1].indexOf("true") !== -1){
                                                        var multiSlect = [];
@@ -810,19 +858,11 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
                                                                }
                                                        jsonPolicy[key]= multiSlect;
                                                }else{
-                                                       //set a space due to empty value caused JSON format error in PolicyRestAdapter and remove it in back-end.
-                                                       if(searchElement.value == ""){
-                                                               searchElement.value = aWhiteSpace;
-                                                       }
                                                        console.log(" searchElement.value = > " + searchElement.value);
                                                        jsonPolicy[key]= searchElement.value;
                                                }
                                } else {
                                        if(searchElement.value != null){
-                                                       //set a default value due to empty value caused JSON format error in PolicyRestAdapter
-                                                       if(searchElement.value == ""){
-                                                               searchElement.value = aWhiteSpace;
-                                                       }
                                                        console.log(" searchElement.value = > " + searchElement.value);
                                                jsonPolicy[key]= searchElement.value;
                                        }
index 4b5a990..72b6f06 100644 (file)
@@ -80,6 +80,26 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA
                console.log("failed");
        });
 
+       PolicyAppService.getData('getDictionary/get_RainyDayDictionaryDataByName').then(function (data) {
+               var j = data;
+               $scope.data = JSON.parse(j.data);
+               console.log($scope.data);
+       $scope.rainyDayDictionaryDatas = JSON.parse($scope.data.rainyDayDictionaryDatas);
+               console.log($scope.rainyDayDictionaryDatas);
+       }, function (error) {
+               console.log("failed");
+       });
+       
+    PolicyAppService.getData('getDictionary/get_RainyDayDictionaryData').then(function (data) {
+       var j = data;
+       $scope.data = JSON.parse(j.data);
+       console.log($scope.data);
+       $scope.rainyDayDictionaryDataEntity = JSON.parse($scope.data.rainyDayDictionaryDatas);
+       console.log($scope.rainyDayDictionaryDatasEntity);
+    }, function (error) {
+       console.log("failed");
+    });
+
     function extend(obj, src) {
         for (var key in src) {
             if (src.hasOwnProperty(key)) obj[key] = src[key];
@@ -166,6 +186,9 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA
        if(!$scope.temp.policy.yamlparams){
                $scope.temp.policy.yamlparams = {};
        }
+       if(!$scope.temp.policy.yamlparams.targets){
+               $scope.temp.policy.yamlparams.targets = [];
+       }
        if(!$scope.temp.policy.yamlparams.blackList){
                $scope.temp.policy.yamlparams.blackList = [];
        }
@@ -178,7 +201,7 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA
     
     }else if($scope.temp.policy.ruleProvider=="Custom"){
           if($scope.temp.policy.attributes.length == 0){
-                  $scope.temp.policy.attributes = [];
+                  $scope.temp.policy.attributes = [];    
           }
           if($scope.temp.policy.settings.length == 0){
                   $scope.temp.policy.settings = [];
@@ -190,6 +213,10 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA
           if($scope.temp.policy.yamlparams.blackList.length==0){
                   $scope.temp.policy.yamlparams.blackList = [];
           }
+    }else if($scope.temp.policy.ruleProvider=="GUARD_YAML"){
+       if($scope.temp.policy.yamlparams.targets.length==0){
+                  $scope.temp.policy.yamlparams.targets = [];
+               }
     }else if($scope.temp.policy.ruleProvider=="Rainy_Day"){
        if($scope.temp.policy.rainyday.treatmentTableChoices == null || $scope.temp.policy.rainyday.treatmentTableChoices.length == 0){
                $scope.temp.policy.rainyday.treatmentTableChoices = [];
@@ -215,6 +242,14 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA
       $scope.temp.policy.settings.splice(lastItem);
     };
     
+    $scope.addNewTarget = function(){
+       $scope.temp.policy.yamlparams.targets.push('');
+    };
+    $scope.removeTarget = function(){
+       var lastItem = $scope.temp.policy.yamlparams.targets.length-1;
+       $scope.temp.policy.yamlparams.targets.splice(lastItem);
+    };
+    
     $scope.addNewBL = function() {
        $scope.temp.policy.yamlparams.blackList.push('');
     };
@@ -232,6 +267,29 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA
        $scope.temp.policy.rainyday.treatmentTableChoices.splice(lastItem);
     };
     
+       $scope.workstepDictionaryDatas = [];
+       $scope.getWorkstepValues = function(bbidValue){
+               for (var i = 0; i < $scope.rainyDayDictionaryDataEntity.length; ++i) {
+           var obj = $scope.rainyDayDictionaryDataEntity[i];
+           if (obj.bbid == bbidValue){
+               $scope.workstepDictionaryDatas.push(obj.workstep);
+           }
+       }
+       };
+       
+       $scope.allowedTreatmentsDatas = [];
+       $scope.getTreatmentValues = function(bbidValue, workstepValue){
+               for (var i = 0; i < $scope.rainyDayDictionaryDataEntity.length; ++i) {
+           var obj = $scope.rainyDayDictionaryDataEntity[i];
+           if (obj.bbid == bbidValue && obj.workstep == workstepValue){
+               var splitAlarm = obj.treatments.split(',');
+               for (var j = 0; j < splitAlarm.length; ++j) {
+                       $scope.allowedTreatmentsDatas.push(splitAlarm[j]);
+               }
+           }
+       }       
+       };
+    
     $scope.ItemNo = 0;
     $scope.ruleAlgorithmDatas = [{"ruleAlgorithms" : $scope.temp.policy.ruleAlgorithmschoices }];
     
index a12300b..f621f2c 100644 (file)
@@ -83,7 +83,7 @@
                        </div>
                </div>
                <div class="well">
-                       <div class="form-group col-sm-3" id="DynamicTemplate">
+                       <div class="form-group col-sm-12" id="DynamicTemplate">
                                <label>Micro Service Attributes:<sup><b>*</b></sup></label><br>
                        </div>
                        </br>
index 49fc70d..973a7af 100644 (file)
                                                        <label>Building Block ID:<sup><b>*</b></sup></label>
                                                </div>
                                                <div class="form-group col-sm-2">
-                                                       <input type="text" class="form-control"
-                                                               ng-disabled="temp.policy.readOnly" ng-model="temp.policy.rainyday.bbid"
-                                                               placeholder="Building Block ID" />
+                                                               <select
+                                                                       class="form-control" ng-disabled="temp.policy.readOnly"
+                                                                       ng-model="temp.policy.rainyday.bbid"
+                                                                       ng-options="option for option in rainyDayDictionaryDatas track by option"
+                                                                       ng-change="getWorkstepValues(temp.policy.rainyday.bbid)">
+                                                                       <option value="">{{temp.policy.rainyday.bbid}}</option>
+                                                               </select>
                                                </div>
                                                <div class="form-group col-sm-1">
                                                        <label>Work Step:<sup><b>*</b></sup></label>
                                                </div>
                                                <div class="form-group col-sm-2">
-                                                       <input type="text" class="form-control"
-                                                               ng-disabled="temp.policy.readOnly" ng-model="temp.policy.rainyday.workstep"
-                                                               placeholder="Work Step" />
+                                                       <select
+                                                                       class="form-control" ng-disabled="temp.policy.readOnly"
+                                                                       ng-model="temp.policy.rainyday.workstep"
+                                                                       ng-options="option for option in workstepDictionaryDatas track by option"
+                                                                       ng-change="getTreatmentValues(temp.policy.rainyday.bbid, temp.policy.rainyday.workstep)">
+                                                                       <option value="">{{temp.policy.rainyday.workstep}}</option>
+                                                       </select>
                                                </div>
                                        </div>
                                        <div class="form-group row">
                                                        <div class="form-group col-sm-1">
                                                                <label>Desired Treatment:<sup><b>*</b></sup></label>
                                                        </div>          
-                                                       <div class="form-group col-sm-3">                                               
-                                                               <select class="form-control" id="mySelect"
+                                                       <div class="form-group col-sm-3">
+                                                               <select
+                                                                       class="form-control" 
                                                                        ng-disabled="temp.policy.readOnly"
                                                                        ng-model="treatmentTableChoice.treatment"
-                                                                       placeholder="Desired Treatment">
-<!--                                                           <option value="">{{tableChoice.desiredtreatment}}</option> -->
-                                                                       <option>Rollback</option>
-                                                                       <option>Manual Handling</option>
-                                                                       <option>Abort</option>
-                                                                       <option>Auto Rollback</option>
-                                                                       <option>Retry</option>
-                                                                       <option>Skip</option>
-                                                               </select>
+                                                                       ng-options="option for option in allowedTreatmentsDatas track by option">
+                                                                       <option value="">{{treatmentTableChoice.treatment}}</option>
+                                                               </select>                                               
                                                        </div>
                                                        <div class="form-group col-sm-1">
                                                                <button type="button" class="btn btn-default"
                        <div class="well">
                                <div class="form-group row">
                                        <div class="form-group col-sm-1">
-                                               <label>Guard YAML Attributes:</label><br>
+                                               <label>Guard BlackList YAML Attributes:</label><br>
                                        </div>
                                </div>
                                <div class="form-group row">
                                                                        placeholder="Recipe" />
                                                        </div>
                                                </div>
+                                               <div class="form-group row" style="margin-left: 2%">
+                                                       <div class="form-group col-sm-3">
+                                                               <label> CLName: </label>
+                                                       </div>
+                                                       <div class="form-group col-sm-3">
+                                                               <input type="text" class="form-control"
+                                                                       ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.clname"
+                                                                       placeholder="CLName" />
+                                                       </div>
+                                               </div>
                                                <div class="form-group row" style="margin-left: 2%">
                                                        <div class="form-group col-sm-3">
                                                                <label> guardActiveStart: </label>
                                                                        placeholder="Recipe" />
                                                        </div>
                                                </div>
+                                               <div class="form-group row" style="margin-left: 2%">
+                                                       <div class="form-group col-sm-3">
+                                                               <label> CLName: </label>
+                                                       </div>
+                                                       <div class="form-group col-sm-3">
+                                                               <input type="text" class="form-control"
+                                                                       ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.clname"
+                                                                       placeholder="CLName" />
+                                                       </div>
+                                               </div>
+                                               <div class="form-group row" style="margin-left: 2%">
+                                                       <div class="form-group col-sm-3">
+                                                               <label> Targets: </label>
+                                                               <button type="button" class="btn btn-default"
+                                                                       ng-disabled="temp.policy.readOnly" ng-click="addNewTarget()">
+                                                                       <i class="fa fa-plus"></i>
+                                                               </button>
+                                                       </div>
+                                                       <div class="form-group col-sm-4">
+                                                               <div data-ng-repeat="choice in temp.policy.yamlparams.targets track by $index">
+                                                                       <div class="form-group row">
+                                                                       <div class="form-group col-sm-9">
+                                                                               <input type="text" class="form-control"
+                                                                               ng-disabled="temp.policy.readOnly"
+                                                                               ng-model="temp.policy.yamlparams.targets[$index]" placeholder="Target" />
+                                                                       </div>
+                                                                       <div class="form-group col-sm-1">
+                                                                               <button type="button" class="btn btn-default" ng-show="$last"
+                                                                               ng-disabled="temp.policy.readOnly" ng-click="removeTarget()">
+                                                                               <i class="fa fa-minus"></i>
+                                                                               </button>
+                                                                       </div>
+                                                                       </div>
+                                                               </div>
+                                                       </div>
+                                               </div>
                                                <div class="form-group row" style="margin-left: 2%">
                                                        <div class="form-group col-sm-3">
                                                                <label> limit: </label>
                                                        <div class="form-group col-sm-3">
                                                                <label> timeWindow: </label>
                                                        </div>
-                                                       <div class="form-group col-sm-3">
+                                                       <div class="form-group col-sm-2">
+                                                               <input type="text" class="form-control"
+                                                                       ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.timeWindow"
+                                                                       placeholder="Time Window" />
+                                                       </div>
+                                                       <div class="form-group col-sm-1">
                                                                <select class="form-control" ng-disabled="temp.policy.readOnly" 
-                                                               ng-model="temp.policy.yamlparams.timeWindow">
-                                                               <option>tw5min</option>
-                                                               <option>tw10min</option>
-                                                               <option>tw30min</option>
-                                                               <option>tw1h</option>
-                                                               <option>tw12h</option>
-                                                               <option>tw1d</option>
-                                                               <option>tw5d</option>
-                                                               <option>tw1w</option>
-                                                               <option>tw1mon</option>
+                                                               ng-model="temp.policy.yamlparams.timeUnits">
+                                                               <option>minute</option>
+                                                               <option>hour</option>
+                                                               <option>day</option>
+                                                               <option>week</option>
+                                                               <option>month</option>
+                                                               <option>year</option>
                                                                </select>
                                                        </div>
                                                </div>
index 78001f4..1122b6f 100644 (file)
@@ -58,11 +58,47 @@ body {
   margin-top: -5px;
 }
 
+.btn.btn-pedefault {
+       color: #444;
+       background-color: #FAFAFA;
+}
+       
 .btn.btn-default {
   color: #444;
   background-color: #FAFAFA;
 }
 
+.btn-add-remove {
+  color: #444;
+  background-color: #FAFAFA;
+  margin-right: 12px;
+  margin-bottom: 10px;
+}
+
+.child_single {
+  color: #444;
+  background-color: #FAFAFA;
+  margin-left: 0px;
+  margin-bottom: 10px;
+  border: 1px solid #ccc;
+  border-radius: 4px;
+}
+
+.children_group {
+    color: #444;
+    background-color: white;
+    margin-left: 20px;
+    margin-bottom: 20px;
+    margin-top: 20px;
+    margin-right: 20px;
+    padding-top: 10px;
+    padding-left: 10px;
+    padding-right: 20px;
+    padding-bottom: 10px;
+    border: 1px solid #ccc;
+    border-radius: 4px;
+}
+
 .btn {
   box-shadow: 0 2px 5px 0 rgba(0, 0, 0, .26);
   font-weight: 500;
index 754f95b..f7a6d24 100644 (file)
@@ -13,7 +13,7 @@
         <div ng-include data-src="'error-bar'" class="clearfix"></div>
       </div>
       <div class="modal-footer">
-        <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="refresh();" ng-disabled="temp.inprocess">Cancel</button>
+        <button type="button" class="btn btn-pedefault" data-dismiss="modal" ng-click="refresh();" ng-disabled="temp.inprocess">Cancel</button>
         <button type="submit" class="btn btn-primary" ng-disabled="temp.inprocess" autofocus="autofocus">Delete</button>
       </div>
       </form>
@@ -42,7 +42,7 @@
         <div ng-include data-src="'error-bar'" class="clearfix"></div>
       </div>
       <div class="modal-footer">
-        <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="refresh();" ng-disabled="temp.inprocess">Cancel</button>
+        <button type="button" class="btn btn-pedefault" data-dismiss="modal" ng-click="refresh();" ng-disabled="temp.inprocess">Cancel</button>
         <button type="submit" class="btn btn-primary" ng-disabled="temp.inprocess" autofocus="autofocus">Delete</button>
       </div>
       </form>
@@ -67,7 +67,7 @@
               <div ng-include data-src="'error-bar'" class="clearfix"></div>
             </div>
             <div class="modal-footer">
-              <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="refresh();" ng-disabled="temp.inprocess">Cancel</button>
+              <button type="button" class="btn btn-pedefault" data-dismiss="modal" ng-click="refresh();" ng-disabled="temp.inprocess">Cancel</button>
               <button type="submit" class="btn btn-primary" ng-disabled="temp.inprocess">Rename</button>
             </div>
         </form>
@@ -89,7 +89,7 @@
               <div ng-include data-src="'error-bar'" class="clearfix"></div>
             </div>
             <div class="modal-footer">
-              <button type="button" class="btn btn-default" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
+              <button type="button" class="btn btn-pedefault" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
             </div>
         </form>
     </div>
               <div ng-include data-src="'error-bar'" class="clearfix"></div>
             </div>
             <div class="modal-footer">
-              <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="refresh();" ng-disabled="temp.inprocess">Cancel</button>
+              <button type="button" class="btn btn-pedefault" data-dismiss="modal" ng-click="refresh();" ng-disabled="temp.inprocess">Cancel</button>
               <button type="submit" class="btn btn-primary" ng-disabled="temp.inprocess">Move</button>
             </div>
         </form>
               <div ng-include data-src="'error-bar'" class="clearfix"></div>
             </div>
             <div class="modal-footer">
-              <button type="button" class="btn btn-default" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
+              <button type="button" class="btn btn-pedefault" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
               <button type="submit" class="btn btn-primary" ng-disabled="temp.inprocess">Save</button>
             </div>
         </form>
               <div ng-include data-src="'error-bar'" class="clearfix"></div>
             </div>
             <div class="modal-footer">
-              <button type="button" class="btn btn-default" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
+              <button type="button" class="btn btn-pedefault" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
               <button type="submit" class="btn btn-primary" ng-disabled="temp.inprocess">Clone</button>
             </div>
         </form>
               <div ng-include data-src="'error-bar'" class="clearfix"></div>
             </div>
             <div class="modal-footer">
-              <button id = "cancel" type="button" class="btn btn-default" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
+              <button id = "cancel" type="button" class="btn btn-pedefault" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
               <button type="submit" class="btn btn-primary" ng-disabled="temp.inprocess">Create</button>
             </div>
         </form>
               <div ng-include data-src="'error-bar'" class="clearfix"></div>
             </div>
             <div class="modal-footer">
-              <button type="button" class="btn btn-default" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
+              <button type="button" class="btn btn-pedefault" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
               <button type="submit" class="btn btn-primary" ng-disabled="temp.inprocess">Create</button>
             </div>
         </form>
             </div>
             <div class="modal-footer">
               <div ng-show="!fileUploader.requesting">
-                  <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
+                  <button type="button" class="btn btn-pedefault" data-dismiss="modal">Cancel</button>
                   <button type="submit" class="btn btn-primary" ng-disabled="!uploadFileList.length || fileUploader.requesting">{{'upload' | translate}}</button>
               </div>
               <div ng-show="fileUploader.requesting">
         </div>
       </div>
       <div class="modal-footer">
-        <button type="button" class="btn btn-default" data-dismiss="modal" ng-disabled="temp.inprocess">Close</button>
+        <button type="button" class="btn btn-pedefault" data-dismiss="modal" ng-disabled="temp.inprocess">Close</button>
       </div>
     </div>
   </div>
index 72985a1..768fe5e 100644 (file)
@@ -62,7 +62,7 @@ body {
                                                        <div class="input-group-btn">
                                                                <div class="btn-group" role="group">
                                                                        <div class="dropdown dropdown-lg">
-                                                                               <button type="button" class="btn btn-default dropdown-toggle"
+                                                                               <button type="button" class="btn btn-pedefault dropdown-toggle"
                                                                                        data-toggle="dropdown" aria-expanded="false">
                                                                                        <span class="caret"></span>
                                                                                </button>
@@ -166,7 +166,7 @@ body {
                                                                                        </form>
                                                                                </div>
                                                                        </div>
-                                                                       <button type="button" class="btn btn-default"
+                                                                       <button type="button" class="btn btn-pedefault"
                                                                                ng-click="refresh(search = null);">
                                                                                <span aria-hidden="true">Clear</span>
                                                                        </button>
index 773955d..a250276 100644 (file)
  */
 package org.openecomp.policy.admin;
 
+import static org.junit.Assert.fail;
+
 import java.io.BufferedReader;
+import java.io.File;
 import java.io.StringReader;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
+import javax.servlet.ServletConfig;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -33,8 +38,13 @@ import org.junit.Test;
 import org.mockito.Mockito;
 import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
 import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.openecomp.policy.controller.CreateDcaeMicroServiceController;
 import org.openecomp.policy.controller.PolicyController;
 import org.openecomp.policy.model.Roles;
+import org.openecomp.policy.rest.dao.CommonClassDao;
+import org.openecomp.policy.rest.jpa.ActionBodyEntity;
+import org.openecomp.policy.rest.jpa.ConfigurationDataEntity;
+import org.openecomp.policy.rest.jpa.GroupPolicyScopeList;
 import org.openecomp.policy.rest.jpa.PolicyEditorScopes;
 import org.openecomp.policy.rest.jpa.PolicyEntity;
 import org.openecomp.policy.rest.jpa.PolicyVersion;
@@ -43,11 +53,13 @@ import org.openecomp.policy.rest.jpa.UserInfo;
 public class PolicyManagerServletTest extends Mockito{
        
        private static Logger logger = FlexLogger.getLogger(PolicyManagerServletTest.class);
+       private List<String> headers = new ArrayList<String>();
 
        private static List<Object> rolesdata;
-       private static List<Object> policyData;
+       private static List<Object> basePolicyData;
        private static List<Object> policyEditorScopes;
        private static List<Object> policyVersion;
+       private static CommonClassDao commonClassDao;
        
        @Before
        public void setUp() throws Exception{
@@ -68,7 +80,7 @@ public class PolicyManagerServletTest extends Mockito{
         rolesdata.add(roles1);
         
         //PolicyEntity Data
-        policyData = new ArrayList<>();
+        basePolicyData = new ArrayList<>();
         String policyContent = "";
         try {
                        ClassLoader classLoader = getClass().getClassLoader();
@@ -80,7 +92,13 @@ public class PolicyManagerServletTest extends Mockito{
         entity.setPolicyName("Config_SampleTest.1.xml");
         entity.setPolicyData(policyContent);
         entity.setScope("com");
-        policyData.add(entity);
+        ConfigurationDataEntity configurationEntity = new ConfigurationDataEntity();
+        configurationEntity.setConfigBody("Sample Test");
+        configurationEntity.setConfigType("OTHER");
+        configurationEntity.setConfigurationName("com.Config_SampleTest1206.1.txt");
+        configurationEntity.setDescription("test");
+        entity.setConfigurationData(configurationEntity);
+        basePolicyData.add(entity);
         
         //PolicyEditorScopes data
         policyEditorScopes = new ArrayList<>();
@@ -106,6 +124,21 @@ public class PolicyManagerServletTest extends Mockito{
         policyVersion.add(policy);
        }
        
+       @Test
+       public void testInit(){
+               PolicyManagerServlet servlet = new PolicyManagerServlet();
+               ServletConfig servletConfig = mock(ServletConfig.class);       
+        try {
+               when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(headers));
+               when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn("xacml.admin.properties");
+               System.setProperty("xacml.rest.admin.closedLoopJSON", new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "JSONConfig.json");
+                       servlet.init(servletConfig);
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+                       fail();
+               }
+       }
+       
        @Test
        public void testDescribePolicy(){
                PolicyManagerServlet servlet = new PolicyManagerServlet();
@@ -116,11 +149,12 @@ public class PolicyManagerServletTest extends Mockito{
         BufferedReader reader = new BufferedReader(new StringReader("{params: { mode: 'DESCRIBEPOLICYFILE', path: 'com.Config_SampleTest1206.1.xml'}}"));
         try {
                        when(request.getReader()).thenReturn(reader);
-                       when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_SampleTest1206.1.xml' and scope ='com'")).thenReturn(policyData);
+                       when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_SampleTest1206.1.xml' and scope ='com'")).thenReturn(basePolicyData);
                        servlet.setPolicyController(controller);
                        servlet.doPost(request, response);
                } catch (Exception e1) {
                        logger.error("Exception Occured"+e1);
+                       fail();
                }
        }
        
@@ -147,9 +181,390 @@ public class PolicyManagerServletTest extends Mockito{
                        servlet.doPost(request, response);
                } catch (Exception e1) {
                        logger.error("Exception Occured"+e1);
+                       fail();
+               }
+        }
+       }
+       
+       @Test
+       public void editBasePolicyTest(){
+               PolicyManagerServlet servlet = new PolicyManagerServlet();
+               HttpServletRequest request = mock(HttpServletRequest.class);       
+        HttpServletResponse response = mock(HttpServletResponse.class); 
+        PolicyController controller = mock(PolicyController.class);
+        List<String> list = new ArrayList<>();
+        list.add("{params: { mode: 'EDITFILE', path: '/com/Config_SampleTest1206.1.xml', onlyFolders: false}}");
+        for(int i =0; i < list.size(); i++){
+               BufferedReader reader = new BufferedReader(new StringReader(list.get(i)));
+            try {
+                       when(request.getReader()).thenReturn(reader);
+                       when(controller.getRoles("Test")).thenReturn(rolesdata);
+                       when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_SampleTest1206.1.xml' and scope ='com'")).thenReturn(basePolicyData);
+                       servlet.setPolicyController(controller);
+                       servlet.setTestUserId("Test");
+                       servlet.doPost(request, response);
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+                       fail();
                }
         }
        }
        
+       @Test
+       public void editBRMSParamPolicyTest(){
+               List<Object> policyData = new ArrayList<>();
+        String policyContent = "";
+        String configData = "";
+        try {
+                       ClassLoader classLoader = getClass().getClassLoader();
+                       policyContent = IOUtils.toString(classLoader.getResourceAsStream("Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml"));
+                       configData = IOUtils.toString(classLoader.getResourceAsStream("com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt"));
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+               }
+        PolicyEntity entity = new PolicyEntity();
+        entity.setPolicyName("Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml");
+        entity.setPolicyData(policyContent);
+        entity.setScope("com");
+        ConfigurationDataEntity configurationEntity = new ConfigurationDataEntity();
+        configurationEntity.setConfigBody(configData);
+        configurationEntity.setConfigType("OTHER");
+        configurationEntity.setConfigurationName("com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt");
+        configurationEntity.setDescription("test");
+        entity.setConfigurationData(configurationEntity);
+        policyData.add(entity);
+               PolicyManagerServlet servlet = new PolicyManagerServlet();
+               HttpServletRequest request = mock(HttpServletRequest.class);       
+        HttpServletResponse response = mock(HttpServletResponse.class); 
+        PolicyController controller = mock(PolicyController.class);
+        List<String> list = new ArrayList<>();
+        list.add("{params: { mode: 'EDITFILE', path: '/com/Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml', onlyFolders: false}}");
+        for(int i =0; i < list.size(); i++){
+               BufferedReader reader = new BufferedReader(new StringReader(list.get(i)));
+            try {
+                       when(request.getReader()).thenReturn(reader);
+                       when(controller.getRoles("Test")).thenReturn(rolesdata);
+                       when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml' and scope ='com'")).thenReturn(policyData);
+                       servlet.setPolicyController(controller);
+                       servlet.setTestUserId("Test");
+                       servlet.doPost(request, response);
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+                       fail();
+               }
+        }
+       }
 
+       @Test
+       public void editBRMSRawPolicyTest(){
+               List<Object> policyData = new ArrayList<>();
+        String policyContent = "";
+        String configData = "";
+        try {
+                       ClassLoader classLoader = getClass().getClassLoader();
+                       policyContent = IOUtils.toString(classLoader.getResourceAsStream("Config_BRMS_Raw_TestBRMSRawPolicy.1.xml"));
+                       configData = IOUtils.toString(classLoader.getResourceAsStream("com.Config_BRMS_Raw_TestBRMSRawPolicy.1.txt"));
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+               }
+        PolicyEntity entity = new PolicyEntity();
+        entity.setPolicyName("Config_BRMS_Raw_TestBRMSRawPolicy.1.xml");
+        entity.setPolicyData(policyContent);
+        entity.setScope("com");
+        ConfigurationDataEntity configurationEntity = new ConfigurationDataEntity();
+        configurationEntity.setConfigBody(configData);
+        configurationEntity.setConfigType("OTHER");
+        configurationEntity.setConfigurationName("com.Config_BRMS_Raw_TestBRMSRawPolicy.1.txt");
+        configurationEntity.setDescription("test");
+        entity.setConfigurationData(configurationEntity);
+        policyData.add(entity);
+               PolicyManagerServlet servlet = new PolicyManagerServlet();
+               HttpServletRequest request = mock(HttpServletRequest.class);       
+        HttpServletResponse response = mock(HttpServletResponse.class); 
+        PolicyController controller = mock(PolicyController.class);
+        List<String> list = new ArrayList<>();
+        list.add("{params: { mode: 'EDITFILE', path: '/com/Config_BRMS_Raw_TestBRMSRawPolicy.1.xml', onlyFolders: false}}");
+        for(int i =0; i < list.size(); i++){
+               BufferedReader reader = new BufferedReader(new StringReader(list.get(i)));
+            try {
+                       when(request.getReader()).thenReturn(reader);
+                       when(controller.getRoles("Test")).thenReturn(rolesdata);
+                       when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_BRMS_Raw_TestBRMSRawPolicy.1.xml' and scope ='com'")).thenReturn(policyData);
+                       servlet.setPolicyController(controller);
+                       servlet.setTestUserId("Test");
+                       servlet.doPost(request, response);
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+                       fail();
+               }
+        }
+       }
+       
+       @Test
+       public void editClosedLoopFaultPolicyTest(){
+               List<Object> policyData = new ArrayList<>();
+        String policyContent = "";
+        String configData = "";
+        try {
+                       ClassLoader classLoader = getClass().getClassLoader();
+                       policyContent = IOUtils.toString(classLoader.getResourceAsStream("Config_Fault_TestClosedLoopPolicy.1.xml"));
+                       configData = IOUtils.toString(classLoader.getResourceAsStream("com.Config_Fault_TestClosedLoopPolicy.1.json"));
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+               }
+        PolicyEntity entity = new PolicyEntity();
+        entity.setPolicyName("Config_Fault_TestClosedLoopPolicy.1.xml");
+        entity.setPolicyData(policyContent);
+        entity.setScope("com");
+        ConfigurationDataEntity configurationEntity = new ConfigurationDataEntity();
+        configurationEntity.setConfigBody(configData);
+        configurationEntity.setConfigType("JSON");
+        configurationEntity.setConfigurationName("com.Config_Fault_TestClosedLoopPolicy.1.json");
+        configurationEntity.setDescription("test");
+        entity.setConfigurationData(configurationEntity);
+        policyData.add(entity);
+               PolicyManagerServlet servlet = new PolicyManagerServlet();
+               HttpServletRequest request = mock(HttpServletRequest.class);       
+        HttpServletResponse response = mock(HttpServletResponse.class); 
+        PolicyController controller = mock(PolicyController.class);
+        List<String> list = new ArrayList<>();
+        list.add("{params: { mode: 'EDITFILE', path: '/com/Config_Fault_TestClosedLoopPolicy.1.xml', onlyFolders: false}}");
+        for(int i =0; i < list.size(); i++){
+               BufferedReader reader = new BufferedReader(new StringReader(list.get(i)));
+            try {
+                       when(request.getReader()).thenReturn(reader);
+                       when(controller.getRoles("Test")).thenReturn(rolesdata);
+                       when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_Fault_TestClosedLoopPolicy.1.xml' and scope ='com'")).thenReturn(policyData);
+                       servlet.setPolicyController(controller);
+                       servlet.setTestUserId("Test");
+                       servlet.doPost(request, response);
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+                       fail();
+               }
+        }
+       }
+       
+       @Test
+       public void editClosedLoopPMPolicyTest(){
+               List<Object> policyData = new ArrayList<>();
+        String policyContent = "";
+        String configData = "";
+        try {
+                       ClassLoader classLoader = getClass().getClassLoader();
+                       policyContent = IOUtils.toString(classLoader.getResourceAsStream("Config_PM_TestClosedLoopPMPolicy.1.xml"));
+                       configData = IOUtils.toString(classLoader.getResourceAsStream("com.Config_PM_TestClosedLoopPMPolicy.1.json"));
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+               }
+        PolicyEntity entity = new PolicyEntity();
+        entity.setPolicyName("Config_PM_TestClosedLoopPMPolicy.1.xml");
+        entity.setPolicyData(policyContent);
+        entity.setScope("com");
+        ConfigurationDataEntity configurationEntity = new ConfigurationDataEntity();
+        configurationEntity.setConfigBody(configData);
+        configurationEntity.setConfigType("JSON");
+        configurationEntity.setConfigurationName("com.Config_PM_TestClosedLoopPMPolicy.1.json");
+        configurationEntity.setDescription("test");
+        entity.setConfigurationData(configurationEntity);
+        policyData.add(entity);
+               PolicyManagerServlet servlet = new PolicyManagerServlet();
+               HttpServletRequest request = mock(HttpServletRequest.class);       
+        HttpServletResponse response = mock(HttpServletResponse.class); 
+        PolicyController controller = mock(PolicyController.class);
+        List<String> list = new ArrayList<>();
+        list.add("{params: { mode: 'EDITFILE', path: '/com/Config_PM_TestClosedLoopPMPolicy.1.xml', onlyFolders: false}}");
+        for(int i =0; i < list.size(); i++){
+               BufferedReader reader = new BufferedReader(new StringReader(list.get(i)));
+            try {
+                       when(request.getReader()).thenReturn(reader);
+                       when(controller.getRoles("Test")).thenReturn(rolesdata);
+                       when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_PM_TestClosedLoopPMPolicy.1.xml' and scope ='com'")).thenReturn(policyData);
+                       servlet.setPolicyController(controller);
+                       servlet.setTestUserId("Test");
+                       servlet.doPost(request, response);
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+                       fail();
+               }
+        }
+       }
+       
+       @Test
+       public void editMicroServicePolicyTest(){
+               GroupPolicyScopeList groupData = new  GroupPolicyScopeList();
+               groupData.setGroupName("Test");
+               groupData.setGroupList("resource=SampleResource,service=SampleService,type=SampleType,closedLoopControlName=SampleClosedLoop");
+               List<Object> groupListData = new ArrayList<>();
+               groupListData.add(groupData);
+               commonClassDao = mock(CommonClassDao.class);
+               CreateDcaeMicroServiceController.setCommonClassDao(commonClassDao);
+               List<Object> policyData = new ArrayList<>();
+        String policyContent = "";
+        String configData = "";
+        try {
+                       ClassLoader classLoader = getClass().getClassLoader();
+                       policyContent = IOUtils.toString(classLoader.getResourceAsStream("Config_MS_vFirewall.1.xml"));
+                       configData = IOUtils.toString(classLoader.getResourceAsStream("com.Config_MS_vFirewall.1.json"));
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+               }
+        PolicyEntity entity = new PolicyEntity();
+        entity.setPolicyName("Config_MS_vFirewall.1.xml");
+        entity.setPolicyData(policyContent);
+        entity.setScope("com");
+        ConfigurationDataEntity configurationEntity = new ConfigurationDataEntity();
+        configurationEntity.setConfigBody(configData);
+        configurationEntity.setConfigType("JSON");
+        configurationEntity.setConfigurationName("com.Config_MS_vFirewall.1.json");
+        configurationEntity.setDescription("test");
+        entity.setConfigurationData(configurationEntity);
+        policyData.add(entity);
+               PolicyManagerServlet servlet = new PolicyManagerServlet();
+               HttpServletRequest request = mock(HttpServletRequest.class);       
+        HttpServletResponse response = mock(HttpServletResponse.class); 
+        PolicyController controller = mock(PolicyController.class);
+        List<String> list = new ArrayList<>();
+        list.add("{params: { mode: 'EDITFILE', path: '/com/Config_MS_vFirewall.1.xml', onlyFolders: false}}");
+        for(int i =0; i < list.size(); i++){
+               BufferedReader reader = new BufferedReader(new StringReader(list.get(i)));
+            try {
+                       when(request.getReader()).thenReturn(reader);
+                       when(commonClassDao.getDataById(GroupPolicyScopeList.class, "groupList", "resource=SampleResource,service=SampleService,type=SampleType,closedLoopControlName=SampleClosedLoop")).thenReturn(groupListData);
+                       when(controller.getRoles("Test")).thenReturn(rolesdata);
+                       when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_MS_vFirewall.1.xml' and scope ='com'")).thenReturn(policyData);
+                       servlet.setPolicyController(controller);
+                       servlet.setTestUserId("Test");
+                       servlet.doPost(request, response);
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+                       fail();
+               }
+        }
+       }
+       
+       @Test
+       public void editFirewallPolicyTest(){
+               List<Object> policyData = new ArrayList<>();
+        String policyContent = "";
+        String configData = "";
+        try {
+                       ClassLoader classLoader = getClass().getClassLoader();
+                       policyContent = IOUtils.toString(classLoader.getResourceAsStream("Config_FW_TestFireWallPolicy.1.xml"));
+                       configData = IOUtils.toString(classLoader.getResourceAsStream("com.Config_FW_TestFireWallPolicy.1.json"));
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+               }
+        PolicyEntity entity = new PolicyEntity();
+        entity.setPolicyName("Config_FW_TestFireWallPolicy.1.xml");
+        entity.setPolicyData(policyContent);
+        entity.setScope("com");
+        ConfigurationDataEntity configurationEntity = new ConfigurationDataEntity();
+        configurationEntity.setConfigBody(configData);
+        configurationEntity.setConfigType("JSON");
+        configurationEntity.setConfigurationName("com.Config_FW_TestFireWallPolicy.1.json");
+        configurationEntity.setDescription("test");
+        entity.setConfigurationData(configurationEntity);
+        policyData.add(entity);
+               PolicyManagerServlet servlet = new PolicyManagerServlet();
+               HttpServletRequest request = mock(HttpServletRequest.class);       
+        HttpServletResponse response = mock(HttpServletResponse.class); 
+        PolicyController controller = mock(PolicyController.class);
+        List<String> list = new ArrayList<>();
+        list.add("{params: { mode: 'EDITFILE', path: '/com/Config_FW_TestFireWallPolicy.1.xml', onlyFolders: false}}");
+        for(int i =0; i < list.size(); i++){
+               BufferedReader reader = new BufferedReader(new StringReader(list.get(i)));
+            try {
+                       when(request.getReader()).thenReturn(reader);
+                       when(controller.getRoles("Test")).thenReturn(rolesdata);
+                       when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_FW_TestFireWallPolicy.1.xml' and scope ='com'")).thenReturn(policyData);
+                       servlet.setPolicyController(controller);
+                       servlet.setTestUserId("Test");
+                       servlet.doPost(request, response);
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+                       fail();
+               }
+        }
+       }
+       
+       @Test
+       public void editActionPolicyTest(){
+               List<Object> policyData = new ArrayList<>();
+        String policyContent = "";
+        String configData = "";
+        try {
+                       ClassLoader classLoader = getClass().getClassLoader();
+                       policyContent = IOUtils.toString(classLoader.getResourceAsStream("Action_TestActionPolicy.1.xml"));
+                       configData = IOUtils.toString(classLoader.getResourceAsStream("com.Action_TestActionPolicy.1.json"));
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+               }
+        PolicyEntity entity = new PolicyEntity();
+        entity.setPolicyName("Action_TestActionPolicy.1.xml");
+        entity.setPolicyData(policyContent);
+        entity.setScope("com");
+        ActionBodyEntity configurationEntity = new ActionBodyEntity();
+        configurationEntity.setActionBody(configData);
+        configurationEntity.setActionBodyName("com.Action_TestActionPolicy.1.json");
+        entity.setActionBodyEntity(configurationEntity);
+        policyData.add(entity);
+               PolicyManagerServlet servlet = new PolicyManagerServlet();
+               HttpServletRequest request = mock(HttpServletRequest.class);       
+        HttpServletResponse response = mock(HttpServletResponse.class); 
+        PolicyController controller = mock(PolicyController.class);
+        List<String> list = new ArrayList<>();
+        list.add("{params: { mode: 'EDITFILE', path: '/com/Action_TestActionPolicy.1.xml', onlyFolders: false}}");
+        for(int i =0; i < list.size(); i++){
+               BufferedReader reader = new BufferedReader(new StringReader(list.get(i)));
+            try {
+                       when(request.getReader()).thenReturn(reader);
+                       when(controller.getRoles("Test")).thenReturn(rolesdata);
+                       when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Action_TestActionPolicy.1.xml' and scope ='com'")).thenReturn(policyData);
+                       servlet.setPolicyController(controller);
+                       servlet.setTestUserId("Test");
+                       servlet.doPost(request, response);
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+                       fail();
+               }
+        }
+       }
+       
+       @Test
+       public void editDecisionPolicyTest(){
+               List<Object> policyData = new ArrayList<>();
+        String policyContent = "";
+        try {
+                       ClassLoader classLoader = getClass().getClassLoader();
+                       policyContent = IOUtils.toString(classLoader.getResourceAsStream("Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml"));
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+               }
+        PolicyEntity entity = new PolicyEntity();
+        entity.setPolicyName("Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml");
+        entity.setPolicyData(policyContent);
+        entity.setScope("com");
+        policyData.add(entity);
+               PolicyManagerServlet servlet = new PolicyManagerServlet();
+               HttpServletRequest request = mock(HttpServletRequest.class);       
+        HttpServletResponse response = mock(HttpServletResponse.class); 
+        PolicyController controller = mock(PolicyController.class);
+        List<String> list = new ArrayList<>();
+        list.add("{params: { mode: 'EDITFILE', path: '/com/Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml', onlyFolders: false}}");
+        for(int i =0; i < list.size(); i++){
+               BufferedReader reader = new BufferedReader(new StringReader(list.get(i)));
+            try {
+                       when(request.getReader()).thenReturn(reader);
+                       when(controller.getRoles("Test")).thenReturn(rolesdata);
+                       when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml' and scope ='com'")).thenReturn(policyData);
+                       servlet.setPolicyController(controller);
+                       servlet.setTestUserId("Test");
+                       servlet.doPost(request, response);
+               } catch (Exception e1) {
+                       logger.error("Exception Occured"+e1);
+                       fail();
+               }
+        }
+       }
 }
index 43b8a6f..07bd549 100644 (file)
  */
 package org.openecomp.policy.controller;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import java.io.BufferedReader;
+import java.io.StringReader;
 import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.List;
@@ -41,12 +43,20 @@ public class AdminTabControllerTest {
 
        private static Logger logger = FlexLogger.getLogger(AdminTabControllerTest.class);
        private static CommonClassDao commonClassDao;
+       private HttpServletRequest request;
+       private MockHttpServletResponse response;
        
        @Before
        public void setUp() throws Exception {
 
                logger.info("setUp: Entering");
         commonClassDao = mock(CommonClassDao.class);
+        
+        request = mock(HttpServletRequest.class);       
+               response =  new MockHttpServletResponse();
+               
+               AdminTabController.setCommonClassDao(commonClassDao);
+               
         GlobalRoleSettings globalRole = new GlobalRoleSettings();
         globalRole.setLockdown(true);
         globalRole.setRole("super-admin");
@@ -57,17 +67,28 @@ public class AdminTabControllerTest {
        
        @Test
        public void testGetAdminRole(){
-               HttpServletRequest request = mock(HttpServletRequest.class);       
-               MockHttpServletResponse response =  new MockHttpServletResponse();
-               
                AdminTabController admin = new AdminTabController();
-               AdminTabController.setCommonClassDao(commonClassDao);
-               admin.getAdminTabEntityData(request, response);
-               
                try {
+                       admin.getAdminTabEntityData(request, response);
                        assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("lockdowndata"));
                } catch (UnsupportedEncodingException e) {
                        logger.error("Exception Occured"+e);
+                       fail();
+               }
+       }
+       
+       @Test
+       public void testSaveAdminRole() throws Exception{
+               AdminTabController admin = new AdminTabController();
+               String data = "{\"lockdowndata\":{\"lockdown\":true}}";
+               BufferedReader reader = new BufferedReader(new StringReader(data));     
+               try {
+                       when(request.getReader()).thenReturn(reader);
+                       admin.saveAdminTabLockdownValue(request, response);
+                       assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("descriptiveScopeDictionaryDatas"));
+               } catch (UnsupportedEncodingException e) {
+                       logger.error("Exception Occured"+e);
+                       fail();
                }
        }
        
index b4619b8..ca91544 100644 (file)
@@ -169,6 +169,7 @@ public class CreateDcaeMicroServiceControllerTest {
                //expect: uniqueKeys should contain a string value 
                CreateDcaeMicroServiceController controllerA = new CreateDcaeMicroServiceController();
                String str = "testing\\.byCorrectWay\\.OfDATA";
+               String value = null;
                assertEquals(1, controllerA.stringBetweenDots(str));
                
                //expect: uniqueKeys should not contain a string value 
diff --git a/POLICY-SDK-APP/src/test/resources/Action_TestActionPolicy.1.xml b/POLICY-SDK-APP/src/test/resources/Action_TestActionPolicy.1.xml
new file mode 100644 (file)
index 0000000..77c9367
--- /dev/null
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:xacml:policy:id:b8e180de-3dcc-4b5b-814d-925e674e573c" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+     <Description>TestActionPolicy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:</Description>
+     <Target>
+         <AnyOf>
+             <AllOf>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">12</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="SamplTest" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+             </AllOf>
+         </AnyOf>
+     </Target>
+     <Rule RuleId="" Effect="Permit">
+         <Target/>
+         <Condition>
+             <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
+                 <Apply FunctionId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                     <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
+                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="SamplTest" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                     </Apply>
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">test</AttributeValue>
+                 </Apply>
+                 <Apply FunctionId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                     <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
+                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="SamplTest" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                     </Apply>
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Sample</AttributeValue>
+                 </Apply>
+             </Apply>
+         </Condition>
+         <ObligationExpressions>
+             <ObligationExpression ObligationId="Test" FulfillOn="Permit">
+                 <AttributeAssignmentExpression AttributeId="performer" Category="urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">PEPAction</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="type" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">REST</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="url" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">http://localhost.com</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="method" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">GET</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="body" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">$URL/Action/com.Action_TestActionPolicy.1.xml.json</AttributeValue>
+                 </AttributeAssignmentExpression>
+             </ObligationExpression>
+         </ObligationExpressions>
+     </Rule>
+ </Policy>
\ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml b/POLICY-SDK-APP/src/test/resources/Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml
new file mode 100644 (file)
index 0000000..ddf1864
--- /dev/null
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:com:xacml:policy:id:256f4712-a965-4817-a851-a71bdeb9fb49" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+    <Description>BRMSParam vFW Demo Policy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:</Description>
+    <Target>
+        <AnyOf>
+            <AllOf>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="PolicyName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+            </AllOf>
+            <AllOf>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DROOLS</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ECOMPName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">BRMS_PARAM_RULE</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ConfigName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskType" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskLevel" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">False</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="guard" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="TTLDate" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+            </AllOf>
+        </AnyOf>
+    </Target>
+    <Rule RuleId="urn:com:xacml:rule:id:8cdb88aa-448b-4ed1-bce5-6a037651e73c" Effect="Permit">
+        <Target>
+            <AnyOf>
+                <AllOf>
+                    <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">ACCESS</AttributeValue>
+                        <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                    </Match>
+                    <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Config</AttributeValue>
+                        <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                    </Match>
+                </AllOf>
+            </AnyOf>
+        </Target>
+        <AdviceExpressions>
+            <AdviceExpression AdviceId="BRMSPARAMID" AppliesTo="Permit">
+                <AttributeAssignmentExpression AttributeId="type" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Configuration</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="URLID" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">$URL/Config/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="PolicyName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="VersionNumber" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="matching:ECOMPName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DROOLS</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="matching:ConfigName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">BRMS_PARAM_RULE</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="key:controller" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">vFW</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="RiskType" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="RiskLevel" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="guard" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">False</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="TTLDate" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
+                </AttributeAssignmentExpression>
+            </AdviceExpression>
+        </AdviceExpressions>
+    </Rule>
+</Policy>
\ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/Config_BRMS_Raw_TestBRMSRawPolicy.1.xml b/POLICY-SDK-APP/src/test/resources/Config_BRMS_Raw_TestBRMSRawPolicy.1.xml
new file mode 100644 (file)
index 0000000..aa8abc4
--- /dev/null
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:xacml:policy:id:05c1c4eb-a94c-4f1c-8ff7-548f7d0b03c2" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+     <Description>TestBRMSRawPolicy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:</Description>
+     <Target>
+         <AnyOf>
+             <AllOf>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_BRMS_Raw_TestBRMSRawPolicy.1.xml</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="PolicyName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+             </AllOf>
+             <AllOf>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DROOLS</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ECOMPName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">BRMS_RAW_RULE</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ConfigName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">High</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskType" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">2</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskLevel" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="guard" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="TTLDate" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+             </AllOf>
+         </AnyOf>
+     </Target>
+     <Rule RuleId="" Effect="Permit">
+         <Target>
+             <AnyOf>
+                 <AllOf>
+                     <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">ACCESS</AttributeValue>
+                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                     </Match>
+                     <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Config</AttributeValue>
+                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                     </Match>
+                 </AllOf>
+             </AnyOf>
+         </Target>
+         <AdviceExpressions>
+             <AdviceExpression AdviceId="BRMSRAWID" AppliesTo="Permit">
+                 <AttributeAssignmentExpression AttributeId="type" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Configuration</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="URLID" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">$URL/Config/com.Config_BRMS_Raw_TestBRMSRawPolicy.1.txt</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="PolicyName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_BRMS_Raw_TestBRMSRawPolicy.1.xml</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="VersionNumber" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="matching:ECOMPName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DROOLS</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="matching:ConfigName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">BRMS_RAW_RULE</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="controller:TestController" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">{
+     "artifactId": "testing",
+     "groupId" : "org.openecomp"
+ }</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="dependencies:TestBRMSDependency," Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">[{
+     "groupId" :"org.test" ,
+     "artifactId" : "test_2.10",
+     "version" : "3.0.2",
+     "exclusions" : [ {
+         "groupId" :"org.test.tests" ,
+         "artifactId" : "test-config_2.10"
+     }]
+ }]</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="key:controller" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">vFW</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="RiskType" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">High</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="RiskLevel" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">2</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="guard" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="TTLDate" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
+                 </AttributeAssignmentExpression>
+             </AdviceExpression>
+         </AdviceExpressions>
+     </Rule>
+ </Policy>
\ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/Config_FW_TestFireWallPolicy.1.xml b/POLICY-SDK-APP/src/test/resources/Config_FW_TestFireWallPolicy.1.xml
new file mode 100644 (file)
index 0000000..f334cae
--- /dev/null
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:xacml:policy:id:2f5c1b1e-7cd4-4e71-9a0d-2fcef2a6cb7b" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+     <Description>TestFireWallPolicy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:</Description>
+     <Target>
+         <AnyOf>
+             <AllOf>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_FW_TestFireWallPolicy.1.xml</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="PolicyName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+             </AllOf>
+             <AllOf>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">TestFireWallPolicy</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ConfigName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskType" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskLevel" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="guard" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="TTLDate" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+             </AllOf>
+         </AnyOf>
+     </Target>
+     <Rule RuleId="" Effect="Permit">
+         <Target>
+             <AnyOf>
+                 <AllOf>
+                     <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">ACCESS</AttributeValue>
+                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                     </Match>
+                     <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Config</AttributeValue>
+                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                     </Match>
+                 </AllOf>
+             </AnyOf>
+         </Target>
+         <AdviceExpressions>
+             <AdviceExpression AdviceId="firewallConfigID" AppliesTo="Permit">
+                 <AttributeAssignmentExpression AttributeId="type" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Configuration</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="URLID" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">$URL/Config/com.Config_FW_TestFireWallPolicy.1.json</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="PolicyName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_FW_TestFireWallPolicy.1.xml</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="VersionNumber" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="matching:ECOMPName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string"/>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="matching:ConfigName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">TestFireWallPolicy</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="RiskType" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="RiskLevel" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="guard" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="TTLDate" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
+                 </AttributeAssignmentExpression>
+             </AdviceExpression>
+         </AdviceExpressions>
+     </Rule>
+ </Policy>
\ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/Config_Fault_TestClosedLoopPolicy.1.xml b/POLICY-SDK-APP/src/test/resources/Config_Fault_TestClosedLoopPolicy.1.xml
new file mode 100644 (file)
index 0000000..82be342
--- /dev/null
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:xacml:policy:id:947cfa37-71da-4c10-9e64-bb3635aa9f52" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+     <Description>TestClosedLoopPolicy@CreatedBy:rb7147@CreatedBy:@ModifiedBy:rb7147@ModifiedBy:</Description>
+     <Target>
+         <AnyOf>
+             <AllOf>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_Fault_TestClosedLoopPolicy.1.xml</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="PolicyName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+             </AllOf>
+             <AllOf>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DCAE</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ECOMPName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskType" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskLevel" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="guard" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">07-06-2017</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="TTLDate" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+             </AllOf>
+         </AnyOf>
+     </Target>
+     <Rule RuleId="" Effect="Permit">
+         <Target>
+             <AnyOf>
+                 <AllOf>
+                     <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">ACCESS</AttributeValue>
+                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                     </Match>
+                     <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Config</AttributeValue>
+                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                     </Match>
+                 </AllOf>
+             </AnyOf>
+         </Target>
+         <AdviceExpressions>
+             <AdviceExpression AdviceId="faultID" AppliesTo="Permit">
+                 <AttributeAssignmentExpression AttributeId="type" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Configuration</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="URLID" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">$URL/Config/com.Config_Fault_TestClosedLoopPolicy.1.json</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="PolicyName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_Fault_TestClosedLoopPolicy.1.xml</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="VersionNumber" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="matching:ECOMPName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DCAE</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="RiskType" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="RiskLevel" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="guard" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="TTLDate" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">07-06-2017</AttributeValue>
+                 </AttributeAssignmentExpression>
+             </AdviceExpression>
+         </AdviceExpressions>
+     </Rule>
+ </Policy>
\ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/Config_MS_vFirewall.1.xml b/POLICY-SDK-APP/src/test/resources/Config_MS_vFirewall.1.xml
new file mode 100644 (file)
index 0000000..4fd0b7b
--- /dev/null
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:com:xacml:policy:id:34928b05-b0f6-4974-8458-f4d34a2a1764" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+    <Description>Micro Service vFirewall Demo Policy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:</Description>
+    <Target>
+        <AnyOf>
+            <AllOf>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_MS_vFirewall.1.xml</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="PolicyName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+            </AllOf>
+            <AllOf>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DCAE</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ECOMPName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleConfigName</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ConfigName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">TcaMetrics-v1.0.0.5</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="service" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vFirewall</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="uuid" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleServiceLocation</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="location" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskType" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskLevel" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">False</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="guard" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.openecomp.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">07-06-2017</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="TTLDate" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+            </AllOf>
+        </AnyOf>
+    </Target>
+    <Rule RuleId="urn:com:xacml:rule:id:063161de-0534-4989-bd01-42f784daf21e" Effect="Permit">
+        <Target>
+            <AnyOf>
+                <AllOf>
+                    <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">ACCESS</AttributeValue>
+                        <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                    </Match>
+                    <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Config</AttributeValue>
+                        <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                    </Match>
+                </AllOf>
+            </AnyOf>
+        </Target>
+        <AdviceExpressions>
+            <AdviceExpression AdviceId="MSID" AppliesTo="Permit">
+                <AttributeAssignmentExpression AttributeId="type" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Configuration</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="URLID" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">$URL/Config/com.Config_MS_vFirewall.1.json</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="PolicyName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_MS_vFirewall.1.xml</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="VersionNumber" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="matching:ECOMPName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DCAE</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="matching:ConfigName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleConfigName</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="matching:service" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">TcaMetrics-v1.0.0.5</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="matching:uuid" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vFirewall</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="matching:Location" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleServiceLocation</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="Priority" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="RiskType" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="RiskLevel" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="guard" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                </AttributeAssignmentExpression>
+                <AttributeAssignmentExpression AttributeId="TTLDate" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">07-06-2017</AttributeValue>
+                </AttributeAssignmentExpression>
+            </AdviceExpression>
+        </AdviceExpressions>
+    </Rule>
+</Policy>
\ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/Config_PM_TestClosedLoopPMPolicy.1.xml b/POLICY-SDK-APP/src/test/resources/Config_PM_TestClosedLoopPMPolicy.1.xml
new file mode 100644 (file)
index 0000000..ca56cf4
--- /dev/null
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:xacml:policy:id:a3ff3c48-b16f-436a-9aaa-ac7a3515b0e8" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+     <Description>TestClosedLoopPMPolicy@CreatedBy:rb7147@CreatedBy:@ModifiedBy:rb7147@ModifiedBy:</Description>
+     <Target>
+         <AnyOf>
+             <AllOf>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_PM_TestClosedLoopPMPolicy.1.xml</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="PolicyName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+             </AllOf>
+             <AllOf>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Test</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ECOMPName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskType" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskLevel" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="guard" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="TTLDate" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Registration Failure(Trinity)</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ServiceType" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+             </AllOf>
+         </AnyOf>
+     </Target>
+     <Rule RuleId="" Effect="Permit">
+         <Target>
+             <AnyOf>
+                 <AllOf>
+                     <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">ACCESS</AttributeValue>
+                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                     </Match>
+                     <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Config</AttributeValue>
+                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                     </Match>
+                 </AllOf>
+             </AnyOf>
+         </Target>
+         <AdviceExpressions>
+             <AdviceExpression AdviceId="PMID" AppliesTo="Permit">
+                 <AttributeAssignmentExpression AttributeId="type" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Configuration</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="URLID" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">$URL/Config/com.Config_PM_TestClosedLoopPMPolicy.1.json</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="PolicyName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_PM_TestClosedLoopPMPolicy.1.xml</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="VersionNumber" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="matching:ECOMPName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Test</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="matching:ServiceType" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Registration Failure(Trinity)</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="RiskType" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="RiskLevel" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="guard" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
+                 </AttributeAssignmentExpression>
+                 <AttributeAssignmentExpression AttributeId="TTLDate" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
+                 </AttributeAssignmentExpression>
+             </AdviceExpression>
+         </AdviceExpressions>
+     </Rule>
+ </Policy>
\ No newline at end of file
index 5c32cd4..5390548 100644 (file)
@@ -27,7 +27,7 @@
                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="guard" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
                 </Match>
                 <Match MatchId="org.openecomp.function.regex-match">
-                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">NA</AttributeValue>
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="TTLDate" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
                 </Match>
                 <Match MatchId="org.openecomp.function.regex-match">
@@ -82,7 +82,7 @@
                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
                 </AttributeAssignmentExpression>
                 <AttributeAssignmentExpression AttributeId="TTLDate" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
-                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">NA</AttributeValue>
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
                 </AttributeAssignmentExpression>
             </AdviceExpression>
         </AdviceExpressions>
diff --git a/POLICY-SDK-APP/src/test/resources/Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml b/POLICY-SDK-APP/src/test/resources/Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml
new file mode 100644 (file)
index 0000000..74a0e68
--- /dev/null
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:xacml:policy:id:b622d808-ba62-4392-93c8-eaff0cbfb63f" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+     <Description>TestDecisionPolicyWithRuleAlgorithms@CreatedBy:rb7147@CreatedBy:@ModifiedBy:rb7147@ModifiedBy:</Description>
+     <Target>
+         <AnyOf>
+             <AllOf>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="PolicyName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+             </AllOf>
+             <AllOf>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Test</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ECOMPName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+                 <Match MatchId="org.openecomp.function.regex-match">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">test</AttributeValue>
+                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="SamplTest" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                 </Match>
+             </AllOf>
+         </AnyOf>
+     </Target>
+     <VariableDefinition VariableId="TestSettings">
+         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">test</AttributeValue>
+     </VariableDefinition>
+     <Rule RuleId="" Effect="Permit">
+         <Target>
+             <AnyOf>
+                 <AllOf>
+                     <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DECIDE</AttributeValue>
+                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                     </Match>
+                 </AllOf>
+             </AnyOf>
+         </Target>
+         <Condition>
+             <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
+                 <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Sample</AttributeValue>
+                     <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
+                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="SamplTest" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                     </Apply>
+                 </Apply>
+                 <Apply FunctionId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">test</AttributeValue>
+                     <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
+                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="SamplTest" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                     </Apply>
+                 </Apply>
+             </Apply>
+         </Condition>
+     </Rule>
+     <Rule RuleId="" Effect="Deny">
+         <Target>
+             <AnyOf>
+                 <AllOf>
+                     <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DECIDE</AttributeValue>
+                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                     </Match>
+                 </AllOf>
+             </AnyOf>
+         </Target>
+         <Condition>
+             <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:not">
+                 <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
+                     <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
+                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Sample</AttributeValue>
+                         <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
+                             <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="SamplTest" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                         </Apply>
+                     </Apply>
+                     <Apply FunctionId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">test</AttributeValue>
+                         <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
+                             <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="SamplTest" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                         </Apply>
+                     </Apply>
+                 </Apply>
+             </Apply>
+         </Condition>
+     </Rule>
+ </Policy>
\ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/JSONConfig.json b/POLICY-SDK-APP/src/test/resources/JSONConfig.json
new file mode 100644 (file)
index 0000000..23f9859
--- /dev/null
@@ -0,0 +1,132 @@
+[
+    {
+        "serviceTypePolicyName": "Registration Failure(Trinity)",
+        "verticaMetrics": "DATETIMEUTC\n VNFC_NAME\n BW_SIP_STATS_REGISTER_RESPONSE_CODE_VALUE \nBW_SIP_STATS_REGISTER_RESPONSE_INS \n BW_SIP_STATS_REGISTER_RESPONSE_OUTS",
+        "attributes": {
+            "Onset&abatement anomaly detection": {
+                "PtileLimit": "Percentile value used by anomaly detection model",
+                "Threshold": "initial value for the quantile at percentile(PtileLimit) used by the anomaly detection model",
+                "Window": "Number of weeks anomaly detection model keeps in memory to estimate Threshold",
+                "Training": "Number of historical weeks anomaly detection model needs for training ",
+                "FractionSamplePerDay": "This corresponds to the minimum number of samples per day to be used in the daily percentile computation when updating the distribution tail crossing model. When there are less samples than that threshold, the model is not updated with these samples. "
+            },
+            "Onset signature trigger": {
+                "ConsecutiveIntervalOnset": "Number of consecutive intervals normalized metric must trigger the anomaly detection model before resulting in an action",
+                "RetryTimer": "Minimum interval between policy triggers"
+            },
+            "Abatement signature trigger": {
+                "ConsecutiveIntervalAbatement": "Number of consecutive intervals normalized metric does not trigger the anomaly detection model after onset signature was triggered"
+            },
+            "Onset & abatement UEB notification": {
+                "OnsetMessage": "Value of field OnSetMessage sent by Analytics Engine published on UEB",
+                "AbatementMessage": "Value of field AbatementMessage sent by Analytics Engine published on UEB",
+                "PolicyName": "Value of field PolicyName sent by Analytics Engine published on UEB"
+            }
+        },
+        "policyDescription": "Policy to detect instances where SIP registration rate exceeds a normal level over a number of consecutive sampling periods. \n Notes \n (1) Vertica metrics normalized and combined in a SIP registration failure probability per Site and per VM. \n (2) Anomaly detection model operates on SIP registration failure probability. \n (3) Anomaly detection consists of an estimated distribution percentile threshold crossing. \n (4) Actions: Send email and/or UEB notification"
+    },
+    {
+        "serviceTypePolicyName": "International Fraud(Trinity)",
+        "verticaMetrics": "INTERVAL_START_TS\n CUSTOMER\n A_SITE\n A_SBG\n BW\n Z_COUNTRY\n CALL_COUNT\n MINUTES_OF_USE",
+        "attributes": {
+            "Onset&abatement anomaly detection": {
+                "PtileLimit": "Percentile value used by anomaly detection model",
+                "Threshold": "initial value for the quantile at percentile(PtileLimit) used by the anomaly detection model",
+                "Window": "Number of weeks anomaly detection model keeps in memory to estimate Threshold",
+                "Training": "Number of historical weeks anomaly detection model needs for training ",
+                 "FractionSamplePerDay": "This corresponds to the minimum number of samples per day to be used in the daily percentile computation when updating the distribution tail crossing model. When there are less samples than that threshold, the model is not updated with these samples. "
+            },
+            "Onset signature trigger": {
+                "ConsecutiveIntervalOnset": "Number of consecutive intervals normalized metric must trigger the anomaly detection model before resulting in an action",
+                "RetryTimer": "Minimum interval between policy triggers"
+            },
+            "Abatement signature trigger": {
+                "ConsecutiveIntervalAbatement": "Number of consecutive intervals normalized metric does not trigger the anomaly detection model after onset signature was triggered"
+            },
+            "Onset & abatement UEB notification ": {
+                "OnsetMessage": "Value of field OnSetMessage sent by Analytics Engine published on UEB",
+                "AbatementMessage": "Value of field AbatementMessage sent by Analytics Engine published on UEB",
+                "PolicyName": "Value of field PolicyName sent by Analytics Engine published on UEB"
+            }
+        },
+        "policyDescription": "Policy to detect instances where count of calls towards an international destination exceeds a normal level over a number of consecutive sampling periods. \n Notes \n (1) Vertica metrics normalized and combined in a SIP registration failure probability per Customer, per Site and per VM. \n (2) Anomaly detection model operates on counts towards an international destination. \n (3) Anomaly detection consists of an estimated distribution percentile threshold crossing. \n (4) Actions: Send email and/or UEB notification"
+    },
+    {
+        "serviceTypePolicyName": "No dial tone(Trinity)",
+        "verticaMetrics": "INTERVAL_START_TS\n SUM(CALLS_ATTEMPTED)\n SUM(NO_ANSWER_OR_VOICE_MAIL)\n A_SITE or A_SBG or BW or CUSTOMER",
+        "attributes": {
+            "Onset&abatement anomaly detection": {
+                "PtileLimit": "Percentile value used by anomaly detection model",
+                "Threshold": "initial value for the quantile at percentile(PtileLimit) used by the anomaly detection model",
+                "Window": "Number of weeks anomaly detection model keeps in memory to estimate Threshold",
+                "Training": "Number of historical weeks anomaly detection model needs for training ",
+                 "FractionSamplePerDay": "This corresponds to the minimum number of samples per day to be used in the daily percentile computation when updating the distribution tail crossing model. When there are less samples than that threshold, the model is not updated with these samples. "
+            },
+            "Onset signature trigger": {
+                "ConsecutiveIntervalOnset": "Number of consecutive intervals normalized metric must trigger the anomaly detection model before resulting in an action",
+                "RetryTimer": "Minimum interval between policy triggers"
+            },
+            "Abatement signature trigger": {
+                "ConsecutiveIntervalAbatement": "Number of consecutive intervals normalized metric does not trigger the anomaly detection model after onset signature was triggered"
+            },
+            "Onset & abatement UEB notification ": {
+                "OnsetMessage": "Value of field OnSetMessage sent by Analytics Engine published on UEB",
+                "AbatementMessage": "Value of field AbatementMessage sent by Analytics Engine published on UEB",
+                "PolicyName": "Value of field PolicyName sent by Analytics Engine published on UEB"
+            }
+        },
+        "policyDescription": "Policy to detect ? \n Notes:\n (1) Actions: Send email and/or UEB notification"
+    },
+    {
+        "serviceTypePolicyName": "Call storm(Trinity)",
+        "verticaMetrics": "",
+        "attributes": {
+            "Onset&abatement anomaly detection": {
+                "SeasonLength": "Metric seasonality (5min sampling period with 7 days seasonality: 7*288) used by Holt-Winters model",
+                "TrainLength": "Training length (5min sampling period with 7 days seasonality and 5 cycles training: 7*288*5) used by Holt-Winters",
+                "Alpha": "Smoothing parameter (range 0-1, default 0.2)",
+                "Beta": "Trend parameter (range 0-1, default 0) ",
+                "Gamma": "Seasonality (range 0-1, default 0.05)",
+                "Deviation Threshold": "Approximately a limit on the factor by how much current value has deviated compared to expected variance"
+            },
+            "Onset signature trigger": {
+                "RetryTimer": "Minimum interval between policy triggers"
+            },
+            "Abatement signature trigger": {
+                "Hw-Timeout": "Maximum time for an HealthCheck response (measured from the time a positive App-C response was received)",
+                "OnSetMessage": "Value of field Message sent by Analytics Engine published on UEB "
+            },
+            "Onset & abatement UEB notification ": {
+                "AbatementMessage": "Value of field AbatementMessage sent by Analytics Engine published on UEB",
+                "PolicyName": "Value of field PolicyName sent by Analytics Engine published on UEB"
+            }
+        },
+        "policyDescription": "Policy to detect instances where count of Formatted table ? exceeds a predicted level. \n Notes \n (1) Vertica metrics normalized and combined in ? per Customer, per Site and per VM. \n (2) Anomaly detection model operates on ? \n (3) Anomaly detection consists of detecting deviations from Holt-Winters predictions. \n (4) Actions: Send email and/or UEB notification"
+    },
+    {
+        "serviceTypePolicyName": "Registration storm(Trinity)",
+        "verticaMetrics": "",
+        "attributes": {
+            "Onset&abatement anomaly detection": {
+                "SeasonLength": "Metric seasonality (5min sampling period with 7 days seasonality: 7*288) used by Holt-Winters model",
+                "TrainLength": "Training length (5min sampling period with 7 days seasonality and 5 cycles training: 7*288*5) used by Holt-Winters",
+                "Alpha": "Smoothing parameter (range 0-1, default 0.2)",
+                "Beta": "Trend parameter (range 0-1, default 0) ",
+                "Gamma": "Seasonality (range 0-1, default 0.05)",
+                "Deviation Threshold": "Approximately a limit on the factor by how much current value has deviated compared to expected variance"
+            },
+            "Onset signature trigger": {
+                "RetryTimer": "Minimum interval between policy triggers"
+            },
+            "Abatement signature trigger": {
+                "Hw-Timeout": "Maximum time for an HealthCheck response (measured from the time a positive App-C response was received)",
+                "OnSetMessage": "Value of field Message sent by Analytics Engine published on UEB "
+            },
+            "Onset & abatement UEB notification ": {
+                "AbatementMessage": "Value of field AbatementMessage sent by Analytics Engine published on UEB",
+                "PolicyName": "Value of field PolicyName sent by Analytics Engine published on UEB"
+            }
+        },
+        "policyDescription": "Policy to detect instances where count of Formatted table ? exceeds a predicted level. \n Notes \n (1) Vertica metrics normalized and combined in ? per Customer, per Site and per VM. \n (2) Anomaly detection model operates on ? \n (3) Anomaly detection consists of detecting deviations from Holt-Winters predictions. \n (4) Actions: Send email and/or UEB notification"
+    }
+]
\ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/com.Action_TestActionPolicy.1.json b/POLICY-SDK-APP/src/test/resources/com.Action_TestActionPolicy.1.json
new file mode 100644 (file)
index 0000000..7f228f9
--- /dev/null
@@ -0,0 +1 @@
+{"a":"b"}
\ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt b/POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt
new file mode 100644 (file)
index 0000000..955afbd
--- /dev/null
@@ -0,0 +1,1145 @@
+/* Autogenerated Code Please Don't change/remove this comment section. This is for the UI purpose. 
+        <$%BRMSParamTemplate=ControlLoopDemo__closedLoopControlName%$> 
+ */ 
+
+
+/*-
+ * ============LICENSE_START=======================================================
+ * archetype-closed-loop-demo-rules
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.controlloop;
+
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.UUID;
+
+import org.openecomp.policy.controlloop.VirtualControlLoopEvent;
+import org.openecomp.policy.controlloop.ControlLoopEventStatus;
+import org.openecomp.policy.controlloop.VirtualControlLoopNotification;
+import org.openecomp.policy.controlloop.ControlLoopNotificationType;
+import org.openecomp.policy.controlloop.ControlLoopOperation;
+import org.openecomp.policy.controlloop.ControlLoopOperationWrapper;
+import org.openecomp.policy.template.demo.ControlLoopException;
+
+import org.openecomp.policy.aai.AAINQF199.AAINQF199CloudRegion;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperties;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperty;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199GenericVNF;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199InstanceFilters;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItem;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItems;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Manager;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199NamedQuery;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199QueryParameters;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Request;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199RequestWrapper;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Response;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ResponseWrapper;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ServiceInstance;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Tenant;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199VfModule;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199VServer;
+import org.openecomp.policy.aai.util.Serialization;
+
+import org.openecomp.policy.appc.CommonHeader;
+import org.openecomp.policy.appc.Request;
+import org.openecomp.policy.appc.Response;
+import org.openecomp.policy.appc.ResponseCode;
+import org.openecomp.policy.appc.ResponseStatus;
+import org.openecomp.policy.appc.ResponseValue;
+
+import org.openecomp.policy.template.demo.EventManager;
+import org.openecomp.policy.vnf.trafficgenerator.PGRequest;
+import org.openecomp.policy.vnf.trafficgenerator.PGStream;
+import org.openecomp.policy.vnf.trafficgenerator.PGStreams;
+
+import org.openecomp.policy.mso.MSOManager;
+import org.openecomp.policy.mso.MSORequest;
+import org.openecomp.policy.mso.MSORequestStatus;
+import org.openecomp.policy.mso.MSORequestDetails;
+import org.openecomp.policy.mso.MSOModelInfo;
+import org.openecomp.policy.mso.MSOCloudConfiguration;
+import org.openecomp.policy.mso.MSORequestInfo;
+import org.openecomp.policy.mso.MSORequestParameters;
+import org.openecomp.policy.mso.MSORelatedInstanceListElement;
+import org.openecomp.policy.mso.MSORelatedInstance;
+import org.openecomp.policy.mso.MSOResponse;
+
+import org.openecomp.policy.drools.system.PolicyEngine;
+
+//
+// These parameters are required to build the runtime policy
+//
+declare Params
+    closedLoopControlName : String
+    actor : String
+    aaiURL : String
+    aaiUsername : String
+    aaiPassword : String
+    msoURL : String
+    msoUsername : String
+    msoPassword : String
+    aaiNamedQueryUUID : String
+    aaiPatternMatch : int 
+    notificationTopic : String
+    appcTopic : String
+end
+
+/*
+*
+* Called once and only once to insert the parameters into working memory for this Closed Loop policy.
+* (Comment SETUP rule out for the first ECOMP opensource release since policy BRMS_GW already puts a Params fact in there)
+*
+*
+*rule "BRMSParamvFWDemoPolicy.SETUP"
+*      when
+*      then
+*              System.out.println("rule SETUP is triggered.");
+*              Params params = new Params();
+*              params.setClosedLoopControlName("CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8");
+*              params.setActor("APPC");
+*              params.setAaiURL("null");
+*              params.setAaiUsername("null");
+*              params.setAaiPassword("null");
+*              params.setMsoURL("null");
+*              params.setMsoUsername("null");
+*              params.setMsoPassword("null");
+*              params.setAaiNamedQueryUUID("null");
+*              params.setAaiPatternMatch(1);
+*              params.setNotificationTopic("POLICY-CL-MGT");
+*              params.setAppcTopic("APPC-CL");
+*              //
+*              // This stays in memory as long as the rule is alive and running
+*              //
+*              insert(params);
+*end
+*/
+/*
+*
+* This rule responds to DCAE Events
+*
+*/
+rule "BRMSParamvFWDemoPolicy.EVENT"
+       when
+        $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+        $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+        not ( EventManager( closedLoopControlName == $event.closedLoopControlName ))
+       then
+               System.out.println("rule EVENT is triggered.");
+               try {
+                       // 
+                       // Check the requestID in the event to make sure it is not null before we create the EventManager. 
+                       // The EventManager will do extra syntax checking as well check if the closed loop is disabled/
+                       //
+                       if ($event.requestID == null) {
+                               VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+                               notification.notification = ControlLoopNotificationType.REJECTED;
+                               notification.from = "policy";
+                               notification.message = "Missing requestID from DCAE event";
+                               notification.policyName = drools.getRule().getName();
+                               notification.policyScope = "com";
+                               notification.policyVersion = "1";
+                               //
+                               // Let interested parties know
+                               //
+                               try {
+                                       System.out.println(Serialization.gsonPretty.toJson(notification));
+                                       PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                               } catch (Exception e) {
+                                       e.printStackTrace();
+                                       System.out.println("Can't deliver notification: " + notification);
+                               }
+                               //
+                               // Retract it from memory
+                               //
+                               retract($event);
+                               System.out.println("Event with requestID=null has been retracted.");
+                       } else {
+                               //
+                               // Create an EventManager
+                               //
+                               EventManager manager = new EventManager($params.getClosedLoopControlName(), $event.requestID, $event.target);
+                               //
+                               // Determine if EventManager can actively process the event (i.e. syntax)
+                               //
+                               VirtualControlLoopNotification notification = manager.activate($event);
+                               notification.from = "policy"; 
+                               notification.policyName = drools.getRule().getName();
+                               notification.policyScope = "com";
+                               notification.policyVersion = "1";
+                               //
+                               // Are we actively pursuing this event?
+                               //
+                               if (notification.notification == ControlLoopNotificationType.ACTIVE) {
+                                       //
+                                       // Insert Event Manager into memory, this will now kick off processing.
+                                       //
+                                       insert(manager);
+                                       //
+                                       // Let interested parties know
+                                       //
+                                       try {
+                                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                                       } catch (Exception e) {
+                                               e.printStackTrace();
+                                               System.out.println("Can't deliver notification: " + notification);
+                                       }               
+                               } else {
+                                       //
+                                       // Let interested parties know
+                                       //
+                                       try {
+                                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                                       } catch (Exception e) {
+                                               e.printStackTrace();
+                                               System.out.println("Can't deliver notification: " + notification);
+                                       }
+                                       //
+                                       // Retract it from memory
+                                       //
+                                       retract($event);
+                               }
+                               //
+                               // Now that the manager is inserted into Drools working memory, we'll wait for
+                               // another rule to fire in order to continue processing. This way we can also
+                               // then screen for additional ONSET and ABATED events for this same RequestIDs 
+                               // and for different RequestIDs but with the same closedLoopControlName and target.
+                               //
+                       }
+               //
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+                       notification.notification = ControlLoopNotificationType.REJECTED;
+                       notification.message = "Exception occurred " + e.getMessage();
+                       notification.policyName = drools.getRule().getName();
+                       notification.policyScope = "com";
+                       notification.policyVersion = "1";
+                       //
+                       //
+                       //
+                       try {
+                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                       } catch (Exception e1) {
+                               System.out.println("Can't deliver notification: " + notification);
+                               e1.printStackTrace();
+                       }
+                       //
+                       // Retract the event
+                       //
+                       retract($event);
+               }
+end
+
+/*
+*
+* This rule happens when we got a valid ONSET, closed loop is enabled and an Event Manager
+* is created. We can start the operations for this closed loop.
+*
+*/
+rule "BRMSParamvFWDemoPolicy.EVENT.MANAGER"
+       when
+               $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+               $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+               $manager : EventManager( closedLoopControlName == $event.closedLoopControlName, controlLoopResult == null)
+       then
+               System.out.println("rule EVENT.MANAGER is triggered.");
+               //
+               // Check which event this is.
+               //
+               EventManager.NEW_EVENT_STATUS eventStatus = $manager.onNewEvent($event);
+               //
+               // We only want the initial ONSET event in memory,
+               // all the other events need to be retracted to support
+               // cleanup and avoid the other rules being fired for this event.
+               //
+               if (eventStatus != EventManager.NEW_EVENT_STATUS.FIRST_ONSET) {
+                       System.out.println("Retracting "+eventStatus+" Event.");
+                       retract($event);
+                       return;
+               }
+               //
+               // Now the event in memory is first onset event
+               //
+               try {
+                       //
+                       // Pull the known AAI field from the Event
+                       //
+                       // generic-vnf is needed for vFirewall case
+                       // vserver-name is needed for vLoadBalancer case
+                       //
+                       String genericVNF = $event.AAI.get("generic-vnf.vnf-id");
+                       String vserver = $event.AAI.get("vserver.vserver-name");
+                       //
+                       // Check if we are implementing a simple pattern match.
+                       //
+                       if ($params.getAaiPatternMatch() == 1) {
+                               //
+                               // Yes
+                               //
+                               //Basic naming characteristics:
+                               //VF Name (9 char)+VM name (13 char total)+VFC (19 char total)
+                               //Example: 
+                               //VF Name (9 characters):    cscf0001v
+                               //VM Name(13 characters): cscf0001vm001
+                               //VFC name(19 characters): cscf0001vm001cfg001
+                               //
+                               // zdfw1fwl01fwl02 or zdfw1fwl01fwl01  
+                               // replaced with
+                               // zdfw1fwl01pgn02 or zdfw1fwl01pgn01
+                               //
+                               int index = genericVNF.lastIndexOf("fwl");
+                               if (index == -1) {
+                                       System.err.println("The generic-vnf.vnf-id from DCAE Event is not valid.");
+                               } else {
+                                       genericVNF = genericVNF.substring(0, index) + "pgn" + genericVNF.substring(index+"fwl".length());
+                               }
+                               //
+                               // Construct an APPC request
+                               //
+                               ControlLoopOperation operation = new ControlLoopOperation();
+                               operation.actor = $params.getActor();
+                               operation.operation = "ModifyConfig";
+                               operation.target = $event.target;
+                               //
+                               // Create operationWrapper
+                               //
+                               ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);
+                               //
+                               // insert operationWrapper into memory
+                               //
+                               insert(operationWrapper);
+                               //
+                               Request request = new Request();
+                               request.CommonHeader = new CommonHeader();
+                               request.CommonHeader.RequestID = $event.requestID;
+                               request.Action = operation.operation;
+                               request.Payload = new HashMap<String, Object>();
+                               //
+                               // Fill in the payload
+                               //
+                               request.Payload.put("generic-vnf.vnf-id", genericVNF);
+                               //
+                               PGRequest pgRequest = new PGRequest();
+                               pgRequest.pgStreams = new PGStreams();
+                               
+                               PGStream pgStream;
+                               for(int i = 0; i < 5; i++){
+                                       pgStream = new PGStream();
+                                       pgStream.streamId = "fw_udp"+(i+1);
+                                       pgStream.isEnabled = "true";
+                                       pgRequest.pgStreams.pgStream.add(pgStream);
+                               }
+                               request.Payload.put("pg-streams", pgRequest.pgStreams);
+                               
+                               if (request != null) {
+                                       //
+                                       // Insert request into memory
+                                       //
+                                       insert(request);
+                                       //
+                                       // Tell interested parties we are performing this Operation
+                                       //
+                                       VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+                                       notification.notification = ControlLoopNotificationType.OPERATION;
+                                       // message and history ??
+                                       notification.from = "policy";
+                                       notification.policyName = drools.getRule().getName();
+                                       notification.policyScope = "com";
+                                       notification.policyVersion = "1";
+                                       try {
+                                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                                       } catch (Exception e) {
+                                               System.out.println("Can't deliver notification: " + notification);
+                                               e.printStackTrace();
+                                       }
+                                       //
+                                       // Now send the operation request
+                                       //
+                                       if (request instanceof Request) {
+                                               try {
+                                                       System.out.println("APPC request sent:");
+                                                       System.out.println(Serialization.gsonPretty.toJson(request));
+                                                       PolicyEngine.manager.deliver($params.getAppcTopic(), request);
+                                               } catch (Exception e) {
+                                                       e.printStackTrace();
+                                                       System.out.println("Can't deliver request: " + request);
+                                               }
+                                       }
+                               } else {
+                                       //
+                                       // what happens if it is null
+                                       //
+                               }
+                               //
+                       } else {
+                               //
+                               // create AAI named-query request with UUID started with "F199"
+                               //
+                               AAINQF199Request aainqf199request = new AAINQF199Request();
+                               AAINQF199QueryParameters aainqf199queryparam = new AAINQF199QueryParameters();
+                               AAINQF199NamedQuery aainqf199namedquery = new AAINQF199NamedQuery();
+                               AAINQF199InstanceFilters aainqf199instancefilter = new AAINQF199InstanceFilters();
+                               //
+                               // queryParameters
+                               //
+                               aainqf199namedquery.namedQueryUUID = UUID.fromString($params.getAaiNamedQueryUUID()); 
+                               aainqf199queryparam.namedQuery = aainqf199namedquery;
+                               aainqf199request.queryParameters = aainqf199queryparam;
+                               //
+                               // instanceFilters
+                               //
+                               Map aainqf199instancefiltermap = new HashMap();
+                               Map aainqf199instancefiltermapitem = new HashMap();
+                               aainqf199instancefiltermapitem.put("vserver-name", vserver); 
+                               aainqf199instancefiltermap.put("vserver", aainqf199instancefiltermapitem);
+                               aainqf199instancefilter.instanceFilter.add(aainqf199instancefiltermap);
+                               aainqf199request.instanceFilters = aainqf199instancefilter;
+                               //
+                               // print aainqf199request for debug
+                               //
+                               System.out.println("AAI Request sent:");
+                               System.out.println(Serialization.gsonPretty.toJson(aainqf199request));
+                               //
+                               // Create AAINQF199RequestWrapper
+                               //
+                               AAINQF199RequestWrapper aainqf199RequestWrapper = new AAINQF199RequestWrapper($event.requestID, aainqf199request);
+                               //
+                               // insert aainqf199request into memory
+                               //
+                               insert(aainqf199RequestWrapper);
+                       }
+                       //
+               } catch (Exception e) {
+                e.printStackTrace();
+               }
+end
+
+/*
+*
+* This rule happens when we got a valid ONSET, closed loop is enabled, an Event Manager
+* is created, AAI Manager and AAI Request are ready in memory. We can start sending query to AAI and then wait for response.
+*
+*/
+rule "BRMSParamvFWDemoPolicy.EVENT.MANAGER.AAINQF199REQUEST"
+       when
+               $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+               $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+               $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+               $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)
+       then
+               System.out.println("rule EVENT.MANAGER.AAINQF199REQUEST is triggered.");
+               //
+               // send the request
+               //
+               AAINQF199Response aainqf199response = AAINQF199Manager.postQuery($params.getAaiURL(), $params.getAaiUsername(), $params.getAaiPassword(),
+                                                                                                          $aainqf199RequestWrapper.aainqf199request, $event.requestID);
+               //
+               // Check AAI response
+               //
+               if (aainqf199response == null) {
+                       System.err.println("Failed to get AAI response");
+                       //
+                       // Fail and retract everything
+                       //
+                       retract($event);
+                       retract($manager);
+                       retract($aainqf199RequestWrapper);
+               } else {
+                       //
+                       // Create AAINQF199ResponseWrapper
+                       //
+                       AAINQF199ResponseWrapper aainqf199ResponseWrapper = new AAINQF199ResponseWrapper($event.requestID, aainqf199response);
+                       //
+                       // insert aainqf199ResponseWrapper to memeory
+                       //
+                       insert(aainqf199ResponseWrapper);
+               }
+end
+
+/*
+*
+* This rule happens when we got a valid AAI response. We can start sending request to APPC or MSO now.
+*
+*/
+rule "BRMSParamvFWDemoPolicy.EVENT.MANAGER.AAINQF199RESPONSE"
+       when 
+               $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+               $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+               $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+               $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)
+               $aainqf199ResponseWrapper : AAINQF199ResponseWrapper(requestID == $event.requestID)
+       then
+               System.out.println("rule EVENT.MANAGER.AAINQF199RESPONSE is triggered.");
+               //
+               // Extract related fields out of AAINQF199RESPONSE
+               //
+               String vnfItemVnfId, vnfItemVnfType, vnfItemPersonaModelId, vnfItemPersonaModelVersion, vnfItemModelName, 
+                      vnfItemModelVersion, vnfItemModelNameVersionId, serviceItemServiceInstanceId, serviceItemPersonaModelId,
+                      serviceItemModelName, serviceItemModelType, serviceItemModelVersion, serviceItemModelNameVersionId,
+                      vfModuleItemVfModuleName, vfModuleItemPersonaModelId, vfModuleItemPersonaModelVersion, vfModuleItemModelName, 
+                      vfModuleItemModelNameVersionId, tenantItemTenantId, cloudRegionItemCloudRegionId;
+               try {
+                       //
+                       // vnfItem
+                       //
+                       vnfItemVnfId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfID;
+                       vnfItemVnfType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfType;
+                       vnfItemVnfType = vnfItemVnfType.substring(vnfItemVnfType.lastIndexOf("/")+1);
+                       vnfItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelId;
+                       vnfItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelVersion;
+                       vnfItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;
+                       vnfItemModelVersion =           $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(2).propertyValue;
+                       vnfItemModelNameVersionId =     $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;
+                       //
+                       // serviceItem
+                       //
+                       serviceItemServiceInstanceId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.serviceInstanceID;
+                       serviceItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelId;
+                       serviceItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;
+                       serviceItemModelType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(1).propertyValue;
+                       serviceItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelVersion;
+                       serviceItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;
+                       //
+                       // Find the index for base vf module and non-base vf module
+                       //
+                       int baseIndex = -1;
+                       int nonBaseIndex = -1;
+                       List<AAINQF199InventoryResponseItem> inventoryItems = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems;
+                       for (AAINQF199InventoryResponseItem m : inventoryItems) {
+                               if (m.vfModule != null && m.vfModule.isBaseVfModule == true) {
+                                       baseIndex = inventoryItems.indexOf(m);
+                               } else if (m.vfModule != null && m.vfModule.isBaseVfModule == false && m.vfModule.orchestrationStatus == null) {
+                                       nonBaseIndex = inventoryItems.indexOf(m);
+                               }
+                               //
+                               if (baseIndex != -1 && nonBaseIndex != -1) {
+                                       break;
+                               }
+                       }
+                       //
+                       // Report the error if either base vf module or non-base vf module is not found
+                       //
+                       if (baseIndex == -1 || nonBaseIndex == -1) {
+                               System.err.println("Either base or non-base vf module is not found from AAI response.");
+                               retract($aainqf199RequestWrapper);
+                               retract($aainqf199ResponseWrapper);
+                               retract($manager);
+                               retract($event);
+                               return;
+                       }
+                       //
+                       // This comes from the base module
+                       //
+                       vfModuleItemVfModuleName =                      $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(baseIndex).vfModule.vfModuleName;
+                       vfModuleItemVfModuleName = vfModuleItemVfModuleName.replace("Vfmodule", "vDNS");
+                       //
+                       // vfModuleItem - NOT the base module
+                       //
+                       vfModuleItemPersonaModelId =            $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.personaModelId;
+                       vfModuleItemPersonaModelVersion =       $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.personaModelVersion;
+                       vfModuleItemModelName =                         $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(0).propertyValue;
+                       vfModuleItemModelNameVersionId =        $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(4).propertyValue;
+                       //
+                       // tenantItem
+                       //
+                       tenantItemTenantId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).tenant.tenantId;
+                       //
+                       // cloudRegionItem
+                       //
+                       cloudRegionItemCloudRegionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).items.inventoryResponseItems.get(0).cloudRegion.cloudRegionId;
+                       //
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+                       notification.notification = ControlLoopNotificationType.REJECTED;
+                       notification.message = "Exception occurred " + e.getMessage();
+                       notification.policyName = drools.getRule().getName();
+                       notification.policyScope = "com";
+                       notification.policyVersion = "1";
+                       //
+                       try {
+                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                       } catch (Exception e1) {
+                               System.out.println("Can't deliver notification: " + notification);
+                               e1.printStackTrace();
+                       }
+                       //
+                       notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+                       notification.message = "Invalid named-query response from AAI";
+            //
+            try {
+               System.out.println(Serialization.gsonPretty.toJson(notification));
+                PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+            } catch (Exception e1) {
+                System.out.println("Can't deliver notification: " + notification);
+                e1.printStackTrace();
+            }
+                       //
+                       // Retract everything
+                       //
+                       retract($aainqf199RequestWrapper);
+                       retract($aainqf199ResponseWrapper);
+                       retract($manager);
+                       retract($event);
+                       return;
+               }       
+               //
+               // Extracted fields should not be null
+               //
+               if ((vnfItemVnfId == null) || (vnfItemVnfType == null) ||
+                   (vnfItemPersonaModelId == null) || (vnfItemModelName == null) ||
+                   (vnfItemModelVersion == null) || (vnfItemModelNameVersionId == null) ||
+                   (serviceItemServiceInstanceId == null) || (serviceItemModelName == null) ||
+                   (serviceItemModelType == null) || (serviceItemModelVersion == null) ||
+                   (serviceItemModelNameVersionId == null) || (vfModuleItemVfModuleName == null) ||
+                   (vfModuleItemPersonaModelId == null) || (vfModuleItemPersonaModelVersion == null) ||
+                   (vfModuleItemModelName == null) || (vfModuleItemModelNameVersionId == null) ||
+                   (tenantItemTenantId == null) || (cloudRegionItemCloudRegionId == null)) {
+                       //
+                       System.err.println("some fields are missing from AAI response.");
+                       //
+                       // Fail and retract everything
+                       //
+                       retract($aainqf199RequestWrapper);
+                       retract($aainqf199ResponseWrapper);
+                       retract($manager);
+                       retract($event);
+                       return;
+               }
+               //
+               // We don't need them any more
+               //
+               retract($aainqf199ResponseWrapper);
+               retract($aainqf199RequestWrapper);  
+               //
+               // check the actor of this closed loop
+               //
+               switch ($params.getActor()) {
+                       case "APPC":
+                       {
+                               //
+                               // Construct an APPC request
+                               //
+                               ControlLoopOperation operation = new ControlLoopOperation();
+                               operation.actor = $params.getActor();
+                               operation.operation = "ModifyConfig";
+                               operation.target = $event.target;
+                               //
+                               // Create operationWrapper
+                               //
+                               ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);
+                               //
+                               // insert operationWrapper into memory
+                               //
+                               insert(operationWrapper);
+                               //
+                               Request request = new Request();
+                               request.CommonHeader = new CommonHeader();
+                               request.CommonHeader.RequestID = $event.requestID;
+                               request.Action = operation.operation;
+                               request.Payload = new HashMap<String, Object>();
+                               //
+                               // Fill in the payload
+                               // Hardcode genericVNF for now since AAI has not been ready for vFirewall demo case
+                               //
+                               String genericVNF = "zdfw1fwl01pgn02";
+                               request.Payload.put("generic-vnf.vnf-id", genericVNF);
+                               //
+                               PGRequest pgRequest = new PGRequest();
+                               pgRequest.pgStreams = new PGStreams();
+                               
+                               PGStream pgStream;
+                               for(int i = 0; i < 5; i++){
+                                       pgStream = new PGStream();
+                                       pgStream.streamId = "fw_udp"+(i+1);
+                                       pgStream.isEnabled = "true";
+                                       pgRequest.pgStreams.pgStream.add(pgStream);
+                               }
+                               request.Payload.put("pg-streams", pgRequest.pgStreams);
+                               
+                               if (request != null) {
+                                       //
+                                       // Insert request into memory
+                                       //
+                                       insert(request);
+                                       //
+                                       // Tell interested parties we are performing this Operation
+                                       //
+                                       VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+                                       notification.notification = ControlLoopNotificationType.OPERATION;
+                                       // message and history ??
+                                       notification.from = "policy";
+                                       notification.policyName = drools.getRule().getName();
+                                       notification.policyScope = "com";
+                                       notification.policyVersion = "1";
+                                       try {
+                                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                                       } catch (Exception e) {
+                                               System.out.println("Can't deliver notification: " + notification);
+                                               e.printStackTrace();
+                                       }
+                                       //
+                                       // Now send the operation request
+                                       //
+                                       if (request instanceof Request) {
+                                               try {
+                                                       System.out.println("APPC request sent:");
+                                                       System.out.println(Serialization.gsonPretty.toJson(request));
+                                                       PolicyEngine.manager.deliver($params.getAppcTopic(), request);
+                                               } catch (Exception e) {
+                                                       e.printStackTrace();
+                                                       System.out.println("Can't deliver request: " + request);
+                                               }
+                                       }
+                               } else {
+                                       //
+                                       // what happens if it is null
+                                       //
+                               }
+                       }
+                       break;
+                       case "MSO":
+                       {
+                               //
+                               // Construct an operation
+                               //
+                               ControlLoopOperation operation = new ControlLoopOperation();
+                               operation.actor = $params.getActor();
+                               operation.operation = "createModuleInstance";
+                               operation.target = $event.target;
+                               //
+                               // Create operationWrapper
+                               //
+                               ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);
+                               //
+                               // Construct an MSO request
+                               //
+                               MSORequest request = new MSORequest();
+                               request.requestDetails = new MSORequestDetails();
+                               request.requestDetails.modelInfo = new MSOModelInfo();
+                               request.requestDetails.cloudConfiguration = new MSOCloudConfiguration();
+                               request.requestDetails.requestInfo = new MSORequestInfo();
+                               request.requestDetails.requestParameters = new MSORequestParameters();
+                               request.requestDetails.requestParameters.userParams = null;
+                               //
+                               // cloudConfiguration
+                               //
+                               request.requestDetails.cloudConfiguration.lcpCloudRegionId = cloudRegionItemCloudRegionId;
+                               request.requestDetails.cloudConfiguration.tenantId = tenantItemTenantId;
+                               //
+                               // modelInfo
+                               //
+                               request.requestDetails.modelInfo.modelType = "vfModule";
+                               request.requestDetails.modelInfo.modelInvariantId = vfModuleItemPersonaModelId;
+                               request.requestDetails.modelInfo.modelNameVersionId = vfModuleItemModelNameVersionId;
+                               request.requestDetails.modelInfo.modelName = vfModuleItemModelName;
+                               request.requestDetails.modelInfo.modelVersion = vfModuleItemPersonaModelVersion;
+                               //
+                               // requestInfo
+                               //
+                               request.requestDetails.requestInfo.instanceName = vfModuleItemVfModuleName;
+                               request.requestDetails.requestInfo.source = "POLICY";
+                               request.requestDetails.requestInfo.suppressRollback = false;
+                               //
+                               // relatedInstanceList
+                               //
+                               MSORelatedInstanceListElement relatedInstanceListElement1 = new MSORelatedInstanceListElement();
+                               MSORelatedInstanceListElement relatedInstanceListElement2 = new MSORelatedInstanceListElement();
+                               relatedInstanceListElement1.relatedInstance = new MSORelatedInstance();
+                               relatedInstanceListElement2.relatedInstance = new MSORelatedInstance();
+                               //
+                               relatedInstanceListElement1.relatedInstance.instanceId = serviceItemServiceInstanceId;
+                               relatedInstanceListElement1.relatedInstance.modelInfo = new MSOModelInfo();
+                               relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "service";
+                               relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = serviceItemPersonaModelId;
+                               relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId = serviceItemModelNameVersionId;
+                               relatedInstanceListElement1.relatedInstance.modelInfo.modelName = serviceItemModelName;
+                               relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = serviceItemModelVersion;
+                               //
+                               relatedInstanceListElement2.relatedInstance.instanceId = vnfItemVnfId;
+                               relatedInstanceListElement2.relatedInstance.modelInfo = new MSOModelInfo();
+                               relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "vnf";
+                               relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = vnfItemPersonaModelId;
+                               relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = vnfItemModelNameVersionId;
+                               relatedInstanceListElement2.relatedInstance.modelInfo.modelName = vnfItemModelName;
+                               relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = vnfItemModelVersion;
+                               relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = vnfItemVnfType;
+                               //      
+                               request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);
+                               request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);
+                               //
+                               // print MSO request for debug
+                               //
+                               System.out.println("MSO request sent:");
+                               System.out.println(Serialization.gsonPretty.toJson(request));
+                               //
+                               //
+                               //
+                               if (request != null) {
+                                       //
+                                       // Tell interested parties we are performing this Operation
+                                       //
+                                       VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+                                       notification.notification = ControlLoopNotificationType.OPERATION;
+                                       notification.from = "policy";
+                                       notification.policyName = drools.getRule().getName();
+                                       notification.policyScope = "com";
+                                       notification.policyVersion = "1";
+                                       try {
+                                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                                       } catch (Exception e) {
+                                               System.out.println("Can't deliver notification: " + notification);
+                                               e.printStackTrace();
+                                       }
+                                       //
+                                       // Concatenate serviceItemServiceInstanceId and vnfItemVnfId to msoURL
+                                       //
+                                       String MSOUrl = $params.getMsoURL() + "/serviceInstances/v2/" + serviceItemServiceInstanceId + "/vnfs/" + vnfItemVnfId + "/vfModules";
+                                       //
+                                       // Call MSO
+                                       //
+                                       MSOResponse response = MSOManager.createModuleInstance(MSOUrl, $params.getMsoURL(), $params.getMsoUsername(), $params.getMsoPassword(), request);
+                                       //
+                                       if (response != null) {
+                                               //
+                                               // Assign requestId
+                                               //
+                                               request.requestId = $event.requestID.toString();                                                
+                                               response.request.requestId = $event.requestID.toString();
+                                               //
+                                               // Insert facts
+                                               //
+                                               insert(operationWrapper);
+                                               insert(request);
+                                               insert(response);
+                                       } else {
+                                               //
+                                               // MSO request not even accepted
+                                               //
+                                               notification.message = operationWrapper.operation.toMessage();
+                                               operationWrapper.operation.message = operationWrapper.operation.toMessage();
+                                               operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+                                               $manager.setControlLoopResult("FAILURE_EXCEPTION");
+                                               notification.history.add(operationWrapper.operation);
+                                               notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;
+                                               //
+                                               // Let interested parties know
+                                               //
+                                               try {
+                                                       System.out.println(Serialization.gsonPretty.toJson(notification));
+                                                       PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                                               } catch (Exception e) {
+                                                       System.out.println("Can't deliver notification: " + notification);
+                                                       e.printStackTrace();
+                                               }
+                           notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+                        try {
+                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                        } catch (Exception e) {
+                               System.out.println("Can't deliver notification: " + notification);
+                               e.printStackTrace();
+                        }
+                                               //
+                                               // Retract everything
+                                               //
+                                               retract($event);
+                                               retract($manager);
+                                       }
+                               } else {
+                                       System.err.println("constructed MSO request is invalid.");
+                               }
+                       }
+                       break; 
+               } 
+end
+               
+/*
+*
+* This rule responds to APPC Response Events
+*
+*/
+rule "BRMSParamvFWDemoPolicy.APPC.RESPONSE"
+       when
+               $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+               $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+               $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+               $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )
+               $request : Request( getCommonHeader().RequestID == $event.requestID )
+               $response : Response( getCommonHeader().RequestID == $event.requestID ) 
+       then
+               System.out.println("rule APPC.RESPONSE is triggered.");
+               if ($response.Status == null) {
+                       $operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+                       $manager.setControlLoopResult("FAILURE_EXCEPTION");
+               } 
+               //
+               // Get the Response Code
+               //
+               ResponseCode code = ResponseCode.toResponseCode($response.Status.Code);
+               if (code == null) {
+                       $operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+                       $manager.setControlLoopResult("FAILURE_EXCEPTION");
+               }
+               //
+               // Construct notification
+               //
+               VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+               notification.from = "policy";
+               notification.policyName = drools.getRule().getName();
+               notification.policyScope = "com";
+               notification.policyVersion = "1";
+               notification.message = $operationWrapper.operation.toMessage();
+               $operationWrapper.operation.message = $operationWrapper.operation.toMessage();
+               //
+               // Ok, let's figure out what APP-C's response is
+               //
+               switch (code) {
+                       case ACCEPT:
+                               $operationWrapper.operation.outcome = "PROCESSING";
+                               break;
+                       case ERROR:
+                       case REJECT:
+                               $operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+                               $manager.setControlLoopResult("FAILURE_EXCEPTION");
+                               break;
+                       case SUCCESS:
+                               $operationWrapper.operation.outcome = "SUCCESS";
+                               $manager.setControlLoopResult("SUCCESS");
+                               break;
+                       case FAILURE:
+                               $operationWrapper.operation.outcome = "FAILURE";
+                               $manager.setControlLoopResult("FAILURE");
+                               break;
+               }
+               if ($operationWrapper.operation.outcome.equals("SUCCESS")) {
+                       notification.history.add($operationWrapper.operation);
+                       notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;
+                       //
+                       // Let interested parties know
+                       //
+                       try {
+                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                       } catch (Exception e) {
+                               System.out.println("Can't deliver notification: " + notification);
+                               e.printStackTrace();
+                       }
+            notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;
+            try {
+               System.out.println(Serialization.gsonPretty.toJson(notification));
+               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+            } catch (Exception e) {
+               System.out.println("Can't deliver notification: " + notification);
+               e.printStackTrace();
+            }
+
+                       //
+                       // We are going to retract these objects from memory
+                       //
+                       System.out.println("Retracting everything");
+                       retract($operationWrapper);
+                       retract($request);
+                       retract($response);
+                       retract($event);
+                       retract($manager);
+               } else if ($operationWrapper.operation.outcome.equals("PROCESSING")) {
+                       retract($response);
+               } else {
+                       notification.history.add($operationWrapper.operation);
+                       notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;
+                       //
+                       // Let interested parties know
+                       //
+                       try {
+                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                       } catch (Exception e) {
+                               System.out.println("Can't deliver notification: " + notification);
+                               e.printStackTrace();
+                       }
+            notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+            //
+            // Let interested parties know
+            //
+            try {
+               System.out.println(Serialization.gsonPretty.toJson(notification));
+               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+            } catch (Exception e) {
+               System.out.println("Can't deliver notification: " + notification);
+               e.printStackTrace();
+            }
+                       //
+                       // We are going to retract these objects from memory
+                       //
+                       System.out.println("Retracting everything");
+                       retract($operationWrapper);
+                       retract($request);
+                       retract($response);
+                       retract($event);
+                       retract($manager);
+               }
+               
+end            
+
+/*
+*
+* This rule is used to clean up APPC response
+*
+*/             
+rule "BRMSParamvFWDemoPolicy.APPC.RESPONSE.CLEANUP"
+       when
+               $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+        $response : Response($id : getCommonHeader().RequestID )
+               not ( VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), requestID == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) ) 
+       then
+               System.out.println("rule APPC.RESPONSE.CLEANUP is triggered.");
+               retract($response);
+end
+
+/*
+*
+* This rule responds to MSO Response Events
+*
+*/
+rule "BRMSParamvFWDemoPolicy.MSO.RESPONSE"
+       when
+               $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+               $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+               $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+               $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )
+               $request : MSORequest( requestId == $event.requestID.toString() )
+               $response : MSOResponse( request.requestId == $event.requestID.toString() )     
+       then
+               System.out.println("rule MSO.RESPONSE is triggered.");
+               //
+               // Construct notification
+               //
+               VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+               notification.from = "policy";
+               notification.policyName = drools.getRule().getName();
+               notification.policyScope = "com";
+               notification.policyVersion = "1";
+               notification.message = $operationWrapper.operation.toMessage();
+               $operationWrapper.operation.message = $operationWrapper.operation.toMessage();
+               //
+               // The operation can either be succeeded or failed
+               // 
+               if($response.request.requestStatus.requestState.equals("COMPLETE")) {
+                       $operationWrapper.operation.outcome = "SUCCESS";
+                       $manager.setControlLoopResult("SUCCESS");
+                       notification.history.add($operationWrapper.operation);
+                       notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;
+                       //
+                       // Let interested parties know
+                       //
+                       try {
+                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                       } catch (Exception e) {
+                               System.out.println("Can't deliver notification: " + notification);
+                               e.printStackTrace();
+                       }
+                       notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;
+            //
+            // Let interested parties know
+            //
+            try {
+               System.out.println(Serialization.gsonPretty.toJson(notification));
+               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+            } catch (Exception e) {
+               System.out.println("Can't deliver notification: " + notification);
+               e.printStackTrace();
+            }
+            //
+                       // We are going to retract these objects from memory
+                       //
+                       System.out.println("Retracting everything");
+                       retract($operationWrapper);
+                       retract($request);
+                       retract($response);
+                       retract($event);
+                       retract($manager);
+               } else {
+                       $operationWrapper.operation.outcome = "FAILURE";
+                       $manager.setControlLoopResult("FAILURE");
+                       notification.history.add($operationWrapper.operation);
+                       notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;
+                       //
+                       // Let interested parties know
+                       //
+                       try {
+                               System.out.println(Serialization.gsonPretty.toJson(notification));
+                               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+                       } catch (Exception e) {
+                               System.out.println("Can't deliver notification: " + notification);
+                               e.printStackTrace();
+                       }
+                       notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+            //
+            // Let interested parties know
+            //
+            try {
+               System.out.println(Serialization.gsonPretty.toJson(notification));
+               PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+            } catch (Exception e) {
+               System.out.println("Can't deliver notification: " + notification);
+               e.printStackTrace();
+            }
+            //
+                       // We are going to retract these objects from memory
+                       //
+                       System.out.println("Retracting everything");
+                       retract($operationWrapper);
+                       retract($request);
+                       retract($response);
+                       retract($event);
+                       retract($manager);
+               }
+               
+end    
+rule "com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.Params" 
+       salience 1000 
+       when
+       then
+               Params params = new Params();
+               params.setAaiPatternMatch(1);
+               params.setAppcTopic("APPC-CL");
+               params.setAaiURL("null");
+               params.setMsoPassword("null");
+               params.setClosedLoopControlName("CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8");
+               params.setMsoURL("null");
+               params.setAaiUsername("null");
+               params.setActor("APPC");
+               params.setMsoUsername("null");
+               params.setAaiNamedQueryUUID("null");
+               params.setAaiPassword("null");
+               params.setNotificationTopic("POLICY-CL-MGT");
+               insert(params);
+end
diff --git a/POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Raw_TestBRMSRawPolicy.1.txt b/POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Raw_TestBRMSRawPolicy.1.txt
new file mode 100644 (file)
index 0000000..6924fc3
--- /dev/null
@@ -0,0 +1,35 @@
+package com.sample
+import com.sample.DroolsTest.Message;
+// Declare the Parameters here.
+declare Params
+    samPoll : int
+    value : String
+end
+// This Rule will be generated by the UI.
+rule "Create parameters structure"
+    salience 1000  
+    when
+    then
+        Params params = new Params();
+        params.setSamPoll(76);
+        params.setValue("Bobby");
+        insertLogical(params);
+end
+// Start using the parameters as below in Rules.
+rule "Rule 1: Check parameter structure access from when/then"
+    when
+        $param: Params()
+        Params($param.samPoll > 50)
+    then
+        System.out.println("Firing rule 1");
+        System.out.println($param);
+end
+rule "Rule 2: Check parameter value access from when/then"
+    when
+        $param: Params()
+        Params($param.samPoll > 50)
+    then
+        System.out.println("Firing rule 2");
+        System.out.println($param.getValue());
+        System.out.println($param.getSamPoll());
+end
diff --git a/POLICY-SDK-APP/src/test/resources/com.Config_FW_TestFireWallPolicy.1.json b/POLICY-SDK-APP/src/test/resources/com.Config_FW_TestFireWallPolicy.1.json
new file mode 100644 (file)
index 0000000..eae1ed5
--- /dev/null
@@ -0,0 +1 @@
+{"serviceTypeId":"/v0/firewall/pan","configName":"TestFireWallPolicy","deploymentOption":{"deployNow":false},"securityZoneId":"1.5.3","vendorServiceId":"vipr","vendorSpecificData":{"idMap":[{"astraId":"1.5.3","vendorId":"deviceGroup:dev"}]},"serviceGroups":[],"addressGroups":[],"firewallRuleList":[{"position":"1","ruleName":"test","fromZones":[],"toZones":[],"negateSource":false,"negateDestination":false,"sourceList":[],"destinationList":[],"sourceServices":[],"destServices":[],"action":null,"description":null,"enabled":true,"log":true}],"ruleToTag":[{"ruleName":"test","tags":[{"key":"test","value":"test"}],"tagPickerName":"test","networkRole":"test"}]}
\ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/com.Config_Fault_TestClosedLoopPolicy.1.json b/POLICY-SDK-APP/src/test/resources/com.Config_Fault_TestClosedLoopPolicy.1.json
new file mode 100644 (file)
index 0000000..f7e25ca
--- /dev/null
@@ -0,0 +1 @@
+{"trinity":false,"vUSP":true,"mcr":false,"gama":false,"vDNS":false,"vnfType":"SampleVNF","vServices":null,"closedLoopPolicyStatus":"Active","triggerSignatures":{"signatures":"((NOT(NOT(1.0.2.3)AND(1.0.2.3)), Time = 11)AND((NOT(1.0.2.3)AND(1.0.2.3)), Time = 12))","timeWindow":11,"trapMaxAge":12},"actions":"SampleVSCL","timeInterval":11,"timeOutvPRO":11,"timeOutRuby":11,"retrys":1,"agingWindow":1,"geoLink":"TEST","emailAddress":"aa@test.con","verificationSignatures":{"signatures":"(NOT(1.0.2.3)AND(1.0.2.3))","timeWindow":12},"conditions":"SEND","triggerSignaturesUsedForUI":{"signatures":"NOT@!SampleVarbind@!AND@!SampleVarbind#!?!NOT@!SampleVarbind@!OR@!SampleVarbind#!NOT@!A1@!AND@!SampleVarbind#!NOT@!A1@!AND@!A2#!?!","connectSignatures":"NOT@!Trap1@!11@!AND@!Trap1@!12#!?!"},"verificationSignaturesUsedForUI":{"signatures":"NOT@!SampleVarbind@!AND@!SampleVarbind#!?!","connectSignatures":null},"triggerTimeWindowUsedForUI":11,"verfificationTimeWindowUsedForUI":12,"pepName":null,"pepAction":null,"templateVersion":null,"trapMaxAgeUsedForUI":12,"ecompname":null}
diff --git a/POLICY-SDK-APP/src/test/resources/com.Config_MS_vFirewall.1.json b/POLICY-SDK-APP/src/test/resources/com.Config_MS_vFirewall.1.json
new file mode 100644 (file)
index 0000000..6b128f1
--- /dev/null
@@ -0,0 +1 @@
+{"service":"TcaMetrics","location":"SampleServiceLocation","uuid":"/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vFirewall","policyName":"vFirewall","description":"Micro Service vFirewall Demo Policy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:","configName":"SampleConfigName","templateVersion":"OpenSource.version.1","version":"1.0.0.5","priority":"1","policyScope":"resource=SampleResource,service=SampleService,type=SampleType,closedLoopControlName=SampleClosedLoop","content":{"thresholds":[{"severity":"MAJOR","fieldPath":"$.event.measurementsForVfScalingFields.vNicUsageArray[*].packetsIn","thresholdValue":"300","closedLoopControlName":"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8","version":"1.0.2","direction":"LESS_OR_EQUAL"},{"severity":"CRITICAL","fieldPath":"$.event.measurementsForVfScalingFields.vNicUsageArray[*].packetsIn","thresholdValue":"700","closedLoopControlName":"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8","version":"1.0.2","direction":"GREATER_OR_EQUAL"}],"functionalRole":"vFirewall","name":"0"}}
\ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/com.Config_PM_TestClosedLoopPMPolicy.1.json b/POLICY-SDK-APP/src/test/resources/com.Config_PM_TestClosedLoopPMPolicy.1.json
new file mode 100644 (file)
index 0000000..e0057ed
--- /dev/null
@@ -0,0 +1 @@
+{"serviceTypePolicyName": "Registration Failure(Trinity)","vUSP":true,"attributes":{"PtileLimit":"11","Threshold":"12","Window":"13","Training":"14","FractionSamplePerDay":"15","ConsecutiveIntervalOnset":"11","RetryTimer":"12","ConsecutiveIntervalAbatement":"11","OnsetMessage":"11","AbatementMessage":"12","PolicyName":"13"},"geoLink":"TEST","emailAddress":"test@test.com"}
index b50f398..823a56b 100644 (file)
@@ -67,6 +67,10 @@ public enum DictionaryType{
         * Indicates SafePolicy Dictionaries
         */
        SafePolicy("SafePolicy"),
+       /**
+        * Enum support entry to extend dictionary 
+        */
+       Extended("Extended"),
        ;
        
        private String name;
index d7ec9ac..06a2e47 100644 (file)
@@ -165,12 +165,16 @@ public class AutoClientEnd {
                                try{
                                        handler.notificationReceived(notification);
                                }catch (Exception e){
-                                       logger.error("Error in Clients Handler Object : " + e.getMessage());
+                                       logger.error("Error in Clients Handler Object : ", e);
                                }
                        } else if (scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) {
                                PDPNotification newNotification = MatchStore.checkMatch(notification);
                                if (newNotification.getNotificationType() != null) {
-                                       handler.notificationReceived(newNotification);
+                                       try{
+                                               handler.notificationReceived(newNotification);
+                                       }catch (Exception e){
+                                               logger.error("Error in Clients Handler Object : ", e);
+                                       }
                                }
                        }
                }
index dfbefcd..e763935 100644 (file)
@@ -52,7 +52,6 @@ public class PolicyUtils {
        private PolicyUtils(){
                // Private Constructor
        }
-       
        public static String objectToJsonString(Object o) throws JsonProcessingException{
                ObjectMapper mapper = new ObjectMapper();
                return mapper.writeValueAsString(o);
@@ -87,13 +86,13 @@ public class PolicyUtils {
        }
        
        public static String  emptyPolicyValidator(String field){
-               String error;
+        String error;
         if ("".equals(field) || field.contains(" ") || !field.matches("^[a-zA-Z0-9_]*$")) {
             error = "The Value in Required Field will allow only '{0-9}, {a-z}, {A-Z}, _' following set of Combinations";
             return error;
         } else {
             if(CharMatcher.ASCII.matchesAllOf((CharSequence) field)){
-                error = SUCCESS;
+                 error = SUCCESS;
             }else{
                 error = "The Value Contains Non ASCII Characters";
                 return error;
@@ -101,7 +100,7 @@ public class PolicyUtils {
         }
         return error;   
     } 
-       
+    
        public static String  emptyPolicyValidatorWithSpaceAllowed(String field){
         String error;
         if ("".equals(field) || !field.matches("^[a-zA-Z0-9_ ]*$")) {
@@ -117,7 +116,6 @@ public class PolicyUtils {
         }
         return error;   
     } 
-    
     public static String descriptionValidator(String field) {
         String error;
         if (field.contains("@CreatedBy:") || field.contains("@ModifiedBy:")) {
@@ -129,6 +127,15 @@ public class PolicyUtils {
         return error;   
     }
     
+    public static Boolean isInteger(String number){
+       try{
+               Integer.parseInt(number);
+       }catch(NumberFormatException e){
+               return false;
+       }
+       return true;
+    }
+    
     public static String validateEmailAddress(String emailAddressValue) {
         String error = SUCCESS;
         List<String> emailList = Arrays.asList(emailAddressValue.split(","));
@@ -136,7 +143,7 @@ public class PolicyUtils {
             Pattern pattern = Pattern.compile(EMAIL_PATTERN);
             Matcher matcher = pattern.matcher(emailList.get(i).trim());
             if(!matcher.matches()){
-                error = "Please check the Following Email Address is not Valid ....   " +emailList.get(i).toString();
+                error = "Please check the Following Email Address is not Valid ....   " +emailList.get(i);
                 return error;
             }else{
                 error = SUCCESS;
@@ -149,28 +156,28 @@ public class PolicyUtils {
      * Check for "[ERR" to see if there are any errors. 
      */
     public static String brmsRawValidate(String rule){
-       VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
-       Verifier verifier = vBuilder.newVerifier();
-       verifier.addResourcesToVerify(new ReaderResource(new StringReader(rule)), ResourceType.DRL);
-       // Check if there are any Errors in Verification. 
-       if(!verifier.getErrors().isEmpty()){
-               boolean ignore = false;
-               StringBuilder message = new StringBuilder("Not a Valid DRL rule"); 
-               for(VerifierError error: verifier.getErrors()){
-                       // Ignore annotations Error Messages
-                       if(!error.getMessage().contains("'@'") && !error.getMessage().contains(PACKAGE_ERROR)){
-                               ignore= true;
-                               message.append("\n" + error.getMessage());
-                       }
-               }
-               // Ignore new package names with {
-               // More checks for message to check if its a package error.
-               if(ignore && !message.toString().contains("Parser returned a null Package")){
-                       message.append("[ERR 107]");
-               }
-               return message.toString();
-       }
-       return "";
+        VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
+        Verifier verifier = vBuilder.newVerifier();
+        verifier.addResourcesToVerify(new ReaderResource(new StringReader(rule)), ResourceType.DRL);
+        // Check if there are any Errors in Verification. 
+        if(!verifier.getErrors().isEmpty()){
+               boolean ignore = false;
+            StringBuilder message = new StringBuilder("Not a Valid DRL rule"); 
+            for(VerifierError error: verifier.getErrors()){
+                // Ignore annotations Error Messages
+                if(!error.getMessage().contains("'@'") && !error.getMessage().contains(PACKAGE_ERROR)){
+                       ignore= true;
+                    message.append("\n" + error.getMessage());
+                }
+            }
+            // Ignore new package names with {
+            // More checks for message to check if its a package error.
+            if(ignore && !message.toString().contains("Parser returned a null Package")){
+               message.append("[ERR 107]");
+            }
+            return message.toString();
+        }
+        return "";
     }
     
     /**
index d9e8868..b890bb1 100644 (file)
@@ -55,6 +55,7 @@ path.logs: ${{POLICY_HOME}}/logs
 # Set the bind address to a specific IP (IPv4 or IPv6):
 #
 #network.host: 192.168.0.1
+network.host: ["${{ELK_NETWORK_HOST}}", "127.0.0.1"]
 #
 # Set a custom port for HTTP:
 #
@@ -87,4 +88,4 @@ path.logs: ${{POLICY_HOME}}/logs
 #
 # Require explicit names when deleting indices:
 #
-#action.destructive_requires_name: true
+#action.destructive_requires_name: true
\ No newline at end of file
index c3d3f1d..9c25c74 100644 (file)
@@ -6,7 +6,7 @@
                        "version": "${{BRMS_DEPENDENCY_VERSION}}"
                }, {
                        "groupId": "org.onap.policy.drools-applications",
-                       "artifactId": "controlloop",
+                       "artifactId": "events",
                        "version": "${{BRMS_DEPENDENCY_VERSION}}"
                }, {
                        "groupId": "org.onap.policy.drools-applications",
index 79839af..d9df903 100644 (file)
 #
 # Default PIP Configuration from Policy. 
 # 
-xacml.pip.engines=AAF,sql1
+xacml.pip.engines=AAF,historydb
 
 ### AAF PIP Configuration. 
 AAF.description=AAFEngine to communicate with AAF to take decisions
 AAF.classname=org.openecomp.policy.xacml.std.pip.engines.aaf.AAFEngine
 AAF.name=AAFEngine
 
-### sql1 PIP Configuration. 
-# Class from XACML resource. 
-sql1.classname=com.att.research.xacml.std.pip.engines.jdbc.JDBCEngine
-sql1.name=OperationsHistory
-sql1.description=Database of operations performed via closed loop.
-sql1.issuer=org:openecomp:xacml:sql123
-sql1.type=jdbc
-# Configurable Values. 
-sql1.jdbc.driver=${{JDBC_DRIVER}}
-sql1.jdbc.url=${{JDBC_URL}}
-sql1.jdbc.conn.user=${{JDBC_USER}}
-sql1.jdbc.conn.password=${{JDBC_PASSWORD}}
-
-#Each of the following resolvers corresponds to a specific time window. The only difference between them is the "interval" in the "select" SQL query and the "issuer".
-sql1.resolvers=tw5min,tw10min,tw30min,tw1h,tw12h,tw1d,tw5d,tw1w,tw1mon
-
-##############################################
-sql1.resolver.tw5min.select=select count(*) as count from operationshistory10 where outcome<>'Failure_Guard' and actor=? and operation=? and target=? and endtime between date_sub(now(),interval 5 minute) and now()
-sql1.resolver.tw5min.field.count.issuer=org:openecomp:xacml:sql:tw5min
-
-sql1.resolver.tw5min.classname=com.att.research.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver
-sql1.resolver.tw5min.name=OperationsCount
-sql1.resolver.tw5min.description=This returns the number of previous operations within the given time window
-sql1.resolver.tw5min.fields=count
-sql1.resolver.tw5min.field.count.id=count
-sql1.resolver.tw5min.field.count.datatype=http://www.w3.org/2001/XMLSchema#integer
-sql1.resolver.tw5min.field.count.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw5min.parameters=actor,operation,target
-sql1.resolver.tw5min.parameter.actor.id=actor
-sql1.resolver.tw5min.parameter.actor.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw5min.parameter.actor.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw5min.parameter.operation.id=recipe
-sql1.resolver.tw5min.parameter.operation.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw5min.parameter.operation.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw5min.parameter.target.id=target
-sql1.resolver.tw5min.parameter.target.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw5min.parameter.target.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-
-##############################################
-sql1.resolver.tw10min.select=select count(*) as count from operationshistory10 where outcome<>'Failure_Guard' and actor=? and operation=? and target=? and endtime between date_sub(now(),interval 10 minute) and now()
-sql1.resolver.tw10min.field.count.issuer=org:openecomp:xacml:sql:tw10min
-
-sql1.resolver.tw10min.classname=com.att.research.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver
-sql1.resolver.tw10min.name=OperationsCount
-sql1.resolver.tw10min.description=This returns the number of previous operations within the given time window
-sql1.resolver.tw10min.fields=count
-sql1.resolver.tw10min.field.count.id=count
-sql1.resolver.tw10min.field.count.datatype=http://www.w3.org/2001/XMLSchema#integer
-sql1.resolver.tw10min.field.count.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw10min.parameters=actor,operation,target
-sql1.resolver.tw10min.parameter.actor.id=actor
-sql1.resolver.tw10min.parameter.actor.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw10min.parameter.actor.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw10min.parameter.operation.id=recipe
-sql1.resolver.tw10min.parameter.operation.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw10min.parameter.operation.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw10min.parameter.target.id=target
-sql1.resolver.tw10min.parameter.target.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw10min.parameter.target.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-
-##############################################
-sql1.resolver.tw30min.select=select count(*) as count from operationshistory10 where outcome<>'Failure_Guard' and actor=? and operation=? and target=? and endtime between date_sub(now(),interval 30 minute) and now()
-sql1.resolver.tw30min.field.count.issuer=org:openecomp:xacml:sql:tw30min
-
-sql1.resolver.tw30min.classname=com.att.research.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver
-sql1.resolver.tw30min.name=OperationsCount
-sql1.resolver.tw30min.description=This returns the number of previous operations within the given time window
-sql1.resolver.tw30min.fields=count
-sql1.resolver.tw30min.field.count.id=count
-sql1.resolver.tw30min.field.count.datatype=http://www.w3.org/2001/XMLSchema#integer
-sql1.resolver.tw30min.field.count.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw30min.parameters=actor,operation,target
-sql1.resolver.tw30min.parameter.actor.id=actor
-sql1.resolver.tw30min.parameter.actor.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw30min.parameter.actor.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw30min.parameter.operation.id=recipe
-sql1.resolver.tw30min.parameter.operation.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw30min.parameter.operation.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw30min.parameter.target.id=target
-sql1.resolver.tw30min.parameter.target.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw30min.parameter.target.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-
-##############################################
-sql1.resolver.tw1h.select=select count(*) as count from operationshistory10 where outcome<>'Failure_Guard' and actor=? and operation=? and target=? and endtime between date_sub(now(),interval 1 hour) and now()
-sql1.resolver.tw1h.field.count.issuer=org:openecomp:xacml:sql:tw1h
-
-sql1.resolver.tw1h.classname=com.att.research.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver
-sql1.resolver.tw1h.name=OperationsCount
-sql1.resolver.tw1h.description=This returns the number of previous operations within the given time window
-sql1.resolver.tw1h.fields=count
-sql1.resolver.tw1h.field.count.id=count
-sql1.resolver.tw1h.field.count.datatype=http://www.w3.org/2001/XMLSchema#integer
-sql1.resolver.tw1h.field.count.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1h.parameters=actor,operation,target
-sql1.resolver.tw1h.parameter.actor.id=actor
-sql1.resolver.tw1h.parameter.actor.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1h.parameter.actor.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1h.parameter.operation.id=recipe
-sql1.resolver.tw1h.parameter.operation.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1h.parameter.operation.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1h.parameter.target.id=target
-sql1.resolver.tw1h.parameter.target.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1h.parameter.target.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-
-
-##############################################
-sql1.resolver.tw12h.select=select count(*) as count from operationshistory10 where outcome<>'Failure_Guard' and actor=? and operation=? and target=? and endtime between date_sub(now(),interval 12 hour) and now()
-sql1.resolver.tw12h.field.count.issuer=org:openecomp:xacml:sql:tw12h
-
-sql1.resolver.tw12h.classname=com.att.research.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver
-sql1.resolver.tw12h.name=OperationsCount
-sql1.resolver.tw12h.description=This returns the number of previous operations within the given time window
-sql1.resolver.tw12h.fields=count
-sql1.resolver.tw12h.field.count.id=count
-sql1.resolver.tw12h.field.count.datatype=http://www.w3.org/2001/XMLSchema#integer
-sql1.resolver.tw12h.field.count.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw12h.parameters=actor,operation,target
-sql1.resolver.tw12h.parameter.actor.id=actor
-sql1.resolver.tw12h.parameter.actor.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw12h.parameter.actor.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw12h.parameter.operation.id=recipe
-sql1.resolver.tw12h.parameter.operation.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw12h.parameter.operation.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw12h.parameter.target.id=target
-sql1.resolver.tw12h.parameter.target.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw12h.parameter.target.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-
-
-#############################
-sql1.resolver.tw1d.select=select count(*) as count from operationshistory10 where outcome<>'Failure_Guard' and actor=? and operation=? and target=? and endtime between date_sub(now(),interval 1 day) and now()
-sql1.resolver.tw1d.field.count.issuer=org:openecomp:xacml:sql:tw1d
-
-sql1.resolver.tw1d.classname=com.att.research.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver
-sql1.resolver.tw1d.name=OperationsCount
-sql1.resolver.tw1d.description=This returns the number of previous operations within the given time window
-sql1.resolver.tw1d.fields=count
-sql1.resolver.tw1d.field.count.id=count
-sql1.resolver.tw1d.field.count.datatype=http://www.w3.org/2001/XMLSchema#integer
-sql1.resolver.tw1d.field.count.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1d.parameters=actor,operation,target
-sql1.resolver.tw1d.parameter.actor.id=actor
-sql1.resolver.tw1d.parameter.actor.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1d.parameter.actor.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1d.parameter.operation.id=recipe
-sql1.resolver.tw1d.parameter.operation.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1d.parameter.operation.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1d.parameter.target.id=target
-sql1.resolver.tw1d.parameter.target.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1d.parameter.target.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-
-
-#############################
-sql1.resolver.tw5d.select=select count(*) as count from operationshistory10 where outcome<>'Failure_Guard' and actor=? and operation=? and target=? and endtime between date_sub(now(),interval 5 day) and now()
-sql1.resolver.tw5d.field.count.issuer=org:openecomp:xacml:sql:tw5d
-
-sql1.resolver.tw5d.classname=com.att.research.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver
-sql1.resolver.tw5d.name=OperationsCount
-sql1.resolver.tw5d.description=This returns the number of previous operations within the given time window
-sql1.resolver.tw5d.fields=count
-sql1.resolver.tw5d.field.count.id=count
-sql1.resolver.tw5d.field.count.datatype=http://www.w3.org/2001/XMLSchema#integer
-sql1.resolver.tw5d.field.count.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw5d.parameters=actor,operation,target
-sql1.resolver.tw5d.parameter.actor.id=actor
-sql1.resolver.tw5d.parameter.actor.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw5d.parameter.actor.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw5d.parameter.operation.id=recipe
-sql1.resolver.tw5d.parameter.operation.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw5d.parameter.operation.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw5d.parameter.target.id=target
-sql1.resolver.tw5d.parameter.target.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw5d.parameter.target.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-
-
-#############################
-sql1.resolver.tw1w.select=select count(*) as count from operationshistory10 where outcome<>'Failure_Guard' and actor=? and operation=? and target=? and endtime between date_sub(now(),interval 1 week) and now()
-sql1.resolver.tw1w.field.count.issuer=org:openecomp:xacml:sql:tw1w
-
-sql1.resolver.tw1w.classname=com.att.research.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver
-sql1.resolver.tw1w.name=OperationsCount
-sql1.resolver.tw1w.description=This returns the number of previous operations within the given time window
-sql1.resolver.tw1w.fields=count
-sql1.resolver.tw1w.field.count.id=count
-sql1.resolver.tw1w.field.count.datatype=http://www.w3.org/2001/XMLSchema#integer
-sql1.resolver.tw1w.field.count.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1w.parameters=actor,operation,target
-sql1.resolver.tw1w.parameter.actor.id=actor
-sql1.resolver.tw1w.parameter.actor.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1w.parameter.actor.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1w.parameter.operation.id=recipe
-sql1.resolver.tw1w.parameter.operation.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1w.parameter.operation.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1w.parameter.target.id=target
-sql1.resolver.tw1w.parameter.target.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1w.parameter.target.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-
-#############################
-sql1.resolver.tw1mon.select=select count(*) as count from operationshistory10 where outcome<>'Failure_Guard' and actor=? and operation=? and target=? and endtime between date_sub(now(),interval 1 month) and now()
-sql1.resolver.tw1mon.field.count.issuer=org:openecomp:xacml:sql:tw1mon
-
-sql1.resolver.tw1mon.classname=com.att.research.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver
-sql1.resolver.tw1mon.name=OperationsCount
-sql1.resolver.tw1mon.description=This returns the number of previous operations within the given time window
-sql1.resolver.tw1mon.fields=count
-sql1.resolver.tw1mon.field.count.id=count
-sql1.resolver.tw1mon.field.count.datatype=http://www.w3.org/2001/XMLSchema#integer
-sql1.resolver.tw1mon.field.count.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1mon.parameters=actor,operation,target
-sql1.resolver.tw1mon.parameter.actor.id=actor
-sql1.resolver.tw1mon.parameter.actor.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1mon.parameter.actor.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1mon.parameter.operation.id=recipe
-sql1.resolver.tw1mon.parameter.operation.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1mon.parameter.operation.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
-sql1.resolver.tw1mon.parameter.target.id=target
-sql1.resolver.tw1mon.parameter.target.datatype=http://www.w3.org/2001/XMLSchema#string
-sql1.resolver.tw1mon.parameter.target.category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource
+# PIP Engine Definition
+#
+historydb.classname=org.openecomp.policy.xacml.std.pip.engines.OperationHistoryEngine
+historydb.issuer=org:onap:xacml:guard:historydb
+historydb.name=operationHistoryDB
\ No newline at end of file
index 7750047..7653963 100644 (file)
@@ -138,3 +138,6 @@ xacml.rest.pep.idfile = client.properties
 #Required only, when we use AAF
 policy.aaf.namespace = ${{POLICY_AAF_NAMESPACE}}
 policy.aaf.resource = ${{POLICY_AAF_RESOURCE}}
+# Decision Response settings. 
+# can be either PERMIT or DENY. 
+decision.indeterminate.response=${{DECISION_INDETERMINATE_RESPONSE}}
index 95c1300..fbdfade 100644 (file)
@@ -32,3 +32,4 @@ node_type=pdp_xacml
 resource_name=pdp_1
 dependency_groups=pdplp_1;brmsgw_1
 
+DECISION_INDETERMINATE_RESPONSE=DENY
\ No newline at end of file