Merge "Added Junits for POLICY-SDK-APP controllers"
authorJorge Hernandez <jh1730@att.com>
Wed, 21 Feb 2018 18:30:10 +0000 (18:30 +0000)
committerGerrit Code Review <gerrit@onap.org>
Wed, 21 Feb 2018 18:30:10 +0000 (18:30 +0000)
59 files changed:
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ActionPolicy.java
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTransaction.java
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/model/PDPPolicyContainer.java [deleted file]
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/model/RemoveGroupPolicy.java
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreation.java
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/JPAUtils.java
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/PolicyContainer.java [deleted file]
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/PolicyItemSetChangeNotifier.java [deleted file]
ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/ActionPolicyTest.java
ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicyTest.java
ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java
ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/ElkConnectorImplTest.java
ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PairTest.java [new file with mode: 0644]
ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyElasticDataTest.java [new file with mode: 0644]
ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyLocatorTest.java [new file with mode: 0644]
ONAP-PAP-REST/src/test/resources/Config_SampleTest1206.1.xml [new file with mode: 0644]
ONAP-PAP-REST/src/test/resources/pdps/testgroup2/com.Config_SampleBasePolicy.1.xml [new file with mode: 0644]
ONAP-PAP-REST/src/test/resources/pdps/testgroup2/xacml.pip.properties [new file with mode: 0644]
ONAP-PAP-REST/src/test/resources/pdps/testgroup2/xacml.policy.properties [new file with mode: 0644]
ONAP-PAP-REST/src/test/resources/pdps/xacml.properties [new file with mode: 0644]
ONAP-REST/src/main/java/org/onap/policy/rest/util/PDPPolicyContainer.java [moved from POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPPolicyContainer.java with 97% similarity]
ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyContainer.java [moved from POLICY-SDK-APP/src/main/java/org/onap/policy/utils/PolicyContainer.java with 96% similarity]
ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyItemSetChangeNotifier.java [moved from POLICY-SDK-APP/src/main/java/org/onap/policy/utils/PolicyItemSetChangeNotifier.java with 92% similarity]
ONAP-REST/src/main/java/org/onap/policy/rest/util/Webapps.java [deleted file]
ONAP-REST/src/test/java/org/onap/policy/rest/util/PDPPolicyContainerTest.java [new file with mode: 0644]
ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdEngine.java
POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java
POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java
POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java
POLICY-SDK-APP/src/main/java/org/onap/policy/utils/ConfigurableRESTUtils.java [deleted file]
PolicyEngineAPI/src/main/java/org/onap/policy/api/DeletePolicyCondition.java
PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryType.java
PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyClass.java
PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigStatus.java
PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyDecision.java
PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyResponseStatus.java
PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyType.java
PolicyEngineAPI/src/main/java/org/onap/policy/api/RuleProvider.java
PolicyEngineAPI/src/main/java/org/onap/policy/models/APIDictionaryResponse.java
PolicyEngineAPI/src/main/java/org/onap/policy/std/MatchStore.java
PolicyEngineAPI/src/main/java/org/onap/policy/std/Matches.java
PolicyEngineAPI/src/main/java/org/onap/policy/std/NotificationUnMarshal.java
PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchStoreTest.java
PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchesTest.java
PolicyEngineAPI/src/test/java/org/onap/policy/std/test/NotificationUnMarshalTest.java
PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyConfigTest.java
PolicyEngineAPI/src/test/java/org/onap/policy/test/APIDictionaryResponseTest.java [new file with mode: 0644]
PolicyEngineAPI/src/test/java/org/onap/policy/test/DeletePolicyConditionTest.java
PolicyEngineAPI/src/test/java/org/onap/policy/test/DeletePolicyParametersTest.java
PolicyEngineAPI/src/test/java/org/onap/policy/test/DictionaryTypeTest.java
PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyClassTest.java
PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigStatusTest.java
PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyDecisionTest.java
PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyResponseStatusTest.java
PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyTypeTest.java
PolicyEngineAPI/src/test/java/org/onap/policy/test/RuleProviderTest.java

index bedc212..650713c 100644 (file)
@@ -1096,55 +1096,6 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
                                return;
                        }
                }
-               //This would occur if we received a notification of a policy rename from AC
-               String oldPolicyName = request.getParameter("oldPolicyName");
-               String newPolicyName = request.getParameter("newPolicyName");
-               if(oldPolicyName != null && newPolicyName != null){
-                       if(LOGGER.isDebugEnabled()){
-                               LOGGER.debug("\nXACMLPapServlet.doPut() - before decoding"
-                                               + "\npolicyToCreateUpdate = " + " ");
-                       }
-                       //decode it
-                       try{
-                               oldPolicyName = URLDecoder.decode(oldPolicyName, "UTF-8");
-                               newPolicyName = URLDecoder.decode(newPolicyName, "UTF-8");
-                               if(LOGGER.isDebugEnabled()){
-                                       LOGGER.debug("\nXACMLPapServlet.doPut() - after decoding"
-                                                       + "\npolicyToCreateUpdate = " + " ");
-                               }
-                       } catch(UnsupportedEncodingException e){
-                               PolicyLogger.error("\nXACMLPapServlet.doPut() - Unsupported URL encoding of policyToCreateUpdate (UTF-8)"
-                                               + "\npolicyToCreateUpdate = " + " ");
-                               setResponseError(response,HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"policyToCreateUpdate encoding not supported"
-                                               + "\nfailure with the following exception: " + e);
-                               loggingContext.transactionEnded();
-                               PolicyLogger.audit("Transaction Failed - See error.log");
-                               im.endTransaction();
-                               return;
-                       }
-                       //send it to PolicyDBDao
-                       PolicyDBDaoTransaction renameTransaction = policyDBDao.getNewTransaction();
-                       try{
-                               renameTransaction.renamePolicy(oldPolicyName,newPolicyName, "XACMLPapServlet.doPut");
-                       }catch(Exception e){
-                               renameTransaction.rollbackTransaction();
-                               setResponseError(response,HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"createUpdateTransaction.createPolicy(policyToCreateUpdate, XACMLPapServlet.doPut) "
-                                               + "\nfailure with the following exception: " + e);
-                               loggingContext.transactionEnded();
-                               PolicyLogger.audit("Transaction Failed - See error.log");
-                               im.endTransaction();
-                               return;
-                       }
-                       loggingContext.metricStarted();
-                       renameTransaction.commitTransaction();
-                       loggingContext.metricEnded();
-                       PolicyLogger.metrics("XACMLPapServlet goPut commitTransaction");
-                       response.setStatus(HttpServletResponse.SC_OK);
-                       loggingContext.transactionEnded();
-                       PolicyLogger.audit("Transaction Ended Successfully");
-                       im.endTransaction();
-                       return;
-               }
                //
                // See if this is Admin Console registering itself with us
                //
@@ -2274,33 +2225,6 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
         * @throws IOException
         */
        private void doACDelete(HttpServletRequest request, HttpServletResponse response, String groupId, ONAPLoggingContext loggingContext) throws IOException {
-               //This code is to allow deletes to propagate to the database since delete is not implemented
-               String isDeleteNotify = request.getParameter("isDeleteNotify");
-               if(isDeleteNotify != null){
-                       String policyToDelete = request.getParameter("policyToDelete");
-                       try{
-                               policyToDelete = URLDecoder.decode(policyToDelete,"UTF-8");
-                       } catch(UnsupportedEncodingException e){
-                               LOGGER.error("Unsupported URL encoding of policyToDelete (UTF-8", e);
-                               setResponseError(response,HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"policyToDelete encoding not supported");
-                               return;
-                       }
-                       PolicyDBDaoTransaction deleteTransaction = policyDBDao.getNewTransaction();
-                       try{
-                               deleteTransaction.deletePolicy(policyToDelete);
-                       } catch(Exception e){
-                               deleteTransaction.rollbackTransaction();
-                               setResponseError(response,HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"deleteTransaction.deleteTransaction(policyToDelete) "
-                                               + "\nfailure with the following exception: " + e);
-                               return;
-                       }
-                       loggingContext.metricStarted();
-                       deleteTransaction.commitTransaction();
-                       loggingContext.metricEnded();
-                       PolicyLogger.metrics("XACMLPapServlet doACPut commitTransaction");
-                       response.setStatus(HttpServletResponse.SC_OK);
-                       return;
-               }
                PolicyDBDaoTransaction removePdpOrGroupTransaction = policyDBDao.getNewTransaction();
                try {
                        // for all DELETE operations the group must exist before the operation can be done
@@ -2881,7 +2805,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
                                }
                        }
                        // remove any ACs that are no longer connected
-                       if (disconnectedACs.size() > 0) {
+                       if (!disconnectedACs.isEmpty()) {
                                adminConsoleURLStringList.removeAll(disconnectedACs);
                        }
                }
index 2e2fa0d..91530c7 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP-PAP-REST
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -31,6 +31,17 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
+import org.onap.policy.common.logging.eelf.MessageCodes;
+import org.onap.policy.common.logging.eelf.PolicyLogger;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.rest.adapter.PolicyRestAdapter;
+import org.onap.policy.rest.dao.CommonClassDao;
+import org.onap.policy.rest.jpa.FunctionDefinition;
+import org.onap.policy.xacml.api.XACMLErrorConstants;
+
+import com.att.research.xacml.api.pap.PAPException;
+
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType;
@@ -45,21 +56,7 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionsType;
 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.onap.policy.pap.xacml.rest.XACMLPapServlet;
-import org.onap.policy.pap.xacml.rest.util.JPAUtils;
-import org.onap.policy.rest.adapter.PolicyRestAdapter;
-import org.onap.policy.rest.jpa.Datatype;
-import org.onap.policy.rest.jpa.FunctionDefinition;
-import org.onap.policy.xacml.api.XACMLErrorConstants;
-
-import com.att.research.xacml.api.pap.PAPException;
-
-import org.onap.policy.common.logging.eelf.MessageCodes;
-import org.onap.policy.common.logging.eelf.PolicyLogger;
-import org.onap.policy.common.logging.flexlogger.FlexLogger; 
-import org.onap.policy.common.logging.flexlogger.Logger; 
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType; 
 
 public class ActionPolicy extends Policy {
     
@@ -90,7 +87,9 @@ public class ActionPolicy extends Policy {
     List<String> dynamicFieldOneRuleAlgorithms = new LinkedList<>();
     List<String> dynamicFieldTwoRuleAlgorithms = new LinkedList<>();
     
-    protected Map<String, String> dropDownMap = new HashMap<>();
+
+    
+    private CommonClassDao commonClassDao;
     
     private static boolean isAttribute = false;
     private synchronized static boolean getAttribute () {
@@ -102,11 +101,12 @@ public class ActionPolicy extends Policy {
         super();
     }
     
-    public ActionPolicy(PolicyRestAdapter policyAdapter){
+    public ActionPolicy(PolicyRestAdapter policyAdapter, CommonClassDao commonClassDao){
         this.policyAdapter = policyAdapter;
+        this.commonClassDao = commonClassDao;
     }
-    
-    @Override
+
+       @Override
     public Map<String, String> savePolicies() throws PAPException {
         
         Map<String, String> successMap = new HashMap<>();
@@ -210,23 +210,22 @@ public class ActionPolicy extends Policy {
             dynamicFieldFunctionRuleAlgorithms = policyAdapter.getDynamicRuleAlgorithmCombo();
             dynamicFieldOneRuleAlgorithms = policyAdapter.getDynamicRuleAlgorithmField1();
             dynamicFieldTwoRuleAlgorithms = policyAdapter.getDynamicRuleAlgorithmField2();
-            dropDownMap = createDropDownMap();
                         
             // Rule attributes are optional and dynamic so check and add them to condition.
-            if (dynamicLabelRuleAlgorithms != null && dynamicLabelRuleAlgorithms.size() > 0) {
+            if (dynamicLabelRuleAlgorithms != null && !dynamicLabelRuleAlgorithms.isEmpty()) {
                 boolean isCompound = false;
                 ConditionType condition = new ConditionType();
                 int index = dynamicFieldOneRuleAlgorithms.size() - 1;
 
                 for (String labelAttr : dynamicLabelRuleAlgorithms) {
                     // if the rule algorithm as a label means it is a compound
-                    if (dynamicFieldOneRuleAlgorithms.get(index).toString().equals(labelAttr)) {
+                    if (dynamicFieldOneRuleAlgorithms.get(index).equals(labelAttr)) {
                         ApplyType actionApply = new ApplyType();
 
-                        String selectedFunction = (String) dynamicFieldFunctionRuleAlgorithms.get(index).toString();
-                        String value1 = (String) dynamicFieldOneRuleAlgorithms.get(index).toString();
-                        String value2 = dynamicFieldTwoRuleAlgorithms.get(index).toString();
-                        actionApply.setFunctionId(dropDownMap.get(selectedFunction));
+                        String selectedFunction = dynamicFieldFunctionRuleAlgorithms.get(index).toString();
+                        String value1 = dynamicFieldOneRuleAlgorithms.get(index);
+                        String value2 = dynamicFieldTwoRuleAlgorithms.get(index);
+                        actionApply.setFunctionId(getFunctionDefinitionId(selectedFunction));
                         actionApply.getExpression().add(new ObjectFactory().createApply(getInnerActionApply(value1)));
                         actionApply.getExpression().add(new ObjectFactory().createApply(getInnerActionApply(value2)));
                         condition.setExpression(new ObjectFactory().createApply(actionApply));
@@ -381,9 +380,9 @@ public class ActionPolicy extends Policy {
                 }
 
                 // Getting the values from the form.
-                String functionKey = dynamicFieldFunctionRuleAlgorithms.get(index).toString();
-                String value2 = dynamicFieldTwoRuleAlgorithms.get(index).toString();
-                actionApply.setFunctionId(dropDownMap.get(functionKey));
+                String functionKey = dynamicFieldFunctionRuleAlgorithms.get(index);
+                String value2 = dynamicFieldTwoRuleAlgorithms.get(index);
+                actionApply.setFunctionId(getFunctionDefinitionId(functionKey));
                 // if two text field are rule attributes.
                 if ((value1.contains(RULE_VARIABLE)) && (value2.contains(RULE_VARIABLE))) {
                     ApplyType innerActionApply1 = new ApplyType();
@@ -463,10 +462,10 @@ public class ActionPolicy extends Policy {
     // if the rule algorithm is multiple compound one setting the apply
     protected ApplyType getCompoundApply(int index) {
         ApplyType actionApply = new ApplyType();
-        String selectedFunction = dynamicFieldFunctionRuleAlgorithms.get(index).toString();
-        String value1 = dynamicFieldOneRuleAlgorithms.get(index).toString();
-        String value2 = dynamicFieldTwoRuleAlgorithms.get(index).toString();
-        actionApply.setFunctionId(dropDownMap.get(selectedFunction));
+        String selectedFunction = dynamicFieldFunctionRuleAlgorithms.get(index);
+        String value1 = dynamicFieldOneRuleAlgorithms.get(index);
+        String value2 = dynamicFieldTwoRuleAlgorithms.get(index);
+        actionApply.setFunctionId(getFunctionDefinitionId(selectedFunction));
         actionApply.getExpression().add(new ObjectFactory().createApply(getInnerActionApply(value1)));
         actionApply.getExpression().add(new ObjectFactory().createApply(getInnerActionApply(value2)));
         return actionApply;
@@ -485,32 +484,18 @@ public class ActionPolicy extends Policy {
         assignmentHeaders.setExpression(new ObjectFactory().createAttributeValue(headersAttributeValue));
         return assignmentHeaders;
     }
-    
-    private Map<String,String> createDropDownMap(){
-        JPAUtils jpaUtils = null;
-        Map<String, String> dropDownMap = new HashMap<>();
-        try {
-            jpaUtils = JPAUtils.getJPAUtilsInstance(XACMLPapServlet.getEmf());
-        } catch (Exception e) {
-            LOGGER.error("Exception Occured"+e);
-        }
-        if(jpaUtils != null){
-            Map<Datatype, List<FunctionDefinition>> functionMap = jpaUtils.getFunctionDatatypeMap();
-            
-            for (Datatype id : functionMap.keySet()) {
-                List<FunctionDefinition> functionDefinitions = (List<FunctionDefinition>) functionMap
-                        .get(id);
-                for (FunctionDefinition functionDef : functionDefinitions) {
-                    dropDownMap.put(functionDef.getShortname(),functionDef.getXacmlid());
-                }
-            }
-        }
-        return dropDownMap;
-    }
 
     @Override
     public Object getCorrectPolicyDataObject() {
         return policyAdapter.getPolicyData();
     }
+    
+    public String getFunctionDefinitionId(String key){
+       FunctionDefinition object = (FunctionDefinition) commonClassDao.getDataById(FunctionDefinition.class, "short_name", key);
+       if(object != null){
+               return object.getXacmlid();
+       }
+       return null;
+    }
 
 }
\ No newline at end of file
index 22d2da3..56c23ac 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP-PAP-REST
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -53,9 +53,8 @@ import org.onap.policy.controlloop.policy.guard.GuardPolicy;
 import org.onap.policy.controlloop.policy.guard.MatchParameters;
 import org.onap.policy.controlloop.policy.guard.builder.ControlLoopGuardBuilder;
 import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
-import org.onap.policy.pap.xacml.rest.util.JPAUtils;
 import org.onap.policy.rest.adapter.PolicyRestAdapter;
-import org.onap.policy.rest.jpa.Datatype;
+import org.onap.policy.rest.dao.CommonClassDao;
 import org.onap.policy.rest.jpa.DecisionSettings;
 import org.onap.policy.rest.jpa.FunctionDefinition;
 import org.onap.policy.utils.PolicyUtils;
@@ -108,15 +107,15 @@ public class DecisionPolicy extends Policy {
        List<String> dynamicFieldTwoRuleAlgorithms = new LinkedList<>();
        List<String> dataTypeList = new LinkedList<>();
        
-       protected Map<String, String> dropDownMap = new HashMap<>();
+       private CommonClassDao commonClassDao;
        
-
        public DecisionPolicy() {
                super();
        }
        
-       public DecisionPolicy(PolicyRestAdapter policyAdapter){
+       public DecisionPolicy(PolicyRestAdapter policyAdapter, CommonClassDao commonClassDao){
                this.policyAdapter = policyAdapter;
+               this.commonClassDao = commonClassDao;
        }
        
        @Override
@@ -419,7 +418,6 @@ public class DecisionPolicy extends Policy {
                dynamicFieldComboRuleAlgorithms = policyAdapter.getDynamicRuleAlgorithmCombo();
                dynamicFieldOneRuleAlgorithms = policyAdapter.getDynamicRuleAlgorithmField1();
                dynamicFieldTwoRuleAlgorithms = policyAdapter.getDynamicRuleAlgorithmField2();
-               dropDownMap = createDropDownMap();
                
                if(policyAdapter.getRuleProvider()!=null && policyAdapter.getRuleProvider().equals(AAFPROVIDER)){
                        // Values for AAF Provider are here for XML Creation. 
@@ -494,7 +492,7 @@ public class DecisionPolicy extends Policy {
                                        String selectedFunction = dynamicFieldComboRuleAlgorithms.get(index);
                                        String value1 = dynamicFieldOneRuleAlgorithms.get(index);
                                        String value2 = dynamicFieldTwoRuleAlgorithms.get(index);
-                                       decisionApply.setFunctionId(dropDownMap.get(selectedFunction));
+                                       decisionApply.setFunctionId(getFunctionDefinitionId(selectedFunction));
                                        decisionApply.getExpression().add(new ObjectFactory().createApply(getInnerDecisionApply(value1)));
                                        decisionApply.getExpression().add(new ObjectFactory().createApply(getInnerDecisionApply(value2)));
                                        condition.setExpression(new ObjectFactory().createApply(decisionApply));
@@ -633,7 +631,7 @@ public class DecisionPolicy extends Policy {
                                // Getting the values from the form.
                                String functionKey = dynamicFieldComboRuleAlgorithms.get(index);
                                String value2 = dynamicFieldTwoRuleAlgorithms.get(index);
-                               decisionApply.setFunctionId(dropDownMap.get(functionKey));
+                               decisionApply.setFunctionId(getFunctionDefinitionId(functionKey));
                                // if two text field are rule attributes.
                                if ((value1.contains(RULE_VARIABLE)) && (value2.contains(RULE_VARIABLE))) {
                                        ApplyType innerDecisionApply1 = new ApplyType();
@@ -721,7 +719,7 @@ public class DecisionPolicy extends Policy {
                String selectedFunction = dynamicFieldComboRuleAlgorithms.get(index);
                String value1 = dynamicFieldOneRuleAlgorithms.get(index);
                String value2 = dynamicFieldTwoRuleAlgorithms.get(index);
-               decisionApply.setFunctionId(dropDownMap.get(selectedFunction));
+               decisionApply.setFunctionId(getFunctionDefinitionId(selectedFunction));
                decisionApply.getExpression().add(new ObjectFactory().createApply(getInnerDecisionApply(value1)));
                decisionApply.getExpression().add(new ObjectFactory().createApply(getInnerDecisionApply(value2)));
                return decisionApply;
@@ -760,24 +758,6 @@ public class DecisionPolicy extends Policy {
                dataTypeList.add(dataType);
        }
        
-       private Map<String,String> createDropDownMap(){
-               JPAUtils jpaUtils = null;
-               try {
-                       jpaUtils = JPAUtils.getJPAUtilsInstance(XACMLPapServlet.getEmf());
-               } catch (Exception e) {
-                       LOGGER.error("Exception Occured"+e);
-               }
-               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()) {
-                                       dropDownOptions.put(functionDef.getShortname(),functionDef.getXacmlid());
-                               }
-                       }
-               }
-               return dropDownOptions;
-       }
        
        private String getDataType(String key) {
                
@@ -800,4 +780,12 @@ public class DecisionPolicy extends Policy {
                return policyAdapter.getData();
        }
        
+       public String getFunctionDefinitionId(String key){
+       FunctionDefinition object = (FunctionDefinition) commonClassDao.getDataById(FunctionDefinition.class, "short_name", key);
+       if(object != null){
+               return object.getXacmlid();
+       }
+       return null;
+    }
+       
 }
index 568830f..2fb6367 100644 (file)
@@ -28,7 +28,6 @@ import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.ProtocolException;
@@ -39,9 +38,6 @@ import java.nio.file.Files;
 import java.nio.file.InvalidPathException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
 import java.util.Base64;
 import java.util.Date;
 import java.util.HashMap;
@@ -53,11 +49,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 
-import javax.crypto.BadPaddingException;
-import javax.crypto.Cipher;
-import javax.crypto.IllegalBlockSizeException;
-import javax.crypto.NoSuchPaddingException;
-import javax.crypto.spec.SecretKeySpec;
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
 import javax.persistence.LockModeType;
@@ -69,10 +60,8 @@ import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathFactory;
 
-import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.io.IOUtils;
-import org.elasticsearch.common.Strings;
 import org.onap.policy.common.logging.eelf.MessageCodes;
 import org.onap.policy.common.logging.eelf.PolicyLogger;
 import org.onap.policy.common.logging.flexlogger.FlexLogger;
@@ -88,14 +77,12 @@ import org.onap.policy.rest.jpa.GroupEntity;
 import org.onap.policy.rest.jpa.PdpEntity;
 import org.onap.policy.rest.jpa.PolicyDBDaoEntity;
 import org.onap.policy.rest.jpa.PolicyEntity;
-import org.onap.policy.rest.util.Webapps;
 import org.onap.policy.utils.CryptoUtils;
 import org.onap.policy.xacml.api.pap.OnapPDP;
 import org.onap.policy.xacml.api.pap.OnapPDPGroup;
 import org.onap.policy.xacml.api.pap.PAPPolicyEngine;
 import org.onap.policy.xacml.std.pap.StdPDPGroup;
 import org.onap.policy.xacml.std.pap.StdPDPPolicy;
-import org.onap.policy.xacml.util.XACMLPolicyScanner;
 import org.onap.policy.xacml.util.XACMLPolicyWriter;
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
@@ -119,6 +106,32 @@ public class PolicyDBDao {
        public static final String PROPERTIES_CONFIG = "PROPERTIES";
        public static final String OTHER_CONFIG = "OTHER";
        public static final String AUDIT_USER = "audit";
+       
+       //Declared to static variables which were repeating multiple times across the PolicyDBDao
+       public static final String config = "Config";
+       public static final String action = "Action";
+       public static final String groupIdVar = "groupId";
+       public static final String deletedVar = "deleted";
+       public static final String groupEntitySelectQuery = "SELECT g FROM GroupEntity g WHERE g.groupId=:groupId AND g.deleted=:deleted";
+       public static final String pdpEntitySelectQuery = "SELECT p FROM PdpEntity p WHERE p.pdpId=:pdpId AND p.deleted=:deleted";
+       public static final String groupCannotBeFound = "The group could not be found with id ";
+       public static final String foundInDBNotDeleted = " were found in the database that are not deleted";
+       public static final String moreThanOnePDP = "Somehow, more than one pdp with the same id ";
+       public static final String deletedStatusFound = " and deleted status were found in the database";
+       public static final String duplicateGroupId = "Somehow, more than one group with the same id ";
+       public static final String pdpIdVariable = "pdpId";
+       public static final String queryFailedToCheckExisting = "Query failed trying to check for existing group";
+       public static final String queryFailedToGetGroup = "Query failed trying to get group ";
+       public static final String scope = "scope";
+       public static final String policyDBDaoVar = "PolicyDBDao";
+       public static final String duplicatePolicyId = "Somehow, more than one policy with the id ";
+       public static final String foundInDB = " were found in the database";
+       
+       public static boolean isJunit = false;
+
+       public static void setJunit(boolean isJunit) {
+               PolicyDBDao.isJunit = isJunit;
+       }
 
        /**
         * Get an instance of a PolicyDBDao. It creates one if it does not exist.
@@ -151,9 +164,11 @@ public class PolicyDBDao {
                }
                throw new IllegalStateException("The PolicyDBDao.currentInstance is Null.  Use getPolicyDBDao(EntityManagerFactory emf)");
        }
+       
        public void setPapEngine(PAPPolicyEngine papEngine2){
-               this.papEngine = (PAPPolicyEngine) papEngine2;
+               this.papEngine = papEngine2;
        }
+       
        private PolicyDBDao(EntityManagerFactory emf){
                logger.debug("PolicyDBDao(EntityManagerFactory emf) as PolicyDBDao("+emf+") called");
                this.emf = emf;
@@ -223,7 +238,7 @@ public class PolicyDBDao {
                        policyDBDaoEntityList = getPolicyDBDaoEntityQuery.getResultList();
 
                } catch(Exception e){
-                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Exception querying for other registered PolicyDBDaos");
+                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Exception querying for other registered PolicyDBDaos");
                        logger.warn("List of remote PolicyDBDaos will be empty", e);
                }
                try{
@@ -242,7 +257,7 @@ public class PolicyDBDao {
 
        public PolicyDBDaoTransaction getNewTransaction(){
                logger.debug("getNewTransaction() as getNewTransaction() called");
-               return (PolicyDBDaoTransaction)(new PolicyDBDaoTransactionInstance());
+               return new PolicyDBDaoTransactionInstance();
        }
 
        /*
@@ -257,7 +272,7 @@ public class PolicyDBDao {
                int auditWaitMs = Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_TRANS_WAIT));
                //Use the (extended) audit timeout time in ms
                int auditTimeoutMs = Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_AUDIT_TIMEOUT)); 
-               return (PolicyDBDaoTransaction)(new PolicyDBDaoTransactionInstance(auditTimeoutMs, auditWaitMs));
+               return new PolicyDBDaoTransactionInstance(auditTimeoutMs, auditWaitMs);
        }
 
 
@@ -277,27 +292,6 @@ public class PolicyDBDao {
                return one.equals(two);
        }
 
-       /**
-        * Computes the scope in dotted format based on an absolute path and a path that divides the scope.
-        * @param fullPath An absolute path including scope folders and other folders(does not have to be absolute, must just contain scope and other folders before)
-        * @param pathToExclude The path that acts as a division between the scope and the other folders
-        * @return The scope in dotted format (org.onap)
-        */
-       private static String computeScope(String fullPath, String pathToExclude){
-               logger.debug("computeScope(String fullPath, String pathToExclude) as computeScope("+fullPath+", "+pathToExclude+") called");
-               int excludeIndex = fullPath.indexOf(pathToExclude);
-               String scopePath = fullPath.substring(excludeIndex+pathToExclude.length());
-               String scope = scopePath.replace('\\', '.');
-               scope = scope.replace('/', '.');
-               if(scope.charAt(0) == '.'){
-                       scope = scope.substring(1);
-               }
-               if(scope.charAt(scope.length()-1) == '.'){
-                       scope = scope.substring(0, scope.length()-1);
-               }
-               return scope;
-       }
-
        /**
         * Returns the url of this local pap server, removing the username and password, if they are present
         * @return The url of this local pap server
@@ -309,9 +303,8 @@ public class PolicyDBDao {
                        return null;
                }
                return splitPapUrlUserPass(url);
-
-
        }
+       
        private String[] splitPapUrlUserPass(String url){
                String[] urlUserPass = new String[3];
                String[] commaSplit = url.split(",");
@@ -320,14 +313,14 @@ public class PolicyDBDao {
                        urlUserPass[1] = commaSplit[1];
                        urlUserPass[2] = commaSplit[2];
                }
-               if(urlUserPass[1] == null || urlUserPass[1].equals("")){
+               if(urlUserPass[1] == null || "".equals(urlUserPass[1])){
                        String usernamePropertyValue = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_USERID);
                        if(usernamePropertyValue != null){
                                urlUserPass[1] = usernamePropertyValue;
                        }
                }
-               if(urlUserPass[2] == null || urlUserPass[2].equals("")){
-                       String passwordPropertyValue = CryptoUtils.decryptTxtNoExStr(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS));
+               if(urlUserPass[2] == null || "".equals(urlUserPass[2])){
+                       String passwordPropertyValue = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS);
                        if(passwordPropertyValue != null){
                                urlUserPass[2] = passwordPropertyValue;
                        }
@@ -335,7 +328,7 @@ public class PolicyDBDao {
                //if there is no comma, for some reason there is no username and password, so don't try to cut them off
                return urlUserPass;
        }
-
+       
        /**
         * Register the PolicyDBDao instance in the PolicyDBDaoEntity table
         * @return Boolean, were we able to register?
@@ -347,7 +340,6 @@ public class PolicyDBDao {
                if(url == null || url.length<3){                        
                        return false;
                }
-               
                EntityManager em = emf.createEntityManager();
                try{
                        startTransactionSynced(em, 1000);
@@ -364,7 +356,7 @@ public class PolicyDBDao {
                                        em.getTransaction().commit();
                                        em.close();                                     
                                } catch(Exception e2){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e2, "PolicyDBDao", "COULD NOT CREATE DATABASELOCK ROW.  WILL TRY ONE MORE TIME");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e2, policyDBDaoVar, "COULD NOT CREATE DATABASELOCK ROW.  WILL TRY ONE MORE TIME");
                                }
                                em = null;
                                em = emf.createEntityManager();
@@ -372,7 +364,7 @@ public class PolicyDBDao {
                                        startTransactionSynced(em, 1000);
                                } catch(Exception e3){
                                        String msg = "DATABASE LOCKING NOT WORKING. CONCURRENCY CONTROL NOT WORKING";
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e3, "PolicyDBDao", msg);
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e3, policyDBDaoVar, msg);
                                        throw new IllegalStateException("msg" + "\n" + e3);
                                }
                        }
@@ -387,7 +379,7 @@ public class PolicyDBDao {
                        txt = CryptoUtils.encryptTxt(url[2].getBytes(StandardCharsets.UTF_8));
                } catch(Exception e){
                        logger.debug(e);
-                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Could not encrypt PAP password");
+                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Could not encrypt PAP password");
                }
                if(foundPolicyDBDaoEntity == null){
                        PolicyDBDaoEntity newPolicyDBDaoEntity = new PolicyDBDaoEntity();
@@ -396,7 +388,6 @@ public class PolicyDBDao {
                        newPolicyDBDaoEntity.setDescription("PAP server at "+url[0]);
                        newPolicyDBDaoEntity.setUsername(url[1]);
                        newPolicyDBDaoEntity.setPassword(txt);
-                       
                        try{
                                em.getTransaction().commit();
                        } catch(Exception e){
@@ -405,19 +396,17 @@ public class PolicyDBDao {
                                        em.getTransaction().rollback();
                                } catch(Exception e2){
                                        logger.debug(e2);
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e2, "PolicyDBDao", "Could not add new PolicyDBDao to the database");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e2, policyDBDaoVar, "Could not add new PolicyDBDao to the database");
                                }
                        }
                } else {
                        //just want to update in order to change modified date
-                       
                        if(url[1] != null && !stringEquals(url[1], foundPolicyDBDaoEntity.getUsername())){
                                foundPolicyDBDaoEntity.setUsername(url[1]);
                        }
                        if(txt != null && !stringEquals(txt, foundPolicyDBDaoEntity.getPassword())){
                                foundPolicyDBDaoEntity.setPassword(txt);
                        }
-                       
                        foundPolicyDBDaoEntity.preUpdate();
                        try{
                                em.getTransaction().commit();
@@ -427,7 +416,7 @@ public class PolicyDBDao {
                                        em.getTransaction().rollback();
                                } catch(Exception e2){
                                        logger.debug(e2);
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e2, "PolicyDBDao", "Could not update PolicyDBDao in the database");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e2, policyDBDaoVar, "Could not update PolicyDBDao in the database");
                                }
                        }
                }
@@ -435,22 +424,20 @@ public class PolicyDBDao {
                logger.debug("\nPolicyDBDao.register(). Success!!\n");
                return true;
        }
+       
        public void notifyOthers(long entityId,String entityType){
                notifyOthers(entityId,entityType,null);
        }
+       
        public void notifyOthers(long entityId, String entityType, String newGroupId){
                logger.debug("notifyOthers(long entityId, String entityType, long newGroupId) as notifyOthers("+entityId+","+entityType+","+newGroupId+") called");             
                LinkedList<Thread> notifyThreads = new LinkedList<>();
 
                //we're going to run notifications in parallel threads to speed things up
                for(Object obj : otherServers){
-
                        Thread newNotifyThread = new Thread(new NotifyOtherThread(obj, entityId, entityType, newGroupId));
-
                        newNotifyThread.start();
-
                        notifyThreads.add(newNotifyThread);
-
                }
                //we want to wait for all notifications to complete or timeout before we unlock the interface and allow more changes
                for(Thread t : notifyThreads){
@@ -460,8 +447,6 @@ public class PolicyDBDao {
                                logger.warn("Could not join a notifcation thread" + e);
                        }
                }
-
-
        }
 
        private class NotifyOtherThread implements Runnable {
@@ -489,7 +474,6 @@ public class PolicyDBDao {
                                //if we can't decrypt, might as well try it anyway
                                txt = dbdEntity.getPassword();
                        }
-                       
                        Base64.Encoder encoder = Base64.getEncoder();                   
                        String encoding = encoder.encodeToString((username+":"+txt).getBytes(StandardCharsets.UTF_8));
                        HttpURLConnection connection = null;
@@ -513,13 +497,13 @@ public class PolicyDBDao {
                                        o = "undefined";
                                }
                                if(papUrl.equals(ourUrl)){
-                                       logger.debug(((String)o)+" is our url, skipping notify");
+                                       logger.debug(o+" is our url, skipping notify");
                                        return;
                                }
                                if(newGroupId == null){
-                                       url = new URL(((String)o)+"?policydbdaourl="+papUrl+"&entityid="+entityId+"&entitytype="+entityType);
+                                       url = new URL(o+"?policydbdaourl="+papUrl+"&entityid="+entityId+"&entitytype="+entityType);
                                } else {
-                                       url = new URL(((String)o)+"?policydbdaourl="+papUrl+"&entityid="+entityId+"&entitytype="+entityType+"&extradata="+newGroupId);
+                                       url = new URL(o+"?policydbdaourl="+papUrl+"&entityid="+entityId+"&entitytype="+entityType+"&extradata="+newGroupId);
                                }
                        } catch (MalformedURLException e) {
                                logger.warn("Caught MalformedURLException on: new URL()", e);
@@ -553,7 +537,6 @@ public class PolicyDBDao {
                        int readTimeout;
                        try{
                                readTimeout = Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_NOTIFY_TIMEOUT));
-
                        } catch(Exception e){
                                logger.error("xacml.rest.pap.notify.timeoutms property not set, using a default.", e);
                                readTimeout = 10000;
@@ -587,7 +570,6 @@ public class PolicyDBDao {
                                logger.warn("Caught Exception on: connection.getResponseCode() ", e);
                        }
 
-
                        connection.disconnect();
                }
        }
@@ -603,28 +585,17 @@ public class PolicyDBDao {
 
                        XPathFactory xpathFactory = XPathFactory.newInstance();
                        XPath xpath = xpathFactory.newXPath();
-
-
+                       
                        description = xpath.evaluate(expression, document);             
                }catch(Exception e){
                        logger.error("Exception Occured while evaluating path"+e);
                }
-
                return description;
        }
-
-       private static String getDescriptionFromXacml(String xacmlData){
-               String openTag = "<Description>";
-               String closeTag = "</Description>";
-               int descIndex = xacmlData.indexOf(openTag);
-               int endDescIndex = xacmlData.indexOf(closeTag);
-               String desc = xacmlData.substring(descIndex+openTag.length(),endDescIndex);
-               return desc;
-       }
        
-       private final String POLICY_NOTIFICATION = "policy";
-       private final String PDP_NOTIFICATION = "pdp";
-       private final String GROUP_NOTIFICATION = "group";
+       private static final String POLICY_NOTIFICATION = "policy";
+       private static final String PDP_NOTIFICATION = "pdp";
+       private static final String GROUP_NOTIFICATION = "group";
        public void handleIncomingHttpNotification(String url, String entityId, String entityType, String extraData, XACMLPapServlet xacmlPapServlet){
                logger.info("DBDao url: " + url + " has reported an update on "+entityType+" entity "+entityId);                
                PolicyDBDaoTransaction transaction = this.getNewTransaction();
@@ -632,7 +603,6 @@ public class PolicyDBDao {
                int retries;
                try{
                        retries = Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_INCOMINGNOTIFICATION_TRIES));
-
                } catch(Exception e){
                        logger.error("xacml.rest.pap.incomingnotification.tries property not set, using a default of 3."+e);
                        retries = 3;
@@ -647,11 +617,11 @@ public class PolicyDBDao {
                case POLICY_NOTIFICATION:
                        for(int i=0; i<retries;i++){
                                try{
-                                       handleIncomingPolicyChange(url, entityId,extraData);
+                                       handleIncomingPolicyChange(entityId);
                                        break;
                                } catch(Exception e){
                                        logger.debug(e);
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught exception on handleIncomingPolicyChange("+url+", "+entityId+", "+extraData+")");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught exception on handleIncomingPolicyChange("+url+", "+entityId+", "+extraData+")");
                                }
                                try{
                                        Thread.sleep(pauseBetweenRetries);
@@ -664,11 +634,11 @@ public class PolicyDBDao {
                case PDP_NOTIFICATION:
                        for(int i=0; i<retries;i++){
                                try{
-                                       handleIncomingPdpChange(url, entityId, transaction);
+                                       handleIncomingPdpChange(entityId, transaction);
                                        break;
                                } catch(Exception e){
                                        logger.debug(e);
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught exception on handleIncomingPdpChange("+url+", "+entityId+", "+transaction+")");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught exception on handleIncomingPdpChange("+url+", "+entityId+", "+transaction+")");
                                }
                                try{
                                        Thread.sleep(pauseBetweenRetries);
@@ -681,11 +651,11 @@ public class PolicyDBDao {
                case GROUP_NOTIFICATION:
                        for(int i=0; i<retries;i++){
                                try{
-                                       handleIncomingGroupChange(url, entityId, extraData, transaction, xacmlPapServlet);
+                                       handleIncomingGroupChange(entityId, extraData, transaction);
                                        break;
                                }catch(Exception e){
                                        logger.debug(e);
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught exception on handleIncomingGroupChange("+url+", "+entityId+", "+extraData+", "+transaction+", "+xacmlPapServlet+")");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught exception on handleIncomingGroupChange("+url+", "+entityId+", "+extraData+", "+transaction+", "+xacmlPapServlet+")");
                                }
                                try{
                                        Thread.sleep(pauseBetweenRetries);
@@ -699,7 +669,8 @@ public class PolicyDBDao {
                //no changes should be being made in this function, we still need to close
                transaction.rollbackTransaction();
        }
-       private void handleIncomingGroupChange(String url, String groupId, String extraData,PolicyDBDaoTransaction transaction,XACMLPapServlet xacmlPapServlet) throws PAPException, PolicyDBException{
+       
+       private void handleIncomingGroupChange(String groupId, String extraData,PolicyDBDaoTransaction transaction) throws PAPException, PolicyDBException{
                GroupEntity groupRecord = null;
                long groupIdLong = -1;
                try{
@@ -710,7 +681,7 @@ public class PolicyDBDao {
                try{
                        groupRecord = transaction.getGroup(groupIdLong);
                } catch(Exception e){
-                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception trying to get pdp group record with transaction.getGroup("+groupIdLong+");");
+                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception trying to get pdp group record with transaction.getGroup("+groupIdLong+");");
                        throw new PAPException("Could not get local group "+groupIdLong);
                }
                if(groupRecord == null){
@@ -738,13 +709,13 @@ public class PolicyDBDao {
                                try {
                                        newLocalGroup = papEngine.getGroup(extraData);
                                } catch (PAPException e) {
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught PAPException trying to get new pdp group with papEngine.getGroup("+extraData+");");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught PAPException trying to get new pdp group with papEngine.getGroup("+extraData+");");
                                }
                        }
                        try {
                                papEngine.removeGroup(localGroup, newLocalGroup);
                        } catch (NullPointerException | PAPException e) {
-                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught PAPException trying to get remove pdp group with papEngine.removeGroup("+localGroup+", "+newLocalGroup+");");
+                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught PAPException trying to get remove pdp group with papEngine.removeGroup("+localGroup+", "+newLocalGroup+");");
                                throw new PAPException("Could not remove group "+groupId);
                        }
                }
@@ -753,13 +724,13 @@ public class PolicyDBDao {
                        try {
                                papEngine.newGroup(groupRecord.getgroupName(), groupRecord.getDescription());
                        } catch (NullPointerException | PAPException e) {
-                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught PAPException trying to create pdp group with papEngine.newGroup(groupRecord.getgroupName(), groupRecord.getDescription());");
+                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught PAPException trying to create pdp group with papEngine.newGroup(groupRecord.getgroupName(), groupRecord.getDescription());");
                                throw new PAPException("Could not create group "+groupRecord);
                        }
                        try {
                                localGroup = papEngine.getGroup(groupRecord.getGroupId());
                        } catch (PAPException e1) {
-                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e1, "PolicyDBDao", "Caught PAPException trying to get pdp group we just created with papEngine.getGroup(groupRecord.getGroupId());\nAny PDPs or policies in the new group may not have been added");
+                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e1, policyDBDaoVar, "Caught PAPException trying to get pdp group we just created with papEngine.getGroup(groupRecord.getGroupId());\nAny PDPs or policies in the new group may not have been added");
                                return;
                        }
                        //add possible pdps to group
@@ -769,7 +740,7 @@ public class PolicyDBDao {
                                try {
                                        papEngine.newPDP(pdp.getPdpId(), localGroup, pdp.getPdpName(), pdp.getDescription(), pdp.getJmxPort());
                                } catch (NullPointerException | PAPException e) {
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught PAPException trying to get create pdp with papEngine.newPDP(pdp.getPdpId(), localGroup, pdp.getPdpName(), pdp.getDescription(), pdp.getJmxPort());");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught PAPException trying to get create pdp with papEngine.newPDP(pdp.getPdpId(), localGroup, pdp.getPdpName(), pdp.getDescription(), pdp.getJmxPort());");
                                        throw new PAPException("Could not create pdp "+pdp);
                                }
                        }
@@ -791,7 +762,7 @@ public class PolicyDBDao {
                                        papEngine.setDefaultGroup(localGroup);
                                        return;
                                } catch (PAPException e) {
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught PAPException trying to set default group with papEngine.SetDefaultGroup("+localGroupClone+");");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught PAPException trying to set default group with papEngine.SetDefaultGroup("+localGroupClone+");");
                                        throw new PAPException("Could not set default group to "+localGroupClone);
                                }                               
                        }               
@@ -811,17 +782,15 @@ public class PolicyDBDao {
                        }
                        if(needToUpdate){
                                try {
-
                                        papEngine.updateGroup(localGroupClone);
                                } catch (PAPException e) {
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught PAPException trying to update group with papEngine.updateGroup("+localGroupClone+");");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught PAPException trying to update group with papEngine.updateGroup("+localGroupClone+");");
                                        throw new PAPException("Could not update group "+localGroupClone);
                                }
                        }                               
-
                }
-               //call command that corresponds to the change that was made
        }
+       
        //this will also handle removes, since incoming pdpGroup has no policies internally, we are just going to add them all in from the db
        private boolean updateGroupPoliciesInFileSystem(OnapPDPGroup pdpGroup,OnapPDPGroup oldPdpGroup, GroupEntity groupRecord, PolicyDBDaoTransaction transaction) throws PAPException, PolicyDBException{
                if(!(pdpGroup instanceof StdPDPGroup)){
@@ -830,7 +799,7 @@ public class PolicyDBDao {
                StdPDPGroup group = (StdPDPGroup)pdpGroup;
                //this must always be true since we don't explicitly know when a delete is occuring
                boolean didUpdate = true;
-               HashMap<String,PDPPolicy> currentPolicySet = new HashMap<String,PDPPolicy>(oldPdpGroup.getPolicies().size());
+               HashMap<String,PDPPolicy> currentPolicySet = new HashMap<>(oldPdpGroup.getPolicies().size());
                HashSet<PDPPolicy> newPolicySet = new HashSet<>();
                for(PDPPolicy pdpPolicy : oldPdpGroup.getPolicies()){
                        currentPolicySet.put(pdpPolicy.getId(), pdpPolicy);
@@ -861,7 +830,6 @@ public class PolicyDBDao {
                        group.setPolicies(newPolicySet);
                }
                return didUpdate;
-
        }
        
        /*
@@ -885,11 +853,9 @@ public class PolicyDBDao {
                        if(currentPolicyMap.containsKey(pdpPolicyId)){
                                newPolicySet.add(currentPolicyMap.get(pdpPolicyId));
                        } else {
-                               
                                //convert PolicyEntity object to PDPPolicy
-                               String name = null;
-               name = pdpPolicyId.replace(".xml", "");
-               name = name.substring(0, name.lastIndexOf("."));
+               String name = pdpPolicyId.replace(".xml", "");
+               name = name.substring(0, name.lastIndexOf('.'));
                                InputStream policyStream = new ByteArrayInputStream(policy.getPolicyData().getBytes());
                                pdpGroup.copyPolicyToFile(pdpPolicyId,name,policyStream);
                                URI location = Paths.get(pdpGroup.getDirectory().toAbsolutePath().toString(), pdpPolicyId).toUri();
@@ -901,9 +867,7 @@ public class PolicyDBDao {
                                        logger.debug(e);
                                        PolicyLogger.error("PolicyDBDao: Exception occurred while creating the StdPDPPolicy newPolicy object " + e.getMessage());
                                }
-                               
                        }
-                       
                }
 
                for(String id : currentPolicyMap.keySet()) {
@@ -957,7 +921,7 @@ public class PolicyDBDao {
         return nameAndVersion;
     }
     
-       private void handleIncomingPdpChange(String url, String pdpId, PolicyDBDaoTransaction transaction) throws PAPException{
+       private void handleIncomingPdpChange(String pdpId, PolicyDBDaoTransaction transaction) throws PAPException{
                //get pdp
                long pdpIdLong = -1;
                try{
@@ -969,7 +933,7 @@ public class PolicyDBDao {
                try{
                        pdpRecord = transaction.getPdp(pdpIdLong);
                }catch(Exception e){
-                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception trying to get pdp record with transaction.getPdp("+pdpIdLong+");");
+                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception trying to get pdp record with transaction.getPdp("+pdpIdLong+");");
                        throw new PAPException("Could not get local pdp "+pdpIdLong);
                }
                if(pdpRecord == null){
@@ -985,7 +949,7 @@ public class PolicyDBDao {
                        try {
                                papEngine.removePDP((OnapPDP) localPdp);
                        } catch (PAPException e) {
-                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught PAPException trying to get remove pdp with papEngine.removePDP("+localPdp+");");
+                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught PAPException trying to get remove pdp with papEngine.removePDP("+localPdp+");");
                                throw new PAPException("Could not remove pdp "+pdpId);
                        }
                }
@@ -996,13 +960,13 @@ public class PolicyDBDao {
                        try {
                                localGroup = papEngine.getGroup(pdpRecord.getGroup().getGroupId());
                        } catch (PAPException e1) {
-                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e1, "PolicyDBDao", "Caught PAPException trying to get local group to add pdp to with papEngine.getGroup(pdpRecord.getGroup().getGroupId());");
+                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e1, policyDBDaoVar, "Caught PAPException trying to get local group to add pdp to with papEngine.getGroup(pdpRecord.getGroup().getGroupId());");
                                throw new PAPException("Could not get local group");
                        }                       
                        try {
                                papEngine.newPDP(pdpRecord.getPdpId(), localGroup, pdpRecord.getPdpName(), pdpRecord.getDescription(), pdpRecord.getJmxPort());
                        } catch (NullPointerException | PAPException e) {
-                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught PAPException trying to create pdp with papEngine.newPDP("+pdpRecord.getPdpId()+", "+localGroup+", "+pdpRecord.getPdpName()+", "+pdpRecord.getDescription()+", "+pdpRecord.getJmxPort()+");");
+                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught PAPException trying to create pdp with papEngine.newPDP("+pdpRecord.getPdpId()+", "+localGroup+", "+pdpRecord.getPdpName()+", "+pdpRecord.getDescription()+", "+pdpRecord.getJmxPort()+");");
                                throw new PAPException("Could not create pdp "+pdpRecord);
                        }
                } else {
@@ -1029,13 +993,13 @@ public class PolicyDBDao {
                                        newPdpGroup = papEngine.getGroup(pdpRecord.getGroup().getGroupId());
                                }catch(PAPException e){
                                        //ok, now we have an issue. Time to stop things
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught PAPException trying to get id of local group to move pdp to with papEngine.getGroup(pdpRecord.getGroup().getGroupId());");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught PAPException trying to get id of local group to move pdp to with papEngine.getGroup(pdpRecord.getGroup().getGroupId());");
                                        throw new PAPException("Could not get local group");
                                }
                                try{
                                        papEngine.movePDP((OnapPDP) localPdp, newPdpGroup);
                                }catch(PAPException e){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught PAPException trying to move pdp with papEngine.movePDP(localPdp, newPdpGroup);");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught PAPException trying to move pdp with papEngine.movePDP(localPdp, newPdpGroup);");
                                        throw new PAPException("Could not move pdp "+localPdp);
                                }
                        }
@@ -1047,7 +1011,7 @@ public class PolicyDBDao {
                                try {
                                        papEngine.updatePDP((OnapPDP) localPdp);
                                } catch (PAPException e) {
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught PAPException trying to update pdp with papEngine.updatePdp("+localPdp+");");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught PAPException trying to update pdp with papEngine.updatePdp("+localPdp+");");
                                        throw new PAPException("Could not update pdp "+localPdp);
                                }
                        }
@@ -1055,7 +1019,7 @@ public class PolicyDBDao {
                //compare to local situation
                //call command to update
        }
-       private void handleIncomingPolicyChange(String url, String policyId,String oldPathString){
+       private void handleIncomingPolicyChange(String policyId){
                String policyName = null;
                EntityManager em = emf.createEntityManager();
                Query getPolicyEntityQuery = em.createNamedQuery("PolicyEntity.FindById");
@@ -1076,22 +1040,22 @@ public class PolicyDBDao {
                                Path subFile = null;
 
                                if (policy.getConfigurationData()!= null){
-                                       subFile = getPolicySubFile(policy.getConfigurationData().getConfigurationName(), "Config");
+                                       subFile = getPolicySubFile(policy.getConfigurationData().getConfigurationName(), config);
                                }else if(policy.getActionBodyEntity()!= null){
-                                       subFile = getPolicySubFile(policy.getActionBodyEntity().getActionBodyName(), "Action");
+                                       subFile = getPolicySubFile(policy.getActionBodyEntity().getActionBodyName(), action);
                                }
 
                                if(subFile != null){
                                        Files.deleteIfExists(subFile);
                                }
                                if (policy.getConfigurationData()!= null){
-                                       writePolicySubFile(policy, "Config");
+                                       writePolicySubFile(policy, config);
                                }else if(policy.getActionBodyEntity()!= null){
-                                       writePolicySubFile(policy, "Action");
+                                       writePolicySubFile(policy, action);
                                }
                        }
                } catch (IOException e1) {
-                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e1, "PolicyDBDao", "Error occurred while performing [" + action + "] of Policy File: " + policyName);
+                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e1, policyDBDaoVar, "Error occurred while performing [" + action + "] of Policy File: " + policyName);
                }       
        }
 
@@ -1107,9 +1071,10 @@ public class PolicyDBDao {
                return fileName.substring(0, fileName.lastIndexOf('.'));
        }
 
-       private Path getPolicySubFile(String filename, String subFileType){
+       private Path getPolicySubFile(String inputFileName, String subFileType){
+               String filename = inputFileName;
                logger.info("getPolicySubFile(" + filename + ", " + subFileType + ")");
-               Path filePath = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_WEBAPPS).toString(), subFileType);
+               Path filePath = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_WEBAPPS), subFileType);
                File file = null;
 
                filename = FilenameUtils.removeExtension(filename);
@@ -1134,14 +1099,13 @@ public class PolicyDBDao {
                String type = null;
                String subTypeName = null;
                String subTypeBody = null;
-               if (policyType.equalsIgnoreCase("config")){
-                       type = "Config";
+               if (config.equalsIgnoreCase(policyType)){
+                       type = config;
                        subTypeName = FilenameUtils.removeExtension(policy.getConfigurationData().getConfigurationName());
                        subTypeBody = policy.getConfigurationData().getConfigBody();
 
                        String configType = policy.getConfigurationData().getConfigType();
 
-
                        if (configType != null) {
                                if (configType.equals(JSON_CONFIG)) {
                                        subTypeName = subTypeName + ".json";
@@ -1156,13 +1120,10 @@ public class PolicyDBDao {
                                        subTypeName = subTypeName + ".txt";
                                }
                        }
-
-               }else if (policyType.equalsIgnoreCase("action")){
-                       type = "Action";
+               }else if (action.equalsIgnoreCase(policyType)){
+                       type = action;
                        subTypeName = policy.getActionBodyEntity().getActionBodyName();
                        subTypeBody = policy.getActionBodyEntity().getActionBody();
-
-
                }
                Path filePath = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_WEBAPPS).toString(), type);
 
@@ -1173,18 +1134,18 @@ public class PolicyDBDao {
                try {
                        Files.deleteIfExists(Paths.get(filePath.toString(), subTypeName));
                        File file = Paths.get(filePath.toString(),subTypeName).toFile();
-                       file.createNewFile();
-                       FileWriter fileWriter = new FileWriter(file, false); // false to overwrite
-                       fileWriter.write(subTypeBody);
-                       fileWriter.close();
-                       success = true;
-
+                       boolean value = file.createNewFile();
+                       logger.debug("New file created successfully"+value);
+                       try(FileWriter fileWriter = new FileWriter(file, false)){
+                               // false to overwrite
+                               fileWriter.write(subTypeBody);
+                               fileWriter.close();
+                               success = true;
+                       }
                } catch (Exception e) {
-                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Exception occured while creating Configuration File for Policy : " + policy.getPolicyName());
+                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Exception occured while creating Configuration File for Policy : " + policy.getPolicyName());
                }                                       
-
                return success;
-
        }
 
        public void auditLocalDatabase(PAPPolicyEngine papEngine2){
@@ -1193,7 +1154,7 @@ public class PolicyDBDao {
                        deleteAllGroupTables();
                        auditGroups(papEngine2);
                } catch(Exception e){
-                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "auditLocalDatabase() error");
+                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "auditLocalDatabase() error");
                        logger.error("Exception Occured"+e);
                }
        }
@@ -1205,34 +1166,28 @@ public class PolicyDBDao {
                EntityManager em = emf.createEntityManager();
                em.getTransaction().begin();
                
-               Query groupQuery = em.createQuery("SELECT g FROM GroupEntity g WHERE g.groupId=:groupId AND g.deleted=:deleted");
-               groupQuery.setParameter("groupId", group.getId());
-               groupQuery.setParameter("deleted", false);
-               List<?> groupQueryList;
-               try{
-                       groupQueryList = groupQuery.getResultList();
-               }catch(Exception e){
-                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception trying to check if group exists groupQuery.getResultList()");
+               StdPDPGroup updatedGroup = null;
+               try {
+                       Query groupQuery = em.createQuery(groupEntitySelectQuery);
+                       groupQuery.setParameter(groupIdVar, group.getId());
+                       groupQuery.setParameter(deletedVar, false);
+                       List<?> groupQueryList = groupQuery.getResultList();
+                       if(groupQueryList!=null && !groupQueryList.isEmpty()){
+                               GroupEntity dbgroup = (GroupEntity)groupQueryList.get(0);
+                               updatedGroup = synchronizeGroupPoliciesInFileSystem(group, dbgroup);
+                               logger.info("Group was updated during file system audit: " + updatedGroup.toString());
+                       }
+               } catch (PAPException | PolicyDBException e) {
+                       logger.error(e);
+               } catch (Exception e) {
+                       logger.error(e);
+                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception trying to check if group exists groupQuery.getResultList()");
                        throw new PersistenceException("Query failed trying to check if group "+group.getId()+" exists");
                }
                
-               GroupEntity dbgroup = null;
-               if(groupQueryList!=null){
-                       dbgroup = (GroupEntity)groupQueryList.get(0);
-               }
-               
                em.getTransaction().commit();
                em.close();
                
-               StdPDPGroup updatedGroup = null;
-               try {
-                       updatedGroup = synchronizeGroupPoliciesInFileSystem(group, dbgroup);
-               } catch (PAPException e) {
-                       logger.error(e);
-               } catch (PolicyDBException e) {
-                       logger.error(e);
-               }
-               logger.info("Group was updated during file system audit: " + updatedGroup.toString());
                return updatedGroup;
                
        }
@@ -1295,7 +1250,7 @@ public class PolicyDBDao {
                                                        List<PolicyEntity> policyEntityList;
                                                        Query getPolicyEntitiesQuery = em.createNamedQuery("PolicyEntity.findByNameAndScope");
                                                        getPolicyEntitiesQuery.setParameter("name", stringArray[0]);
-                                                       getPolicyEntitiesQuery.setParameter("scope", stringArray[1]);
+                                                       getPolicyEntitiesQuery.setParameter(scope, stringArray[1]);
 
                                                        policyEntityList = getPolicyEntitiesQuery.getResultList();
                                                        PolicyEntity policyEntity = null;
@@ -1306,16 +1261,16 @@ public class PolicyDBDao {
                                                                groupEntity.addPolicyToGroup(policyEntity);
                                                        }
                                                }catch(Exception e2){
-                                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e2, "PolicyDBDao", "Exception auditGroups inner catch");
+                                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e2, policyDBDaoVar, "Exception auditGroups inner catch");
                                                }
                                        }
                                }catch(Exception e1){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e1, "PolicyDBDao", "Exception auditGroups middle catch");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e1, policyDBDaoVar, "Exception auditGroups middle catch");
                                }
                        }
                }catch(Exception e){
                        em.getTransaction().rollback();
-                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Exception auditGroups outer catch");
+                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Exception auditGroups outer catch");
                        em.close();
                        return;
                }
@@ -1334,7 +1289,8 @@ public class PolicyDBDao {
        //copied from ConfigPolicy.java and modified
        // Here we are adding the extension for the configurations file based on the
        // config type selection for saving.
-       private String getConfigFile(String filename, String configType) {
+       private String getConfigFile(String inputFilename, String configType) {
+               String filename = inputFilename;
                logger.debug("getConfigFile(String filename, String scope, String configType) as getConfigFile("+filename+", "+configType+") called");
                filename = FilenameUtils.removeExtension(filename);
                String id = configType;
@@ -1412,7 +1368,7 @@ public class PolicyDBDao {
                        if(!(s instanceof String)){
                                return true;
                        }
-                       if(s.equals("")){
+                       if("".equals(s)){
                                return true;
                        }
                }
@@ -1531,7 +1487,7 @@ public class PolicyDBDao {
                                try{
                                        em.getTransaction().commit();
                                } catch(RollbackException e){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught RollbackException on em.getTransaction().commit()");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught RollbackException on em.getTransaction().commit()");
                                        throw new PersistenceException("The commit failed. Message:\n"+e.getMessage());
                                }
                                em.close();
@@ -1541,13 +1497,13 @@ public class PolicyDBDao {
                                                try{
                                                        notifyOthers(policyId,POLICY_NOTIFICATION,newGroupId);
                                                } catch(Exception e){
-                                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception on notifyOthers("+policyId+","+POLICY_NOTIFICATION+","+newGroupId+")");
+                                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception on notifyOthers("+policyId+","+POLICY_NOTIFICATION+","+newGroupId+")");
                                                }
                                        } else {
                                                try{
                                                        notifyOthers(policyId,POLICY_NOTIFICATION);
                                                } catch(Exception e){
-                                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception on notifyOthers("+policyId+","+POLICY_NOTIFICATION+")");
+                                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception on notifyOthers("+policyId+","+POLICY_NOTIFICATION+")");
                                                }
                                        }
                                }
@@ -1557,13 +1513,13 @@ public class PolicyDBDao {
                                                try{
                                                        notifyOthers(groupId,GROUP_NOTIFICATION,newGroupId);
                                                } catch(Exception e){
-                                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception on notifyOthers("+groupId+","+GROUP_NOTIFICATION+","+newGroupId+")");
+                                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception on notifyOthers("+groupId+","+GROUP_NOTIFICATION+","+newGroupId+")");
                                                }
                                        } else {
                                                try{
                                                        notifyOthers(groupId,GROUP_NOTIFICATION);
                                                } catch(Exception e){
-                                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception on notifyOthers("+groupId+","+GROUP_NOTIFICATION+")");
+                                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception on notifyOthers("+groupId+","+GROUP_NOTIFICATION+")");
                                                }
                                        }
                                }
@@ -1572,7 +1528,7 @@ public class PolicyDBDao {
                                        try{
                                                notifyOthers(pdpId,PDP_NOTIFICATION);
                                        } catch(Exception e){
-                                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception on notifyOthers("+pdpId+","+PDP_NOTIFICATION+")");
+                                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception on notifyOthers("+pdpId+","+PDP_NOTIFICATION+")");
                                        }
                                }
                        }
@@ -1590,12 +1546,12 @@ public class PolicyDBDao {
                                        try{
                                                em.getTransaction().rollback();                                 
                                        } catch(Exception e){
-                                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Could not rollback transaction");
+                                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Could not rollback transaction");
                                        }
                                        try{
                                                em.close();
                                        }catch(Exception e){
-                                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Could not close EntityManager");
+                                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Could not close EntityManager");
                                        }
 
                                } else {
@@ -1610,11 +1566,10 @@ public class PolicyDBDao {
                        if(transactionTimer instanceof Thread){
                                transactionTimer.interrupt();
                        }
-
-
                }
 
-               private void createPolicy(PolicyRestAdapter policy, String username, String policyScope, String policyName, String policyDataString) {
+               private void createPolicy(PolicyRestAdapter policy, String username, String policyScope, String inputPolicyName, String policyDataString) {
+                       String policyName = inputPolicyName;
                        logger.debug("createPolicy(PolicyRestAdapter policy, String username, String policyScope, String policyName, String policyDataString) as createPolicy("+policy+", "+username+", "+policyScope+", "+policyName+", "+policyDataString+") called");
                        synchronized(emLock){
                                checkBeforeOperationRun();
@@ -1628,12 +1583,12 @@ public class PolicyDBDao {
                                }
                                policyName = policyName.split(":")[1];
                                Query createPolicyQuery = em.createQuery("SELECT p FROM PolicyEntity p WHERE p.scope=:scope AND p.policyName=:policyName");                     
-                               createPolicyQuery.setParameter("scope", policyScope);
+                               createPolicyQuery.setParameter(scope, policyScope);
                                createPolicyQuery.setParameter("policyName", policyName);
                                List<?> createPolicyQueryList = createPolicyQuery.getResultList();
                                PolicyEntity newPolicyEntity;
                                boolean update;
-                               if(createPolicyQueryList.size() < 1){
+                               if(createPolicyQueryList.isEmpty()){
                                        newPolicyEntity = new PolicyEntity();
                                        update = false;
                                } else if(createPolicyQueryList.size() > 1){
@@ -1645,7 +1600,7 @@ public class PolicyDBDao {
                                }                       
 
                                ActionBodyEntity newActionBodyEntity = null;
-                               if(policy.getPolicyType().equals("Action")){
+                               if(policy.getPolicyType().equals(action)){
                                        boolean abupdate = false;
                                        if(newPolicyEntity.getActionBodyEntity() == null){
                                                newActionBodyEntity = new ActionBodyEntity();
@@ -1662,45 +1617,12 @@ public class PolicyDBDao {
                                                //trim the .xml off the end
                                                String policyNameClean = FilenameUtils.removeExtension(configName);
                                                String actionBodyName =  policyNameClean + ".json";
-                                               Path actionBodyPath = Paths.get(Webapps.getActionHome(), actionBodyName);
-                                               if(logger.isDebugEnabled()){
-                                                       logger.debug("\nPolicyDBDao.createPolicy"
-                                                                       + "\n   actionBodyPath = " + actionBodyPath);
-                                               }
-                                               //get the action body
-                                               String actionBodyString = null;
-                                               String actionBodyPathStr = null;
-                                               InputStream fileContentStream = null;
-
-                                               if (Files.exists(actionBodyPath)) {
-                                                       try {
-                                                               actionBodyPathStr = (actionBodyPath != null ? actionBodyPath.toString() : null);
-                                                               fileContentStream = new FileInputStream(actionBodyPathStr);
-                                                               actionBodyString = IOUtils.toString(fileContentStream);
-                                                               if(logger.isDebugEnabled()){
-                                                                       logger.debug("\nPolicyDBDao.createPolicy"
-                                                                                       + "\n   actionBodyPathStr = " + actionBodyPathStr
-                                                                                       + "\n   actionBodyString = " + actionBodyString);
-                                                               }
-                                                       } catch (FileNotFoundException e) {
-                                                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught FileNotFoundException on new actionBodyPathStr FileInputStream("+actionBodyPathStr+")");
-                                                               throw new IllegalArgumentException("The actionBodyPathStr file path " + actionBodyPathStr + " does not exist" 
-                                                                               + "\nEXCEPTION: " + e);
-                                                       } catch(IOException e2){
-                                                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e2, "PolicyDBDao", "Caught IOException on actionBodyPath newIOUtils.toString("+fileContentStream+")");
-                                                               throw new IllegalArgumentException("The actionBodyPath file path cannot be read" + fileContentStream 
-                                                                               + "\nEXCEPTION: " + e2);
-                                                       } finally {
-                                                               IOUtils.closeQuietly(fileContentStream);
-                                                       }
 
-                                                       if(actionBodyString == null){
-                                                               throw new IllegalArgumentException("The file path (" + actionBodyPathStr + ") cannot be read");
-                                                       }
-                                               } else {
+                                               //get the action body
+                                               String actionBodyString = policy.getActionBody();
+                                               if(actionBodyString == null){
                                                        actionBodyString = "{}";
                                                }
-
                                                newActionBodyEntity.setActionBody(actionBodyString);
                                                newActionBodyEntity.setActionBodyName(actionBodyName);
                                                newActionBodyEntity.setModifiedBy("PolicyDBDao.createPolicy()");
@@ -1732,7 +1654,7 @@ public class PolicyDBDao {
                                }
 
                                ConfigurationDataEntity newConfigurationDataEntity;
-                               if(policy.getPolicyType().equals("Config")){
+                               if(policy.getPolicyType().equals(config)){
                                        boolean configUpdate;
                                        if(newPolicyEntity.getConfigurationData() == null){
                                                newConfigurationDataEntity = new ConfigurationDataEntity();
@@ -1770,7 +1692,7 @@ public class PolicyDBDao {
                                                                newConfigurationDataEntity.setConfigBody(policy.getConfigBodyData());
                                                        }
                                                }
-                                               if(newConfigurationDataEntity.isDeleted() == true){
+                                               if(newConfigurationDataEntity.isDeleted()){
                                                        newConfigurationDataEntity.setDeleted(false);
                                                }
 
@@ -1818,11 +1740,9 @@ public class PolicyDBDao {
                                newPolicyEntity.setConfigurationData(newConfigurationDataEntity);
                                newPolicyEntity.setActionBodyEntity(newActionBodyEntity);
 
-
                                em.flush();
                                this.policyId = newPolicyEntity.getPolicyId();
                        }
-
                        return;
                }
 
@@ -1848,7 +1768,7 @@ public class PolicyDBDao {
                                        policyId = policyName;
                                        policyQuery = em.createQuery("SELECT p FROM PolicyEntity p WHERE p.policyName=:name AND p.scope=:scope");
                                        policyQuery.setParameter("name", policyId);
-                                       policyQuery.setParameter("scope", scope);
+                                       policyQuery.setParameter(scope, scope);
                                } else{
                                        policyId = String.valueOf(policyID);
                                        policyQuery = em.createNamedQuery("PolicyEntity.FindById");
@@ -1858,135 +1778,20 @@ public class PolicyDBDao {
                                try{
                                        policyQueryList = policyQuery.getResultList();
                                }catch(Exception e){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception trying to get policy with policyQuery.getResultList()");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception trying to get policy with policyQuery.getResultList()");
                                        throw new PersistenceException("Query failed trying to get policy "+policyId);
                                }
-                               if(policyQueryList.size() < 1){
+                               if(policyQueryList.isEmpty()){
                                        PolicyLogger.error("Policy does not exist with id "+policyId);
                                        throw new PersistenceException("Group policy is being added to does not exist with id "+policyId);
                                } else if(policyQueryList.size() > 1){
-                                       PolicyLogger.error("Somehow, more than one policy with the id "+policyId+" were found in the database");
-                                       throw new PersistenceException("Somehow, more than one policy with the id "+policyId+" were found in the database");
+                                       PolicyLogger.error(duplicatePolicyId+policyId+foundInDB);
+                                       throw new PersistenceException(duplicatePolicyId+policyId+foundInDB);
                                }
                                return (PolicyEntity)policyQueryList.get(0);
                        }
                }
 
-               @Override
-               public void renamePolicy(String oldPath, String newPath,String username){
-/*                     String[] oldPolicy = getScopeAndNameAndType(oldPath);
-                       String[] newPolicy = getScopeAndNameAndType(newPath);
-                       if(oldPolicy == null || newPolicy == null){
-                               PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW+"Could not parse one or more of the path names: "
-                                               +oldPath+", "+newPath);
-                               throw new IllegalArgumentException("Could not parse one or more of the path names");
-                       }
-                       synchronized (emLock) {
-                               checkBeforeOperationRun();
-
-                               PolicyEntity existingPolicy;
-                               boolean existingPolicyDeleted = false;
-                               List<?> groups = null;
-                               try{
-                                       existingPolicy = getPolicy(newPolicy[1],newPolicy[0]);
-                               } catch(Exception e){
-                                       existingPolicy = null;
-                               }
-                               if(existingPolicy != null && !existingPolicy.isDeleted()){
-                                       logger.error("The policy named "+existingPolicy.getPolicyName()+" already exists, cannot rename policy: "+newPolicy);
-                                       throw new IllegalArgumentException("The policy named "+existingPolicy.getPolicyName()+" already exists, cannot rename policy: "+newPolicy);
-                               } else if(existingPolicy != null && existingPolicy.isDeleted()){
-                                       try{
-                                               Query getGroups = em.createQuery("SELECT g FROM GroupEntity g JOIN g.policies p WHERE p.policyId=:pid");
-
-                                               getGroups.setParameter("pid", existingPolicy.getPolicyId());
-                                               groups = getGroups.getResultList();
-                                       }catch(Exception e){
-                                               groups = new LinkedList<>();
-                                       }
-                                       for(Object o : groups){
-                                               GroupEntity group = (GroupEntity)o;
-                                               group.removePolicyFromGroup(existingPolicy);
-                                       }
-                                       try{
-                                               em.flush();
-                                       }catch(Exception e){
-                                               logger.error("Error while removing the policy from groups: "+existingPolicy.getPolicyName());
-                                       }
-                                       try{
-                                               em.remove(existingPolicy);
-                                               em.flush();
-                                       }catch(Exception e){
-                                               logger.error("Could not remove the existing deleted policy: "+existingPolicy.getPolicyName());
-                                       }
-                                       existingPolicyDeleted = true;
-                                       //create the new policy
-                                       //for each of the groups, add the new policy
-                               }
-
-                               PolicyEntity policyToRename;
-                               try{
-                                       policyToRename = getPolicy(oldPolicy[1],oldPolicy[0]);
-                               } catch(Exception e){
-                                       PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "PolicyDBDao", "Could not get policy record to rename: "
-                                                       +oldPolicy[1]);
-                                       throw new PersistenceException("Could not get policy record to rename");
-                               }
-                               String policyDataString = null;
-                               InputStream fileContentStream = null;
-                               String policyFilePath = Paths.get(oldPath).toAbsolutePath().toString();
-                               //I want to try the old path first, then if it doesn't work, try the new path
-                               for(int i=0;i<2;i++){
-                                       try {
-                                               fileContentStream = new FileInputStream(policyFilePath);
-                                               policyDataString = IOUtils.toString(fileContentStream);
-                                       } catch (FileNotFoundException e) {
-                                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught FileNotFoundException on new FileInputStream("+policyFilePath+")");
-                                               //if we can't find the oldPath, we'll try the new path
-                                               if(i == 0){
-                                                       policyFilePath = Paths.get(newPath).toAbsolutePath().toString();
-                                                       continue;
-                                               }
-                                               throw new IllegalArgumentException("The file path does not exist");
-                                       } catch(IOException e2){
-                                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e2, "PolicyDBDao", "Caught IOException on newIOUtils.toString("+fileContentStream+")");
-                                               throw new IllegalArgumentException("The file path cannot be read");
-                                       } finally {
-                                               IOUtils.closeQuietly(fileContentStream);
-                                       }
-                                       if(policyDataString == null){
-                                               throw new IllegalArgumentException("The file path cannot be read");
-                                       }
-                                       //escape the loop
-                                       i=2;
-                               }
-                               policyToRename.setPolicyName(newPolicy[1]);
-                               policyToRename.setPolicyData(policyDataString);
-                               policyToRename.setScope(newPolicy[0]);
-                               policyToRename.setModifiedBy(username);
-                               if(policyToRename.getConfigurationData() != null){
-                                       String configType = policyToRename.getConfigurationData().getConfigType();
-                                       policyToRename.getConfigurationData().setConfigurationName(getConfigFile(newPolicy[1], configType));
-                                       policyToRename.getConfigurationData().setModifiedBy(username);
-                               }
-                               if(policyToRename.getActionBodyEntity() != null){
-                                       String newActionName = newPolicy[0]+"."+removeFileExtension(newPolicy[1])+".json";
-                                       policyToRename.getActionBodyEntity().setActionBodyName(newActionName);
-                                       policyToRename.getActionBodyEntity().setModifiedBy(username);
-                               }
-                               if(existingPolicyDeleted){
-                                       for(Object o : groups){
-
-                                               GroupEntity group = (GroupEntity)o;
-                                               group.addPolicyToGroup(policyToRename);
-                                       }
-                               }
-                               em.flush();
-                               this.policyId = policyToRename.getPolicyId();
-                               this.newGroupId = oldPath;
-                       }*/
-               }
-
                @Override
                public GroupEntity getGroup(long groupKey){
                        logger.debug("getGroup(int groupKey) as getGroup("+groupKey+") called");
@@ -2002,15 +1807,15 @@ public class PolicyDBDao {
                                try{
                                        groupQueryList = groupQuery.getResultList();
                                }catch(Exception e){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception trying to get group with groupQuery.getResultList()");
-                                       throw new PersistenceException("Query failed trying to get group "+groupKey);
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception trying to get group with groupQuery.getResultList()");
+                                       throw new PersistenceException(queryFailedToGetGroup+groupKey);
                                }
-                               if(groupQueryList.size() < 1){
+                               if(groupQueryList.isEmpty()){
                                        PolicyLogger.error("Group does not exist with groupKey "+groupKey);
                                        throw new PersistenceException("Group does not exist with groupKey "+groupKey);
                                } else if(groupQueryList.size() > 1){
-                                       PolicyLogger.error("Somehow, more than one group with the groupKey "+groupKey+" were found in the database");
-                                       throw new PersistenceException("Somehow, more than one group with the groupKey "+groupKey+" were found in the database");
+                                       PolicyLogger.error("Somehow, more than one group with the groupKey "+groupKey+foundInDB);
+                                       throw new PersistenceException("Somehow, more than one group with the groupKey "+groupKey+foundInDB);
                                }
                                return (GroupEntity)groupQueryList.get(0);
                        }
@@ -2026,24 +1831,25 @@ public class PolicyDBDao {
                                checkBeforeOperationRun(true);
                                //check if group exists
                                Query groupQuery = em.createQuery("SELECT g FROM GroupEntity g WHERE g.groupId=:groupId");
-                               groupQuery.setParameter("groupId", groupId);                    
+                               groupQuery.setParameter(groupIdVar, groupId);                   
                                List<?> groupQueryList;
                                try{
                                        groupQueryList = groupQuery.getResultList();
                                }catch(Exception e){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception trying to get group with groupQuery.getResultList()");
-                                       throw new PersistenceException("Query failed trying to get group "+groupId);
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception trying to get group with groupQuery.getResultList()");
+                                       throw new PersistenceException(queryFailedToGetGroup+groupId);
                                }
-                               if(groupQueryList.size() < 1){
+                               if(groupQueryList.isEmpty()){
                                        PolicyLogger.error("Group does not exist with id "+groupId);
                                        throw new PersistenceException("Group does not exist with id "+groupId);
                                } else if(groupQueryList.size() > 1){
-                                       PolicyLogger.error("Somehow, more than one group with the id "+groupId+" were found in the database");
-                                       throw new PersistenceException("Somehow, more than one group with the id "+groupId+" were found in the database");
+                                       PolicyLogger.error(duplicateGroupId +groupId+foundInDB);
+                                       throw new PersistenceException(duplicateGroupId+groupId+foundInDB);
                                }
                                return (GroupEntity)groupQueryList.get(0);
                        }
                }
+               
                @Override
                public List<?> getPdpsInGroup(long groupKey){
                        logger.debug("getPdpsInGroup(int groupKey) as getPdpsInGroup("+groupKey+") called");
@@ -2057,6 +1863,7 @@ public class PolicyDBDao {
                                return pdpsQuery.getResultList();
                        }
                }
+               
                @Override
                public PdpEntity getPdp(long pdpKey){
                        logger.debug("getPdp(int pdpKey) as getPdp("+pdpKey+") called");
@@ -2072,65 +1879,19 @@ public class PolicyDBDao {
                                try{
                                        pdpQueryList = pdpQuery.getResultList();
                                }catch(Exception e){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception trying to get pdp with pdpQuery.getResultList()");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception trying to get pdp with pdpQuery.getResultList()");
                                        throw new PersistenceException("Query failed trying to get pdp "+pdpKey);
                                }
-                               if(pdpQueryList.size() < 1){
+                               if(pdpQueryList.isEmpty()){
                                        PolicyLogger.error("Pdp does not exist with pdpKey "+pdpKey);
                                        throw new PersistenceException("Pdp does not exist with pdpKey "+pdpKey);
                                } else if(pdpQueryList.size() > 1){
-                                       PolicyLogger.error("Somehow, more than one pdp with the pdpKey "+pdpKey+" were found in the database");
-                                       throw new PersistenceException("Somehow, more than one pdp with the pdpKey "+pdpKey+" were found in the database");
+                                       PolicyLogger.error("Somehow, more than one pdp with the pdpKey "+pdpKey+foundInDB);
+                                       throw new PersistenceException("Somehow, more than one pdp with the pdpKey "+pdpKey+foundInDB);
                                }
                                return (PdpEntity)pdpQueryList.get(0);
                        }
                }
-               
-               public void deletePolicy(String policyToDeletes){
-                       /*synchronized(emLock){
-                               checkBeforeOperationRun();
-                               logger.debug("deletePolicy(String policyToDeletes) as deletePolicy("+policyToDeletes+") called");
-                               String[] scopeNameAndType = getScopeAndNameAndType(policyToDeletes);
-                               if(scopeNameAndType == null){
-                                       throw new IllegalArgumentException("Could not parse file path");
-                               }
-                               String realScope = scopeNameAndType[0];
-                               String realName = scopeNameAndType[1];
-                               Query deletePolicyQuery = em.createQuery("SELECT p FROM PolicyEntity p WHERE p.scope=:scope AND p.policyName=:policyName AND p.deleted=:deleted");                      
-                               deletePolicyQuery.setParameter("scope",realScope);
-                               deletePolicyQuery.setParameter("policyName", realName);
-                               deletePolicyQuery.setParameter("deleted", false);
-                               List<?> deletePolicyQueryList = deletePolicyQuery.getResultList();
-                               if(deletePolicyQueryList.size() < 1){
-                                       logger.warn("The policy being deleted could not be found.");
-                                       return;
-                               } else if(deletePolicyQueryList.size() > 1){
-                                       PolicyLogger.error("Somehow, more than one policy with the same scope, name, and deleted status were found in the database");
-                                       throw new PersistenceException("Somehow, more than one policy with the same scope, name, and deleted status were found in the database");
-                               } else {
-                                       PolicyEntity policyToDelete = (PolicyEntity)deletePolicyQueryList.get(0);
-                                       policyToDelete.setDeleted(true);
-                                       if(policyToDelete.getConfigurationData() != null){
-                                               ConfigurationDataEntity cde = em.find(ConfigurationDataEntity.class,policyToDelete.getConfigurationData().getConfigurationDataId());                                    
-                                               if(cde != null){
-                                                       cde.setDeleted(true);
-                                               }
-                                       }
-                                       if(policyToDelete.getActionBodyEntity() != null){
-                                               ActionBodyEntity abe = em.find(ActionBodyEntity.class,policyToDelete.getActionBodyEntity().getActionBodyId());                                  
-                                               if(abe != null){
-                                                       abe.setDeleted(true);
-                                               }
-                                       }
-
-                                       em.flush();
-                                       this.policyId = policyToDelete.getPolicyId();
-
-                               }
-                       }
-*/
-               }
-
 
                @Override
                public boolean isTransactionOpen() {
@@ -2140,51 +1901,8 @@ public class PolicyDBDao {
                        }
                }
 
-
-               @Override
-               public void clonePolicy(String oldPolicyPath, String newPolicyPath, String username){
-                       /*String[] oldPolicyData = getScopeAndNameAndType(oldPolicyPath);
-                       String[] newPolicyData = getScopeAndNameAndType(newPolicyPath);
-                       if(oldPolicyData == null || newPolicyData == null){
-                               PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW+"Could not parse one or more of the path names: "
-                                               +oldPolicyPath+", "+newPolicyPath);
-                               throw new IllegalArgumentException("Could not parse the oldPolicyPath or newPolicyPath");
-                       }
-                       PolicyEntity oldPolicy;
-                       try{
-                               oldPolicy = getPolicy(oldPolicyData[1],oldPolicyData[0]);
-                       }catch(Exception e){
-                               PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "PolicyDBDao", "Could not get policy record to clone: "
-                                               +oldPolicyData[1]);
-                               throw new PersistenceException("Could not get policy record to clone");
-                       }
-                       ConfigurationDataEntity clonedConfig = null;
-                       if(oldPolicy.getConfigurationData() != null){
-                               clonedConfig = new ConfigurationDataEntity();
-                               em.persist(clonedConfig);
-                               clonedConfig.setConfigBody(oldPolicy.getConfigurationData().getConfigBody());
-                               clonedConfig.setConfigType(oldPolicy.getConfigurationData().getConfigType());
-                               clonedConfig.setCreatedBy(username);
-                               clonedConfig.setConfigurationName(getConfigFile(newPolicyData[1], oldPolicy.getConfigurationData().getConfigType()));
-                               clonedConfig.setDescription(oldPolicy.getConfigurationData().getDescription());
-                               clonedConfig.setModifiedBy(username);
-                               em.flush();
-                       }
-                       ActionBodyEntity clonedAction = null;
-                       if(oldPolicy.getActionBodyEntity() != null){
-                               clonedAction = new ActionBodyEntity();
-                               em.persist(clonedAction);
-                               clonedAction.setActionBody(oldPolicy.getActionBodyEntity().getActionBody());
-                               clonedAction.setActionBodyName(newPolicyData[0]+"."+newPolicyData[1]+".json");
-                               clonedAction.setCreatedBy(username);
-                               clonedAction.setModifiedBy(username);
-                               em.flush();
-                       }                       
-
-*/
-               }
-
-               private String processConfigPath(String configPath){
+               private String processConfigPath(String inputConfigPath){
+                       String configPath = inputConfigPath;
                        String webappsPath = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_WEBAPPS);
                        if(webappsPath == null){
                                logger.error("Webapps property does not exist");
@@ -2200,6 +1918,7 @@ public class PolicyDBDao {
                        }
                        return configPath;
                }
+               
                private String readConfigFile(String configPath){
                        String configDataString = null;
                        InputStream configContentStream = null;
@@ -2235,19 +1954,23 @@ public class PolicyDBDao {
                                        policyDataString = IOUtils.toString(policyXmlStream);
                                } catch (IOException e) {
                                        policyDataString = "could not read";
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught IOException on IOUtils.toString("+policyXmlStream+")");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught IOException on IOUtils.toString("+policyXmlStream+")");
                                        throw new IllegalArgumentException("Cannot parse the policy xml from the PolicyRestAdapter.");
                                }
                                IOUtils.closeQuietly(policyXmlStream);
+                               if(isJunit){
+                                       //Using parentPath object to set policy data.
+                                       policyDataString = policy.policyAdapter.getParentPath();
+                               }
                                String configPath = "";
-                               if (policy.policyAdapter.getPolicyType().equalsIgnoreCase("Config")) {
+                               if (policy.policyAdapter.getPolicyType().equalsIgnoreCase(config)) {
                                        configPath = evaluateXPath("/Policy/Rule/AdviceExpressions/AdviceExpression[contains(@AdviceId,'ID')]/AttributeAssignmentExpression[@AttributeId='URLID']/AttributeValue/text()", policyDataString);
-                               } else if (policy.policyAdapter.getPolicyType().equalsIgnoreCase("Action")) {
+                               } else if (policy.policyAdapter.getPolicyType().equalsIgnoreCase(action)) {
                                        configPath = evaluateXPath("/Policy/Rule/ObligationExpressions/ObligationExpression[contains(@ObligationId, " +policy.policyAdapter.getActionAttribute()+ ")]/AttributeAssignmentExpression[@AttributeId='body']/AttributeValue/text()", policyDataString);
                                }
 
                                String prefix = null;
-                               if (policy.policyAdapter.getPolicyType().equalsIgnoreCase("Config")) {
+                               if (policy.policyAdapter.getPolicyType().equalsIgnoreCase(config)) {
 
                                        prefix = configPath.substring(configPath.indexOf(policyScope+".")+policyScope.concat(".").length(), configPath.lastIndexOf(policy.policyAdapter.getPolicyName()));
                                        if(isNullOrEmpty(policy.policyAdapter.getConfigBodyData())){
@@ -2265,9 +1988,9 @@ public class PolicyDBDao {
                                                }
                                                policy.policyAdapter.setConfigBodyData(configData);
                                        }
-                               } else if (policy.policyAdapter.getPolicyType().equalsIgnoreCase("Action")) {
+                               } else if (action.equalsIgnoreCase(policy.policyAdapter.getPolicyType())) {
                                        prefix = "Action_";
-                               } else if (policy.policyAdapter.getPolicyType().equalsIgnoreCase("Decision")) {
+                               } else if ("Decision".equalsIgnoreCase(policy.policyAdapter.getPolicyType())) {
                                        prefix = "Decision_";
                                }
 
@@ -2276,13 +1999,11 @@ public class PolicyDBDao {
                                        throw new IllegalArgumentException("The data field is not an instance of PolicyType");
                                }
                                String finalName = policyScope + "." + prefix+policy.policyAdapter.getPolicyName()+"."+((PolicyType)policy.policyAdapter.getData()).getVersion()+".xml";
-                               if(policy.policyAdapter.getConfigType() == null || policy.policyAdapter.getConfigType().equals("")){
+                               if(policy.policyAdapter.getConfigType() == null || "".equals(policy.policyAdapter.getConfigType())){
                                        //get the config file extension
                                        String ext = "";
-                                       if (configPath != null) {
-                                               if (!configPath.equalsIgnoreCase("")) {
-                                                       ext = configPath.substring(configPath.lastIndexOf('.'), configPath.length());;
-                                               }
+                                       if (configPath != null && !"".equalsIgnoreCase(configPath)) {
+                                               ext = configPath.substring(configPath.lastIndexOf('.'), configPath.length());;
                                        }
 
                                        if(ext.contains("txt")){
@@ -2294,7 +2015,7 @@ public class PolicyDBDao {
                                        } else if(ext.contains("properties")){
                                                policy.policyAdapter.setConfigType(PROPERTIES_CONFIG);
                                        } else {
-                                               if (policy.policyAdapter.getPolicyType().equalsIgnoreCase("Action")){
+                                               if (policy.policyAdapter.getPolicyType().equalsIgnoreCase(action)){
                                                        policy.policyAdapter.setConfigType(JSON_CONFIG);
                                                }
                                        }
@@ -2327,31 +2048,30 @@ public class PolicyDBDao {
                        }
                }
 
-
-
                @Override
-               public void createGroup(String groupId, String groupName, String groupDescription, String username) {
+               public void createGroup(String groupId, String groupName, String inputGroupDescription, String username) {
+                       String groupDescription = inputGroupDescription;
                        logger.debug("deletePolicy(String policyToDeletes) as createGroup("+groupId+", "+groupName+", "+groupDescription+") called");
                        if(isNullOrEmpty(groupId, groupName, username)){
                                throw new IllegalArgumentException("groupId, groupName, and username must not be null or empty");
                        }
-                       if(!(groupDescription instanceof String)){
+                       if(groupDescription == null){
                                groupDescription = "";
                        }
 
                        synchronized(emLock){
                                checkBeforeOperationRun();
-                               Query checkGroupQuery = em.createQuery("SELECT g FROM GroupEntity g WHERE g.groupId=:groupId AND g.deleted=:deleted");
-                               checkGroupQuery.setParameter("groupId", groupId);
-                               checkGroupQuery.setParameter("deleted", false);
+                               Query checkGroupQuery = em.createQuery(groupEntitySelectQuery);
+                               checkGroupQuery.setParameter(groupIdVar, groupId);
+                               checkGroupQuery.setParameter(deletedVar, false);
                                List<?> checkGroupQueryList;
                                try{
                                        checkGroupQueryList = checkGroupQuery.getResultList();
                                } catch(Exception e){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception on checkGroupQuery.getResultList()");
-                                       throw new PersistenceException("Query failed trying to check for existing group");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception on checkGroupQuery.getResultList()");
+                                       throw new PersistenceException(queryFailedToCheckExisting);
                                }
-                               if(checkGroupQueryList.size() > 0){
+                               if(!checkGroupQueryList.isEmpty()){
                                        PolicyLogger.error("The group being added already exists with id "+groupId);
                                        throw new PersistenceException("The group being added already exists with id "+groupId);
                                }
@@ -2380,22 +2100,22 @@ public class PolicyDBDao {
 
                        synchronized(emLock){
                                checkBeforeOperationRun();
-                               Query getGroupQuery = em.createQuery("SELECT g FROM GroupEntity g WHERE g.groupId=:groupId AND g.deleted=:deleted");
-                               getGroupQuery.setParameter("groupId", group.getId());
-                               getGroupQuery.setParameter("deleted", false);
+                               Query getGroupQuery = em.createQuery(groupEntitySelectQuery);
+                               getGroupQuery.setParameter(groupIdVar, group.getId());
+                               getGroupQuery.setParameter(deletedVar, false);
                                List<?> getGroupQueryList;
                                try{
                                        getGroupQueryList = getGroupQuery.getResultList();
                                } catch(Exception e){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception on getGroupQuery.getResultList()");
-                                       throw new PersistenceException("Query failed trying to get group "+group.getId()+" for editing");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception on getGroupQuery.getResultList()");
+                                       throw new PersistenceException(queryFailedToGetGroup+group.getId()+" for editing");
                                }
-                               if(getGroupQueryList.size() < 1){
+                               if(getGroupQueryList.isEmpty()){
                                        PolicyLogger.error("The group cannot be found to update with id "+group.getId());
                                        throw new PersistenceException("The group cannot be found to update with id "+group.getId());
                                } else if(getGroupQueryList.size() > 1){
-                                       PolicyLogger.error("Somehow, more than one group with the same id "+group.getId()+" and deleted status were found in the database");
-                                       throw new PersistenceException("Somehow, more than one group with the same id "+group.getId()+" and deleted status were found in the database");
+                                       PolicyLogger.error(duplicateGroupId+group.getId()+deletedStatusFound);
+                                       throw new PersistenceException(duplicateGroupId+group.getId()+deletedStatusFound);
                                }
                                GroupEntity groupToUpdateInDB = (GroupEntity)getGroupQueryList.get(0);
                                if(!stringEquals(groupToUpdateInDB.getModifiedBy(), username)){
@@ -2409,7 +2129,7 @@ public class PolicyDBDao {
                                try {
                                        oldGroup = (StdPDPGroup) papEngine.getGroup(group.getId());
                                } catch (PAPException e1) {
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e1, "PolicyDBDao", "We cannot get the group from the papEngine to delete policies");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e1, policyDBDaoVar, "We cannot get the group from the papEngine to delete policies");
                                }
                                if(oldGroup == null){
                                        PolicyLogger.error("We cannot get the group from the papEngine to delete policies");
@@ -2427,12 +2147,10 @@ public class PolicyDBDao {
                                                        try{
                                                                if(scopeAndName!=null){
                                                                        policyToDelete = getPolicy(scopeAndName[0],scopeAndName[1]);
-                                                               
                                                                        if ("XACMLPapServlet.doDelete".equals(username)) {
-       
                                                                                Iterator<PolicyEntity> dbPolicyIt = groupToUpdateInDB.getPolicies().iterator();
                                                                                String policyName = getPolicyNameAndVersionFromPolicyFileName(policyToDelete.getPolicyName())[0];
-                                                               
+                                                       
                                                                                logger.info("PolicyDBDao: delete policy from GroupEntity");
                                                                                try{
                                                                                        while(dbPolicyIt.hasNext()){
@@ -2451,10 +2169,9 @@ public class PolicyDBDao {
                                                                                        PolicyLogger.error("Could not delete policy with name: "+ policyToDelete.getScope()+"."+policyToDelete.getPolicyName()+"\n ID: "+ policyToDelete.getPolicyId());
                                                                }
                                                                        }
-                                                               }
-                                                               
+                                                               }       
                                                        }catch(Exception e){
-                                                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Could not get policy to remove: "+pol.getId());
+                                                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Could not get policy to remove: "+pol.getId());
                                                                throw new PersistenceException("Could not get policy to remove: "+pol.getId());
                                                        }
                                                }
@@ -2464,17 +2181,17 @@ public class PolicyDBDao {
                                if(group.getName() != null && !stringEquals(group.getName(),groupToUpdateInDB.getgroupName())){
                                        //we need to check if the new id exists in the database
                                        String newGroupId = createNewPDPGroupId(group.getName());
-                                       Query checkGroupQuery = em.createQuery("SELECT g FROM GroupEntity g WHERE g.groupId=:groupId AND g.deleted=:deleted");
-                                       checkGroupQuery.setParameter("groupId", newGroupId);
-                                       checkGroupQuery.setParameter("deleted", false);
+                                       Query checkGroupQuery = em.createQuery(groupEntitySelectQuery);
+                                       checkGroupQuery.setParameter(groupIdVar, newGroupId);
+                                       checkGroupQuery.setParameter(deletedVar, false);
                                        List<?> checkGroupQueryList;
                                        try{
                                                checkGroupQueryList = checkGroupQuery.getResultList();
                                        } catch(Exception e){
-                                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception on checkGroupQuery.getResultList()");
-                                               throw new PersistenceException("Query failed trying to check for existing group");
+                                               PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception on checkGroupQuery.getResultList()");
+                                               throw new PersistenceException(queryFailedToCheckExisting);
                                        }
-                                       if(checkGroupQueryList.size() != 0){
+                                       if(!checkGroupQueryList.isEmpty()){
                                                PolicyLogger.error("The new group name already exists, group id "+newGroupId);
                                                throw new PersistenceException("The new group name already exists, group id "+newGroupId);
                                        }
@@ -2482,7 +2199,6 @@ public class PolicyDBDao {
                                        groupToUpdateInDB.setGroupName(group.getName());
                                        this.newGroupId = group.getId();
                                }
-
                                em.flush();
                                this.groupId = groupToUpdateInDB.getGroupKey();
                        }
@@ -2494,37 +2210,34 @@ public class PolicyDBDao {
                        if(isNullOrEmpty(pdpID, groupID,pdpName,username)){
                                throw new IllegalArgumentException("pdpID, groupID, pdpName, and username must not be null or empty");
                        }
-                       if(!(pdpDescription instanceof String)){
-                               pdpDescription = "";
-                       }
                        synchronized(emLock){
                                checkBeforeOperationRun();
-                               Query checkGroupQuery = em.createQuery("SELECT g FROM GroupEntity g WHERE g.groupId=:groupId AND g.deleted=:deleted");
-                               checkGroupQuery.setParameter("groupId", groupID);
-                               checkGroupQuery.setParameter("deleted", false);
+                               Query checkGroupQuery = em.createQuery(groupEntitySelectQuery);
+                               checkGroupQuery.setParameter(groupIdVar, groupID);
+                               checkGroupQuery.setParameter(deletedVar, false);
                                List<?> checkGroupQueryList;
                                try{
                                        checkGroupQueryList = checkGroupQuery.getResultList();
                                } catch(Exception e){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception trying to check for existing group on checkGroupQuery.getResultList()");
-                                       throw new PersistenceException("Query failed trying to check for existing group");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception trying to check for existing group on checkGroupQuery.getResultList()");
+                                       throw new PersistenceException(queryFailedToCheckExisting);
                                }
                                if(checkGroupQueryList.size() != 1){
                                        PolicyLogger.error("The group does not exist");
                                        throw new PersistenceException("The group does not exist");
                                }
-                               Query checkDuplicateQuery = em.createQuery("SELECT p FROM PdpEntity p WHERE p.pdpId=:pdpId AND p.deleted=:deleted");
-                               checkDuplicateQuery.setParameter("pdpId", pdpID);
-                               checkDuplicateQuery.setParameter("deleted", false);
+                               Query checkDuplicateQuery = em.createQuery(pdpEntitySelectQuery);
+                               checkDuplicateQuery.setParameter(pdpIdVariable, pdpID);
+                               checkDuplicateQuery.setParameter(deletedVar, false);
                                List<?> checkDuplicateList;
                                try{
                                        checkDuplicateList = checkDuplicateQuery.getResultList();
                                } catch(Exception e){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception trying to check for duplicate PDP "+pdpID+" on checkDuplicateQuery.getResultList()");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception trying to check for duplicate PDP "+pdpID+" on checkDuplicateQuery.getResultList()");
                                        throw new PersistenceException("Query failed trying to check for duplicate PDP "+pdpID);
                                }
                                PdpEntity newPdp;
-                               if(checkDuplicateList.size() > 0){
+                               if(!checkDuplicateList.isEmpty()){
                                        logger.warn("PDP already exists with id "+pdpID);                               
                                        newPdp = (PdpEntity)checkDuplicateList.get(0);
                                } else {
@@ -2543,7 +2256,6 @@ public class PolicyDBDao {
 
                                em.flush();
                                this.pdpId = newPdp.getPdpKey();
-
                        }
                }
 
@@ -2560,22 +2272,22 @@ public class PolicyDBDao {
 
                        synchronized(emLock){
                                checkBeforeOperationRun();
-                               Query getPdpQuery = em.createQuery("SELECT p FROM PdpEntity p WHERE p.pdpId=:pdpId AND p.deleted=:deleted");
-                               getPdpQuery.setParameter("pdpId", pdp.getId());
-                               getPdpQuery.setParameter("deleted", false);
+                               Query getPdpQuery = em.createQuery(pdpEntitySelectQuery);
+                               getPdpQuery.setParameter(pdpIdVariable, pdp.getId());
+                               getPdpQuery.setParameter(deletedVar, false);
                                List<?> getPdpQueryList;
                                try{
                                        getPdpQueryList = getPdpQuery.getResultList();
                                } catch(Exception e){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception on getPdpQuery.getResultList()");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception on getPdpQuery.getResultList()");
                                        throw new PersistenceException("Query failed trying to get PDP "+pdp.getId());
                                }
-                               if(getPdpQueryList.size() < 1){
+                               if(getPdpQueryList.isEmpty()){
                                        PolicyLogger.error("The pdp cannot be found to update with id "+pdp.getId());
                                        throw new PersistenceException("The pdp cannot be found to update with id "+pdp.getId());
                                } else if(getPdpQueryList.size() > 1){
-                                       PolicyLogger.error("Somehow, more than one pdp with the same id "+pdp.getId()+" and deleted status were found in the database");
-                                       throw new PersistenceException("Somehow, more than one pdp with the same id "+pdp.getId()+" and deleted status were found in the database");
+                                       PolicyLogger.error(moreThanOnePDP+pdp.getId()+deletedStatusFound);
+                                       throw new PersistenceException(moreThanOnePDP+pdp.getId()+deletedStatusFound);
                                }
                                PdpEntity pdpToUpdate = (PdpEntity)getPdpQueryList.get(0);
                                if(!stringEquals(pdpToUpdate.getModifiedBy(), username)){
@@ -2609,33 +2321,33 @@ public class PolicyDBDao {
                        synchronized(emLock){
                                checkBeforeOperationRun();
                                //check if pdp exists
-                               Query getPdpQuery = em.createQuery("SELECT p FROM PdpEntity p WHERE p.pdpId=:pdpId AND p.deleted=:deleted");
-                               getPdpQuery.setParameter("pdpId", pdp.getId());
-                               getPdpQuery.setParameter("deleted", false);
+                               Query getPdpQuery = em.createQuery(pdpEntitySelectQuery);
+                               getPdpQuery.setParameter(pdpIdVariable, pdp.getId());
+                               getPdpQuery.setParameter(deletedVar, false);
                                List<?> getPdpQueryList;
                                try{
                                        getPdpQueryList = getPdpQuery.getResultList();
                                } catch(Exception e){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception on getPdpQuery.getResultList()");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception on getPdpQuery.getResultList()");
                                        throw new PersistenceException("Query failed trying to get pdp to move with id "+pdp.getId());
                                }
-                               if(getPdpQueryList.size() < 1){
+                               if(getPdpQueryList.isEmpty()){
                                        PolicyLogger.error("The pdp cannot be found to move with id "+pdp.getId());
                                        throw new PersistenceException("The pdp cannot be found to move with id "+pdp.getId());
                                } else if(getPdpQueryList.size() > 1){
-                                       PolicyLogger.error("Somehow, more than one pdp with the same id "+pdp.getId()+" and deleted status were found in the database");
-                                       throw new PersistenceException("Somehow, more than one pdp with the same id "+pdp.getId()+" and deleted status were found in the database");
+                                       PolicyLogger.error(moreThanOnePDP+pdp.getId()+deletedStatusFound);
+                                       throw new PersistenceException(moreThanOnePDP+pdp.getId()+deletedStatusFound);
                                }
 
                                //check if new group exists
-                               Query checkGroupQuery = em.createQuery("SELECT g FROM GroupEntity g WHERE g.groupId=:groupId AND g.deleted=:deleted");
-                               checkGroupQuery.setParameter("groupId", group.getId());
-                               checkGroupQuery.setParameter("deleted", false);
+                               Query checkGroupQuery = em.createQuery(groupEntitySelectQuery);
+                               checkGroupQuery.setParameter(groupIdVar, group.getId());
+                               checkGroupQuery.setParameter(deletedVar, false);
                                List<?> checkGroupQueryList;
                                try{
                                        checkGroupQueryList = checkGroupQuery.getResultList();
                                } catch(Exception e){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception trying to get group on checkGroupQuery.getResultList()");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception trying to get group on checkGroupQuery.getResultList()");
                                        throw new PersistenceException("Query failed trying to get new group "+group.getId());
                                }
                                if(checkGroupQueryList.size() != 1){
@@ -2666,22 +2378,22 @@ public class PolicyDBDao {
 
                        synchronized(emLock){
                                checkBeforeOperationRun();
-                               Query getGroupQuery = em.createQuery("SELECT g FROM GroupEntity g WHERE g.groupId=:groupId AND g.deleted=:deleted");
-                               getGroupQuery.setParameter("groupId", group.getId());
-                               getGroupQuery.setParameter("deleted", false);
+                               Query getGroupQuery = em.createQuery(groupEntitySelectQuery);
+                               getGroupQuery.setParameter(groupIdVar, group.getId());
+                               getGroupQuery.setParameter(deletedVar, false);
                                List<?> getGroupQueryList;
                                try{
                                        getGroupQueryList = getGroupQuery.getResultList();
                                } catch(Exception e){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception on getGroupQuery.getResultList()");
-                                       throw new PersistenceException("Query failed trying to get group "+group.getId());
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception on getGroupQuery.getResultList()");
+                                       throw new PersistenceException(queryFailedToGetGroup+group.getId());
                                }
-                               if(getGroupQueryList.size() < 1){
+                               if(getGroupQueryList.isEmpty()){
                                        PolicyLogger.error("The group cannot be found to set default with id "+group.getId());                          
                                        throw new PersistenceException("The group cannot be found to set default with id "+group.getId());
                                } else if(getGroupQueryList.size() > 1){
-                                       PolicyLogger.error("Somehow, more than one group with the same id "+group.getId()+" and deleted status were found in the database");
-                                       throw new PersistenceException("Somehow, more than one group with the same id "+group.getId()+" and deleted status were found in the database");
+                                       PolicyLogger.error(duplicateGroupId+group.getId()+deletedStatusFound);
+                                       throw new PersistenceException(duplicateGroupId+group.getId()+deletedStatusFound);
                                }
                                GroupEntity newDefaultGroup = (GroupEntity)getGroupQueryList.get(0);
                                newDefaultGroup.setDefaultGroup(true);
@@ -2694,15 +2406,14 @@ public class PolicyDBDao {
                                Query setAllGroupsNotDefault = em.createQuery("UPDATE GroupEntity g SET g.defaultGroup=:defaultGroup WHERE g.deleted=:deleted AND g.groupKey<>:groupKey");
                                //not going to set modified by for all groups
                                setAllGroupsNotDefault.setParameter("defaultGroup", false);
-                               setAllGroupsNotDefault.setParameter("deleted", false);
+                               setAllGroupsNotDefault.setParameter(deletedVar, false);
                                setAllGroupsNotDefault.setParameter("groupKey", newDefaultGroup.getGroupKey());
                                try{
                                        logger.info("set " + setAllGroupsNotDefault.executeUpdate() + " groups as not default");
                                } catch(Exception e){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception on setAllGroupsNotDefault.executeUpdate()");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception on setAllGroupsNotDefault.executeUpdate()");
                                        throw new PersistenceException("Could not set all other groups default to false");
                                }
-
                                em.flush();
                        }
                }
@@ -2724,52 +2435,52 @@ public class PolicyDBDao {
                        }
                        synchronized(emLock){
                                checkBeforeOperationRun();
-                               Query deleteGroupQuery = em.createQuery("SELECT g FROM GroupEntity g WHERE g.groupId=:groupId AND g.deleted=:deleted");
-                               deleteGroupQuery.setParameter("groupId", group.getId());
-                               deleteGroupQuery.setParameter("deleted", false);
+                               Query deleteGroupQuery = em.createQuery(groupEntitySelectQuery);
+                               deleteGroupQuery.setParameter(groupIdVar, group.getId());
+                               deleteGroupQuery.setParameter(deletedVar, false);
                                List<?> deleteGroupQueryList;
                                try{
                                        deleteGroupQueryList = deleteGroupQuery.getResultList();
                                } catch(Exception e){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception trying to check if group exists deleteGroupQuery.getResultList()");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception trying to check if group exists deleteGroupQuery.getResultList()");
                                        throw new PersistenceException("Query failed trying to check if group exists");
                                }
-                               if(deleteGroupQueryList.size() < 1){
-                                       logger.warn("The group could not be found with id " + group.getId());
+                               if(deleteGroupQueryList.isEmpty()){
+                                       logger.warn(groupCannotBeFound + group.getId());
                                        return;
                                } else if(deleteGroupQueryList.size() > 1){
-                                       PolicyLogger.error("Somehow, more than one group with the id "+group.getId()+" were found in the database that are not deleted");
-                                       throw new PersistenceException("Somehow, more than one group with the id "+group.getId()+" were found in the database that are not deleted");
+                                       PolicyLogger.error(duplicateGroupId+group.getId()+foundInDBNotDeleted);
+                                       throw new PersistenceException(duplicateGroupId+group.getId()+foundInDBNotDeleted);
                                }                               
 
                                Query pdpsInGroupQuery = em.createQuery("SELECT p FROM PdpEntity p WHERE p.groupEntity=:group and p.deleted=:deleted");
                                pdpsInGroupQuery.setParameter("group", ((GroupEntity)deleteGroupQueryList.get(0)));
-                               pdpsInGroupQuery.setParameter("deleted", false);
+                               pdpsInGroupQuery.setParameter(deletedVar, false);
                                List<?> pdpsInGroupList;
                                try{
                                        pdpsInGroupList = pdpsInGroupQuery.getResultList();
                                } catch(Exception e){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception trying to get PDPs in group on pdpsInGroupQuery.getResultList()");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception trying to get PDPs in group on pdpsInGroupQuery.getResultList()");
                                        throw new PersistenceException("Query failed trying to get PDPs in group");
                                }
-                               if(pdpsInGroupList.size() > 0){
+                               if(!pdpsInGroupList.isEmpty()){
                                        if(moveToGroup != null){
                                                Query checkMoveToGroupQuery = em.createQuery("SELECT o FROM GroupEntity o WHERE o.groupId=:groupId AND o.deleted=:deleted");
-                                               checkMoveToGroupQuery.setParameter("groupId", moveToGroup.getId());
-                                               checkMoveToGroupQuery.setParameter("deleted", false);
+                                               checkMoveToGroupQuery.setParameter(groupIdVar, moveToGroup.getId());
+                                               checkMoveToGroupQuery.setParameter(deletedVar, false);
                                                List<?> checkMoveToGroupList;
                                                try{
                                                        checkMoveToGroupList = checkMoveToGroupQuery.getResultList();
                                                } catch(Exception e){
-                                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception trying to check if group exists checkMoveToGroupQuery.getResultList()");
+                                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception trying to check if group exists checkMoveToGroupQuery.getResultList()");
                                                        throw new PersistenceException("Query failed trying to check if group exists");
                                                }
-                                               if(checkMoveToGroupList.size() < 1){
-                                                       PolicyLogger.error("The group could not be found with id " + moveToGroup.getId());
-                                                       throw new PersistenceException("The group could not be found with id " + moveToGroup.getId());
+                                               if(checkMoveToGroupList.isEmpty()){
+                                                       PolicyLogger.error(groupCannotBeFound + moveToGroup.getId());
+                                                       throw new PersistenceException(groupCannotBeFound + moveToGroup.getId());
                                                } else if(checkMoveToGroupList.size() > 1){
-                                                       PolicyLogger.error("Somehow, more than one group with the id "+moveToGroup.getId()+" were found in the database that are not deleted");
-                                                       throw new PersistenceException("Somehow, more than one group with the id "+moveToGroup.getId()+" were found in the database that are not deleted");
+                                                       PolicyLogger.error(duplicateGroupId+moveToGroup.getId()+foundInDBNotDeleted);
+                                                       throw new PersistenceException(duplicateGroupId+moveToGroup.getId()+foundInDBNotDeleted);
                                                } else {
                                                        GroupEntity newGroup = (GroupEntity)checkMoveToGroupList.get(0);
                                                        for(Object pdpObject : pdpsInGroupList){
@@ -2779,11 +2490,10 @@ public class PolicyDBDao {
                                                                        pdp.setModifiedBy(username);
                                                                }
                                                                try{
-
                                                                        em.flush();
                                                                        this.newGroupId = newGroup.getGroupId();
                                                                } catch(PersistenceException e){
-                                                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught PersistenceException trying to set pdp group to null on em.flush()");
+                                                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught PersistenceException trying to set pdp group to null on em.flush()");
                                                                        throw new PersistenceException("Query failed trying to set pdp group to ");
                                                                }
                                                        }
@@ -2814,22 +2524,22 @@ public class PolicyDBDao {
                        synchronized(emLock){
                                checkBeforeOperationRun();
                                //check if group exists
-                               Query groupQuery = em.createQuery("SELECT g FROM GroupEntity g WHERE g.groupId=:groupId AND g.deleted=:deleted");
-                               groupQuery.setParameter("groupId", groupID);
-                               groupQuery.setParameter("deleted", false);
+                               Query groupQuery = em.createQuery(groupEntitySelectQuery);
+                               groupQuery.setParameter(groupIdVar, groupID);
+                               groupQuery.setParameter(deletedVar, false);
                                List<?> groupQueryList;
                                try{
                                        groupQueryList = groupQuery.getResultList();
                                }catch(Exception e){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception trying to check if group exists groupQuery.getResultList()");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception trying to check if group exists groupQuery.getResultList()");
                                        throw new PersistenceException("Query failed trying to check if group "+groupID+" exists");
                                }
-                               if(groupQueryList.size() < 1){
+                               if(groupQueryList.isEmpty()){
                                        PolicyLogger.error("Group policy is being added to does not exist with id "+groupID);
                                        throw new PersistenceException("Group policy is being added to does not exist with id "+groupID);
                                } else if(groupQueryList.size() > 1){
-                                       PolicyLogger.error("Somehow, more than one group with the id "+groupID+" were found in the database that are not deleted");
-                                       throw new PersistenceException("Somehow, more than one group with the id "+groupID+" were found in the database that are not deleted");
+                                       PolicyLogger.error(duplicateGroupId+groupID+foundInDBNotDeleted);
+                                       throw new PersistenceException(duplicateGroupId+groupID+foundInDBNotDeleted);
                                }
                                                                
                                //we need to convert the form of the policy id that is used groups into the form that is used 
@@ -2837,22 +2547,22 @@ public class PolicyDBDao {
                                String[] policyNameScopeAndVersion = getNameScopeAndVersionFromPdpPolicy(policyID);                     
                                Query policyQuery = em.createQuery("SELECT p FROM PolicyEntity p WHERE p.policyName=:policyName AND p.scope=:scope AND p.deleted=:deleted");
                                policyQuery.setParameter("policyName", policyNameScopeAndVersion[0]);
-                               policyQuery.setParameter("scope", policyNameScopeAndVersion[1]);                        
-                               policyQuery.setParameter("deleted", false);
+                               policyQuery.setParameter(scope, policyNameScopeAndVersion[1]);                  
+                               policyQuery.setParameter(deletedVar, false);
                                List<?> policyQueryList;
                                try{
                                        policyQueryList = policyQuery.getResultList();
                                } catch(Exception e){
                                        logger.debug(e);
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception trying to check if policy exists policyQuery.getResultList()");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception trying to check if policy exists policyQuery.getResultList()");
                                        throw new PersistenceException("Query failed trying to check if policy "+policyNameScopeAndVersion[0]+" exists");
                                }
-                               if(policyQueryList.size() < 1){
+                               if(policyQueryList.isEmpty()){
                                        PolicyLogger.error("Policy being added to the group does not exist with policy id "+policyNameScopeAndVersion[0]);
                                        throw new PersistenceException("Policy being added to the group does not exist with policy id "+policyNameScopeAndVersion[0]);                          
                                } else if(policyQueryList.size() > 1){
-                                       PolicyLogger.error("Somehow, more than one policy with the id "+policyNameScopeAndVersion[0]+" were found in the database that are not deleted");
-                                       throw new PersistenceException("Somehow, more than one group with the id "+policyNameScopeAndVersion[0]+" were found in the database that are not deleted");
+                                       PolicyLogger.error(duplicatePolicyId+policyNameScopeAndVersion[0]+foundInDBNotDeleted);
+                                       throw new PersistenceException(duplicateGroupId+policyNameScopeAndVersion[0]+foundInDBNotDeleted);
                                }
                                logger.info("PolicyDBDao: Getting group and policy from database");
                                GroupEntity group = (GroupEntity)groupQueryList.get(0);
@@ -2877,17 +2587,14 @@ public class PolicyDBDao {
                                em.flush();
                                
                                // After adding policy to the db group we need to make sure the filesytem group is in sync with the db group
-                               StdPDPGroup pdpGroup = null;
-                               StdPDPGroup updatedGroup = null;
                                try {
-                                       pdpGroup = (StdPDPGroup) papEngine.getGroup(group.getGroupId());
-                                       updatedGroup = synchronizeGroupPoliciesInFileSystem(pdpGroup, group);
+                                       StdPDPGroup pdpGroup = (StdPDPGroup) papEngine.getGroup(group.getGroupId());
+                                       return synchronizeGroupPoliciesInFileSystem(pdpGroup, group);
                                } catch (PAPException e) {
                                        logger.debug(e);
                                        PolicyLogger.error("PolicyDBDao: Could not synchronize the filesystem group with the database group. " + e.getMessage());
                                }
-
-                               return updatedGroup;
+                               return null;
                        }
                }
 
@@ -2900,20 +2607,20 @@ public class PolicyDBDao {
                        }
                        synchronized(emLock){
                                checkBeforeOperationRun();
-                               Query pdpQuery = em.createQuery("SELECT p FROM PdpEntity p WHERE p.pdpId=:pdpId AND p.deleted=:deleted");
-                               pdpQuery.setParameter("pdpId", pdpID);
-                               pdpQuery.setParameter("deleted", false);
+                               Query pdpQuery = em.createQuery(pdpEntitySelectQuery);
+                               pdpQuery.setParameter(pdpIdVariable, pdpID);
+                               pdpQuery.setParameter(deletedVar, false);
                                List<?> pdpList;
                                try{
                                        pdpList = pdpQuery.getResultList();
                                } catch(Exception e){
-                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception trying to check if pdp exists  pdpQuery.getResultList()");
+                                       PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught Exception trying to check if pdp exists  pdpQuery.getResultList()");
                                        throw new PersistenceException("Query failed trying to check if pdp "+pdpID+" exists");
                                }
                                if(pdpList.size() > 1){
-                                       PolicyLogger.error("Somehow, more than one pdp with the id "+pdpID+" were found in the database that are not deleted");
-                                       throw new PersistenceException("Somehow, more than one pdp with the id "+pdpID+" were found in the database that are not deleted");
-                               } else if(pdpList.size() < 1){
+                                       PolicyLogger.error("Somehow, more than one pdp with the id "+pdpID+foundInDBNotDeleted);
+                                       throw new PersistenceException("Somehow, more than one pdp with the id "+pdpID+foundInDBNotDeleted);
+                               } else if(pdpList.isEmpty()){
                                        PolicyLogger.error("Pdp being removed does not exist with id "+pdpID);
                                        return;
                                }
@@ -2931,7 +2638,7 @@ public class PolicyDBDao {
        }
 
        private PolicyDBDao(){
-
+               //empty constructor
        }
        
        public static PolicyDBDaoTestClass getPolicyDBDaoTestClass(){
@@ -2942,15 +2649,9 @@ public class PolicyDBDao {
                String getConfigFile(String filename, String scope, PolicyRestAdapter policy){
                        return scope + "." + PolicyDBDao.this.getConfigFile(filename, policy);
                }
-               String computeScope(String fullPath, String pathToExclude){
-                       return PolicyDBDao.computeScope(fullPath, pathToExclude);
-               }
-               String getDescriptionFromXacml(String xacmlData){
-                       return PolicyDBDao.getDescriptionFromXacml(xacmlData);
-               }
         String[] getPolicyNameAndVersionFromPolicyFileName(String originalPolicyName) throws PolicyDBException{
             return PolicyDBDao.this.getPolicyNameAndVersionFromPolicyFileName(originalPolicyName);
         }
        }
 
-}
\ No newline at end of file
+}
index 70b8e80..8bfcab9 100644 (file)
@@ -58,17 +58,6 @@ public interface PolicyDBDaoTransaction {
         */
        public boolean isTransactionOpen();
        
-       
-       
-       /**
-        * Delete an existing policy
-        * @param policyToDelete The file path of the policy to delete
-        * @throws IllegalArgumentException If the file path given can not be parsed
-        * @throws IllegalStateException If a transaction is open that has not yet been committed
-        * @throws PolicyDBException If a database error occurs
-        */
-       public void deletePolicy(String policyToDelete) throws PolicyDBException;
-       
        /**
         * Rollback (undo) the current transaction.
         */
@@ -184,9 +173,4 @@ public interface PolicyDBDaoTransaction {
        public GroupEntity getGroup(String groupId);
        public List<?> getPdpsInGroup(long groupKey);
        public PdpEntity getPdp(long pdpKey);
-
-       void renamePolicy(String oldPath, String newPath,String username);
-
-       void clonePolicy(String oldPolicyPath, String newPolicyPath, String username);
-               
 }
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/model/PDPPolicyContainer.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/model/PDPPolicyContainer.java
deleted file mode 100644 (file)
index 23aa761..0000000
+++ /dev/null
@@ -1,345 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-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=========================================================
- */
-
-package org.onap.policy.pap.xacml.rest.model;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
-import org.onap.policy.pap.xacml.rest.util.PolicyContainer;
-import org.onap.policy.pap.xacml.rest.util.PolicyItemSetChangeNotifier;
-import org.onap.policy.xacml.api.XACMLErrorConstants;
-import org.onap.policy.xacml.std.pap.StdPDPPolicy;
-
-import com.att.research.xacml.api.pap.PDP;
-import com.att.research.xacml.api.pap.PDPGroup;
-import com.att.research.xacml.api.pap.PDPPolicy;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements PolicyContainer.Indexed {
-       private static final long serialVersionUID = 1L;
-       private static Logger logger    = FlexLogger.getLogger(PDPPolicyContainer.class);
-       
-        /**
-     * String identifier of a file's "Id" property.
-     */
-    public static final String PROPERTY_ID = "Id";
-
-   /**
-     * String identifier of a file's "name" property.
-     */
-    public static final String PROPERTY_NAME = "Name";
-
-    /**
-      * String identifier of a file's "name" property.
-      */
-     public static final String PROPERTY_VERSION = "Version";
-     
-    /**
-     * String identifier of a file's "Description" property.
-     */
-    public static final String PROPERTY_DESCRIPTION = "Description";
-    
-    /**
-     * String identifier of a file's "IsRoot" property.
-     */
-    public static final String PROPERTY_ISROOT = "Root";
-
-    /**
-     * List of the string identifiers for the available properties.
-     */
-    private static Collection<String> pdpPolicyProperties;
-    private final transient Object data;
-    private transient List<PDPPolicy> policies;
-    
-       @SuppressWarnings("unchecked")
-       public PDPPolicyContainer(Object data) {
-               super();
-               this.data = data;
-               if (this.data instanceof PDPGroup) {
-                       policies = new ArrayList<> (((PDPGroup) this.data).getPolicies());
-               }
-               if (this.data instanceof PDP) {
-                       policies = new ArrayList<> (((PDP) this.data).getPolicies());
-               }
-               if (this.data instanceof Set) {
-                       policies = new ArrayList<> ((Set<PDPPolicy>)data);
-               }
-               if (this.policies == null) {
-                       logger.info("NULL policies");
-                       throw new NullPointerException("PDPPolicyContainer created with unexpected Object type '" + data.getClass().getName() + "'");
-               }
-               this.setContainer(this);
-       }
-       
-       @Override
-       public Object nextItemId(Object itemId) {
-               if (logger.isTraceEnabled()) {
-                       logger.trace("nextItemId: " + itemId);
-               }
-               int index = this.policies.indexOf(itemId);
-               if (index == -1 || ((index + 1) >= this.policies.size())) {
-                       return null;
-               }               
-               return new PDPPolicyItem(this.policies.get(index + 1));
-       }
-
-       @Override
-       public Object prevItemId(Object itemId) {
-               if (logger.isTraceEnabled()) {
-                       logger.trace("prevItemId: " + itemId);
-               }
-               int index = this.policies.indexOf(itemId);
-               if (index <= 0) {
-                       return null;
-               }
-               return new PDPPolicyItem(this.policies.get(index - 1));
-       }
-
-       @Override
-       public Object firstItemId() {
-               if (logger.isTraceEnabled()) {
-                       logger.trace("firstItemId: ");
-               }
-               if (this.policies.isEmpty()) {
-                       return null;
-               }
-               return new PDPPolicyItem(this.policies.get(0));
-       }
-
-       @Override
-       public Object lastItemId() {
-               if (logger.isTraceEnabled()) {
-                       logger.trace("lastItemid: ");
-               }
-               if (this.policies.isEmpty()) {
-                       return null;
-               }
-               return new PDPPolicyItem(this.policies.get(this.policies.size() - 1));
-       }
-
-       @Override
-       public boolean isFirstId(Object itemId) {
-               if (logger.isTraceEnabled()) {
-                       logger.trace("isFirstId: " + itemId);
-               }
-               if (this.policies.isEmpty()) {
-                       return false;
-               }
-               return (itemId.equals(this.policies.get(0)));
-       }
-
-       @Override
-       public boolean isLastId(Object itemId) {
-               if (logger.isTraceEnabled()) {
-                       logger.trace("isLastId: " + itemId);
-               }
-               if (this.policies.isEmpty()) {
-                       return false;
-               }
-               return (itemId.equals(this.policies.get(this.policies.size() - 1)));
-       }
-
-       @Override
-       public Object addItemAfter(Object previousItemId){
-               return null;
-       }
-
-       @Override
-       public Collection<?> getContainerPropertyIds() {
-               return pdpPolicyProperties;
-       }
-
-       @Override
-       public Collection<?> getItemIds() {
-               final Collection<Object> items = new ArrayList<>();
-               items.addAll(this.policies);
-               return Collections.unmodifiableCollection(items);
-       }
-       
-       
-       @Override
-       public Class<?> getType(Object propertyId) {
-        if (propertyId.equals(PROPERTY_ID)) {
-            return String.class;
-        }
-        if (propertyId.equals(PROPERTY_NAME)) {
-            return String.class;
-        }
-        if (propertyId.equals(PROPERTY_VERSION)) {
-            return String.class;
-        }
-        if (propertyId.equals(PROPERTY_DESCRIPTION)) {
-            return String.class;
-        }
-        if (propertyId.equals(PROPERTY_ISROOT)) {
-            return Boolean.class;
-        }
-               return null;
-       }
-
-       @Override
-       public int size() {
-               if (logger.isTraceEnabled()) {
-                       logger.trace("size: " + this.policies.size());
-               }
-               return this.policies.size();
-       }
-
-       @Override
-       public boolean containsId(Object itemId) {
-               if (logger.isTraceEnabled()) {
-                       logger.trace("containsId: " + itemId);
-               }
-               return this.policies.contains(itemId);
-       }
-
-       @Override
-       public Object addItem(){
-               throw new UnsupportedOperationException("Cannot add an empty policy.");
-       }
-
-       @Override
-       public boolean removeItem(Object itemId){
-               if (logger.isTraceEnabled()) {
-                       logger.trace("removeItem: " + itemId);
-               }
-               ObjectMapper mapper = new ObjectMapper();
-               mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-               StdPDPPolicy pdpPolicy = null;
-               try {
-                       pdpPolicy = mapper.readValue(itemId.toString() , StdPDPPolicy.class);
-                       for(int i = 0; i< policies.size(); i++){
-                               if(policies.get(i).getId().equalsIgnoreCase(pdpPolicy.getId())){
-                                       return this.policies.remove(this.policies.get(i));
-                               }
-                       }
-               } catch (Exception e) {
-                       logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Exception Occured While Mapping the Removing Policy from PDP Group to Std Policy"+e);
-               }       
-               return this.policies.remove(itemId);
-       }
-
-       @Override
-       public boolean addContainerProperty(Object propertyId, Class<?> type,
-                       Object defaultValue){
-               return false;
-       }
-
-       @Override
-       public boolean removeContainerProperty(Object propertyId){
-               return false;
-       }
-
-       @Override
-       public boolean removeAllItems(){
-               return false;
-       }
-
-       @Override
-       public int indexOfId(Object itemId) {
-               if (logger.isTraceEnabled()) {
-                       logger.trace("indexOfId: " + itemId);
-               }
-               return this.policies.indexOf(itemId);
-       }
-
-       @Override
-       public Object getIdByIndex(int index) {
-               if (logger.isTraceEnabled()) {
-                       logger.trace("getIdByIndex: " + index);
-               }
-               return this.policies.get(index);
-       }
-
-       @Override
-       public List<?> getItemIds(int startIndex, int numberOfItems) {
-               if (logger.isTraceEnabled()) {
-                       logger.trace("getItemIds: " + startIndex + " " + numberOfItems);
-               }
-               if (numberOfItems < 0) {
-                       throw new IllegalArgumentException();
-               }
-               return this.policies.subList(startIndex, startIndex + numberOfItems);
-       }
-
-       @Override
-       public Object addItemAt(int index) {
-               if (logger.isTraceEnabled()) {
-                       logger.trace("addItemAt: " + index);
-               }
-               return null;
-       }
-
-       public class PDPPolicyItem {
-               private final PDPPolicy policy;
-               
-               public PDPPolicyItem(PDPPolicy itemId) {
-                       this.policy = itemId;
-               }
-
-               public String getId() {
-                       if (logger.isTraceEnabled()) {
-                               logger.trace("getId: " + this.policy);
-                       }
-                       return this.policy.getId();
-               }
-               
-               public String getName() {
-                       if (logger.isTraceEnabled()) {
-                               logger.trace("getName: " + this.policy);
-                       }
-                       return this.policy.getName();
-               }
-               
-               public String getVersion() {
-                       if (logger.isTraceEnabled()) {
-                               logger.trace("getVersion: " + this.policy);
-                       }
-                       return this.policy.getVersion();
-               }
-               
-               public String getDescription() {
-                       if (logger.isTraceEnabled()) {
-                               logger.trace("getDescription: " + this.policy);
-                       }
-                       return this.policy.getDescription();
-               }
-               
-               public boolean getRoot() {
-                       if (logger.isTraceEnabled()) {
-                               logger.trace("isRoot: " + this.policy);
-                       }
-                       return this.policy.isRoot();
-               }
-               
-               public void setRoot(Boolean root) {
-                       ((StdPDPPolicy)this.policy).setRoot(root);
-               }
-       
-       }
-}
\ No newline at end of file
index d05a1ab..8c891bf 100644 (file)
@@ -24,6 +24,7 @@ import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
 
+import org.onap.policy.rest.util.PDPPolicyContainer;
 import org.onap.policy.xacml.api.pap.OnapPDPGroup;
 import org.onap.policy.xacml.std.pap.StdPDPGroup;
 
index 415c779..48f67aa 100644 (file)
@@ -123,33 +123,33 @@ public class PolicyCreation extends AbstractPolicyCreation{
                        String policyType = policyData.getPolicyType();
 
                        String filePrefix = null;
-                       if (policyType.equalsIgnoreCase("Config")) {
+                       if ("Config".equalsIgnoreCase(policyType)) {
                                policyConfigType = policyData.getConfigPolicyType();
-                               if (policyConfigType.equalsIgnoreCase("Firewall Config")) {
+                               if ("Firewall Config".equalsIgnoreCase(policyConfigType)) {
                                        filePrefix = "Config_FW_";
-                               }else if (policyConfigType.equalsIgnoreCase("ClosedLoop_Fault")) {
+                               }else if ("ClosedLoop_Fault".equalsIgnoreCase(policyConfigType)) {
                                        filePrefix = "Config_Fault_";
-                               }else if (policyConfigType.equalsIgnoreCase("ClosedLoop_PM")) {
+                               }else if ("ClosedLoop_PM".equalsIgnoreCase(policyConfigType)) {
                                        filePrefix = "Config_PM_";
-                               }else if (policyConfigType.equalsIgnoreCase("Micro Service")) {
+                               }else if ("Micro Service".equalsIgnoreCase(policyConfigType)) {
                                        filePrefix = "Config_MS_";
-                               }else if (policyConfigType.equalsIgnoreCase("BRMS_Raw")) {
+                               }else if ("BRMS_Raw".equalsIgnoreCase(policyConfigType)) {
                                        filePrefix = "Config_BRMS_Raw_";
-                               }else if (policyConfigType.equalsIgnoreCase("BRMS_Param")) {
+                               }else if ("BRMS_Param".equalsIgnoreCase(policyConfigType)) {
                                        filePrefix = "Config_BRMS_Param_";
                                }else {
                                        filePrefix = "Config_"; 
                                }
-                       } else if (policyType.equalsIgnoreCase("Action")) {
+                       } else if ("Action".equalsIgnoreCase(policyType)) {
                                filePrefix = "Action_";
-                       } else if (policyType.equalsIgnoreCase("Decision")) {
+                       } else if ("Decision".equalsIgnoreCase(policyType)) {
                                filePrefix = "Decision_";
                        }
 
                        int version = 0;
                        int highestVersion = 0;
-                       String createdBy = "";
-                       String modifiedBy = userId;
+                       String createdBy;
+                       String modifiedBy;
                        String scopeCheck = policyData.getDomainDir().replace(".", File.separator);
                        PolicyEditorScopes policyEditorScope = (PolicyEditorScopes) commonClassDao.getEntityItem(PolicyEditorScopes.class, "scopeName", scopeCheck);
                        if(policyEditorScope == null){
@@ -192,7 +192,7 @@ public class PolicyCreation extends AbstractPolicyCreation{
                                        response.setStatus(HttpServletResponse.SC_CONFLICT);
                                        response.addHeader("error", "policyExists");
                                        response.addHeader("policyName", policyData.getPolicyName());
-                                       return new ResponseEntity<String>(body, status);
+                                       return new ResponseEntity<>(body, status);
                                }               
                        }else{
                                // if policy does not exist and the request is updatePolicy return error
@@ -261,7 +261,7 @@ public class PolicyCreation extends AbstractPolicyCreation{
                                        if(policyData.getApiflag() == null){
                                                // If there is any dynamic field create the matches here
                                                String key="templateName";
-                                               String value=(String) policyData.getRuleName();
+                                               String value= policyData.getRuleName();
                                                drlRuleAndUIParams.put(key, value);
                                                if(policyData.getRuleData().size() > 0){
                                                        for(Object keyValue: policyData.getRuleData().keySet()){
@@ -360,7 +360,7 @@ public class PolicyCreation extends AbstractPolicyCreation{
                                                policyData.setActionDictMethod(jsonData.getMethod());
                                        }
                                }
-                               newPolicy = new ActionPolicy(policyData);
+                               newPolicy = new ActionPolicy(policyData, commonClassDao);
                        } else if (policyType.equalsIgnoreCase("Decision")) {
                                if(policyData.getApiflag() == null){
                                        Map<String, String> settingsMap = new HashMap<>();
@@ -374,7 +374,7 @@ public class PolicyCreation extends AbstractPolicyCreation{
                                        List<String> errorCodeList = new LinkedList<>();
                                        List<String> treatmentList = new LinkedList<>();
 
-                                       if(policyData.getSettings().size() > 0){
+                                       if(!policyData.getSettings().isEmpty()){
                                                for(Object settingsData : policyData.getSettings()){
                                                        if(settingsData instanceof LinkedHashMap<?, ?>){
                                                                String key = ((LinkedHashMap<?, ?>) settingsData).get("key").toString();
@@ -445,7 +445,7 @@ public class PolicyCreation extends AbstractPolicyCreation{
                                        policyData.setErrorCodeList(errorCodeList);
                                        policyData.setTreatmentList(treatmentList);
                                }
-                               newPolicy = new DecisionPolicy(policyData);
+                               newPolicy = new DecisionPolicy(policyData, commonClassDao);
                        }
 
                        if(newPolicy != null){
@@ -455,7 +455,7 @@ public class PolicyCreation extends AbstractPolicyCreation{
                                status = HttpStatus.INTERNAL_SERVER_ERROR;
                                response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);                                                               
                                response.addHeader("error", "error");
-                               return new ResponseEntity<String>(body, status);
+                               return new ResponseEntity<>(body, status);
                        }
                        
                        PolicyDBDaoTransaction policyDBDaoTransaction = null;
index e18ca9e..22c44a8 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP-PAP-REST
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
 
 package org.onap.policy.pap.xacml.rest.util;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
 import javax.persistence.Query;
-import javax.servlet.ServletException;
 
 import org.onap.policy.rest.XacmlAdminAuthorization;
-import org.onap.policy.rest.jpa.Attribute;
-import org.onap.policy.rest.jpa.Datatype;
-import org.onap.policy.rest.jpa.FunctionDefinition;
 import org.onap.policy.rest.jpa.GlobalRoleSettings;
 
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeSelectorType;
-
 import org.onap.policy.common.logging.flexlogger.FlexLogger; 
 import org.onap.policy.common.logging.flexlogger.Logger;
 
@@ -46,9 +34,6 @@ public class JPAUtils {
        private static final Logger LOGGER      = FlexLogger.getLogger(JPAUtils.class);
        
        private static EntityManagerFactory emf;
-       private static final Object mapAccess = new Object();
-       private static Map<Datatype, List<FunctionDefinition>> mapDatatype2Function = null;
-       private static Map<String, FunctionDefinition> mapID2Function = null;
        private static JPAUtils currentInstance = null;
        
        
@@ -76,109 +61,6 @@ public class JPAUtils {
                JPAUtils.emf = emf;     
        }
        
-       /**
-        * Gets the current instance of JPAUtils. 
-        * @return The instance of JPAUtils or throws exception if the given instance is null.
-        * @throws IllegalStateException if a JPAUtils instance is null. Call getJPAUtilsInstance(EntityManagerFactory emf) to get this.
-        */
-       public static JPAUtils getJPAUtilsInstance(){
-               LOGGER.debug("getJPAUtilsInstance() as getJPAUtilsInstance() called");
-               if(currentInstance != null){
-                       return currentInstance;
-               }
-               throw new IllegalStateException("The JPAUtils.currentInstance is Null.  Use getJPAUtilsInstance(EntityManagerFactory emf)");
-       }
-       
-       public static AttributeDesignatorType createDesignator(Attribute attribute) {
-               AttributeDesignatorType designator = new AttributeDesignatorType();
-               designator.setAttributeId(attribute.getXacmlId());
-               if (attribute.getCategoryBean() != null) {
-                       designator.setCategory(attribute.getCategoryBean().getXacmlId());
-               } else {
-                       LOGGER.warn("No category bean");
-               }
-               if (attribute.getDatatypeBean() != null) {
-                       designator.setDataType(attribute.getDatatypeBean().getXacmlId());
-               } else {
-                       LOGGER.warn("No datatype bean");
-               }
-               designator.setIssuer(attribute.getIssuer());
-               designator.setMustBePresent(attribute.isMustBePresent());
-               return designator;
-       }
-               
-       public static AttributeSelectorType     createSelector(Attribute attribute) {
-               AttributeSelectorType selector = new AttributeSelectorType();
-               selector.setContextSelectorId(attribute.getXacmlId());
-               selector.setPath(attribute.getSelectorPath());
-               if (attribute.getCategoryBean() != null) {
-                       selector.setCategory(attribute.getCategoryBean().getXacmlId());
-               } else {
-                       LOGGER.warn("No category bean");
-               }
-               if (attribute.getDatatypeBean() != null) {
-                       selector.setDataType(attribute.getDatatypeBean().getXacmlId());
-               } else {
-                       LOGGER.warn("No datatype bean");
-               }
-               selector.setMustBePresent(attribute.isMustBePresent());
-               return selector;
-       }
-       
-       /**
-        * Builds a map in memory of a functions return datatype to function definition. Useful in limiting the number
-        * of SQL calls to DB especially when we don't expect these to change much.
-        * 
-        * @return - A HashMap of Datatype JPA Container ID's to FunctionDefinition objects
-        */
-       public Map<Datatype, List<FunctionDefinition>>  getFunctionDatatypeMap() {              
-               
-               synchronized(mapAccess) {
-                       if (mapDatatype2Function == null||mapDatatype2Function.isEmpty()) {
-                               try {
-                                       buildFunctionMaps();
-                               } catch (ServletException e) {
-                                       LOGGER.error("Exception Occured"+e);
-                               }
-                       }
-               }
-               return mapDatatype2Function;
-       }
-       
-       public Map<String, FunctionDefinition> getFunctionIDMap() {
-               synchronized(mapAccess) {
-                       if (mapID2Function == null||mapID2Function.isEmpty()) {
-                               try {
-                                       buildFunctionMaps();
-                               } catch (ServletException e) {
-                                       LOGGER.error("Exception Occured"+e);
-                               }
-                       }
-               }
-               return mapID2Function;
-       }
-       
-       private static void buildFunctionMaps() throws ServletException {
-               mapDatatype2Function = new HashMap<>();
-               mapID2Function = new HashMap<>();
-
-               EntityManager em = emf.createEntityManager();
-               Query getFunctionDefinitions = em.createNamedQuery("FunctionDefinition.findAll");       
-               List<?> functionList = getFunctionDefinitions.getResultList();  
-               
-               for (Object id : functionList) {
-                       FunctionDefinition value = (FunctionDefinition)id;
-                       mapID2Function.put(value.getXacmlid(), value);
-                       if (!mapDatatype2Function.containsKey(value.getDatatypeBean())) {
-                               mapDatatype2Function.put(value.getDatatypeBean(), new ArrayList<FunctionDefinition>());
-                       }
-                       mapDatatype2Function.get(value.getDatatypeBean()).add(value);
-               }
-
-               em.close();
-               
-       }
-       
        /**
         * Returns the lockdown value, in case of exception it is assumed that lockdown functionality
         * is not supported and returns false.
@@ -233,7 +115,4 @@ public class JPAUtils {
                
                return globalRoleSettings.isLockdown();
        }
-       
-       
-
 }
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/PolicyContainer.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/PolicyContainer.java
deleted file mode 100644 (file)
index 5d2453b..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP 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.onap.policy.pap.xacml.rest.util;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.List;
-
-
-public interface PolicyContainer extends Serializable{
-       
-    public Collection<?> getContainerPropertyIds();
-    
-    public Collection<?> getItemIds();
-
-    public Class<?> getType(Object propertyId);
-
-    public int size();
-  
-    public boolean containsId(Object itemId);
-
-    public Object addItem() throws UnsupportedOperationException;
-    
-    public boolean removeItem(Object itemId)
-            throws UnsupportedOperationException;
-
-    public boolean addContainerProperty(Object propertyId, Class<?> type,
-            Object defaultValue) throws UnsupportedOperationException;
-   
-    public boolean removeContainerProperty(Object propertyId)
-            throws UnsupportedOperationException;
-
-    public boolean removeAllItems() throws UnsupportedOperationException;
-
-    public interface Ordered extends PolicyContainer {
-
-        public Object nextItemId(Object itemId);
-
-        public Object prevItemId(Object itemId);
-
-        public Object firstItemId();
-
-        public Object lastItemId();
-
-        public boolean isFirstId(Object itemId);
-
-        public boolean isLastId(Object itemId);
-
-        public Object addItemAfter(Object previousItemId)
-                throws UnsupportedOperationException;
-        
-    }
-
-    
-    public interface Indexed extends Ordered {
-
-        public int indexOfId(Object itemId);
-
-        public Object getIdByIndex(int index);
-
-        public List<?> getItemIds(int startIndex, int numberOfItems);
-        
-        public Object addItemAt(int index) throws UnsupportedOperationException;
-
-        public interface ItemAddEvent extends ItemSetChangeEvent {
-
-            public Object getFirstItemId();
-
-            public int getFirstIndex();
-
-            public int getAddedItemsCount();
-        }
-
-     
-        public interface ItemRemoveEvent extends ItemSetChangeEvent {
-          
-            public Object getFirstItemId();
-
-            public int getFirstIndex();
-
-            public int getRemovedItemsCount();
-        }
-    }
-  
-    public interface ItemSetChangeEvent extends Serializable {
-
-        public PolicyContainer getContainer();
-    }
-
-    public interface ItemSetChangeListener extends Serializable {
-
-        public void containerItemSetChange(PolicyContainer.ItemSetChangeEvent event);
-    }
-
-    public interface ItemSetChangeNotifier extends Serializable {
-
-        public void addItemSetChangeListener(
-                PolicyContainer.ItemSetChangeListener listener);
-
-        public void removeItemSetChangeListener(
-                PolicyContainer.ItemSetChangeListener listener);
-    }
-}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/PolicyItemSetChangeNotifier.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/PolicyItemSetChangeNotifier.java
deleted file mode 100644 (file)
index 5d7f785..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP 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.onap.policy.pap.xacml.rest.util;
-
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.EventObject;
-import java.util.LinkedList;
-
-import org.onap.policy.pap.xacml.rest.util.PolicyContainer.ItemSetChangeEvent;
-import org.onap.policy.pap.xacml.rest.util.PolicyContainer.ItemSetChangeListener;
-
-
-
-
-public class PolicyItemSetChangeNotifier implements PolicyContainer.ItemSetChangeNotifier {
-       private static final long serialVersionUID = 1L;
-    private Collection<PolicyContainer.ItemSetChangeListener> itemSetChangeListeners = null;
-    private PolicyContainer container = null;
-    
-    public PolicyItemSetChangeNotifier() {
-    }
-    
-    protected void setContainer(PolicyContainer c) {
-       this.container = c;
-    }
-
-       @Override
-       public void addItemSetChangeListener(ItemSetChangeListener listener) {
-        if (getItemSetChangeListeners() == null) {
-            setItemSetChangeListeners(new LinkedList<PolicyContainer.ItemSetChangeListener>());
-        }
-        getItemSetChangeListeners().add(listener);     }
-
-       @Override
-       public void removeItemSetChangeListener(ItemSetChangeListener listener) {
-        if (getItemSetChangeListeners() != null) {
-            getItemSetChangeListeners().remove(listener);
-        }
-    }
-       
-       protected static class BaseItemSetChangeEvent extends EventObject implements
-           PolicyContainer.ItemSetChangeEvent, Serializable {
-               private static final long serialVersionUID = 1L;
-
-               protected BaseItemSetChangeEvent(PolicyContainer source) {
-                   super(source);
-               }
-               
-               @Override
-               public PolicyContainer getContainer() {
-                   return (PolicyContainer) getSource();
-               }
-       }
-
-    protected void setItemSetChangeListeners(
-            Collection<PolicyContainer.ItemSetChangeListener> itemSetChangeListeners) {
-        this.itemSetChangeListeners = itemSetChangeListeners;
-    }
-    protected Collection<PolicyContainer.ItemSetChangeListener> getItemSetChangeListeners() {
-        return itemSetChangeListeners;
-    }
-  
-    protected void fireItemSetChange() {
-        fireItemSetChange(new BaseItemSetChangeEvent(this.container));
-    }
-
-    protected void fireItemSetChange(ItemSetChangeEvent event) {
-        if (getItemSetChangeListeners() != null) {
-            final Object[] l = getItemSetChangeListeners().toArray();
-            for (int i = 0; i < l.length; i++) {
-                ((PolicyContainer.ItemSetChangeListener) l[i])
-                        .containerItemSetChange(event);
-            }
-        }
-    }
-}
index 55879ca..cb09bec 100644 (file)
@@ -89,7 +89,7 @@ public class ActionPolicyTest {
                attributeMap.put("java", "test");
                policyAdapter.setDynamicFieldConfigAttributes(attributeMap);
                
-               component = new ActionPolicy(policyAdapter);
+               component = new ActionPolicy(policyAdapter, null);
 
         logger.info("setUp: exit");
        }
index caa5707..e16dd98 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP-PAP-REST
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -19,7 +19,6 @@
  */
 package org.onap.policy.pap.xacml.rest.components;
 
-import static org.junit.Assert.*;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.when;
@@ -30,7 +29,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
@@ -101,18 +99,11 @@ public class DecisionPolicyTest {
                policyAdapter.setRainydayMap(treatmentMap);
                policyAdapter.setRainyday(rainyday);
                        
-               component = new DecisionPolicy(policyAdapter);
+               component = new DecisionPolicy(policyAdapter, null);
 
         logger.info("setUp: exit");
        }
 
-       /**
-        * @throws java.lang.Exception
-        */
-       @After
-       public void tearDown() throws Exception {
-       }
-
        /**
         * Test method for {@link org.openecomp.policy.pap.xacml.rest.components.DecisionPolicy#savePolicies()}.
         */
@@ -140,25 +131,7 @@ public class DecisionPolicyTest {
        public void testPrepareToSaveRainyDay() {
                logger.debug("test PrepareToSave Policy: enter");
                policyAdapter.setRuleProvider("Rainy_Day");
-               component = new DecisionPolicy(policyAdapter);
-               boolean response = false;
-               
-               try {
-                       response = component.prepareToSave();
-               } catch (Exception e) {
-                       logger.error("Exception Occured"+e);
-               }
-               assertTrue(response);
-       }
-       
-       /**
-        * Test method for {@link org.openecomp.policy.pap.xacml.rest.components.DecisionPolicy#prepareToSave()}.
-        */
-       @Test
-       public void testPrepareToSaveCustom() {
-               logger.debug("test PrepareToSave Policy: enter");
-               policyAdapter.setRuleProvider("Custom");
-               component = new DecisionPolicy(policyAdapter);
+               component = new DecisionPolicy(policyAdapter, null);
                boolean response = false;
                
                try {
@@ -168,6 +141,4 @@ public class DecisionPolicyTest {
                }
                assertTrue(response);
        }
-
-
 }
\ No newline at end of file
index 546c5c0..c098bf4 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP-PAP-REST
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
 
 package org.onap.policy.pap.xacml.rest.components;
 
+import static org.junit.Assert.fail;
+
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Date;
 import java.util.List;
@@ -36,11 +39,10 @@ import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.junit.After;
 import org.junit.Assert;
-//import org.apache.commons.logging.Log;
-//import org.apache.commons.logging.LogFactory;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
+import org.mockito.Mockito;
 import org.onap.policy.common.logging.flexlogger.FlexLogger;
 import org.onap.policy.common.logging.flexlogger.Logger;
 import org.onap.policy.pap.xacml.rest.components.PolicyDBDao.PolicyDBDaoTestClass;
@@ -51,14 +53,17 @@ import org.onap.policy.rest.jpa.GroupEntity;
 import org.onap.policy.rest.jpa.PdpEntity;
 import org.onap.policy.rest.jpa.PolicyEntity;
 import org.onap.policy.xacml.api.pap.OnapPDPGroup;
+import org.onap.policy.xacml.std.pap.StdEngine;
 import org.onap.policy.xacml.std.pap.StdPDPGroup;
 import org.onap.policy.xacml.util.XACMLPolicyWriter;
 
+import com.att.research.xacml.api.pap.PAPException;
 import com.att.research.xacml.util.XACMLProperties;
 
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
 
-public class PolicyDBDaoTest {
+public class PolicyDBDaoTest extends Mockito{
 
        private static Logger logger = FlexLogger.getLogger(PolicyDBDaoTest.class);
        
@@ -66,8 +71,11 @@ public class PolicyDBDaoTest {
        PolicyDBDao dbd;
        PolicyDBDao dbd2;
        EntityManagerFactory emf;
+       private Path repository;
+       StdEngine stdEngine = null;
+       
        @Before
-       public void init(){
+       public void init() throws PAPException, IOException{
            System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME,"src/test/resources/xacml.pap.properties");
                emf = Persistence.createEntityManagerFactory("testPapPU");
                EntityManager em = emf.createEntityManager();
@@ -90,15 +98,19 @@ public class PolicyDBDaoTest {
                        dbd = PolicyDBDao.getPolicyDBDaoInstance(emf);
                        dbd2 = PolicyDBDao.getPolicyDBDaoInstance(emf);
                } catch (Exception e) {
-                       //logger.error("Exception Occured"+e);
                        Assert.fail();
                }
 
                d = PolicyDBDao.getPolicyDBDaoTestClass();
+               PolicyDBDao.setJunit(true);
+               repository = Paths.get("src/test/resources/pdps");
+        stdEngine = new StdEngine(repository);
+        dbd.setPapEngine(stdEngine);
        }
        
        @After
        public void cleanUp(){
+               PolicyDBDao.setJunit(false);
                EntityManager em = emf.createEntityManager();
                em.getTransaction().begin();
                try{    
@@ -119,14 +131,8 @@ public class PolicyDBDaoTest {
                } catch (IOException e) {
                        //could not delete
                }
-
        }
        
-       @Test
-       public void computeScopeTest(){
-               Assert.assertEquals("com",d.computeScope("C:\\Users\\testuser\\admin\\repo\\com\\", "C:\\Users\\testuser\\admin\\repo"));
-               Assert.assertEquals("org.onap.policy",d.computeScope("/Users/testuser/admin/repo/org.onap.policy", "/Users/testuser/admin/repo"));
-       }
        @Test
        public void getConfigFileTest(){
                PolicyRestAdapter pra = new PolicyRestAdapter();
@@ -138,23 +144,33 @@ public class PolicyDBDaoTest {
                Assert.assertEquals("org.onap.Action_mypolicy.json", configFile);
        }
        
-       @Ignore
        @Test
        public void createFromPolicyObject(){
-               String workspaceDir = "src/test/resources/";
-               File parentPath = new File(workspaceDir+"/com");
                Policy policyObject = new ConfigPolicy();
                policyObject.policyAdapter = new PolicyRestAdapter();
                policyObject.policyAdapter.setConfigName("testpolicy1");
-               policyObject.policyAdapter.setParentPath(parentPath.getAbsolutePath());
                policyObject.policyAdapter.setPolicyDescription("my description");
                policyObject.policyAdapter.setConfigBodyData("this is my test config file");
-               policyObject.policyAdapter.setPolicyName("testpolicy1");
+               policyObject.policyAdapter.setPolicyName("SampleTest1206");
                policyObject.policyAdapter.setConfigType(ConfigPolicy.OTHER_CONFIG);
                policyObject.policyAdapter.setPolicyType("Config");
-               policyObject.policyAdapter.setDomainDir("org.onap");
+               policyObject.policyAdapter.setDomainDir("com");
+               policyObject.policyAdapter.setVersion("1");
                PolicyType policyTypeObject = new PolicyType();
                policyObject.policyAdapter.setPolicyData(policyTypeObject);
+               ClassLoader classLoader = getClass().getClassLoader();
+               PolicyType policyConfig = new PolicyType();
+        policyConfig.setVersion(Integer.toString(1));
+        policyConfig.setPolicyId("");
+        policyConfig.setTarget(new TargetType());
+        policyObject.policyAdapter.setData(policyConfig);
+               mock(XACMLPolicyWriter.class);
+               try {
+                       policyObject.policyAdapter.setParentPath(IOUtils.toString(classLoader.getResourceAsStream("Config_SampleTest1206.1.xml")));
+               } catch (Exception e2) {
+                       fail();
+               }
+               
                PolicyDBDaoTransaction transaction = dbd.getNewTransaction();
                try{
                        transaction.createPolicy(policyObject, "testuser1");
@@ -166,57 +182,31 @@ public class PolicyDBDaoTest {
                
                EntityManager getData = emf.createEntityManager();
                Query getDataQuery = getData.createQuery("SELECT p FROM PolicyEntity p WHERE p.scope=:scope AND p.policyName=:name");
-               getDataQuery.setParameter("scope", "org.onap");
-               getDataQuery.setParameter("name","Config_testpolicy1.xml");
+               getDataQuery.setParameter("scope", "com");
+               getDataQuery.setParameter("name","Config_SampleTest1206.1.xml");
                PolicyEntity result = null;
                try{
-               result = (PolicyEntity)getDataQuery.getSingleResult();
+                       result = (PolicyEntity)getDataQuery.getSingleResult();
                } catch(Exception e){
                        logger.error("Exception Occured"+e);
                        Assert.fail();
                }
                String expectedData;
                try {
-                       expectedData = IOUtils.toString(XACMLPolicyWriter.getXmlAsInputStream(policyTypeObject));
+                       expectedData = IOUtils.toString(classLoader.getResourceAsStream("Config_SampleTest1206.1.xml"));
                } catch (IOException e1) {
                        expectedData = "";
                }
                Assert.assertEquals(expectedData, result.getPolicyData());
                getData.close();
                result = null;
-               File policyFile = new File(workspaceDir+"/org/onap/Config_testpolicy1.xml");
-               try{
-                       transaction = dbd.getNewTransaction();
-                       transaction.deletePolicy(policyFile.getAbsolutePath());
-               } catch(Exception e){
-                       logger.error("Exception Occured"+e);
-                       Assert.fail();
-               }
-               Assert.assertTrue(transaction.isTransactionOpen());
-               try{                            
-                       transaction.deletePolicy(policyFile.getAbsolutePath());
-                       Assert.fail();
-               } catch(IllegalStateException e){
-                       //pass
-               } catch(Exception e){
-                       Assert.fail();
-               }
+
                transaction.commitTransaction();
                Assert.assertFalse(transaction.isTransactionOpen());
-               try{
-                       transaction = dbd.getNewTransaction();
-                       transaction.deletePolicy(policyFile.getAbsolutePath());
-               } catch(Exception e){
-                       logger.error("Exception Occured"+e);
-                       Assert.fail();
-               }
-               //Assert.assertFalse(transaction.isTransactionOpen());
-               transaction.commitTransaction();
        }
 
-       @Ignore
        @Test
-       public void groupTransactions(){                
+       public void groupTransactions(){
                PolicyDBDaoTransaction group = dbd.getNewTransaction();
                String groupName = "test group 1";
                try{
@@ -405,9 +395,6 @@ public class PolicyDBDaoTest {
                        Assert.fail();
                }
                
-               
-               //add policy to group
-               
                //update group
                OnapPDPGroup pdpGroup = new StdPDPGroup("testgroup2", false, "newtestgroup2", "this is my new description", Paths.get("/"));
                group = dbd.getNewTransaction();
@@ -441,12 +428,6 @@ public class PolicyDBDaoTest {
                em.close();
        }
        
-       @Test
-       public void getDescriptionFromXacmlTest(){
-               String myTestDesc = "hello this is a test";
-               String desc = d.getDescriptionFromXacml("<Description>"+myTestDesc+"</Description>");
-               Assert.assertEquals(myTestDesc, desc);
-       }
        @Ignore
        @Test
        public void threadingStabilityTest(){
@@ -618,4 +599,4 @@ public class PolicyDBDaoTest {
                }
        }
 
-}
+}
\ No newline at end of file
index c0f5927..853d75c 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP-PAP-REST
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -27,11 +27,15 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import io.searchbox.client.JestResult;
 
+import java.io.IOException;
 import java.lang.reflect.Method;
 
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 import org.onap.policy.pap.xacml.rest.elk.client.ElkConnector.PolicyIndexType;
 import org.onap.policy.pap.xacml.rest.elk.client.ElkConnectorImpl;
+import org.onap.policy.rest.adapter.PolicyRestAdapter;
 
 public class ElkConnectorImplTest {
 
@@ -96,5 +100,47 @@ public class ElkConnectorImplTest {
                assertNull(r3);
                assertNull(r4);
        }
+       
+       @Rule
+       public ExpectedException thrown = ExpectedException.none();
+       
+       @Test
+       public void testDelete() {
+               thrown.expect(NullPointerException.class);
+
+               ElkConnectorImpl impl = new ElkConnectorImpl();
+               PolicyRestAdapter adapter = new PolicyRestAdapter();
+               impl.delete(adapter);
+               fail("Expected exception to be thrown");
+       }
+
+       
+       @Test
+       public void testPut() throws IOException {
+               thrown.expect(NullPointerException.class);
+               
+               ElkConnectorImpl impl = new ElkConnectorImpl();
+               PolicyRestAdapter adapter = new PolicyRestAdapter();
+               impl.put(adapter);
+               fail("Expected exception to be thrown");
+       }
+       
+       @Test
+       public void testUpdate() {
+               thrown.expect(IllegalStateException.class);
+               
+               ElkConnectorImpl impl = new ElkConnectorImpl();
+               PolicyRestAdapter adapter = new PolicyRestAdapter();
+               impl.update(adapter);
+               fail("Expected exception to be thrown");
+       }
+       
+       @Test
+       public void testSearchWithFilter() {
+               thrown.expect(IllegalStateException.class);
 
+               ElkConnectorImpl impl = new ElkConnectorImpl();
+               impl.search(PolicyIndexType.config, "search", null);
+               fail("Expected exception to be thrown");
+       }
 }
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PairTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PairTest.java
new file mode 100644 (file)
index 0000000..68f1daa
--- /dev/null
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-PAP-REST
+ * ================================================================================
+ * Copyright (C) 2018 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.pap.xacml.rest.elk;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import org.onap.policy.pap.xacml.rest.elk.client.Pair;
+
+public class PairTest {
+       @Test
+       public void testPair() {
+               String testLeft = "left";
+               String testRight = "right";
+               
+               // Test constructor
+               Pair<String, String> pair = new Pair<String, String>(testLeft, testRight);
+               assertEquals(pair.left(), testLeft);
+               assertEquals(pair.right(), testRight);
+               
+               // Test setters
+               pair.left(testRight);
+               pair.right(testLeft);
+               assertEquals(pair.left(), testRight);
+               assertEquals(pair.right(), testLeft);
+       }
+}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyElasticDataTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyElasticDataTest.java
new file mode 100644 (file)
index 0000000..a84e4a0
--- /dev/null
@@ -0,0 +1,188 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-PAP-REST
+ * ================================================================================
+ * Copyright (C) 2018 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.pap.xacml.rest.elk;
+
+import static org.junit.Assert.assertEquals;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import org.junit.Test;
+import org.onap.policy.pap.xacml.rest.elk.client.PolicyElasticData;
+import org.onap.policy.rest.adapter.PolicyRestAdapter;
+import org.onap.policy.rest.adapter.YAMLParams;
+
+public class PolicyElasticDataTest {
+       @Test
+       public void testSetAndGet() {
+               String testKey = "testKey";
+               String testVal = "testVal";
+               LinkedHashMap<String, String> testMap = new LinkedHashMap<String, String>();
+               testMap.put(testKey, testVal);
+               ArrayList<Object> testArray = new ArrayList<Object>();
+               testArray.add(testVal);
+               List<String> testList = new ArrayList<String>();
+               testList.add(testVal);
+               List<Object> testObjectList = new ArrayList<Object>();
+               testObjectList.add(testVal);
+               YAMLParams testYaml = new YAMLParams();
+               
+               PolicyRestAdapter adapter = new PolicyRestAdapter();
+               adapter.setConfigPolicyType(testVal);
+               
+               PolicyElasticData data = new PolicyElasticData(adapter);
+               data.setScope(testVal);
+               assertEquals(data.getScope(), testVal);
+               data.setPolicyType(testVal);
+               assertEquals(data.getPolicyType(), testVal);
+               data.setConfigPolicyType(testVal);
+               assertEquals(data.getConfigPolicyType(), testVal);
+               data.setConfigBodyData(testVal);
+               assertEquals(data.getConfigBodyData(), testVal);
+               data.setPolicyName(testVal);
+               assertEquals(data.getPolicyName(), testVal);
+               data.setPolicyDescription(testVal);
+               assertEquals(data.getPolicyDescription(), testVal);
+               data.setOnapName(testVal);
+               assertEquals(data.getOnapName(), testVal);
+               data.setConfigName(testVal);
+               assertEquals(data.getConfigName(), testVal);
+               data.setConfigType(testVal);
+               assertEquals(data.getConfigType(), testVal);
+               data.setJsonBody(testVal);
+               assertEquals(data.getJsonBody(), testVal);
+               data.setServiceTypePolicyName(testMap);
+               assertEquals(data.getServiceTypePolicyName(), testMap);
+               data.setVerticaMetrics(testMap);
+               assertEquals(data.getVerticaMetrics(), testMap);
+               data.setDescription(testMap);
+               assertEquals(data.getDescription(), testMap);
+               data.setAttributeFields(testMap);
+               assertEquals(data.getAttributeFields(), testMap);
+               data.setPolicyScope(testVal);
+               assertEquals(data.getPolicyScope(), testVal);
+               data.setProviderComboBox(testVal);
+               assertEquals(data.getProviderComboBox(), testVal);
+               data.setRiskType(testVal);
+               assertEquals(data.getRiskType(), testVal);
+               data.setRiskLevel(testVal);
+               assertEquals(data.getRiskLevel(), testVal);
+               data.setGuard(testVal);
+               assertEquals(data.getGuard(), testVal);
+               data.setTtlDate(testVal);
+               assertEquals(data.getTtlDate(), testVal);
+               data.setMatching(testMap);
+               assertEquals(data.getMatching(), testMap);
+               data.setTriggerSignatures(testArray);
+               assertEquals(data.getTriggerSignatures(), testArray);
+               data.setSymptomSignatures(testArray);
+               assertEquals(data.getSymptomSignatures(), testArray);
+               data.setLogicalConnector(testVal);
+               assertEquals(data.getLogicalConnector(), testVal);
+               data.setPolicyStatus(testVal);
+               assertEquals(data.getPolicyStatus(), testVal);
+               data.setGocServerScope(testVal);
+               assertEquals(data.getGocServerScope(), testVal);
+               data.setSupressionType(testVal);
+               assertEquals(data.getSupressionType(), testVal);
+               data.setServiceType(testVal);
+               assertEquals(data.getServiceType(),testVal);
+               data.setUuid(testVal);
+               assertEquals(data.getUuid(), testVal);
+               data.setLocation(testVal);
+               assertEquals(data.getLocation(), testVal);
+               data.setPriority(testVal);
+               assertEquals(data.getPriority(), testVal);
+               data.setMsLocation(testVal);
+               assertEquals(data.getMsLocation(),testVal);
+               data.setRuleName(testVal);
+               assertEquals(data.getRuleName(), testVal);
+               data.setBrmsParamBody(testMap);
+               assertEquals(data.getBrmsParamBody(), testMap);
+               data.setBrmsController(testVal);
+               assertEquals(data.getBrmsController(), testVal);
+               data.setBrmsDependency(testList);
+               assertEquals(data.getBrmsDependency(), testList);
+               data.setRuleData(testMap);
+               assertEquals(data.getRuleData(), testMap);
+               data.setRuleListData(testMap);
+               assertEquals(data.getRuleListData(), testMap);
+               data.setDrlRuleAndUIParams(testMap);
+               assertEquals(data.getDrlRuleAndUIParams(), testMap);
+               data.setClearTimeOut(testVal);
+               assertEquals(data.getClearTimeOut(), testVal);
+               data.setTrapMaxAge(testVal);
+               assertEquals(data.getTrapMaxAge(), testVal);
+               data.setVerificationclearTimeOut(testVal);
+               assertEquals(data.getVerificationclearTimeOut(), testVal);
+               data.setDynamicLayoutMap(testMap);
+               assertEquals(data.getDynamicLayoutMap(), testMap);
+               data.setFwPolicyType(testVal);
+               assertEquals(data.getFwPolicyType(), testVal);
+               data.setFwattributes(testArray);
+               assertEquals(data.getFwattributes(), testArray);
+               data.setParentForChild(testVal);
+               assertEquals(data.getParentForChild(), testVal);
+               data.setSecurityZone(testVal);
+               assertEquals(data.getSecurityZone(), testVal);
+               data.setRuleCombiningAlgId(testVal);
+               assertEquals(data.getRuleCombiningAlgId(), testVal);
+               data.setDynamicFieldConfigAttributes(testMap);
+               assertEquals(data.getDynamicFieldConfigAttributes(), testMap);
+               data.setDynamicSettingsMap(testMap);
+               assertEquals(data.getDynamicSettingsMap(), testMap);
+               data.setDropDownMap(testMap);
+               assertEquals(data.getDropDownMap(), testMap);
+               data.setActionPerformer(testVal);
+               assertEquals(data.getActionPerformer(), testVal);
+               data.setActionAttribute(testVal);
+               assertEquals(data.getActionAttribute(), testVal);
+               data.setDynamicRuleAlgorithmLabels(testList);
+               assertEquals(data.getDynamicRuleAlgorithmLabels(), testList);
+               data.setDynamicRuleAlgorithmCombo(testList);
+               assertEquals(data.getDynamicRuleAlgorithmCombo(), testList);
+               data.setDynamicRuleAlgorithmField1(testList);
+               assertEquals(data.getDynamicRuleAlgorithmField1(), testList);
+               data.setDynamicRuleAlgorithmField2(testList);
+               assertEquals(data.getDynamicRuleAlgorithmField2(), testList);
+               data.setDynamicVariableList(testObjectList);
+               assertEquals(data.getDynamicVariableList(), testObjectList);
+               data.setDataTypeList(testList);
+               assertEquals(data.getDataTypeList(), testList);
+               data.setActionAttributeValue(testVal);
+               assertEquals(data.getActionAttributeValue(), testVal);
+               data.setRuleProvider(testVal);
+               assertEquals(data.getRuleProvider(), testVal);
+               data.setActionBody(testVal);
+               assertEquals(data.getActionBody(), testVal);
+               data.setActionDictHeader(testVal);
+               assertEquals(data.getActionDictHeader(), testVal);
+               data.setActionDictType(testVal);
+               assertEquals(data.getActionDictType(), testVal);
+               data.setActionDictUrl(testVal);
+               assertEquals(data.getActionDictUrl(), testVal);
+               data.setActionDictMethod(testVal);
+               assertEquals(data.getActionDictMethod(), testVal);
+               data.setYamlparams(testYaml);
+               assertEquals(data.getYamlparams(), testYaml);
+               data.setJsonBodyData(testVal);
+               assertEquals(data.getJsonBodyData(), testVal);
+       }
+}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyLocatorTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyLocatorTest.java
new file mode 100644 (file)
index 0000000..b648a31
--- /dev/null
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-PAP-REST
+ * ================================================================================
+ * Copyright (C) 2018 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.pap.xacml.rest.elk;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import org.onap.policy.pap.xacml.rest.elk.client.PolicyLocator;
+
+public class PolicyLocatorTest {
+       @Test
+       public void testLocator() {
+               String policyType = "type";
+               String policyName = "name";
+        String owner = "owner";
+        String scope = "scope";
+        String policyId = "id";
+        String version = "1.0";
+               String testString = "[owner|scope|type|name|id|v1.0|]";
+
+               PolicyLocator locator = new PolicyLocator(policyType, policyName, owner, 
+                       scope, policyId, version);
+               String locatorString = locator.toString();
+               assertEquals(locatorString, testString);
+       }
+}
diff --git a/ONAP-PAP-REST/src/test/resources/Config_SampleTest1206.1.xml b/ONAP-PAP-REST/src/test/resources/Config_SampleTest1206.1.xml
new file mode 100644 (file)
index 0000000..dcfd0c5
--- /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.onap.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.onap.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="ONAPName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.onap.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.onap.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.onap.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.onap.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.onap.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:ONAPName" 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/ONAP-PAP-REST/src/test/resources/pdps/testgroup2/com.Config_SampleBasePolicy.1.xml b/ONAP-PAP-REST/src/test/resources/pdps/testgroup2/com.Config_SampleBasePolicy.1.xml
new file mode 100644 (file)
index 0000000..168cb55
--- /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:0bc4aa91-cb41-420a-93e1-eca6098797a3" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+    <Description>SampleBasePolicy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:</Description>
+    <Target>
+        <AnyOf>
+            <AllOf>
+                <Match MatchId="org.onap.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_SampleBasePolicy.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.onap.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">ONAP_TEST_123</AttributeValue>
+                    <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ONAPName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+                </Match>
+                <Match MatchId="org.onap.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.onap.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.onap.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.onap.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">17-01-2018</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.onap.function.regex-match">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleBasePolicy</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="" 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_SampleBasePolicy.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_SampleBasePolicy.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:ONAPName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">ONAP_TEST_123</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">SampleBasePolicy</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">17-01-2018</AttributeValue>
+                </AttributeAssignmentExpression>
+            </AdviceExpression>
+        </AdviceExpressions>
+    </Rule>
+</Policy>
diff --git a/ONAP-PAP-REST/src/test/resources/pdps/testgroup2/xacml.pip.properties b/ONAP-PAP-REST/src/test/resources/pdps/testgroup2/xacml.pip.properties
new file mode 100644 (file)
index 0000000..bc4027a
--- /dev/null
@@ -0,0 +1,9 @@
+#
+#Wed Feb 14 16:26:32 EST 2018
+historydb.name=operationHistoryDB
+AAF.description=AAFEngine to communicate with AAF to take decisions
+historydb.issuer=org\:onap\:xacml\:guard\:historydb
+AAF.classname=org.onap.policy.xacml.std.pip.engines.aaf.AAFEngine
+AAF.name=AAFEngine
+historydb.classname=org.onap.policy.xacml.std.pip.engines.OperationHistoryEngine
+xacml.pip.engines=historydb,AAF
diff --git a/ONAP-PAP-REST/src/test/resources/pdps/testgroup2/xacml.policy.properties b/ONAP-PAP-REST/src/test/resources/pdps/testgroup2/xacml.policy.properties
new file mode 100644 (file)
index 0000000..d2218a8
--- /dev/null
@@ -0,0 +1,5 @@
+#
+#Wed Feb 14 16:26:32 EST 2018
+com.Config_SampleBasePolicy.1.xml.name=com.Config_SampleBasePolicy
+xacml.referencedPolicies=
+xacml.rootPolicies=com.Config_SampleBasePolicy.1.xml
diff --git a/ONAP-PAP-REST/src/test/resources/pdps/xacml.properties b/ONAP-PAP-REST/src/test/resources/pdps/xacml.properties
new file mode 100644 (file)
index 0000000..a6b85a0
--- /dev/null
@@ -0,0 +1,10 @@
+#
+#Wed Feb 14 16:29:58 EST 2018
+default.description=this is my new description.
+default.name=newtestgroup2
+default.pdps=http\://localhost\:8082/pdp/
+http\://localhost\:8082/pdp/.description=Registered on first startup
+http\://localhost\:8082/pdp/.jmxport=
+http\://localhost\:8082/pdp/.name=http\://localhost\:8082/pdp/
+xacml.pap.groups=testgroup2
+xacml.pap.groups.default=testgroup2
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.model;
+package org.onap.policy.rest.util;
 
 
 import java.util.ArrayList;
@@ -29,8 +29,6 @@ import java.util.Set;
 
 import org.onap.policy.common.logging.flexlogger.FlexLogger;
 import org.onap.policy.common.logging.flexlogger.Logger;
-import org.onap.policy.utils.PolicyContainer;
-import org.onap.policy.utils.PolicyItemSetChangeNotifier;
 import org.onap.policy.xacml.api.XACMLErrorConstants;
 import org.onap.policy.xacml.std.pap.StdPDPPolicy;
 
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.utils;
+package org.onap.policy.rest.util;
 
 import java.io.Serializable;
 import java.util.Collection;
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.utils;
+package org.onap.policy.rest.util;
 
 
 import java.io.Serializable;
@@ -26,8 +26,8 @@ import java.util.Collection;
 import java.util.EventObject;
 import java.util.LinkedList;
 
-import org.onap.policy.utils.PolicyContainer.ItemSetChangeEvent;
-import org.onap.policy.utils.PolicyContainer.ItemSetChangeListener;
+import org.onap.policy.rest.util.PolicyContainer.ItemSetChangeEvent;
+import org.onap.policy.rest.util.PolicyContainer.ItemSetChangeListener;
 
 
 
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/Webapps.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/Webapps.java
deleted file mode 100644 (file)
index 1fb8ec5..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-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.onap.policy.rest.util;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.onap.policy.rest.XACMLRestProperties;
-
-import org.onap.policy.xacml.api.XACMLErrorConstants;
-
-import com.att.research.xacml.api.pap.PAPException;
-import com.att.research.xacml.util.XACMLProperties;
-
-import org.onap.policy.common.logging.eelf.MessageCodes;
-import org.onap.policy.common.logging.eelf.PolicyLogger;
-
-public class Webapps {
-       private static String actionHome = null;
-       private static String configHome = null;
-       private static Log logger       = LogFactory.getLog(Webapps.class);
-       
-       private Webapps() {
-       }
-       
-       public static String getConfigHome(){
-               try {
-                       loadWebapps();
-               } catch (PAPException e) {
-                       logger.error("Exception Occured while loading webapps",e);
-                       return null;
-               }
-               return configHome;
-       }
-       
-       public static String getActionHome(){
-               try {
-                       loadWebapps();
-               } catch (PAPException e) {
-                       logger.error("Exception Occured while loading webapps",e);
-                       return null;
-               }
-               return actionHome;
-       }
-       
-       private static void loadWebapps() throws PAPException{
-               String errorMessageName = "Invalid Webapps Path Location property :";
-               if(actionHome == null || configHome == null){
-                       Path webappsPath = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_WEBAPPS));
-                       //Sanity Check
-                       if (webappsPath == null) {
-                               logger.error(errorMessageName + XACMLRestProperties.PROP_PAP_WEBAPPS);
-                               PolicyLogger.error(errorMessageName + XACMLRestProperties.PROP_PAP_WEBAPPS);
-                               throw new PAPException(errorMessageName + XACMLRestProperties.PROP_PAP_WEBAPPS);
-                       }
-                       Path webappsPathConfig;
-                       Path webappsPathAction;
-                       if(webappsPath.toString().contains("\\")){
-                               webappsPathConfig = Paths.get(webappsPath.toString()+"\\Config");
-                               webappsPathAction = Paths.get(webappsPath.toString()+"\\Action");
-                       }else{
-                               webappsPathConfig = Paths.get(webappsPath.toString()+"/Config");
-                               webappsPathAction = Paths.get(webappsPath.toString()+"/Action");
-                       }
-                       
-                       checkConfigActionHomeExists(webappsPathConfig, webappsPathAction);
-                       
-                       actionHome = webappsPathAction.toString();
-                       configHome = webappsPathConfig.toString();
-               }
-       }
-       
-       private  static void checkConfigActionHomeExists(Path webappsPathConfig, Path webappsPathAction){
-               if (!webappsPathConfig.toFile().exists()){
-                       try {
-                               Files.createDirectories(webappsPathConfig);
-                       } catch (IOException e) {
-                               logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to create config directory: "
-                                               + webappsPathConfig.toAbsolutePath().toString(), e);
-                               PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Webapps", "Failed to create config directory");
-                       }
-               }
-               
-               if (!webappsPathAction.toFile().exists()){
-                       try {
-                               Files.createDirectories(webappsPathAction);
-                       } catch (IOException e) {
-                               logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to create config directory: "
-                                               + webappsPathAction.toAbsolutePath().toString(), e);
-                               PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Webapps", "Failed to create config directory");
-                       }
-               }
-       }
-
-}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/PDPPolicyContainerTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PDPPolicyContainerTest.java
new file mode 100644 (file)
index 0000000..806816b
--- /dev/null
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2018 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.rest.util;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashSet;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.xacml.std.pap.StdPDPGroup;
+import org.onap.policy.xacml.std.pap.StdPDPPolicy;
+
+import com.att.research.xacml.api.pap.PDPPolicy;
+
+public class PDPPolicyContainerTest {
+       
+       StdPDPGroup group;
+       PDPPolicyContainer container;
+       StdPDPPolicy policy;
+       
+       @Before
+       public void setUp(){
+               group = new StdPDPGroup();
+               group.setDefault(true);
+               group.setDefaultGroup(true);
+               group.setDescription("Test");
+               group.setId("Test");
+               group.setName("Test");
+               group.setOnapPdps(new HashSet<>());
+               group.setOperation("Test");
+               group.setPipConfigs(new HashSet<>());
+               HashSet<PDPPolicy> policies = new HashSet<>();
+               policy = new StdPDPPolicy();
+               policy.setName("Config_test.1.xml");
+               policy.setId("Config_test");
+               policies.add(policy);
+               group.setPolicies(policies);
+               group.setSelectedPolicies(new HashSet<>());
+               container = new PDPPolicyContainer(group);
+       }
+
+       
+       @Test
+       public void testPDPPolicyContainer(){
+               container.nextItemId(policy);
+               container.prevItemId(policy);
+               container.firstItemId();
+               container.lastItemId();
+               container.isFirstId(policy);
+               container.isLastId(policy);
+               container.addItemAfter(policy);
+               container.getContainerPropertyIds();
+               container.getItemIds();
+               container.getType("Id");
+               assertTrue(String.class.equals(String.class));
+               container.getType("Name");
+               assertTrue(String.class.equals(String.class));
+               container.getType("Version");
+               assertTrue(String.class.equals(String.class));
+               container.getType("Description");
+               assertTrue(String.class.equals(String.class));
+               container.getType("Root");
+               assertTrue(Boolean.class.equals(Boolean.class));
+               assertTrue(container.size() == 1);
+               container.containsId(policy);
+               container.removeItem(policy);
+               container.addContainerProperty(null, null, null);
+               container.removeContainerProperty(policy);
+               container.removeAllItems();
+               container.addItemAt(0);
+               
+       }
+}
index 4399f71..273383a 100644 (file)
@@ -320,7 +320,7 @@ public class StdEngine extends StdPDPItemSetChangeNotifier implements PAPPolicyE
                // If it exists already
                //
                if (Files.exists(groupPath)) {
-                       logger.warn(addGroup + id + " directory exists" + groupPath.toString());
+                       logger.warn(addGroup + id + " directory exists");
                } else {
                        try {
                                //
@@ -338,7 +338,7 @@ public class StdEngine extends StdPDPItemSetChangeNotifier implements PAPPolicyE
 
                Path policyProperties = Paths.get(groupPath.toString(), "xacml.policy.properties");
                if (Files.exists(policyProperties)) {
-                       logger.warn(addGroup + id + " file exists: " + policyProperties.toString());
+                       logger.warn(addGroup + id + " file exists");
                } else {
                        Properties props = new Properties();
                        props.setProperty(XACMLProperties.PROP_REFERENCEDPOLICIES, "");
@@ -359,7 +359,7 @@ public class StdEngine extends StdPDPItemSetChangeNotifier implements PAPPolicyE
                Path pipProperties = Paths.get(groupPath.toString(), "xacml.pip.properties");
                Properties props = new Properties();
                if (Files.exists(pipProperties)) {
-                       logger.warn(addGroup + id + " file exists: " + pipProperties.toString());
+                       logger.warn(addGroup + id + " file exists.");
                } else {
                        try {
                                props = setPIPProperties(props);
index de1c551..23392bd 100644 (file)
@@ -21,7 +21,6 @@
 package org.onap.policy.components;
 
 
-import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.PrintWriter;
@@ -42,7 +41,6 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger;
 import org.onap.policy.common.logging.flexlogger.Logger;
 import org.onap.policy.controller.PolicyController;
 import org.onap.policy.rest.jpa.FunctionDefinition;
-import org.onap.policy.utils.XACMLPolicyWriterWithPapNotify;
 import org.onap.policy.xacml.api.XACMLErrorConstants;
 import org.onap.policy.xacml.util.XACMLPolicyScanner;
 
@@ -303,29 +301,6 @@ class HtmlProcessor extends SimpleCallback {
                super.onFinishScan(root);
        }
        
-       @SuppressWarnings("unused")
-       private void writeRawXACML() {
-               if (LOGGER.isTraceEnabled())
-                       LOGGER.trace("ENTER");
-               
-               htmlOut.println("<hr>");                
-               htmlOut.println("<h3>Raw XACML:</h3>");
-               
-               ByteArrayOutputStream bos = new ByteArrayOutputStream();
-               if (rootPolicyObject instanceof PolicySetType) {
-                       XACMLPolicyWriterWithPapNotify.writePolicyFile(bos, (PolicySetType) rootPolicyObject);
-               } else if (rootPolicyObject instanceof PolicyType) {
-                       XACMLPolicyWriterWithPapNotify.writePolicyFile(bos, (PolicyType) rootPolicyObject);
-               }
-               
-               String xacml = bos.toString();
-               xacml = xacml.replaceAll("<", "&lt");
-               xacml = xacml.replaceAll(">", "&gt");
-               htmlOut.println("<pre>");
-               htmlOut.println(xacml);
-               htmlOut.println("</pre>");
-       }
-
        @Override
        public CallbackResult onPreVisitPolicySet(PolicySetType parent, PolicySetType policySet) {
                if (LOGGER.isTraceEnabled())
index 64928f3..e5e868f 100644 (file)
@@ -46,12 +46,12 @@ import org.json.JSONObject;
 import org.onap.policy.common.logging.flexlogger.FlexLogger;
 import org.onap.policy.common.logging.flexlogger.Logger;
 import org.onap.policy.model.PDPGroupContainer;
-import org.onap.policy.model.PDPPolicyContainer;
 import org.onap.policy.model.Roles;
 import org.onap.policy.rest.adapter.AutoPushTabAdapter;
 import org.onap.policy.rest.dao.CommonClassDao;
 import org.onap.policy.rest.jpa.PolicyEntity;
 import org.onap.policy.rest.jpa.PolicyVersion;
+import org.onap.policy.rest.util.PDPPolicyContainer;
 import org.onap.policy.utils.PolicyUtils;
 import org.onap.policy.xacml.api.XACMLErrorConstants;
 import org.onap.policy.xacml.api.pap.OnapPDPGroup;
index d5767b4..0835655 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -31,8 +31,8 @@ import java.util.Set;
 
 import org.onap.policy.common.logging.flexlogger.FlexLogger;
 import org.onap.policy.common.logging.flexlogger.Logger;
-import org.onap.policy.utils.PolicyContainer;
-import org.onap.policy.utils.PolicyItemSetChangeNotifier;
+import org.onap.policy.rest.util.PolicyContainer;
+import org.onap.policy.rest.util.PolicyItemSetChangeNotifier;
 import org.onap.policy.xacml.api.XACMLErrorConstants;
 import org.onap.policy.xacml.api.pap.OnapPDP;
 import org.onap.policy.xacml.api.pap.OnapPDPGroup;
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/ConfigurableRESTUtils.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/ConfigurableRESTUtils.java
deleted file mode 100644 (file)
index 7457610..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP 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.onap.policy.utils;
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.onap.policy.common.logging.flexlogger.FlexLogger; 
-import org.onap.policy.common.logging.flexlogger.Logger;
-
-
-public class ConfigurableRESTUtils  {
-       
-       protected Logger LOGGER = FlexLogger.getLogger(this.getClass());
-
-       //
-       // How the value is returned from the RESTful server
-       //              httpResponseCode means the result is simply the HTTP Response code (e.g. 200, 505, etc.)
-       //              other values identify the encoding used for the string in the body of the HTTP response
-       //
-       public enum REST_RESPONSE_FORMAT {httpResponseCode, json }
-       public enum RESQUEST_METHOD {
-                 GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
-               }
-       
-       private String ERROR_RECEIVED = "ERROR - Unexpected HTTP response: ";
-       
-       public ConfigurableRESTUtils() {
-               //Default Constructor
-       }
-       
-       
-       /**
-        * Call the RESTful API and return a string containing the result.  The string may be either a httpResponseCode or json body
-        *              
-        * @param fullURI
-        * @param hardCodedHeaders
-        * @param httpResponseCodes
-        * @param responseFormat
-        * @param jsonBody
-        * @param requestMethod
-        * @return String
-        */
-       public String sendRESTRequest(String fullURI, Map<String, String> hardCodedHeaderMap, 
-                       Map<Integer,String> httpResponseCodeMap,
-                       REST_RESPONSE_FORMAT responseFormat,
-                       String jsonBody,
-                       RESQUEST_METHOD requestMethod ){
-               
-               String responseString = null;
-               HttpURLConnection connection = null;
-               try {
-                       
-                       URL url = new URL(fullURI);
-
-                       //
-                       // Open up the connection
-                       //
-                       connection = (HttpURLConnection)url.openConnection();
-                       //
-                       // Setup our method and headers
-                       //
-            connection.setRequestMethod(requestMethod.toString());
-
-            connection.setUseCaches(false);
-            
-            // add hard-coded headers
-            for (Entry<String, String> entry : hardCodedHeaderMap.entrySet()) {
-               connection.addRequestProperty(entry.getKey(), entry.getValue());
-            }
-            
-            if (jsonBody != null){
-               connection.setDoInput(true);
-               connection.setDoOutput(true);
-                       OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
-                       out.write(jsonBody);
-                       out.flush();
-                       out.close();
-            } else{
-               connection.connect();
-            }
-            
-            int responseCode = connection.getResponseCode();
-            
-            // check that the response is one we expected (and get the associated value at the same time)
-            responseString = httpResponseCodeMap.get(responseCode);
-            if (responseString == null) {
-               // the response was not configured, meaning it is unexpected and therefore an error
-               LOGGER.error("Unexpected HTTP response code '" + responseCode + "' from RESTful Server");
-               return ERROR_RECEIVED +  " code" + responseCode + " from RESTful Server";
-            }
-            
-            // if the response is contained only in the http code we are done.  Otherwise we need to read the body
-            if (responseFormat == REST_RESPONSE_FORMAT.httpResponseCode) {
-               return responseString;
-            }
-            
-            // Need to read the body and return that as the responseString.
-
-            responseString = null;
-                       // read the inputStream into a buffer (trick found online scans entire input looking for end-of-file)
-                   java.util.Scanner scanner = new java.util.Scanner(connection.getInputStream());
-                   scanner.useDelimiter("\\A");
-                   responseString =  scanner.hasNext() ? scanner.next() : "";
-                   scanner.close();
-                   LOGGER.debug("RESTful body: " + responseString);
-                   return responseString;
-                   
-               } catch (Exception e) {
-                       LOGGER.error("HTTP Request/Response from RESTFUL server: " + e);
-                       responseString =  ERROR_RECEIVED + e;
-               } finally {
-                       // cleanup the connection
-                               if (connection != null) {
-                               try {
-                                       // For some reason trying to get the inputStream from the connection
-                                       // throws an exception rather than returning null when the InputStream does not exist.
-                                       InputStream is = null;
-                                       try {
-                                               is = connection.getInputStream();
-                                       } catch (Exception e1) {
-                                               LOGGER.error("Exception Occured"+e1);
-                                       }
-                                       if (is != null) {
-                                               is.close();
-                                       }
-
-                               } catch (IOException ex) {
-                                       LOGGER.error("Failed to close connection: " + ex, ex);
-                               }
-                               connection.disconnect();
-                       }
-               }
-               return responseString;
-
-       }
-
-}
index 117ac71..34b4817 100644 (file)
@@ -29,38 +29,41 @@ import com.fasterxml.jackson.annotation.JsonCreator;
  * @version 0.1
  */
 public enum DeletePolicyCondition {
-       
-       /**
-        * Indicates a condition to only delete the current version of the policy. 
-        */
-       ONE("Current Version"),
-       
-       /**
-        * Indicates a condition to delete all versions of the policy.
-        */
-       ALL("All Versions");
-       private String name;
 
-       private DeletePolicyCondition(String name){
-               this.name = name;
-       }
+    /**
+     * Indicates a condition to only delete the current version of the policy.
+     */
+    ONE("Current Version"),
 
-       /**
-        * Returns the <code>String</code> format of delete condition for this Policy
-        * @return the <code>String</code> of the delete condition for this Policy
-        */
-       @Override
-       public String toString(){
-               return this.name;
-       }
+    /**
+     * Indicates a condition to delete all versions of the policy.
+     */
+    ALL("All Versions");
 
-       @JsonCreator
-    public static DeletePolicyCondition create (String value) {
-        for(DeletePolicyCondition type: values()){
-            if(type.toString().equals(value) || type.equals(DeletePolicyCondition.valueOf(value))){
+    private final String name;
+
+    private DeletePolicyCondition(final String name) {
+        this.name = name;
+    }
+
+    /**
+     * Returns the <code>String</code> format of delete condition for this
+     * Policy
+     * 
+     * @return the <code>String</code> of the delete condition for this Policy
+     */
+    @Override
+    public String toString() {
+        return this.name;
+    }
+
+    @JsonCreator
+    public static DeletePolicyCondition create(final String value) {
+        for (final DeletePolicyCondition type : values()) {
+            if (type.toString().equalsIgnoreCase(value) || type.name().equalsIgnoreCase(value)) {
                 return type;
             }
         }
-        throw new IllegalArgumentException();
+        throw new IllegalArgumentException("Invalid value: " + value);
     }
 }
index 499295d..56b7322 100644 (file)
@@ -22,80 +22,82 @@ package org.onap.policy.api;
 
 import com.fasterxml.jackson.annotation.JsonCreator;
 
-public enum DictionaryType{
-       /**
-        * Indicates Common Dictionaries. 
-        */
-       Common("Common"),
-       /**
-        * Indicates Action Policy Dictionaries
-        */
-       Action("Action"),
-       /**
-        * Indicates ClosedLoop Policy Dictionaries. 
-        */
-       ClosedLoop("ClosedLoop"),
-       /**
-        * Indicates Firewall Config Policy Dictionaries. 
-        */
-       Firewall("Firewall"),
-       /**
-        * Indicates Decision Policy Dictionaries. 
-        */
-       Decision("Decision"),
-       /**
-        * Indicates BRMS Policy Dictionaries. 
-        */
-       BRMS("BRMS"),
-       /**
-        * Indicates DCAE Micro Service Policy Dictionaries. 
-        */
-       MicroService("MicroService"),
-       /**
-        * Indicates Descriptive Scope Dictionaries
-        */
-       DescriptiveScope("DescriptiveScope"),
-       /**
-        * Indicates Policy Scope Dictionaries
-        */
-       PolicyScope("PolicyScope"),
-       /**
-        * Indicates Enforcer Dictionaries
-        */
-       Enforcer("Enforcer"),
-       /**
-        * Indicates SafePolicy Dictionaries
-        */
-       SafePolicy("SafePolicy"),
-       /**
-        * Enum support entry to extend dictionary 
-        */
-       Extended("Extended"),
-       ;
-       
-       private String name;
-       
-       private DictionaryType(String typeName){
-               this.name = typeName;
-       }
-       
-       /**
-        * Returns the <code>String</code> format of Type for this <code>PolicyClass</code>
-        * @return the <code>String</code> of the Type for this <code>PolicyClass</code>
-        */
-       @Override
-       public String toString() {
-               return this.name;
-       }
-       
-       @JsonCreator
-    public static DictionaryType create (String value) {
-        for(DictionaryType type: values()){
-            if(type.toString().equals(value) || type.equals(DictionaryType.valueOf(value))){
+public enum DictionaryType {
+    /**
+     * Indicates Common Dictionaries.
+     */
+    Common("Common"),
+    /**
+     * Indicates Action Policy Dictionaries
+     */
+    Action("Action"),
+    /**
+     * Indicates ClosedLoop Policy Dictionaries.
+     */
+    ClosedLoop("ClosedLoop"),
+    /**
+     * Indicates Firewall Config Policy Dictionaries.
+     */
+    Firewall("Firewall"),
+    /**
+     * Indicates Decision Policy Dictionaries.
+     */
+    Decision("Decision"),
+    /**
+     * Indicates BRMS Policy Dictionaries.
+     */
+    BRMS("BRMS"),
+    /**
+     * Indicates DCAE Micro Service Policy Dictionaries.
+     */
+    MicroService("MicroService"),
+    /**
+     * Indicates Descriptive Scope Dictionaries
+     */
+    DescriptiveScope("DescriptiveScope"),
+    /**
+     * Indicates Policy Scope Dictionaries
+     */
+    PolicyScope("PolicyScope"),
+    /**
+     * Indicates Enforcer Dictionaries
+     */
+    Enforcer("Enforcer"),
+    /**
+     * Indicates SafePolicy Dictionaries
+     */
+    SafePolicy("SafePolicy"),
+    /**
+     * Enum support entry to extend dictionary
+     */
+    Extended("Extended");
+
+    private final String name;
+
+    private DictionaryType(final String typeName) {
+        this.name = typeName;
+    }
+
+    /**
+     * Returns the <code>String</code> format of Type for this
+     * <code>PolicyClass</code>
+     * 
+     * @return the <code>String</code> of the Type for this
+     *         <code>PolicyClass</code>
+     */
+    @Override
+    public String toString() {
+        return this.name;
+    }
+
+    @JsonCreator
+    public static DictionaryType create(final String value) {
+        for (final DictionaryType type : values()) {
+            if (type.toString().equalsIgnoreCase(value) || type.name().equalsIgnoreCase(value)) {
                 return type;
             }
         }
-        throw new IllegalArgumentException();
+        throw new IllegalArgumentException("Invalid value: " + value);
     }
 
 }
index 6a648e8..fb389bb 100644 (file)
@@ -29,40 +29,44 @@ import com.fasterxml.jackson.annotation.JsonCreator;
  * @version 0.1
  */
 public enum PolicyClass {
-       /**
-        * Indicates Config based Policy. 
-        */
-       Config("Config"),
-       /**
-        * Indicates Action based Policy. 
-        */
-       Action("Action"),
-       /**
-        * Indicates Decision based Policy. 
-        */
-       Decision("Decision")
-       ;
-       private String name;
-       
-       private PolicyClass(String typeName){
-               this.name = typeName;
-       }
-       
-       /**
-        * Returns the <code>String</code> format of Type for this <code>PolicyClass</code>
-        * @return the <code>String</code> of the Type for this <code>PolicyClass</code>
-        */
-       @Override
-       public String toString() {
-               return this.name;
-       }
-       @JsonCreator
-    public static PolicyClass create (String value) {
-        for(PolicyClass type: values()){
-            if(type.toString().equals(value) || type.equals(PolicyClass.valueOf(value))){
+    /**
+     * Indicates Config based Policy.
+     */
+    Config("Config"),
+    /**
+     * Indicates Action based Policy.
+     */
+    Action("Action"),
+    /**
+     * Indicates Decision based Policy.
+     */
+    Decision("Decision");
+
+    private final String name;
+
+    private PolicyClass(final String typeName) {
+        this.name = typeName;
+    }
+
+    /**
+     * Returns the <code>String</code> format of Type for this
+     * <code>PolicyClass</code>
+     * 
+     * @return the <code>String</code> of the Type for this
+     *         <code>PolicyClass</code>
+     */
+    @Override
+    public String toString() {
+        return this.name;
+    }
+
+    @JsonCreator
+    public static PolicyClass create(final String value) {
+        for (final PolicyClass type : values()) {
+            if (type.toString().equalsIgnoreCase(value) || type.name().equalsIgnoreCase(value)) {
                 return type;
             }
         }
-        throw new IllegalArgumentException();
+        throw new IllegalArgumentException("Invalid value: " + value);
     }
 }
index cee1567..f1bbea1 100644 (file)
@@ -23,58 +23,63 @@ package org.onap.policy.api;
 import com.fasterxml.jackson.annotation.JsonCreator;
 
 /**
- * Enumeration of PolicyConfigStatus that can be returned as a part of 
+ * Enumeration of PolicyConfigStatus that can be returned as a part of
  * {@link org.onap.policy.api.PolicyConfig}.
  * 
  * @version 0.1
  */
-public enum PolicyConfigStatus {       
-       /**
-        * Indicates that the Configuration has been successfully retrieved. 
-        */
-       CONFIG_RETRIEVED("retrieved"),
-       /**
-        * Indicates that there is no Configuration Retrieved from PolicyConfig.
-        */
-       CONFIG_NOT_FOUND("not_found"),
-       ;
-       
-       private String name;
-       private PolicyConfigStatus(String name){
-               this.name = name;
-       }
-       
-       /**
-        * Get the <code>PolicyConfigStatus</code> based on <code>String</code> representation of <code>PolicyConfig</code>
-        * 
-        * @param configStatus the <code>String</code> Configuration Status
-        * @return the <code>PolicyConfigResponse</code> with the name matching <code>CONFIG_RETRIEVED</code> or <code>CONFIG_NOT_FOUND</code>
-        * if no match is found
-        */
-       public static PolicyConfigStatus getStatus(String configStatus) {
-               if("retrieved".equalsIgnoreCase(configStatus)) {
-                       return CONFIG_RETRIEVED;
-               }else {
-                       return CONFIG_NOT_FOUND;
-               }
-       }
-       
-       /**
-        * Returns the <code>String</code> name for this <code>PolicyConfigStatus</code>
-        * 
-        * @return the <code>String</code> name for this <code>PolicyConfigStatus</code>
-        */
-       @Override
-       public String toString(){
-               return this.name;
-       }
-       @JsonCreator
-    public static PolicyConfigStatus create (String value) {
-        for(PolicyConfigStatus type: values()){
-            if(type.toString().equals(value) || type.equals(PolicyConfigStatus.valueOf(value))){
+public enum PolicyConfigStatus {
+    /**
+     * Indicates that the Configuration has been successfully retrieved.
+     */
+    CONFIG_RETRIEVED("retrieved"),
+    /**
+     * Indicates that there is no Configuration Retrieved from PolicyConfig.
+     */
+    CONFIG_NOT_FOUND("not_found");
+
+    private final String name;
+
+    private PolicyConfigStatus(final String name) {
+        this.name = name;
+    }
+
+    /**
+     * Get the <code>PolicyConfigStatus</code> based on <code>String</code>
+     * representation of <code>PolicyConfig</code>
+     * 
+     * @param configStatus
+     *            the <code>String</code> Configuration Status
+     * @return the <code>PolicyConfigResponse</code> with the name matching
+     *         <code>CONFIG_RETRIEVED</code> or <code>CONFIG_NOT_FOUND</code> if
+     *         no match is found
+     */
+    public static PolicyConfigStatus getStatus(final String configStatus) {
+        if (CONFIG_RETRIEVED.name.equalsIgnoreCase(configStatus)) {
+            return CONFIG_RETRIEVED;
+        }
+        return CONFIG_NOT_FOUND;
+    }
+
+    /**
+     * Returns the <code>String</code> name for this
+     * <code>PolicyConfigStatus</code>
+     * 
+     * @return the <code>String</code> name for this
+     *         <code>PolicyConfigStatus</code>
+     */
+    @Override
+    public String toString() {
+        return this.name;
+    }
+
+    @JsonCreator
+    public static PolicyConfigStatus create(final String value) {
+        for (final PolicyConfigStatus type : values()) {
+            if (type.toString().equalsIgnoreCase(value) || type.name().equalsIgnoreCase(value)) {
                 return type;
             }
         }
-        throw new IllegalArgumentException();
+        throw new IllegalArgumentException("Invalid value: " + value);
     }
 }
index 6bae84c..782d444 100644 (file)
@@ -23,47 +23,48 @@ package org.onap.policy.api;
 import com.fasterxml.jackson.annotation.JsonCreator;
 
 /**
- * Enumeration of PolicyDecision that can be returned as a part of 
+ * Enumeration of PolicyDecision that can be returned as a part of
  * {@link org.onap.policy.api.DecisionResponse} getDecision().
  * 
  * @version 0.1
  */
 public enum PolicyDecision {
-       /**
-        * Indicates that the Decision is to Permit. 
-        */
-       PERMIT("permit"),
-       /**
-        * Indicates that the Decision is to Deny. 
-        */
-       DENY("deny"),
-       /**
-        * Indicates that the Decision process has some issues. 
-        */
-       ERROR("error")
-       ;
-       
-       private String name;
-       private PolicyDecision(String name){
-               this.name = name;
-       }
-       
-       /**
-        * Returns the <code>String</code> name for this <code>PolicyDecision</code>
-        * 
-        * @return the <code>String</code> name for this <code>PolicyDecision</code>
-        */
-       @Override
-       public String toString(){
-               return this.name;
-       }
-       @JsonCreator
-    public static PolicyDecision create (String value) {
-        for(PolicyDecision type: values()){
-            if(type.toString().equals(value) || type.equals(PolicyDecision.valueOf(value))){
+    /**
+     * Indicates that the Decision is to Permit.
+     */
+    PERMIT("permit"),
+    /**
+     * Indicates that the Decision is to Deny.
+     */
+    DENY("deny"),
+    /**
+     * Indicates that the Decision process has some issues.
+     */
+    ERROR("error");
+
+    private final String name;
+
+    private PolicyDecision(final String name) {
+        this.name = name;
+    }
+
+    /**
+     * Returns the <code>String</code> name for this <code>PolicyDecision</code>
+     * 
+     * @return the <code>String</code> name for this <code>PolicyDecision</code>
+     */
+    @Override
+    public String toString() {
+        return this.name;
+    }
+
+    @JsonCreator
+    public static PolicyDecision create(final String value) {
+        for (final PolicyDecision type : values()) {
+            if (type.toString().equalsIgnoreCase(value) || type.name().equalsIgnoreCase(value)) {
                 return type;
             }
         }
-        throw new IllegalArgumentException();
+        throw new IllegalArgumentException("Invalid value: " + value);
     }
 }
index 63cb918..0db373c 100644 (file)
@@ -28,59 +28,65 @@ import com.fasterxml.jackson.annotation.JsonCreator;
  * 
  * @version 0.2
  */
-public enum PolicyResponseStatus {     
-       /**
-        * Indicates there is no action required.
-        */
-       NO_ACTION_REQUIRED("no_action"),
-       /** 
-        * Indicates that an action has been advised.
-        */
-       ACTION_ADVISED("action_advised"),
-       /**
-        * Indicates that an action has been taken.
-        */
-       ACTION_TAKEN("action_taken")
-       ;
-       
-       private String name;
-       private PolicyResponseStatus(String name){
-               this.name = name;
-       }
-       
-       /**
-        * Get the <code>PolicyResponseStatus</code> based on <code>String</code> representation of <code>PolicyResponse</code>
-        * 
-        * @param responseStatus the <code>String</code> Response Status
-        * @return the <code>PolicyResponseStatus</code> with the name matching <code>ACTION_ADVISED</code> or <code>ACTION_TAKEN</code> or <code>NO_ACTION_REQUIRED</code>
-        */
-       public static PolicyResponseStatus getStatus(String responseStatus) {
-               if("action_advised".equalsIgnoreCase(responseStatus)) {
-                       return ACTION_ADVISED;
-               }else if("action_taken".equalsIgnoreCase(responseStatus)) {
-                       return ACTION_TAKEN;
-               }else {
-                       return NO_ACTION_REQUIRED;
-               }
-       }
-       
-       /**
-        * Returns the <code>String</code> name for this <code>PolicyResponseStatus</code>
-        * 
-        * @return the <code>String</code> name for this <code>PolicyResponseStatus</code>
-        */
-       @Override
-       public String toString(){
-               return this.name;
-       }
-       
-       @JsonCreator
-    public static PolicyResponseStatus create (String value) {
-        for(PolicyResponseStatus type: values()){
-            if(type.toString().equals(value) || type.equals(PolicyResponseStatus.valueOf(value))){
+public enum PolicyResponseStatus {
+    /**
+     * Indicates there is no action required.
+     */
+    NO_ACTION_REQUIRED("no_action"),
+    /**
+     * Indicates that an action has been advised.
+     */
+    ACTION_ADVISED("action_advised"),
+    /**
+     * Indicates that an action has been taken.
+     */
+    ACTION_TAKEN("action_taken");
+
+    private final String name;
+
+    private PolicyResponseStatus(final String name) {
+        this.name = name;
+    }
+
+    /**
+     * Get the <code>PolicyResponseStatus</code> based on <code>String</code>
+     * representation of <code>PolicyResponse</code>
+     * 
+     * @param responseStatus
+     *            the <code>String</code> Response Status
+     * @return the <code>PolicyResponseStatus</code> with the name matching
+     *         <code>ACTION_ADVISED</code> or <code>ACTION_TAKEN</code> or
+     *         <code>NO_ACTION_REQUIRED</code>
+     */
+    public static PolicyResponseStatus getStatus(final String responseStatus) {
+        if (ACTION_ADVISED.name.equalsIgnoreCase(responseStatus)) {
+            return ACTION_ADVISED;
+        } else if (ACTION_TAKEN.name.equalsIgnoreCase(responseStatus)) {
+            return ACTION_TAKEN;
+        } else {
+            return NO_ACTION_REQUIRED;
+        }
+    }
+
+    /**
+     * Returns the <code>String</code> name for this
+     * <code>PolicyResponseStatus</code>
+     * 
+     * @return the <code>String</code> name for this
+     *         <code>PolicyResponseStatus</code>
+     */
+    @Override
+    public String toString() {
+        return this.name;
+    }
+
+    @JsonCreator
+    public static PolicyResponseStatus create(final String value) {
+        for (final PolicyResponseStatus type : values()) {
+            if (type.toString().equalsIgnoreCase(value) || type.name().equalsIgnoreCase(value)) {
                 return type;
             }
         }
-        throw new IllegalArgumentException();
+        throw new IllegalArgumentException("Invalid value: " + value);
     }
 }
index a29a6c4..0ff5480 100644 (file)
@@ -29,45 +29,48 @@ import com.fasterxml.jackson.annotation.JsonCreator;
  * @version 0.2
  */
 public enum PolicyType {
-       /**
-        * Indicates the response is Properties type
-        */
-       PROPERTIES("Properties"),
-       /**
-        * Indicates the response is JSON type
-        */
-       JSON("json"),
-       /**
-        * Indicates the response is XML type
-        */
-       XML("xml"),
-       /**
-        * Indicates the response is Other type
-        */
-       OTHER("other")
-       ;
-       
-       private String name; 
-       
-       private PolicyType(String typeName) {
-               this.name = typeName;
-       }
-       
-       /**
-        * Returns the <code>String</code> format of Type for this <code>PolicyType</code>
-        * @return the <code>String</code> of the Type for this <code>PolicyType</code>
-        */
-       @Override
-       public String toString() {
-               return this.name;
-       }
-       @JsonCreator
-    public static PolicyType create (String value) {
-        for(PolicyType type: values()){
-            if(type.toString().equalsIgnoreCase(value)){
+    /**
+     * Indicates the response is Properties type
+     */
+    PROPERTIES("Properties"),
+    /**
+     * Indicates the response is JSON type
+     */
+    JSON("json"),
+    /**
+     * Indicates the response is XML type
+     */
+    XML("xml"),
+    /**
+     * Indicates the response is Other type
+     */
+    OTHER("other");
+
+    private final String name;
+
+    private PolicyType(final String typeName) {
+        this.name = typeName;
+    }
+
+    /**
+     * Returns the <code>String</code> format of Type for this
+     * <code>PolicyType</code>
+     * 
+     * @return the <code>String</code> of the Type for this
+     *         <code>PolicyType</code>
+     */
+    @Override
+    public String toString() {
+        return this.name;
+    }
+
+    @JsonCreator
+    public static PolicyType create(final String value) {
+        for (final PolicyType type : values()) {
+            if (type.toString().equalsIgnoreCase(value) || type.name().equalsIgnoreCase(value)) {
                 return type;
             }
         }
-        throw new IllegalArgumentException();
-    }  
+        throw new IllegalArgumentException("Invalid value: " + value);
+    }
 }
index 2e45549..913f325 100644 (file)
@@ -29,50 +29,52 @@ import com.fasterxml.jackson.annotation.JsonCreator;
  * @version 0.1
  */
 public enum RuleProvider {
-       /**
-        * Indicates User will be defining the Rule information. 
-        */
-       CUSTOM("Custom"),
-       /**
-        * Indicates AAF will be providing the Rule information. 
-        */
-       AAF("AAF"),
-       /**
-        * Indicates Guard YAML will be providing the Rule information.
-        */
-       GUARD_YAML("GUARD_YAML"),
-       /**
-        * Indicates Guard BLACKLIST YAML 
-        */
-       GUARD_BL_YAML("GUARD_BL_YAML"),
-       /**
-        * Indicates Guard BLACKLIST YAML 
-        */
-       RAINY_DAY("Rainy_Day")
-       ;
-       
-       private String name;
-       
-       private RuleProvider(String typeName){
-               this.name = typeName;
-       }
-       
-       /**
-        * Returns the <code>String</code> format of Type for this <code>AttributeType</code>
-        * @return the <code>String</code> of the Type for this <code>AttributeType</code>
-        */
-       @Override
-       public String toString() {
-               return this.name;
-       }
-       
-       @JsonCreator
-    public static RuleProvider create (String value) {
-        for(RuleProvider type: values()){
-            if(type.toString().equals(value) || type.equals(RuleProvider.valueOf(value))){
+    /**
+     * Indicates User will be defining the Rule information.
+     */
+    CUSTOM("Custom"),
+    /**
+     * Indicates AAF will be providing the Rule information.
+     */
+    AAF("AAF"),
+    /**
+     * Indicates Guard YAML will be providing the Rule information.
+     */
+    GUARD_YAML("GUARD_YAML"),
+    /**
+     * Indicates Guard BLACKLIST YAML
+     */
+    GUARD_BL_YAML("GUARD_BL_YAML"),
+    /**
+     * Indicates Guard BLACKLIST YAML
+     */
+    RAINY_DAY("Rainy_Day");
+
+    private final String name;
+
+    private RuleProvider(final String typeName) {
+        this.name = typeName;
+    }
+
+    /**
+     * Returns the <code>String</code> format of Type for this
+     * <code>AttributeType</code>
+     * 
+     * @return the <code>String</code> of the Type for this
+     *         <code>AttributeType</code>
+     */
+    @Override
+    public String toString() {
+        return this.name;
+    }
+
+    @JsonCreator
+    public static RuleProvider create(final String value) {
+        for (final RuleProvider type : values()) {
+            if (type.toString().equalsIgnoreCase(value) || type.name().equalsIgnoreCase(value)) {
                 return type;
             }
         }
-        throw new IllegalArgumentException();
+        throw new IllegalArgumentException("Invalid value: " + value);
     }
 }
index 050f36b..79c6196 100644 (file)
@@ -21,33 +21,43 @@ package org.onap.policy.models;
 
 public class APIDictionaryResponse {
     private Object dictionaryData;
+
     private Object dictionaryJson;
+
     private int responseCode;
+
     private String responseMessage;
+
     public Object getDictionaryData() {
         return dictionaryData;
     }
-    public void setDictionaryData(Object dictionaryData) {
+
+    public void setDictionaryData(final Object dictionaryData) {
         this.dictionaryData = dictionaryData;
     }
+
     public Object getDictionaryJson() {
         return dictionaryJson;
     }
-    public void setDictionaryJson(Object dictionaryJson) {
+
+    public void setDictionaryJson(final Object dictionaryJson) {
         this.dictionaryJson = dictionaryJson;
     }
+
     public int getResponseCode() {
         return responseCode;
     }
-    public void setResponseCode(int responseCode) {
+
+    public void setResponseCode(final int responseCode) {
         this.responseCode = responseCode;
     }
+
     public String getResponseMessage() {
         return responseMessage;
     }
-    public void setResponseMessage(String responseMessage) {
+
+    public void setResponseMessage(final String responseMessage) {
         this.responseMessage = responseMessage;
     }
-    
-    
+
 }
index e5204d8..fa80299 100644 (file)
@@ -21,7 +21,9 @@
 package org.onap.policy.std;
 
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 
 import org.onap.policy.api.LoadedPolicy;
@@ -29,220 +31,132 @@ import org.onap.policy.api.NotificationType;
 import org.onap.policy.api.PDPNotification;
 import org.onap.policy.api.RemovedPolicy;
 import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger; 
+import org.onap.policy.common.logging.flexlogger.Logger;
 
 public class MatchStore {
-       private static HashSet<Matches> matchStore = new HashSet<>();
-       private static Logger logger = FlexLogger.getLogger(MatchStore.class.getName());
-       
-       private MatchStore() {
-               // Empty Constructor
-       }
-       
-       public static Set<Matches> getMatchStore() {
-               return matchStore;
-       }
-
-       public static void storeMatch(Matches newMatch){
-               // Initialization..
-               if(newMatch!=null){
-                       if(matchStore.isEmpty()){
-                               matchStore.add(newMatch);
-                       }else{
-                               // Check if it is a new Match
-                               Boolean match = false;
-                               for(Matches oldMatch: matchStore){
-                                       // Compare ONAPName
-                                       if(oldMatch.getOnapName().equals(newMatch.getOnapName())){
-                                               // Compare ConfigName if it exists. 
-                                               if(newMatch.getConfigName()!=null && oldMatch.getConfigName()!=null){
-                                                       if(oldMatch.getConfigName().equals(newMatch.getConfigName())){
-                                                               // Compare the Config Attributes if they exist.
-                                                               if(newMatch.getConfigAttributes()!= null && oldMatch.getConfigAttributes()!=null) {
-                                                                       //Simple thing would be comparing their size. 
-                                                                       if(newMatch.getConfigAttributes().size()==oldMatch.getConfigAttributes().size()){
-                                                                               // Now need to compare each of them..
-                                                                               int count= 0;
-                                                                               for(String oldkey: oldMatch.getConfigAttributes().keySet()){
-                                                                                       boolean check = false;
-                                                                                       for(String newKey: newMatch.getConfigAttributes().keySet()){
-                                                                                               if(oldkey.equals(newKey)){
-                                                                                                       if(oldMatch.getConfigAttributes().get(oldkey).equals(newMatch.getConfigAttributes().get(newKey))){
-                                                                                                               check = true;
-                                                                                                       }
-                                                                                               }
-                                                                                       }
-                                                                                       if(check){
-                                                                                               count++;
-                                                                                       }else{
-                                                                                               break;
-                                                                                       }
-                                                                               }
-                                                                               if(count==oldMatch.getConfigAttributes().size()){
-                                                                                       match = true;
-                                                                                       break;
-                                                                               }
-                                                                       }
-                                                               }else if(newMatch.getConfigAttributes()== null && oldMatch.getConfigAttributes()==null){
-                                                                       match = true;
-                                                                       break;
-                                                               }
-                                                       }
-                                               }else if(newMatch.getConfigName()==null && oldMatch.getConfigName()==null){
-                                                       match = true;
-                                                       break;
-                                               }       
-                                       }
-                                       
-                               }
-                               // IF not a match then add it to the MatchStore
-                               if(! match){
-                                       matchStore.add(newMatch);
-                               }
-                       }
-               }
-       }
-       
-       //Logic changes for Requested Policies notifications.. 
-       public static PDPNotification checkMatch(PDPNotification oldNotification) {
-               boolean removed = false;
-               boolean updated = false;
-               if(oldNotification==null){
-                       return null;
-               }
-               StdPDPNotification newNotification = new StdPDPNotification();
-               if(matchStore.isEmpty()) {
-                       logger.debug("No Success Config Calls made yet.. ");
-                       return null;
-               } 
-               if(oldNotification.getRemovedPolicies()!=null && !oldNotification.getRemovedPolicies().isEmpty()){
-                       // send all removed policies to client.
-                       Collection<StdRemovedPolicy> removedPolicies = new HashSet<>();
-                       StdRemovedPolicy newRemovedPolicy;
-                       for(RemovedPolicy removedPolicy: oldNotification.getRemovedPolicies()){
-                               newRemovedPolicy = new StdRemovedPolicy();
-                               newRemovedPolicy.setPolicyName(removedPolicy.getPolicyName());
-                               newRemovedPolicy.setVersionNo(removedPolicy.getVersionNo());
-                               removedPolicies.add(newRemovedPolicy);
-                       }
-                       newNotification.setRemovedPolicies(removedPolicies);
-                       removed = true;
-               }
-               if(oldNotification.getLoadedPolicies()!=null && !oldNotification.getLoadedPolicies().isEmpty()){
-                       Collection<StdLoadedPolicy> updatedPolicies = new HashSet<>();
-                       StdLoadedPolicy newUpdatedPolicy;
-                       for(LoadedPolicy updatedPolicy: oldNotification.getLoadedPolicies()){
-                               // if it is config policies check their matches..
-                               if(updatedPolicy.getMatches()!=null && !updatedPolicy.getMatches().isEmpty()){
-                                       boolean matched;
-                                       for(Matches match : matchStore){
-                                               matched = false;
-                                               // Again Better way would be comparing sizes first.
-                                               // Matches are different need to check if has configAttributes
-                                               if(match.getConfigAttributes()!=null && !match.getConfigAttributes().isEmpty()){
-                                                       // adding onap and config to config-attributes. 
-                                                       int compValues = match.getConfigAttributes().size() + 2;
-                                                       if(updatedPolicy.getMatches().size()== compValues){
-                                                               // Comparing both the values.. 
-                                                               boolean matchAttributes = false;
-                                                               for(String newKey: updatedPolicy.getMatches().keySet()){
-                                                                       if("ONAPName".equals(newKey)){
-                                                                               if(updatedPolicy.getMatches().get(newKey).equals(match.getOnapName())){
-                                                                                       matchAttributes = true;
-                                                                               }else {
-                                                                                       matchAttributes = false;
-                                                                                       break;
-                                                                               }
-                                                                       }else if("ConfigName".equals(newKey)) {
-                                                                               if(updatedPolicy.getMatches().get(newKey).equals(match.getConfigName())){
-                                                                                       matchAttributes = true;
-                                                                               }else{
-                                                                                       matchAttributes = false;
-                                                                                       break;
-                                                                               }
-                                                                       }else {
-                                                                               if(match.getConfigAttributes().containsKey(newKey)){
-                                                                                       if(updatedPolicy.getMatches().get(newKey).equals(match.getConfigAttributes().get(newKey))){
-                                                                                               matchAttributes = true;
-                                                                                       }else{
-                                                                                               matchAttributes = false;
-                                                                                               break;
-                                                                                       }
-                                                                               }else{
-                                                                                       matchAttributes = false;
-                                                                                       break;
-                                                                               }
-                                                                       }
-                                                               }
-                                                               if(matchAttributes){
-                                                                       // Match..
-                                                                       matched = true;
-                                                               }else{
-                                                                       break;
-                                                               }
-                                                       }else {
-                                                               break;
-                                                       }
-                                               }else if(match.getConfigName()!=null){
-                                                       // If there are no config Attributes then check if it has Config Name
-                                                       if(updatedPolicy.getMatches().size()== 2){
-                                                               if(updatedPolicy.getMatches().get("ONAPName").equals(match.getOnapName())){
-                                                                       if(updatedPolicy.getMatches().get("ConfigName").equals(match.getConfigName())){
-                                                                               // Match..
-                                                                               matched = true;
-                                                                       }else{
-                                                                               break;
-                                                                       }
-                                                               }else {
-                                                                       break;
-                                                               }
-                                                       }else{
-                                                               break;
-                                                       }
-                                               }else {
-                                                       // If non exist then assuming the ONAP Name to be there. 
-                                                       if(updatedPolicy.getMatches().size()== 1){
-                                                               if(updatedPolicy.getMatches().get("ONAPName").equals(match.getOnapName())){
-                                                                       // Match.. 
-                                                                       matched = true;
-                                                               }else {
-                                                                       break;
-                                                               }
-                                                       }else{
-                                                               break;
-                                                       }
-                                               }
-                                               // Add logic to add the policy. 
-                                               if(matched){
-                                                       newUpdatedPolicy = new StdLoadedPolicy();
-                                                       newUpdatedPolicy.setPolicyName(updatedPolicy.getPolicyName());
-                                                       newUpdatedPolicy.setVersionNo(updatedPolicy.getVersionNo());
-                                                       newUpdatedPolicy.setMatches(updatedPolicy.getMatches());
-                                                       updatedPolicies.add(newUpdatedPolicy);
-                                                       updated = true;
-                                               }
-                                       }
-                                       
-                               }else {
-                                       //send all non config notifications to client.
-                                       newUpdatedPolicy = new StdLoadedPolicy();
-                                       newUpdatedPolicy.setPolicyName(updatedPolicy.getPolicyName());
-                                       newUpdatedPolicy.setVersionNo(updatedPolicy.getVersionNo());
-                                       updatedPolicies.add(newUpdatedPolicy);
-                                       updated = true;
-                               }
-                       }
-                       newNotification.setLoadedPolicies(updatedPolicies);
-               }
-               // Need to set the type of Update.. 
-               if(removed && updated) {
-                       newNotification.setNotificationType(NotificationType.BOTH);
-               }else if(removed){
-                       newNotification.setNotificationType(NotificationType.REMOVE);
-               }else if(updated){
-                       newNotification.setNotificationType(NotificationType.UPDATE);
-               }
-               return newNotification;
-       }
-       
+    private static final String CONFIG_NAME = "ConfigName";
+
+    private static final String ONAP_NAME = "ONAPName";
+
+    private static final Set<Matches> MATCH_STORE = new HashSet<>();
+
+    private static final Logger LOGGER = FlexLogger.getLogger(MatchStore.class.getName());
+
+    private MatchStore() {
+        // Empty Constructor
+    }
+
+    public static Set<Matches> getMatchStore() {
+        return MATCH_STORE;
+    }
+
+    public static void storeMatch(final Matches newMatch) {
+        if (newMatch != null && !MATCH_STORE.contains(newMatch)) {
+            MATCH_STORE.add(newMatch);
+        }
+    }
+
+    // Logic changes for Requested Policies notifications..
+    public static PDPNotification checkMatch(final PDPNotification oldNotification) {
+        if (oldNotification == null) {
+            return null;
+        }
+        if (MATCH_STORE.isEmpty()) {
+            LOGGER.debug("No Success Config Calls made yet.. ");
+            return null;
+        }
+        return getPDPNotification(oldNotification);
+    }
+
+    private static PDPNotification getPDPNotification(final PDPNotification oldNotification) {
+        boolean removed = false;
+        boolean updated = false;
+        final StdPDPNotification newNotification = new StdPDPNotification();
+        if (isValid(oldNotification.getRemovedPolicies())) {
+            // send all removed policies to client.
+            newNotification.setRemovedPolicies(getStdRemovedPolicies(oldNotification.getRemovedPolicies()));
+            removed = true;
+        }
+        if (isValid(oldNotification.getLoadedPolicies())) {
+            final Collection<StdLoadedPolicy> updatedPolicies = new HashSet<>();
+            for (final LoadedPolicy updatedPolicy : oldNotification.getLoadedPolicies()) {
+                updated = updateStdLoadedPolicy(updated, updatedPolicies, updatedPolicy);
+            }
+            newNotification.setLoadedPolicies(updatedPolicies);
+        }
+        // Need to set the type of Update..
+        if (removed && updated) {
+            newNotification.setNotificationType(NotificationType.BOTH);
+        } else if (removed) {
+            newNotification.setNotificationType(NotificationType.REMOVE);
+        } else if (updated) {
+            newNotification.setNotificationType(NotificationType.UPDATE);
+        }
+        return newNotification;
+    }
+
+    private static boolean updateStdLoadedPolicy(boolean updated, final Collection<StdLoadedPolicy> updatedPolicies,
+            final LoadedPolicy updatedPolicy) {
+        // if it is config policies check their matches
+        if (isValid(updatedPolicy.getMatches())) {
+            final Map<String, String> matchesMap = updatedPolicy.getMatches();
+            final Matches policyMatches = getMatches(matchesMap);
+            for (final Matches match : MATCH_STORE) {
+                if (match.equals(policyMatches)) {
+                    final StdLoadedPolicy newUpdatedPolicy = new StdLoadedPolicy();
+                    newUpdatedPolicy.setPolicyName(updatedPolicy.getPolicyName());
+                    newUpdatedPolicy.setVersionNo(updatedPolicy.getVersionNo());
+                    newUpdatedPolicy.setMatches(updatedPolicy.getMatches());
+                    updatedPolicies.add(newUpdatedPolicy);
+                    updated = true;
+                } else {
+                    break;
+                }
+            }
+
+        } else {
+            // send all non config notifications to client.
+            final StdLoadedPolicy newUpdatedPolicy = new StdLoadedPolicy();
+            newUpdatedPolicy.setPolicyName(updatedPolicy.getPolicyName());
+            newUpdatedPolicy.setVersionNo(updatedPolicy.getVersionNo());
+            updatedPolicies.add(newUpdatedPolicy);
+            updated = true;
+        }
+        return updated;
+    }
+
+    private static Matches getMatches(final Map<String, String> attributes) {
+        final Matches matches = new Matches();
+        matches.setOnapName(attributes.get(ONAP_NAME));
+        matches.setConfigName(attributes.get(CONFIG_NAME));
+
+        final Map<String, String> configAttributes = new HashMap<>(attributes);
+        // remove onap and config to config-attributes.
+        configAttributes.remove(ONAP_NAME);
+        configAttributes.remove(CONFIG_NAME);
+
+        matches.setConfigAttributes(configAttributes);
+
+        return matches;
+    }
+
+    private static boolean isValid(final Map<String, String> map) {
+        return map != null && !map.isEmpty();
+    }
+
+    private static Collection<StdRemovedPolicy> getStdRemovedPolicies(final Collection<RemovedPolicy> policies) {
+        final Set<StdRemovedPolicy> removedPolicies = new HashSet<>();
+        for (final RemovedPolicy removedPolicy : policies) {
+            final StdRemovedPolicy newRemovedPolicy = new StdRemovedPolicy();
+            newRemovedPolicy.setPolicyName(removedPolicy.getPolicyName());
+            newRemovedPolicy.setVersionNo(removedPolicy.getVersionNo());
+            removedPolicies.add(newRemovedPolicy);
+        }
+        return removedPolicies;
+    }
+
+    private static boolean isValid(final Collection<?> collection) {
+        return collection != null && !collection.isEmpty();
+    }
+
 }
index eb382a6..b3486e4 100644 (file)
@@ -23,26 +23,61 @@ package org.onap.policy.std;
 import java.util.Map;
 
 public class Matches {
-       private String onapName = null;
-       private String configName = null;
-       private Map<String,String> configAttributes = null;
-       public String getOnapName() {
-               return onapName;
-       }
-       public void setOnapName(String onapName) {
-               this.onapName = onapName;
-       }
-       public String getConfigName() {
-               return configName;
-       }
-       public void setConfigName(String configName) {
-               this.configName = configName;
-       }
-       public Map<String,String> getConfigAttributes() {
-               return configAttributes;
-       }
-       public void setConfigAttributes(Map<String,String> configAttributes) {
-               this.configAttributes = configAttributes;
-       }
-       
+    private String onapName = null;
+
+    private String configName = null;
+
+    private Map<String, String> configAttributes = null;
+
+    public String getOnapName() {
+        return onapName;
+    }
+
+    public void setOnapName(final String onapName) {
+        this.onapName = onapName;
+    }
+
+    public String getConfigName() {
+        return configName;
+    }
+
+    public void setConfigName(final String configName) {
+        this.configName = configName;
+    }
+
+    public Map<String, String> getConfigAttributes() {
+        return configAttributes;
+    }
+
+    public void setConfigAttributes(final Map<String, String> configAttributes) {
+        this.configAttributes = configAttributes;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((configAttributes == null) ? 0 : configAttributes.hashCode());
+        result = prime * result + ((configName == null) ? 0 : configName.hashCode());
+        result = prime * result + ((onapName == null) ? 0 : onapName.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (obj instanceof Matches) {
+            final Matches other = (Matches) obj;
+            return isEqual(onapName, other.onapName) && isEqual(configName, other.configName)
+                    && isEqual(configAttributes, other.configAttributes);
+        }
+        return false;
+    }
+
+    private boolean isEqual(final Object objectA, final Object objectB) {
+        if (objectA == null) {
+            return objectB == null;
+        }
+        return objectA.equals(objectB);
+    }
+
 }
index 6772f5a..fb70298 100644 (file)
@@ -31,40 +31,48 @@ import org.onap.policy.api.UpdateType;
 import com.fasterxml.jackson.databind.ObjectMapper;
 
 public class NotificationUnMarshal {
-       
-       private NotificationUnMarshal() {
-               // Empty constructor
-       }
-       
-       public static StdPDPNotification notificationJSON(String json) throws IOException{
-               ObjectMapper mapper = new ObjectMapper();
-               StdPDPNotification notification = mapper.readValue(json, StdPDPNotification.class);
-               if(notification == null || notification.getLoadedPolicies() == null){
-                       return notification;
-               }
-           Collection<StdLoadedPolicy> stdLoadedPolicies = new ArrayList<>();
-           for(LoadedPolicy loadedPolicy: notification.getLoadedPolicies()){
-               StdLoadedPolicy stdLoadedPolicy = (StdLoadedPolicy) loadedPolicy;
-               if(notification.getRemovedPolicies()!=null){
-                   Boolean updated = false;
-                   for(RemovedPolicy removedPolicy: notification.getRemovedPolicies()){
-                       String regex = ".(\\d)*.xml";
-                       if(removedPolicy.getPolicyName().replaceAll(regex, "").equals(stdLoadedPolicy.getPolicyName().replaceAll(regex, ""))){
-                           updated  = true;
-                           break;
-                       }
-                   }
-                   if(updated){
-                       stdLoadedPolicy.setUpdateType(UpdateType.UPDATE);
-                   }else{
-                       stdLoadedPolicy.setUpdateType(UpdateType.NEW);
-                   }
-               }else{
-                   stdLoadedPolicy.setUpdateType(UpdateType.NEW);
-               }
-               stdLoadedPolicies.add(stdLoadedPolicy);
-           }
-           notification.setLoadedPolicies(stdLoadedPolicies);
-               return notification;
-       }
+
+    private static final String EMPTY_STRING = "";
+
+    private static final String REGEX = ".(\\d)*.xml";
+
+    private NotificationUnMarshal() {
+        // Empty constructor
+    }
+
+    public static StdPDPNotification notificationJSON(final String json) throws IOException {
+        final ObjectMapper mapper = new ObjectMapper();
+        final StdPDPNotification notification = mapper.readValue(json, StdPDPNotification.class);
+        if (notification == null || notification.getLoadedPolicies() == null) {
+            return notification;
+        }
+        final Collection<StdLoadedPolicy> stdLoadedPolicies = new ArrayList<>();
+        for (final LoadedPolicy loadedPolicy : notification.getLoadedPolicies()) {
+            final StdLoadedPolicy stdLoadedPolicy = (StdLoadedPolicy) loadedPolicy;
+            if (notification.getRemovedPolicies() != null) {
+                if (isUpdated(notification, stdLoadedPolicy)) {
+                    stdLoadedPolicy.setUpdateType(UpdateType.UPDATE);
+                } else {
+                    stdLoadedPolicy.setUpdateType(UpdateType.NEW);
+                }
+            } else {
+                stdLoadedPolicy.setUpdateType(UpdateType.NEW);
+            }
+            stdLoadedPolicies.add(stdLoadedPolicy);
+        }
+        notification.setLoadedPolicies(stdLoadedPolicies);
+        return notification;
+    }
+
+    private static Boolean isUpdated(final StdPDPNotification notification, final StdLoadedPolicy stdLoadedPolicy) {
+        for (final RemovedPolicy removedPolicy : notification.getRemovedPolicies()) {
+            final String removedPolicyName = removedPolicy.getPolicyName();
+            final String loadedPolicyName = stdLoadedPolicy.getPolicyName();
+            if (removedPolicyName.replaceAll(REGEX, EMPTY_STRING)
+                    .equals(loadedPolicyName.replaceAll(REGEX, EMPTY_STRING))) {
+                return true;
+            }
+        }
+        return false;
+    }
 }
index f5a86d1..e3ea735 100644 (file)
 
 package org.onap.policy.std.test;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
-import java.util.Hashtable;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Set;
 
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.onap.policy.api.LoadedPolicy;
+import org.onap.policy.api.NotificationType;
 import org.onap.policy.api.PDPNotification;
 import org.onap.policy.std.MatchStore;
 import org.onap.policy.std.Matches;
+import org.onap.policy.std.StdLoadedPolicy;
 import org.onap.policy.std.StdPDPNotification;
+import org.onap.policy.std.StdRemovedPolicy;
 
 /**
- * The class <code>MatchStoreTest</code> contains tests for the class <code>{@link MatchStore}</code>.
+ * The class <code>MatchStoreTest</code> contains tests for the class
+ * <code>{@link MatchStore}</code>.
  *
  * @generatedBy CodePro at 6/1/16 1:41 PM
  * @version $Revision: 1.0 $
  */
 public class MatchStoreTest {
 
-       /**
-        * Run the PDPNotification checkMatch(PDPNotification) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testCheckMatch_1()
-               throws Exception {
-               PDPNotification oldNotification = null;
-
-               PDPNotification result = MatchStore.checkMatch(oldNotification);
-
-               // 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.onap.policy.std.MatchStore
-               assertNull(result);
-       }
-
-       /**
-        * Run the PDPNotification checkMatch(PDPNotification) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testCheckMatch_2()
-               throws Exception {
-               PDPNotification oldNotification = new StdPDPNotification();
-
-               PDPNotification result = MatchStore.checkMatch(oldNotification);
-
-               // 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.onap.policy.std.MatchStore
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the PDPNotification checkMatch(PDPNotification) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testCheckMatch_3()
-               throws Exception {
-               PDPNotification oldNotification = new StdPDPNotification();
-
-               PDPNotification result = MatchStore.checkMatch(oldNotification);
-
-               // 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.onap.policy.std.MatchStore
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the PDPNotification checkMatch(PDPNotification) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testCheckMatch_4()
-               throws Exception {
-               PDPNotification oldNotification = new StdPDPNotification();
-
-               PDPNotification result = MatchStore.checkMatch(oldNotification);
-
-               // 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.onap.policy.std.MatchStore
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the PDPNotification checkMatch(PDPNotification) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testCheckMatch_5()
-               throws Exception {
-               PDPNotification oldNotification = new StdPDPNotification();
-
-               PDPNotification result = MatchStore.checkMatch(oldNotification);
-
-               // 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.onap.policy.std.MatchStore
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the PDPNotification checkMatch(PDPNotification) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testCheckMatch_6()
-               throws Exception {
-               PDPNotification oldNotification = new StdPDPNotification();
-
-               PDPNotification result = MatchStore.checkMatch(oldNotification);
-
-               // 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.onap.policy.std.MatchStore
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the PDPNotification checkMatch(PDPNotification) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testCheckMatch_7()
-               throws Exception {
-               PDPNotification oldNotification = new StdPDPNotification();
-
-               PDPNotification result = MatchStore.checkMatch(oldNotification);
-
-               // 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.onap.policy.std.MatchStore
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the PDPNotification checkMatch(PDPNotification) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testCheckMatch_8()
-               throws Exception {
-               PDPNotification oldNotification = new StdPDPNotification();
-
-               PDPNotification result = MatchStore.checkMatch(oldNotification);
-
-               // 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.onap.policy.std.MatchStore
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the PDPNotification checkMatch(PDPNotification) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testCheckMatch_9()
-               throws Exception {
-               PDPNotification oldNotification = new StdPDPNotification();
-
-               PDPNotification result = MatchStore.checkMatch(oldNotification);
-
-               // 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.onap.policy.std.MatchStore
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the PDPNotification checkMatch(PDPNotification) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testCheckMatch_10()
-               throws Exception {
-               PDPNotification oldNotification = new StdPDPNotification();
-
-               PDPNotification result = MatchStore.checkMatch(oldNotification);
-
-               // 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.onap.policy.std.MatchStore
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the PDPNotification checkMatch(PDPNotification) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testCheckMatch_11()
-               throws Exception {
-               PDPNotification oldNotification = new StdPDPNotification();
-
-               PDPNotification result = MatchStore.checkMatch(oldNotification);
-
-               // 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.onap.policy.std.MatchStore
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the PDPNotification checkMatch(PDPNotification) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testCheckMatch_12()
-               throws Exception {
-               PDPNotification oldNotification = new StdPDPNotification();
-
-               PDPNotification result = MatchStore.checkMatch(oldNotification);
-
-               // 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.onap.policy.std.MatchStore
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the PDPNotification checkMatch(PDPNotification) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testCheckMatch_13()
-               throws Exception {
-               PDPNotification oldNotification = new StdPDPNotification();
-
-               PDPNotification result = MatchStore.checkMatch(oldNotification);
-
-               // 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.onap.policy.std.MatchStore
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the PDPNotification checkMatch(PDPNotification) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testCheckMatch_14()
-               throws Exception {
-               PDPNotification oldNotification = new StdPDPNotification();
-
-               PDPNotification result = MatchStore.checkMatch(oldNotification);
-
-               // 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.onap.policy.std.MatchStore
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the PDPNotification checkMatch(PDPNotification) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testCheckMatch_15()
-               throws Exception {
-               PDPNotification oldNotification = new StdPDPNotification();
-
-               PDPNotification result = MatchStore.checkMatch(oldNotification);
-
-               // 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.onap.policy.std.MatchStore
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the PDPNotification checkMatch(PDPNotification) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testCheckMatch_16()
-               throws Exception {
-               PDPNotification oldNotification = new StdPDPNotification();
-
-               PDPNotification result = MatchStore.checkMatch(oldNotification);
-
-               // 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.onap.policy.std.MatchStore
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the HashSet<Matches> getMatchStore() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testGetMatchStore_1()
-               throws Exception {
-
-               Set<Matches> result = MatchStore.getMatchStore();
-
-               // add additional test code here
-               // An unexpected exception was thrown in user code while executing this test:
-               //    java.lang.ExceptionInInitializerError
-               //       at org.apache.log4j.Logger.getLogger(Logger.java:104)
-               //       at org.onap.policy.std.MatchStore.<clinit>(MatchStore.java:15)
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the void storeMatch(Matches) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testStoreMatch_1()
-               throws Exception {
-               Matches newMatch = new Matches();
-               newMatch.setConfigName("");
-               newMatch.setOnapName("");
-
-               MatchStore.storeMatch(newMatch);
-
-               // 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.onap.policy.std.MatchStore
-       }
-
-       /**
-        * Run the void storeMatch(Matches) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testStoreMatch_2()
-               throws Exception {
-               Matches newMatch = new Matches();
-               newMatch.setConfigName("");
-               newMatch.setOnapName("");
-
-               MatchStore.storeMatch(newMatch);
-
-               // 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.onap.policy.std.MatchStore
-       }
-
-       /**
-        * Run the void storeMatch(Matches) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testStoreMatch_3()
-               throws Exception {
-               Matches newMatch = new Matches();
-               newMatch.setConfigName("");
-               newMatch.setOnapName("");
-
-               MatchStore.storeMatch(newMatch);
-
-               // 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.onap.policy.std.MatchStore
-       }
-
-       /**
-        * Run the void storeMatch(Matches) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testStoreMatch_4()
-               throws Exception {
-               Matches newMatch = new Matches();
-               newMatch.setConfigAttributes(new Hashtable<String, String>());
-               newMatch.setConfigName("");
-               newMatch.setOnapName("");
-
-               MatchStore.storeMatch(newMatch);
-
-               // 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.onap.policy.std.MatchStore
-       }
-
-       /**
-        * Run the void storeMatch(Matches) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testStoreMatch_5()
-               throws Exception {
-               Matches newMatch = new Matches();
-               newMatch.setConfigAttributes(new Hashtable<String, String>());
-               newMatch.setConfigName("");
-               newMatch.setOnapName("");
-
-               MatchStore.storeMatch(newMatch);
-
-               // 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.onap.policy.std.MatchStore
-       }
-
-       /**
-        * Run the void storeMatch(Matches) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testStoreMatch_6()
-               throws Exception {
-               Matches newMatch = new Matches();
-               newMatch.setConfigAttributes(new Hashtable<String, String>());
-               newMatch.setConfigName("");
-               newMatch.setOnapName("");
-
-               MatchStore.storeMatch(newMatch);
-
-               // 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.onap.policy.std.MatchStore
-       }
-
-       /**
-        * Run the void storeMatch(Matches) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testStoreMatch_7()
-               throws Exception {
-               Matches newMatch = new Matches();
-               newMatch.setConfigAttributes(new Hashtable<String, String>());
-               newMatch.setConfigName("");
-               newMatch.setOnapName("");
-
-               MatchStore.storeMatch(newMatch);
-
-               // 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.onap.policy.std.MatchStore
-       }
-
-       /**
-        * Run the void storeMatch(Matches) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testStoreMatch_8()
-               throws Exception {
-               Matches newMatch = new Matches();
-               newMatch.setConfigName("");
-               newMatch.setOnapName("");
-
-               MatchStore.storeMatch(newMatch);
-
-               // 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.onap.policy.std.MatchStore
-       }
-
-       /**
-        * Run the void storeMatch(Matches) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testStoreMatch_9()
-               throws Exception {
-               Matches newMatch = new Matches();
-               newMatch.setOnapName("");
-
-               MatchStore.storeMatch(newMatch);
-
-               // 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.onap.policy.std.MatchStore
-       }
-
-       /**
-        * Run the void storeMatch(Matches) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testStoreMatch_10()
-               throws Exception {
-               Matches newMatch = new Matches();
-               newMatch.setConfigAttributes(new Hashtable<String, String>());
-               newMatch.setConfigName("");
-               newMatch.setOnapName("");
-
-               MatchStore.storeMatch(newMatch);
-
-               // 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.onap.policy.std.MatchStore
-       }
-
-       /**
-        * Run the void storeMatch(Matches) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testStoreMatch_11()
-               throws Exception {
-               Matches newMatch = new Matches();
-               newMatch.setConfigAttributes(new Hashtable<String, String>());
-               newMatch.setConfigName("");
-               newMatch.setOnapName("");
-
-               MatchStore.storeMatch(newMatch);
-
-               // 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.onap.policy.std.MatchStore
-       }
-
-       /**
-        * Run the void storeMatch(Matches) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testStoreMatch_12()
-               throws Exception {
-               Matches newMatch = new Matches();
-               newMatch.setConfigAttributes(new Hashtable<String, String>());
-               newMatch.setConfigName("");
-               newMatch.setOnapName("");
-
-               MatchStore.storeMatch(newMatch);
-
-               // 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.onap.policy.std.MatchStore
-       }
-
-       /**
-        * Run the void storeMatch(Matches) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testStoreMatch_13()
-               throws Exception {
-               Matches newMatch = new Matches();
-               newMatch.setConfigAttributes(new Hashtable<String, String>());
-               newMatch.setConfigName("");
-               newMatch.setOnapName("");
-
-               MatchStore.storeMatch(newMatch);
-
-               // 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.onap.policy.std.MatchStore
-       }
-
-       /**
-        * Run the void storeMatch(Matches) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testStoreMatch_14()
-               throws Exception {
-               Matches newMatch = new Matches();
-               newMatch.setConfigAttributes(new Hashtable<String, String>());
-               newMatch.setConfigName("");
-               newMatch.setOnapName("");
-
-               MatchStore.storeMatch(newMatch);
-
-               // 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.onap.policy.std.MatchStore
-       }
-
-       /**
-        * Run the void storeMatch(Matches) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testStoreMatch_15()
-               throws Exception {
-               Matches newMatch = new Matches();
-
-               MatchStore.storeMatch(newMatch);
-
-               // 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.onap.policy.std.MatchStore
-       }
-
-       /**
-        * Run the void storeMatch(Matches) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testStoreMatch_16()
-               throws Exception {
-               Matches newMatch = null;
-
-               MatchStore.storeMatch(newMatch);
-
-               // 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.onap.policy.std.MatchStore
-       }
-
-       /**
-        * Perform pre-test initialization.
-        *
-        * @throws Exception
-        *         if the initialization fails for some reason
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @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 6/1/16 1:41 PM
-        */
-       @After
-       public void tearDown()
-               throws Exception {
-               // Add additional tear down code here
-       }
-
-       /**
-        * Launch the test.
-        *
-        * @param args the command line arguments
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       public static void main(String[] args) {
-               new org.junit.runner.JUnitCore().run(MatchStoreTest.class);
-       }
+    private static final String ATTRIBUTE_DUMMY_VALUE = "Value";
+
+    private static final String ATTRIBUTE_DUMMY_KEY = "Key";
+
+    private static final String POLICY_NAME = "ONAP";
+
+    private static final String POLICY_VERSION = "1.0.0";
+
+    private static final String ONAP_NAME_VAL = "ONAPName";
+
+    private static final String CONFIG_NAME_VAL = "ConfigName";
+
+    private static final String EMPTY_STRING = "";
+
+    /**
+     * Perform pre-test initialization.
+     *
+     * @throws Exception
+     *             if the initialization fails for some reason
+     */
+    @Before
+    public void setUp() throws Exception {
+        MatchStore.getMatchStore().clear();
+    }
+
+    @Test
+    public void testCheckMatch_ShouldReturnNullWithNullPDPNotification() throws Exception {
+        final PDPNotification oldNotification = null;
+
+        final PDPNotification result = MatchStore.checkMatch(oldNotification);
+
+        assertNull(result);
+    }
+
+    @Test
+    public void testCheckMatch_ShouldReturnNullIfMatchStoreCacheIsEmpty() throws Exception {
+        final PDPNotification oldNotification = new StdPDPNotification();
+
+        final PDPNotification result = MatchStore.checkMatch(oldNotification);
+        assertNull(result);
+    }
+
+    @Test
+    public void testCheckMatch_ShouldNotReturnNullIfMatchStoreCacheIsNotEmpty() throws Exception {
+        final Matches newMatch = getMatchesInstance(EMPTY_STRING, EMPTY_STRING);
+        MatchStore.storeMatch(newMatch);
+        final PDPNotification oldNotification = new StdPDPNotification();
+
+        final PDPNotification result = MatchStore.checkMatch(oldNotification);
+        assertNotNull(result);
+    }
+
+    @Test
+    public void testGetMatchStore_ShouldNotBeNullOnStartUP() throws Exception {
+        final Set<Matches> result = MatchStore.getMatchStore();
+        assertNotNull(result);
+    }
+
+    @Test
+    public void testStoreMatch_ShouldRetrunEmptyLoadedRemovedPolicesIfNotMatchFoundInMatchStore() throws Exception {
+        final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL);
+
+        MatchStore.storeMatch(newMatch);
+
+        assertFalse(MatchStore.getMatchStore().isEmpty());
+
+        final PDPNotification oldNotification = new StdPDPNotification();
+        final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+        assertTrue(actualPDPNotification.getLoadedPolicies().isEmpty());
+        assertTrue(actualPDPNotification.getRemovedPolicies().isEmpty());
+        assertNull(actualPDPNotification.getNotificationType());
+    }
+
+    @Test
+    public void testStoreMatch_NotificationTypeRemoved_IfRemovedPolicyExistInOldNotification() throws Exception {
+        final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL);
+        final StdRemovedPolicy removedPolicy = getRemovedPolicy(POLICY_VERSION, POLICY_NAME);
+        final PDPNotification oldNotification = getPDPNotification(Arrays.asList(removedPolicy),
+                Collections.emptySet());
+
+        MatchStore.storeMatch(newMatch);
+
+        assertFalse(MatchStore.getMatchStore().isEmpty());
+
+        final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+        assertEquals(NotificationType.REMOVE, actualPDPNotification.getNotificationType());
+        assertFalse(actualPDPNotification.getRemovedPolicies().isEmpty());
+
+    }
+
+    @Test
+    public void testStoreMatch_NoticficationTypeUpdate_IfStdLoadPolicyExistsWithEmptyMatches() throws Exception {
+        final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL);
+        final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, Collections.emptyMap());
+        final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
+                Arrays.asList(stdLoadedPolicy));
+
+        MatchStore.storeMatch(newMatch);
+
+        assertFalse(MatchStore.getMatchStore().isEmpty());
+
+        final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+        assertEquals(NotificationType.UPDATE, actualPDPNotification.getNotificationType());
+        assertFalse(actualPDPNotification.getLoadedPolicies().isEmpty());
+    }
+
+    @Test
+    public void testStoreMatch_NoticficationTypeUpdate_IfStdLoadPolicyExistsWithMatches() throws Exception {
+        final Map<String, String> attribute = getAttributesMap();
+
+        final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, attribute);
+        final Map<String, String> matches = getPolicyMatches(ONAP_NAME_VAL, CONFIG_NAME_VAL);
+        matches.putAll(attribute);
+
+        final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
+        final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
+                Arrays.asList(stdLoadedPolicy));
+
+        MatchStore.storeMatch(newMatch);
+
+        assertFalse(MatchStore.getMatchStore().isEmpty());
+
+        final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+        assertEquals(NotificationType.UPDATE, actualPDPNotification.getNotificationType());
+
+        final Collection<LoadedPolicy> actualLoadPolicies = actualPDPNotification.getLoadedPolicies();
+        assertFalse(actualLoadPolicies.isEmpty());
+
+        final LoadedPolicy loadedPolicy = actualLoadPolicies.iterator().next();
+        assertEquals(stdLoadedPolicy.getPolicyName(), loadedPolicy.getPolicyName());
+        assertEquals(stdLoadedPolicy.getVersionNo(), loadedPolicy.getVersionNo());
+    }
+
+    @Test
+    public void testStoreMatch_NoticficationTypeUpdate_IfStdLoadPolicyExistsWithNullMatches() throws Exception {
+        final Map<String, String> attribute = getAttributesMap();
+
+        final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, attribute);
+
+        final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, null);
+        final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
+                Arrays.asList(stdLoadedPolicy));
+
+        MatchStore.storeMatch(newMatch);
+
+        assertFalse(MatchStore.getMatchStore().isEmpty());
+
+        final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+        assertEquals(NotificationType.UPDATE, actualPDPNotification.getNotificationType());
+
+        final Collection<LoadedPolicy> actualLoadPolicies = actualPDPNotification.getLoadedPolicies();
+        assertFalse(actualLoadPolicies.isEmpty());
+
+        final LoadedPolicy loadedPolicy = actualLoadPolicies.iterator().next();
+        assertEquals(stdLoadedPolicy.getPolicyName(), loadedPolicy.getPolicyName());
+        assertEquals(stdLoadedPolicy.getVersionNo(), loadedPolicy.getVersionNo());
+    }
+
+    @Test
+    public void testStoreMatch_NoticficationTypeNull_IfStdLoadPolicyExistsWithMatchesWithOutMatchingConfigAttribute()
+            throws Exception {
+        final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, getAttributesMap());
+        final Map<String, String> matches = getPolicyMatches(ONAP_NAME_VAL, CONFIG_NAME_VAL);
+
+        final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
+        final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
+                Arrays.asList(stdLoadedPolicy));
+
+        MatchStore.storeMatch(newMatch);
+
+        assertFalse(MatchStore.getMatchStore().isEmpty());
+
+        final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+        assertNull(actualPDPNotification.getNotificationType());
+
+        final Collection<LoadedPolicy> actualLoadPolicies = actualPDPNotification.getLoadedPolicies();
+        assertTrue(actualLoadPolicies.isEmpty());
+
+    }
+
+    @Test
+    public void testStoreMatch_NoticficationTypeUpdate_IfMatchStoreContainMatchesWithNullConStdLoadPolicyExistsWithMatches()
+            throws Exception {
+
+        final Matches newMatch = getMatchesInstance(null, ONAP_NAME_VAL, Collections.emptyMap());
+        final Map<String, String> matches = new HashMap<>();
+        matches.put(ONAP_NAME_VAL, ONAP_NAME_VAL);
+
+        final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
+        final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
+                Arrays.asList(stdLoadedPolicy));
+
+        MatchStore.storeMatch(newMatch);
+
+        assertFalse(MatchStore.getMatchStore().isEmpty());
+
+        final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+        assertEquals(NotificationType.UPDATE, actualPDPNotification.getNotificationType());
+
+        final Collection<LoadedPolicy> actualLoadPolicies = actualPDPNotification.getLoadedPolicies();
+        assertFalse(actualLoadPolicies.isEmpty());
+
+    }
+
+    @Test
+    public void testStoreMatch_NoticficationTypeUpdate_IfMatchStoreContainMatchingMatches() throws Exception {
+
+        final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, Collections.emptyMap());
+        final Map<String, String> matches = getPolicyMatches(ONAP_NAME_VAL, CONFIG_NAME_VAL);
+
+        final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
+        final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
+                Arrays.asList(stdLoadedPolicy));
+
+        MatchStore.storeMatch(newMatch);
+
+        assertFalse(MatchStore.getMatchStore().isEmpty());
+
+        final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+        assertEquals(NotificationType.UPDATE, actualPDPNotification.getNotificationType());
+
+        final Collection<LoadedPolicy> actualLoadPolicies = actualPDPNotification.getLoadedPolicies();
+        assertFalse(actualLoadPolicies.isEmpty());
+
+        final LoadedPolicy loadedPolicy = actualLoadPolicies.iterator().next();
+        assertEquals(stdLoadedPolicy.getPolicyName(), loadedPolicy.getPolicyName());
+        assertEquals(stdLoadedPolicy.getVersionNo(), loadedPolicy.getVersionNo());
+    }
+
+    @Test
+    public void testStoreMatch_NoticficationTypeUpdate_IfMatchStoreContainMatchingMatches2() throws Exception {
+
+        final Matches firstObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, Collections.emptyMap());
+        final Map<String, String> firstPolicyObj = getPolicyMatches(ONAP_NAME_VAL, CONFIG_NAME_VAL);
+        final Map<String, String> attributesMap = getAttributesMap();
+
+        final Matches secondObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, attributesMap);
+        final Map<String, String> secondPolicyObj = getPolicyMatches(ONAP_NAME_VAL, CONFIG_NAME_VAL);
+        secondPolicyObj.putAll(attributesMap);
+
+        final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, firstPolicyObj);
+        final StdLoadedPolicy secondStdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, secondPolicyObj);
+        final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
+                Arrays.asList(stdLoadedPolicy, secondStdLoadedPolicy));
+
+        MatchStore.storeMatch(firstObj);
+        MatchStore.storeMatch(secondObj);
+
+        assertFalse(MatchStore.getMatchStore().isEmpty());
+
+        final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+        assertEquals(NotificationType.UPDATE, actualPDPNotification.getNotificationType());
+
+        final Collection<LoadedPolicy> actualLoadPolicies = actualPDPNotification.getLoadedPolicies();
+        assertFalse(actualLoadPolicies.isEmpty());
+        assertEquals(1, actualLoadPolicies.size());
+    }
+
+    @Test
+    public void testStoreMatch_NoticficationTypeBoth_IfOldNotificationContainRemovedAndLoadedPolicies()
+            throws Exception {
+
+        final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, Collections.emptyMap());
+        final Map<String, String> matches = getPolicyMatches(ONAP_NAME_VAL, CONFIG_NAME_VAL);
+
+        final StdRemovedPolicy removedPolicy = getRemovedPolicy(POLICY_VERSION, POLICY_NAME);
+        final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
+        final PDPNotification oldNotification = getPDPNotification(Arrays.asList(removedPolicy),
+                Arrays.asList(stdLoadedPolicy));
+
+        MatchStore.storeMatch(newMatch);
+
+        assertFalse(MatchStore.getMatchStore().isEmpty());
+
+        final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+        assertEquals(NotificationType.BOTH, actualPDPNotification.getNotificationType());
+        assertFalse(actualPDPNotification.getRemovedPolicies().isEmpty());
+        assertFalse(actualPDPNotification.getLoadedPolicies().isEmpty());
+    }
+
+    private Map<String, String> getPolicyMatches(final String onapName, final String configName) {
+        final Map<String, String> matches = new HashMap<>();
+        matches.put(ONAP_NAME_VAL, onapName);
+        matches.put(CONFIG_NAME_VAL, configName);
+        return matches;
+    }
+
+    @Test
+    public void testStoreMatch_MatchesObjectShouldbeAddOnceToMatchStoreAndNoDuplication() throws Exception {
+        final String[] configNames = new String[] { CONFIG_NAME_VAL, CONFIG_NAME_VAL, "ConfigName1", CONFIG_NAME_VAL,
+                "ConfigName1", null };
+        final String[] onapNames = new String[] { ONAP_NAME_VAL, ONAP_NAME_VAL, "ONAPName1", "ONAPName1", ONAP_NAME_VAL,
+                ONAP_NAME_VAL };
+
+        for (int i = 0; i < configNames.length; i++) {
+
+            final Matches matches = getMatchesInstance(configNames[i], onapNames[i], getAttributesMap());
+            MatchStore.storeMatch(matches);
+            MatchStore.storeMatch(matches);
+        }
+
+        assertEquals(configNames.length - 1, MatchStore.getMatchStore().size());
+
+    }
+
+    @Test
+    public void testStoreMatch_MatchesObjectShouldBeAddedToMatchStore_ConfigAttrValuesAreDifferentThenExistingOne()
+            throws Exception {
+        final Matches firstObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, getAttributesMap());
+        final Matches secondObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, Collections.emptyMap());
+
+        MatchStore.storeMatch(firstObj);
+        MatchStore.storeMatch(secondObj);
+        MatchStore.storeMatch(firstObj);
+
+        assertEquals(2, MatchStore.getMatchStore().size());
+
+    }
+
+    @Test
+    public void testStoreMatch_MatchesObjectShouldBeAddedToMatchStore_ConfigAttrValuesNull() throws Exception {
+        final Matches firstObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, null);
+        final Matches secondObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, null);
+
+        MatchStore.storeMatch(firstObj);
+        MatchStore.storeMatch(secondObj);
+        MatchStore.storeMatch(firstObj);
+
+        assertEquals(1, MatchStore.getMatchStore().size());
+
+    }
+
+    @Test
+    public void testStoreMatch_MatchesObjectShouldBeAddedToMatchStore_OnapNameIsDifferentThenExistingOne()
+            throws Exception {
+        final Matches firstObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, getAttributesMap());
+        final Matches secondObj = getMatchesInstance(CONFIG_NAME_VAL, "ONAPName1", getAttributesMap());
+
+        MatchStore.storeMatch(firstObj);
+        MatchStore.storeMatch(secondObj);
+        MatchStore.storeMatch(firstObj);
+
+        assertEquals(2, MatchStore.getMatchStore().size());
+
+    }
+
+    private Map<String, String> getAttributesMap() {
+        final Map<String, String> attribute = new HashMap<>();
+        attribute.put(ATTRIBUTE_DUMMY_KEY, ATTRIBUTE_DUMMY_VALUE);
+        return attribute;
+    }
+
+    private Matches getMatchesInstance(final String configName, final String onapName) {
+        return getMatchesInstance(configName, onapName, null);
+    }
+
+    private Matches getMatchesInstance(final String configName, final String onapName,
+            final Map<String, String> configAttributes) {
+        final Matches matches = new Matches();
+        matches.setConfigName(configName);
+        matches.setOnapName(onapName);
+        matches.setConfigAttributes(configAttributes);
+        return matches;
+    }
+
+    private StdRemovedPolicy getRemovedPolicy(final String version, final String policyName) {
+        return new StdRemovedPolicy() {
+
+            @Override
+            public String getVersionNo() {
+                return version;
+            }
+
+            @Override
+            public String getPolicyName() {
+                return policyName;
+            }
+        };
+    }
+
+    private PDPNotification getPDPNotification(final Collection<StdRemovedPolicy> removedPolicies,
+            final Collection<StdLoadedPolicy> loadedPolicies) {
+        final StdPDPNotification oldNotification = new StdPDPNotification();
+        oldNotification.setLoadedPolicies(loadedPolicies);
+        oldNotification.setRemovedPolicies(removedPolicies);
+        return oldNotification;
+    }
+
+    private StdLoadedPolicy getStdLoadedPolicy(final String version, final String policyName,
+            final Map<String, String> matches) {
+        return new StdLoadedPolicy() {
+
+            @Override
+            public String getVersionNo() {
+                return version;
+            }
+
+            @Override
+            public String getPolicyName() {
+                return policyName;
+            }
+
+            @Override
+            public Map<String, String> getMatches() {
+                return matches;
+            }
+        };
+    }
+
+    /**
+     * Perform post-test clean-up.
+     *
+     * @throws Exception
+     *             if the clean-up fails for some reason
+     */
+    @After
+    public void tearDown() throws Exception {
+        // Add additional tear down code here
+    }
+
+    /**
+     * Launch the test.
+     *
+     * @param args
+     *            the command line arguments
+     */
+    public static void main(final String[] args) {
+        new org.junit.runner.JUnitCore().run(MatchStoreTest.class);
+    }
 }
index f71d93c..3a76ff4 100644 (file)
 
 package org.onap.policy.std.test;
 
-import java.util.Hashtable;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.*;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 import org.onap.policy.std.Matches;
 
-import static org.junit.Assert.*;
-
 /**
- * The class <code>MatchesTest</code> contains tests for the class <code>{@link Matches}</code>.
+ * The class <code>MatchesTest</code> contains tests for the class
+ * <code>{@link Matches}</code>.
  *
  * @generatedBy CodePro at 6/1/16 1:41 PM
  * @version $Revision: 1.0 $
  */
 public class MatchesTest {
-       /**
-        * Run the Matches() constructor test.
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testMatches_1()
-               throws Exception {
-               Matches result = new Matches();
-               assertNotNull(result);
-               // add additional test code here
-       }
-
-       /**
-        * Run the Map<String, String> getConfigAttributes() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testGetConfigAttributes_1()
-               throws Exception {
-               Matches fixture = new Matches();
-               fixture.setOnapName("");
-               fixture.setConfigAttributes(new Hashtable<String, String>());
-               fixture.setConfigName("");
-
-               Map<String, String> result = fixture.getConfigAttributes();
-
-               // add additional test code here
-               assertNotNull(result);
-               assertEquals(0, result.size());
-       }
-
-       /**
-        * Run the String getConfigName() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testGetConfigName_1()
-               throws Exception {
-               Matches fixture = new Matches();
-               fixture.setOnapName("");
-               fixture.setConfigAttributes(new Hashtable<String, String>());
-               fixture.setConfigName("");
-
-               String result = fixture.getConfigName();
-
-               // add additional test code here
-               assertEquals("", result);
-       }
-
-       /**
-        * Run the String getOnapName() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testGetOnapName_1()
-               throws Exception {
-               Matches fixture = new Matches();
-               fixture.setOnapName("");
-               fixture.setConfigAttributes(new Hashtable<String, String>());
-               fixture.setConfigName("");
-
-               String result = fixture.getOnapName();
-
-               // add additional test code here
-               assertEquals("", result);
-       }
-
-       /**
-        * Run the void setConfigAttributes(Map<String,String>) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testSetConfigAttributes_1()
-               throws Exception {
-               Matches fixture = new Matches();
-               fixture.setOnapName("");
-               fixture.setConfigAttributes(new Hashtable<String, String>());
-               fixture.setConfigName("");
-               Map<String, String> configAttributes = new Hashtable<String, String>();
-
-               fixture.setConfigAttributes(configAttributes);
-
-               // add additional test code here
-       }
-
-       /**
-        * Run the void setConfigName(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testSetConfigName_1()
-               throws Exception {
-               Matches fixture = new Matches();
-               fixture.setOnapName("");
-               fixture.setConfigAttributes(new Hashtable<String, String>());
-               fixture.setConfigName("");
-               String configName = "";
-
-               fixture.setConfigName(configName);
-
-               // add additional test code here
-       }
-
-       /**
-        * Run the void setOnapName(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testSetOnapName_1()
-               throws Exception {
-               Matches fixture = new Matches();
-               fixture.setOnapName("");
-               fixture.setConfigAttributes(new Hashtable<String, String>());
-               fixture.setConfigName("");
-               String onapName = "";
-
-               fixture.setOnapName(onapName);
-
-               // add additional test code here
-       }
-
-       /**
-        * Perform pre-test initialization.
-        *
-        * @throws Exception
-        *         if the initialization fails for some reason
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @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 6/1/16 1:41 PM
-        */
-       @After
-       public void tearDown()
-               throws Exception {
-               // Add additional tear down code here
-       }
-
-       /**
-        * Launch the test.
-        *
-        * @param args the command line arguments
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       public static void main(String[] args) {
-               new org.junit.runner.JUnitCore().run(MatchesTest.class);
-       }
+    private static final String DUMMY_VAL = "SomethingElse";
+
+    private static final String CONFIG_NAME = "CONFIG_NAME";
+
+    private static final String ONAP_NAME = "ONAP_NAME";
+
+    @Test
+    public void testMatches_SetterGetterMethods() {
+        final Matches objUnderTest = getMatches(ONAP_NAME, CONFIG_NAME, Collections.emptyMap());
+
+        final Map<String, String> result = objUnderTest.getConfigAttributes();
+
+        assertEquals(ONAP_NAME, objUnderTest.getOnapName());
+        assertEquals(CONFIG_NAME, objUnderTest.getConfigName());
+        assertEquals(0, result.size());
+    }
+
+    @Test
+    public void testMatches_EqualsMethod_SameObjectsAndSameHasCode() {
+        final Matches firstObject = getMatches(ONAP_NAME, CONFIG_NAME, Collections.emptyMap());
+        final Matches secondObject = getMatches(ONAP_NAME, CONFIG_NAME, Collections.emptyMap());
+
+        assertEquals(firstObject, secondObject);
+        assertEquals(firstObject.hashCode(), secondObject.hashCode());
+    }
+
+    @Test
+    public void testMatchesEqualsMethod_differentConfigName_NotEqualsAndDifferentHashCode() {
+        final Matches firstObject = getMatches(ONAP_NAME, DUMMY_VAL, Collections.emptyMap());
+        final Matches secondObject = getMatches(ONAP_NAME, CONFIG_NAME, Collections.emptyMap());
+
+        assertNotEquals(firstObject, secondObject);
+        assertNotEquals(firstObject.hashCode(), secondObject.hashCode());
+    }
+
+    @Test
+    public void testMatchesEqualsMethod_differentObjects_NotEquals() {
+        final String firstObject = new String();
+        final Matches secondObject = getMatches(ONAP_NAME, CONFIG_NAME, Collections.emptyMap());
+        Assert.assertFalse(secondObject.equals(firstObject));
+    }
+
+    @Test
+    public void testMatchesEqualsMethod_nullObject_NotEqualsAndDifferentHashCode() {
+        final String firstObject = null;
+        final Matches secondObject = getMatches(ONAP_NAME, CONFIG_NAME, Collections.emptyMap());
+
+        assertNotEquals(firstObject, secondObject);
+    }
+
+    @Test
+    public void testMatchesEqualsMethod_NullConfigName_NotEqualsAndDifferentHashCode() {
+        final Matches firstObject = getMatches(ONAP_NAME, CONFIG_NAME, Collections.emptyMap());
+        final Matches secondObject = getMatches(ONAP_NAME, null, Collections.emptyMap());
+
+        assertNotEquals(firstObject, secondObject);
+        assertNotEquals(firstObject.hashCode(), secondObject.hashCode());
+    }
+
+    @Test
+    public void testMatchesEqualsMethod_differentOnapName_NotEqualsAndDifferentHashCode() throws Exception {
+        final Matches firstObject = getMatches(DUMMY_VAL, CONFIG_NAME, Collections.emptyMap());
+        final Matches secondObject = getMatches(ONAP_NAME, CONFIG_NAME, Collections.emptyMap());
+
+        assertNotEquals(firstObject, secondObject);
+        assertNotEquals(firstObject.hashCode(), secondObject.hashCode());
+    }
+
+    @Test
+    public void testMatchesEqualsMethod_NullOnapName_NotEqualsAndDifferentHashCode() throws Exception {
+        final Matches firstObject = getMatches(null, CONFIG_NAME, Collections.emptyMap());
+        final Matches secondObject = getMatches(ONAP_NAME, CONFIG_NAME, Collections.emptyMap());
+
+        assertNotEquals(firstObject, secondObject);
+        assertNotEquals(firstObject.hashCode(), secondObject.hashCode());
+    }
+
+    @Test
+    public void testMatchesEqualsMethod_BothNullOnapName_Equals() throws Exception {
+        final Matches firstObject = getMatches(null, CONFIG_NAME, Collections.emptyMap());
+        final Matches secondObject = getMatches(null, CONFIG_NAME, Collections.emptyMap());
+
+        assertEquals(firstObject, secondObject);
+        assertEquals(firstObject.hashCode(), secondObject.hashCode());
+    }
+
+    @Test
+    public void testMatchesEqualsMethod_BothNullConfigName_Equals() throws Exception {
+        final Matches firstObject = getMatches(ONAP_NAME, null, Collections.emptyMap());
+        final Matches secondObject = getMatches(ONAP_NAME, null, Collections.emptyMap());
+
+        assertEquals(firstObject, secondObject);
+        assertEquals(firstObject.hashCode(), secondObject.hashCode());
+    }
+
+    @Test
+    public void testMatchesEqualsMethod_DifferentConfigAttr_NotEqualsAndDifferentHashCode() throws Exception {
+        final Map<String, String> firstMap = Collections.emptyMap();
+        final Map<String, String> secondMap = new HashMap<>();
+        secondMap.put("key", "value");
+
+        final Matches firstObject = getMatches(ONAP_NAME, CONFIG_NAME, firstMap);
+        final Matches secondObject = getMatches(ONAP_NAME, CONFIG_NAME, secondMap);
+
+        assertNotEquals(firstObject, secondObject);
+        assertNotEquals(firstObject.hashCode(), secondObject.hashCode());
+    }
+
+    @Test
+    public void testMatchesEqualsMethod_NullConfigAttr_NotEqualsAndDifferentHashCode() throws Exception {
+        final Map<String, String> secondMap = new HashMap<>();
+        secondMap.put("key", "value");
+
+        final Matches firstObject = getMatches(ONAP_NAME, CONFIG_NAME, null);
+        final Matches secondObject = getMatches(ONAP_NAME, CONFIG_NAME, secondMap);
+
+        assertNotEquals(firstObject, secondObject);
+        assertNotEquals(firstObject.hashCode(), secondObject.hashCode());
+    }
+
+    @Test
+    public void testMatchesEqualsMethod_BothNullConfigAttr_Equals() throws Exception {
+
+        final Matches firstObject = getMatches(ONAP_NAME, CONFIG_NAME, null);
+        final Matches secondObject = getMatches(ONAP_NAME, CONFIG_NAME, null);
+
+        assertEquals(firstObject, secondObject);
+        assertEquals(firstObject.hashCode(), secondObject.hashCode());
+    }
+
+    private Matches getMatches(final String onapName, final String configName, final Map<String, String> attributes) {
+        final Matches objUnderTest = new Matches();
+        objUnderTest.setOnapName(onapName);
+        objUnderTest.setConfigName(configName);
+        objUnderTest.setConfigAttributes(attributes);
+        return objUnderTest;
+    }
+
+    /**
+     * Perform pre-test initialization.
+     *
+     * @throws Exception
+     *             if the initialization fails for some reason
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @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 6/1/16 1:41 PM
+     */
+    @After
+    public void tearDown() throws Exception {
+        // Add additional tear down code here
+    }
+
+    /**
+     * Launch the test.
+     *
+     * @param args
+     *            the command line arguments
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    public static void main(final String[] args) {
+        new org.junit.runner.JUnitCore().run(MatchesTest.class);
+    }
 }
index fb42f98..d26a1b2 100644 (file)
 
 package org.onap.policy.std.test;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
 
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.onap.policy.api.UpdateType;
 import org.onap.policy.std.NotificationUnMarshal;
+import org.onap.policy.std.StdLoadedPolicy;
 import org.onap.policy.std.StdPDPNotification;
+import org.onap.policy.std.StdRemovedPolicy;
+
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
 
 /**
- * The class <code>NotificationUnMarshalTest</code> contains tests for the class <code>{@link NotificationUnMarshal}</code>.
+ * The class <code>NotificationUnMarshalTest</code> contains tests for the class
+ * <code>{@link NotificationUnMarshal}</code>.
  *
  * @generatedBy CodePro at 6/1/16 1:40 PM
  * @version $Revision: 1.0 $
  */
 public class NotificationUnMarshalTest {
-       /**
-        * Run the StdPDPNotification notificationJSON(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
-       public void testNotificationJSON_1()
-               throws Exception {
-               String json = "";
-
-               StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
-               // add additional test code here
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the StdPDPNotification notificationJSON(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
-       public void testNotificationJSON_2()
-               throws Exception {
-               String json = "";
-
-               StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
-               // add additional test code here
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the StdPDPNotification notificationJSON(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
-       public void testNotificationJSON_3()
-               throws Exception {
-               String json = "";
-
-               StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
-               // add additional test code here
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the StdPDPNotification notificationJSON(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
-       public void testNotificationJSON_4()
-               throws Exception {
-               String json = "";
-
-               StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
-               // add additional test code here
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the StdPDPNotification notificationJSON(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
-       public void testNotificationJSON_5()
-               throws Exception {
-               String json = "";
-
-               StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
-               // add additional test code here
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the StdPDPNotification notificationJSON(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
-       public void testNotificationJSON_6()
-               throws Exception {
-               String json = "";
-
-               StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
-               // add additional test code here
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the StdPDPNotification notificationJSON(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
-       public void testNotificationJSON_7()
-               throws Exception {
-               String json = "";
-
-               StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
-               // add additional test code here
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the StdPDPNotification notificationJSON(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
-       public void testNotificationJSON_8()
-               throws Exception {
-               String json = "";
-
-               StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
-               // add additional test code here
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the StdPDPNotification notificationJSON(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
-       public void testNotificationJSON_9()
-               throws Exception {
-               String json = "";
-
-               StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
-               // add additional test code here
-               assertNotNull(result);
-       }
-
-       /**
-        * Run the StdPDPNotification notificationJSON(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
-       public void testNotificationJSON_10()
-               throws Exception {
-               String json = "";
-
-               StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
-               // add additional test code here
-               assertNotNull(result);
-       }
-
-       /**
-        * Perform pre-test initialization.
-        *
-        * @throws Exception
-        *         if the initialization fails for some reason
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @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 6/1/16 1:40 PM
-        */
-       @After
-       public void tearDown()
-               throws Exception {
-               // Add additional tear down code here
-       }
-
-       /**
-        * Launch the test.
-        *
-        * @param args the command line arguments
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       public static void main(String[] args) {
-               new org.junit.runner.JUnitCore().run(NotificationUnMarshalTest.class);
-       }
+    private static final String EMPTY_STRING = "";
+
+    private static final String POLICY_NAME = "ONAP";
+
+    private static final String POLICY_VERSION = "1.0.0";
+
+    /**
+     * Run the StdPDPNotification notificationJSON(String) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:40 PM
+     */
+    @Test(expected = JsonMappingException.class)
+    public void testNotificationJSON_EmptyString_ShouldThrowException() throws Exception {
+        final StdPDPNotification result = NotificationUnMarshal.notificationJSON(EMPTY_STRING);
+
+        assertNotNull(result);
+    }
+
+    @Test
+    public void testNotificationJSON_StdPDPNotificationJsonStringWithEmptyLoadedAndRemovedPolicies_emptyLoadedPolices()
+            throws Exception {
+        final String json = getPDPNotificationAsJsonString(new StdPDPNotification());
+
+        final StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
+
+        assertNotNull(result);
+        assertTrue(result.getLoadedPolicies().isEmpty());
+    }
+
+    @Test
+    public void testNotificationJSON_StdPDPNotificationJsonStringWithEmptyLoadedpolicy_emptyLoadedPolices()
+            throws Exception {
+        final StdPDPNotification notification = getPDPNotification(
+                Arrays.asList(getRemovedPolicy(POLICY_VERSION, POLICY_NAME)), Collections.emptyList());
+        final String json = getPDPNotificationAsJsonString(notification);
+
+        final StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
+
+        assertNotNull(result);
+        assertTrue(result.getLoadedPolicies().isEmpty());
+    }
+
+    @Test
+    public void testNotificationJSON_validPDPNotificationJsonStringWithRemovedAndLoadedPolicies_UpdateTypeUpdateAndLoadedPolicyAdded()
+            throws Exception {
+        final List<StdRemovedPolicy> removedPolicies = Arrays.asList(getRemovedPolicy(POLICY_VERSION, POLICY_NAME));
+        final List<StdLoadedPolicy> loadedPolicies = Arrays.asList(getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME));
+        final StdPDPNotification notification = getPDPNotification(removedPolicies, loadedPolicies);
+
+        final String json = getPDPNotificationAsJsonString(notification);
+
+        final StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
+
+        assertNotNull(result);
+        assertFalse(result.getLoadedPolicies().isEmpty());
+
+        final StdLoadedPolicy actualPolicy = (StdLoadedPolicy) result.getLoadedPolicies().iterator().next();
+        assertEquals(POLICY_VERSION, actualPolicy.getVersionNo());
+        assertEquals(POLICY_NAME, actualPolicy.getPolicyName());
+        assertEquals(UpdateType.UPDATE, actualPolicy.getUpdateType());
+    }
+
+    /**
+     * Run the StdPDPNotification notificationJSON(String) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:40 PM
+     */
+    @Test
+    public void testNotificationJSON_validPDPNotificationJsonStringWithRemovedAndLoadedPolicies_UpdateTypeNewAndLoadedPolicyAdded()
+            throws Exception {
+        final List<StdRemovedPolicy> removedPolicies = Arrays.asList(getRemovedPolicy(POLICY_VERSION, "Something"));
+        final List<StdLoadedPolicy> loadedPolices = Arrays.asList(getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME));
+        final StdPDPNotification notification = getPDPNotification(removedPolicies, loadedPolices);
+
+        final String json = getPDPNotificationAsJsonString(notification);
+
+        final StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
+
+        assertNotNull(result);
+        assertFalse(result.getLoadedPolicies().isEmpty());
+
+        final StdLoadedPolicy actualPolicy = (StdLoadedPolicy) result.getLoadedPolicies().iterator().next();
+        assertEquals(POLICY_VERSION, actualPolicy.getVersionNo());
+        assertEquals(POLICY_NAME, actualPolicy.getPolicyName());
+        assertEquals(UpdateType.NEW, actualPolicy.getUpdateType());
+    }
+
+    @Test
+    public void testNotificationJSON_validPDPNotificationJsonStringLoadedPoliciesAndNullRemovedPolicies_UpdateTypeNewAndLoadedPolicyAdded()
+            throws Exception {
+        final List<StdLoadedPolicy> loadedPolices = Arrays.asList(getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME));
+        final StdPDPNotification notification = getPDPNotification(null, loadedPolices);
+
+        final String json = getPDPNotificationAsJsonString(notification);
+
+        final StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
+
+        assertNotNull(result);
+        assertFalse(result.getLoadedPolicies().isEmpty());
+
+        final StdLoadedPolicy actualPolicy = (StdLoadedPolicy) result.getLoadedPolicies().iterator().next();
+        assertEquals(POLICY_VERSION, actualPolicy.getVersionNo());
+        assertEquals(POLICY_NAME, actualPolicy.getPolicyName());
+        assertEquals(UpdateType.NEW, actualPolicy.getUpdateType());
+    }
+
+    /**
+     * Run the StdPDPNotification notificationJSON(String) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:40 PM
+     */
+    @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
+    public void testNotificationJSON_7() throws Exception {
+        final String json = EMPTY_STRING;
+
+        final StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
+
+        // add additional test code here
+        assertNotNull(result);
+    }
+
+    /**
+     * Run the StdPDPNotification notificationJSON(String) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:40 PM
+     */
+    @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
+    public void testNotificationJSON_8() throws Exception {
+        final String json = EMPTY_STRING;
+
+        final StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
+
+        // add additional test code here
+        assertNotNull(result);
+    }
+
+    /**
+     * Run the StdPDPNotification notificationJSON(String) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:40 PM
+     */
+    @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
+    public void testNotificationJSON_9() throws Exception {
+        final String json = EMPTY_STRING;
+
+        final StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
+
+        // add additional test code here
+        assertNotNull(result);
+    }
+
+    /**
+     * Run the StdPDPNotification notificationJSON(String) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:40 PM
+     */
+    @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
+    public void testNotificationJSON_10() throws Exception {
+        final String json = EMPTY_STRING;
+
+        final StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
+
+        // add additional test code here
+        assertNotNull(result);
+    }
+
+    private String getPDPNotificationAsJsonString(final StdPDPNotification notification) {
+        final ObjectMapper mapper = new ObjectMapper();
+
+        try {
+            return mapper.writeValueAsString(notification);
+        } catch (final Exception expection) {
+            throw new RuntimeException(expection);
+        }
+
+    }
+
+    private StdPDPNotification getPDPNotification(final Collection<StdRemovedPolicy> removedPolicies,
+            final Collection<StdLoadedPolicy> loadedPolicies) {
+        final StdPDPNotification oldNotification = new StdPDPNotification();
+        oldNotification.setLoadedPolicies(loadedPolicies);
+        oldNotification.setRemovedPolicies(removedPolicies);
+        return oldNotification;
+    }
+
+    private StdRemovedPolicy getRemovedPolicy(final String version, final String policyName) {
+        return new StdRemovedPolicy() {
+
+            @Override
+            public String getVersionNo() {
+                return version;
+            }
+
+            @Override
+            public String getPolicyName() {
+                return policyName;
+            }
+        };
+    }
+
+    private StdLoadedPolicy getStdLoadedPolicy(final String version, final String policyName) {
+        return new StdLoadedPolicy() {
+
+            @Override
+            public String getVersionNo() {
+                return version;
+            }
+
+            @Override
+            public String getPolicyName() {
+                return policyName;
+            }
+
+            @Override
+            public Map<String, String> getMatches() {
+                return Collections.emptyMap();
+            }
+        };
+    }
+
+    /**
+     * Perform pre-test initialization.
+     *
+     * @throws Exception
+     *             if the initialization fails for some reason
+     *
+     * @generatedBy CodePro at 6/1/16 1:40 PM
+     */
+    @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 6/1/16 1:40 PM
+     */
+    @After
+    public void tearDown() throws Exception {
+        // Add additional tear down code here
+    }
+
+    /**
+     * Launch the test.
+     *
+     * @param args
+     *            the command line arguments
+     *
+     * @generatedBy CodePro at 6/1/16 1:40 PM
+     */
+    public static void main(final String[] args) {
+        new org.junit.runner.JUnitCore().run(NotificationUnMarshalTest.class);
+    }
 }
index 736f51b..e754a42 100644 (file)
@@ -20,6 +20,7 @@
 
 package org.onap.policy.std.test;
 
+import java.util.Collections;
 import java.util.Hashtable;
 import java.util.Map;
 import java.util.Properties;
@@ -28,6 +29,7 @@ import javax.json.JsonObject;
 
 import org.junit.*;
 import org.onap.policy.api.PolicyConfigStatus;
+import org.onap.policy.api.PolicyConfigType;
 import org.onap.policy.api.PolicyType;
 import org.onap.policy.std.StdPolicyConfig;
 
@@ -36,786 +38,775 @@ import static org.junit.Assert.*;
 import org.w3c.dom.Document;
 
 /**
- * The class <code>StdPolicyConfigTest</code> contains tests for the class <code>{@link StdPolicyConfig}</code>.
+ * The class <code>StdPolicyConfigTest</code> contains tests for the class
+ * <code>{@link StdPolicyConfig}</code>.
  *
  * @generatedBy CodePro at 6/1/16 1:41 PM
  * @version $Revision: 1.0 $
  */
 public class StdPolicyConfigTest {
-       /**
-        * Run the Map<String, String> getMatchingConditions() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testGetMatchingConditions_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-
-               Map<String, String> result = fixture.getMatchingConditions();
-
-               // add additional test code here
-               assertNotNull(result);
-               assertEquals(0, result.size());
-       }
-
-       /**
-        * Run the String getPolicyConfigMessage() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testGetPolicyConfigMessage_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-
-               String result = fixture.getPolicyConfigMessage();
-
-               // add additional test code here
-               assertEquals("", result);
-       }
-
-       /**
-        * Run the PolicyConfigStatus getPolicyConfigStatus() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testGetPolicyConfigStatus_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-
-               PolicyConfigStatus result = fixture.getPolicyConfigStatus();
-
-               // add additional test code here
-               assertNotNull(result);
-               assertEquals("not_found", result.toString());
-               assertEquals("CONFIG_NOT_FOUND", result.name());
-               assertEquals(1, result.ordinal());
-       }
-
-       /**
-        * Run the String getPolicyName() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testGetPolicyName_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-
-               String result = fixture.getPolicyName();
-
-               // add additional test code here
-               assertEquals("", result);
-       }
-
-       /**
-        * Run the String getPolicyName() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testGetPolicyName_2()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName((String) null);
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-
-               String result = fixture.getPolicyName();
-
-               // add additional test code here
-               assertEquals(null, result);
-       }
-
-       /**
-        * Run the String getPolicyName() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testGetPolicyName_3()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-
-               String result = fixture.getPolicyName();
-
-               // add additional test code here
-               assertEquals("", result);
-       }
-
-       /**
-        * Run the String getPolicyVersion() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testGetPolicyVersion_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-
-               String result = fixture.getPolicyVersion();
-
-               // add additional test code here
-               assertEquals("", result);
-       }
-
-       /**
-        * Run the Map<String, String> getResponseAttributes() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testGetResponseAttributes_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-
-               Map<String, String> result = fixture.getResponseAttributes();
-
-               // add additional test code here
-               assertNotNull(result);
-               assertEquals(0, result.size());
-       }
-
-       /**
-        * Run the PolicyType getType() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testGetType_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-
-               PolicyType result = fixture.getType();
-
-               // add additional test code here
-               assertNotNull(result);
-               assertEquals("json", result.toString());
-               assertEquals("JSON", result.name());
-               assertEquals(1, result.ordinal());
-       }
-
-       /**
-        * Run the void setConfigStatus(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testSetConfigStatus_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-               String configStatus = "";
-
-               fixture.setConfigStatus(configStatus);
-
-               // add additional test code here
-       }
-
-       /**
-        * Run the void setConfigStatus(String,PolicyConfigStatus) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testSetConfigStatus_2()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-               String configStatus = "";
-               PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND;
-
-               fixture.setConfigStatus(configStatus, policyConfigStatus);
-
-               // add additional test code here
-       }
-
-       /**
-        * Run the void setDocument(Document) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testSetDocument_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-               Document document = null;
-
-               fixture.setDocument(document);
-
-               // add additional test code here
-       }
-
-       /**
-        * Run the void setJsonObject(JsonObject) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testSetJsonObject_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-               JsonObject jsonObject = null;
-
-               fixture.setJsonObject(jsonObject);
-
-               // add additional test code here
-       }
-
-       /**
-        * Run the void setMatchingConditions(Map<String,String>) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testSetMatchingConditions_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-               Map<String, String> matchingConditions = new Hashtable<String, String>();
-
-               fixture.setMatchingConditions(matchingConditions);
-
-               // add additional test code here
-       }
-
-       /**
-        * Run the void setOther(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testSetOther_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-               String other = "";
-
-               fixture.setOther(other);
-
-               // add additional test code here
-       }
-
-       /**
-        * Run the void setPolicyConfigStatus(PolicyConfigStatus) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testSetPolicyConfigStatus_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-               PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND;
-
-               fixture.setPolicyConfigStatus(policyConfigStatus);
-
-               // add additional test code here
-       }
-
-       /**
-        * Run the void setPolicyName(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testSetPolicyName_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-               String policyName = "";
-
-               fixture.setPolicyName(policyName);
-
-               // add additional test code here
-       }
-
-       /**
-        * Run the void setPolicyType(PolicyType) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testSetPolicyType_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-               PolicyType policyType = PolicyType.JSON;
-
-               fixture.setPolicyType(policyType);
-
-               // add additional test code here
-       }
-
-       /**
-        * Run the void setPolicyVersion(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testSetPolicyVersion_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-               String policyVersion = "";
-
-               fixture.setPolicyVersion(policyVersion);
-
-               // add additional test code here
-       }
-
-       /**
-        * Run the void setProperties(Properties) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testSetProperties_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-               Properties properties = new Properties();
-
-               fixture.setProperties(properties);
-
-               // add additional test code here
-       }
-
-       /**
-        * Run the void setResponseAttributes(Map<String,String>) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testSetResponseAttributes_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-               Map<String, String> responseAttributes = new Hashtable<String, String>();
-
-               fixture.setResponseAttributes(responseAttributes);
-
-               // add additional test code here
-       }
-
-       /**
-        * Run the JsonObject toJSON() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testToJSON_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-
-               JsonObject result = fixture.toJSON();
-
-               // add additional test code here
-               assertEquals(null, result);
-       }
-
-       /**
-        * Run the String toOther() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testToOther_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-
-               String result = fixture.toOther();
-
-               // add additional test code here
-               assertEquals("", result);
-       }
-
-       /**
-        * Run the Properties toProperties() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testToProperties_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-
-               Properties result = fixture.toProperties();
-
-               // add additional test code here
-               assertNotNull(result);
-               assertEquals(0, result.size());
-       }
-
-       /**
-        * Run the String toString() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testToString_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("test");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-
-               String result = fixture.toString();
-
-               // add additional test code here
-               assertEquals("PolicyConfig [ policyConfigStatus=not_found, policyConfigMessage=, policyName=test]", result);
-       }
-
-       /**
-        * Run the Document toXML() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testToXML_1()
-               throws Exception {
-               StdPolicyConfig fixture = new StdPolicyConfig();
-               fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
-               fixture.setDocument((Document) null);
-               fixture.setResponseAttributes(new Hashtable<String, String>());
-               fixture.setPolicyVersion("");
-               fixture.setOther("");
-               fixture.setPolicyType(PolicyType.JSON);
-               fixture.setPolicyName("");
-               fixture.setProperties(new Properties());
-               fixture.setJsonObject((JsonObject) null);
-               fixture.setMatchingConditions(new Hashtable<String, String>());
-
-               Document result = fixture.toXML();
-
-               // add additional test code here
-               assertEquals(null, result);
-       }
-
-       /**
-        * Perform pre-test initialization.
-        *
-        * @throws Exception
-        *         if the initialization fails for some reason
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @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 6/1/16 1:41 PM
-        */
-       @After
-       public void tearDown()
-               throws Exception {
-               // Add additional tear down code here
-       }
-
-       /**
-        * Launch the test.
-        *
-        * @param args the command line arguments
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       public static void main(String[] args) {
-               new org.junit.runner.JUnitCore().run(StdPolicyConfigTest.class);
-       }
+    private static final String POLICY_NAME = "PolicyName";
+
+    private static final String POLICY_NAME_WITH_XML_EXT = POLICY_NAME + ".1.xml";
+
+    private static final String EMPTY_STRING = "";
+
+    /**
+     * Run the Map<String, String> getMatchingConditions() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testGetMatchingConditions_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+
+        final Map<String, String> result = fixture.getMatchingConditions();
+
+        // add additional test code here
+        assertNotNull(result);
+        assertEquals(0, result.size());
+    }
+
+    /**
+     * Run the String getPolicyConfigMessage() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testGetPolicyConfigMessage_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+
+        final String result = fixture.getPolicyConfigMessage();
+
+        // add additional test code here
+        assertEquals(EMPTY_STRING, result);
+    }
+
+    /**
+     * Run the PolicyConfigStatus getPolicyConfigStatus() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testGetPolicyConfigStatus_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+
+        final PolicyConfigStatus result = fixture.getPolicyConfigStatus();
+
+        // add additional test code here
+        assertNotNull(result);
+        assertEquals("not_found", result.toString());
+        assertEquals("CONFIG_NOT_FOUND", result.name());
+        assertEquals(1, result.ordinal());
+    }
+
+    /**
+     * Run the String getPolicyName() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testGetPolicyName_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+
+        final String result = fixture.getPolicyName();
+
+        // add additional test code here
+        assertEquals(EMPTY_STRING, result);
+    }
+
+    /**
+     * Run the String getPolicyName() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testGetPolicyName_2() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName((String) null);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+
+        final String result = fixture.getPolicyName();
+
+        // add additional test code here
+        assertEquals(null, result);
+    }
+
+    /**
+     * Run the String getPolicyName() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testGetPolicyName_3() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+
+        final String result = fixture.getPolicyName();
+
+        // add additional test code here
+        assertEquals(EMPTY_STRING, result);
+    }
+
+    /**
+     * Run the String getPolicyVersion() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testGetPolicyVersion_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+
+        final String result = fixture.getPolicyVersion();
+
+        // add additional test code here
+        assertEquals(EMPTY_STRING, result);
+    }
+
+    /**
+     * Run the Map<String, String> getResponseAttributes() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testGetResponseAttributes_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+
+        final Map<String, String> result = fixture.getResponseAttributes();
+
+        // add additional test code here
+        assertNotNull(result);
+        assertEquals(0, result.size());
+    }
+
+    /**
+     * Run the PolicyType getType() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testGetType_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+
+        final PolicyType result = fixture.getType();
+
+        // add additional test code here
+        assertNotNull(result);
+        assertEquals("json", result.toString());
+        assertEquals("JSON", result.name());
+        assertEquals(1, result.ordinal());
+    }
+
+    /**
+     * Run the void setConfigStatus(String) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testSetGetPolicyConfigType_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyType(PolicyConfigType.BRMS_RAW);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+        fixture.setConfigStatus(EMPTY_STRING);
+
+        assertEquals(PolicyConfigType.BRMS_RAW, fixture.getPolicyType());
+
+    }
+
+    /**
+     * Run the void setConfigStatus(String,PolicyConfigStatus) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testSetConfigStatus_2() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+        final String configStatus = EMPTY_STRING;
+        final PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND;
+
+        fixture.setConfigStatus(configStatus, policyConfigStatus);
+
+        // add additional test code here
+    }
+
+    /**
+     * Run the void setDocument(Document) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testSetDocument_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+        final Document document = null;
+
+        fixture.setDocument(document);
+
+        // add additional test code here
+    }
+
+    /**
+     * Run the void setJsonObject(JsonObject) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testSetJsonObject_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+        final JsonObject jsonObject = null;
+
+        fixture.setJsonObject(jsonObject);
+
+        // add additional test code here
+    }
+
+    /**
+     * Run the void setMatchingConditions(Map<String,String>) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testSetMatchingConditions_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+        final Map<String, String> matchingConditions = new Hashtable<String, String>();
+
+        fixture.setMatchingConditions(matchingConditions);
+
+        // add additional test code here
+    }
+
+    /**
+     * Run the void setOther(String) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testSetOther_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+        final String other = EMPTY_STRING;
+
+        fixture.setOther(other);
+
+        // add additional test code here
+    }
+
+    /**
+     * Run the void setPolicyConfigStatus(PolicyConfigStatus) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testSetPolicyConfigStatus_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+        final PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND;
+
+        fixture.setPolicyConfigStatus(policyConfigStatus);
+
+        assertEquals(policyConfigStatus, fixture.getPolicyConfigStatus());
+    }
+
+    @Test
+    public void testSetGetPolicyName_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(Collections.emptyMap());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(Collections.emptyMap());
+        fixture.setPolicyName(EMPTY_STRING);
+
+        assertEquals(EMPTY_STRING, fixture.getPolicyName());
+
+    }
+
+    @Test
+    public void testSetGetPolicyName_2() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(Collections.emptyMap());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(POLICY_NAME_WITH_XML_EXT);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(Collections.emptyMap());
+
+        assertEquals(POLICY_NAME, fixture.getPolicyName());
+
+    }
+
+    /**
+     * Run the void setPolicyType(PolicyType) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testSetPolicyType_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(Collections.emptyMap());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(Collections.emptyMap());
+        final PolicyType policyType = PolicyType.JSON;
+
+        fixture.setPolicyType(policyType);
+
+        assertEquals(policyType, fixture.getType());
+    }
+
+    /**
+     * Run the void setPolicyVersion(String) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testSetPolicyVersion_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(Collections.emptyMap());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(Collections.emptyMap());
+        fixture.setPolicyVersion(EMPTY_STRING);
+
+        assertEquals(EMPTY_STRING, fixture.getPolicyVersion());
+
+    }
+
+    /**
+     * Run the void setProperties(Properties) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testSetProperties_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(Collections.emptyMap());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(Collections.emptyMap());
+        final Properties properties = new Properties();
+
+        fixture.setProperties(properties);
+
+        // add additional test code here
+    }
+
+    /**
+     * Run the void setResponseAttributes(Map<String,String>) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testSetResponseAttributes_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+        final Map<String, String> responseAttributes = new Hashtable<String, String>();
+
+        fixture.setResponseAttributes(responseAttributes);
+
+        // add additional test code here
+    }
+
+    /**
+     * Run the JsonObject toJSON() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testToJSON_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+
+        final JsonObject result = fixture.toJSON();
+
+        // add additional test code here
+        assertEquals(null, result);
+    }
+
+    /**
+     * Run the String toOther() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testToOther_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+
+        final String result = fixture.toOther();
+
+        // add additional test code here
+        assertEquals(EMPTY_STRING, result);
+    }
+
+    /**
+     * Run the Properties toProperties() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testToProperties_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+
+        final Properties result = fixture.toProperties();
+
+        // add additional test code here
+        assertNotNull(result);
+        assertEquals(0, result.size());
+    }
+
+    /**
+     * Run the String toString() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testToString_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName("test");
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+
+        final String result = fixture.toString();
+
+        // add additional test code here
+        assertEquals("PolicyConfig [ policyConfigStatus=not_found, policyConfigMessage=, policyName=test]", result);
+    }
+
+    /**
+     * Run the Document toXML() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testToXML_1() throws Exception {
+        final StdPolicyConfig fixture = new StdPolicyConfig();
+        fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+        fixture.setDocument((Document) null);
+        fixture.setResponseAttributes(new Hashtable<String, String>());
+        fixture.setPolicyVersion(EMPTY_STRING);
+        fixture.setOther(EMPTY_STRING);
+        fixture.setPolicyType(PolicyType.JSON);
+        fixture.setPolicyName(EMPTY_STRING);
+        fixture.setProperties(new Properties());
+        fixture.setJsonObject((JsonObject) null);
+        fixture.setMatchingConditions(new Hashtable<String, String>());
+
+        final Document result = fixture.toXML();
+
+        // add additional test code here
+        assertEquals(null, result);
+    }
+
+    /**
+     * Perform pre-test initialization.
+     *
+     * @throws Exception
+     *             if the initialization fails for some reason
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @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 6/1/16 1:41 PM
+     */
+    @After
+    public void tearDown() throws Exception {
+        // Add additional tear down code here
+    }
+
+    /**
+     * Launch the test.
+     *
+     * @param args
+     *            the command line arguments
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    public static void main(final String[] args) {
+        new org.junit.runner.JUnitCore().run(StdPolicyConfigTest.class);
+    }
 }
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/APIDictionaryResponseTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/APIDictionaryResponseTest.java
new file mode 100644 (file)
index 0000000..44bf759
--- /dev/null
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * APIDictionaryResponse
+ * ================================================================================
+ * Copyright (C) 2018 Ericsson. 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.test;
+
+import static org.junit.Assert.assertEquals;
+
+import javax.ws.rs.core.Response.Status;
+
+import org.junit.Test;
+import org.onap.policy.models.APIDictionaryResponse;
+
+public class APIDictionaryResponseTest {
+
+    private static final String JSON_STRING = "JSON_STRING";
+
+    private static final String DICTIONARY_DATA = "DICTIONARY_DATA";
+
+    @Test
+    public final void testSetAndGet() {
+        final APIDictionaryResponse objUnderTest = new APIDictionaryResponse();
+        objUnderTest.setDictionaryData(DICTIONARY_DATA);
+        objUnderTest.setDictionaryJson(JSON_STRING);
+        objUnderTest.setResponseCode(Status.BAD_GATEWAY.getStatusCode());
+        objUnderTest.setResponseMessage(Status.BAD_GATEWAY.toString());
+
+        assertEquals(DICTIONARY_DATA, objUnderTest.getDictionaryData());
+        assertEquals(JSON_STRING, objUnderTest.getDictionaryJson());
+        assertEquals(Status.BAD_GATEWAY.getStatusCode(), objUnderTest.getResponseCode());
+        assertEquals(Status.BAD_GATEWAY.toString(), objUnderTest.getResponseMessage());
+
+    }
+}
index d59a146..7255f1c 100644 (file)
@@ -26,73 +26,58 @@ import org.onap.policy.api.DeletePolicyCondition;
 import static org.junit.Assert.*;
 
 /**
- * The class <code>DeletePolicyConditionTest</code> contains tests for the class <code>{@link DeletePolicyCondition}</code>.
+ * The class <code>DeletePolicyConditionTest</code> contains tests for the class
+ * <code>{@link DeletePolicyCondition}</code>.
  *
  * @generatedBy CodePro at 6/1/16 1:41 PM
  * @version $Revision: 1.0 $
  */
 public class DeletePolicyConditionTest {
-       /**
-        * Run the String toString() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testToString_1()
-               throws Exception {
-               DeletePolicyCondition fixture = DeletePolicyCondition.ALL;
 
-               String result = fixture.toString();
+    @Test
+    public void testToString_1() throws Exception {
+        final DeletePolicyCondition fixture = DeletePolicyCondition.ALL;
 
-               // add additional test code here
-               assertEquals("All Versions", result);
-               
-               assertEquals(DeletePolicyCondition.ALL, DeletePolicyCondition.create(DeletePolicyCondition.ALL.name()));
-       }
+        final String result = fixture.toString();
 
-       @Test(expected = IllegalArgumentException.class)
-       public void testException() {
-               DeletePolicyCondition.create("foobar");
-       }
-       
-       /**
-        * Perform pre-test initialization.
-        *
-        * @throws Exception
-        *         if the initialization fails for some reason
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Before
-       public void setUp()
-               throws Exception {
-               // add additional set up code here
-       }
+        // add additional test code here
+        assertEquals("All Versions", result);
 
-       /**
-        * Perform post-test clean-up.
-        *
-        * @throws Exception
-        *         if the clean-up fails for some reason
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @After
-       public void tearDown()
-               throws Exception {
-               // Add additional tear down code here
-       }
+        assertEquals(DeletePolicyCondition.ALL, DeletePolicyCondition.create(DeletePolicyCondition.ALL.name()));
+    }
 
-       /**
-        * Launch the test.
-        *
-        * @param args the command line arguments
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       public static void main(String[] args) {
-               new org.junit.runner.JUnitCore().run(DeletePolicyConditionTest.class);
-       }
+    @Test
+    public void testCreate_EnumName_DeletePolicyConditionEnum() {
+        for (final DeletePolicyCondition condition : DeletePolicyCondition.values()) {
+            final DeletePolicyCondition actualCondition = DeletePolicyCondition.create(condition.name());
+            assertEquals(condition, actualCondition);
+            assertEquals(condition.toString(), actualCondition.toString());
+        }
+    }
+
+    @Test
+    public void testCreate_StringValue_DeletePolicyConditionEnum() {
+        for (final DeletePolicyCondition condition : DeletePolicyCondition.values()) {
+            final DeletePolicyCondition actualCondition = DeletePolicyCondition.create(condition.toString());
+            assertEquals(condition, actualCondition);
+        }
+
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testException() {
+        DeletePolicyCondition.create("foobar");
+    }
+
+    /**
+     * Launch the test.
+     *
+     * @param args
+     *            the command line arguments
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    public static void main(final String[] args) {
+        new org.junit.runner.JUnitCore().run(DeletePolicyConditionTest.class);
+    }
 }
index 423b839..14e1360 100644 (file)
@@ -29,286 +29,181 @@ import org.onap.policy.api.DeletePolicyParameters;
 import static org.junit.Assert.*;
 
 /**
- * The class <code>DeletePolicyParametersTest</code> contains tests for the class <code>{@link DeletePolicyParameters}</code>.
+ * The class <code>DeletePolicyParametersTest</code> contains tests for the
+ * class <code>{@link DeletePolicyParameters}</code>.
  *
  * @generatedBy CodePro at 6/1/16 1:40 PM
  * @version $Revision: 1.0 $
  */
 public class DeletePolicyParametersTest {
-       /**
-        * Run the DeletePolicyCondition getDeleteCondition() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test
-       public void testGetDeleteCondition_1()
-               throws Exception {
-               DeletePolicyParameters fixture = new DeletePolicyParameters();
-               fixture.setPolicyComponent("");
-               fixture.setPolicyName("");
-               fixture.setDeleteCondition(DeletePolicyCondition.ALL);
-               fixture.setRequestID(UUID.randomUUID());
-               fixture.setPdpGroup("");
-
-               DeletePolicyCondition result = fixture.getDeleteCondition();
-
-               // add additional test code here
-               assertNotNull(result);
-               assertEquals("All Versions", result.toString());
-               assertEquals("ALL", result.name());
-               assertEquals(1, result.ordinal());
-       }
-
-       /**
-        * Run the String getPdpGroup() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test
-       public void testGetPdpGroup_1()
-               throws Exception {
-               DeletePolicyParameters fixture = new DeletePolicyParameters();
-               fixture.setPolicyComponent("");
-               fixture.setPolicyName("");
-               fixture.setDeleteCondition(DeletePolicyCondition.ALL);
-               fixture.setRequestID(UUID.randomUUID());
-               fixture.setPdpGroup("");
-
-               String result = fixture.getPdpGroup();
-
-               // add additional test code here
-               assertEquals("", result);
-       }
-
-       /**
-        * Run the String getPolicyComponent() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test
-       public void testGetPolicyComponent_1()
-               throws Exception {
-               DeletePolicyParameters fixture = new DeletePolicyParameters();
-               fixture.setPolicyComponent("");
-               fixture.setPolicyName("");
-               fixture.setDeleteCondition(DeletePolicyCondition.ALL);
-               fixture.setRequestID(UUID.randomUUID());
-               fixture.setPdpGroup("");
-
-               String result = fixture.getPolicyComponent();
-
-               // add additional test code here
-               assertEquals("", result);
-       }
-
-       /**
-        * Run the String getPolicyName() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test
-       public void testGetPolicyName_1()
-               throws Exception {
-               DeletePolicyParameters fixture = new DeletePolicyParameters();
-               fixture.setPolicyComponent("");
-               fixture.setPolicyName("");
-               fixture.setDeleteCondition(DeletePolicyCondition.ALL);
-               fixture.setRequestID(UUID.randomUUID());
-               fixture.setPdpGroup("");
-
-               String result = fixture.getPolicyName();
-
-               // add additional test code here
-               assertEquals("", result);
-       }
-
-       /**
-        * Run the UUID getRequestID() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test
-       public void testGetRequestID_1()
-               throws Exception {
-               DeletePolicyParameters fixture = new DeletePolicyParameters();
-               fixture.setPolicyComponent("");
-               fixture.setPolicyName("");
-               fixture.setDeleteCondition(DeletePolicyCondition.ALL);
-               fixture.setRequestID(UUID.fromString("482e90e2-2ad7-4265-9893-4cfe08ef1e3d"));
-               fixture.setPdpGroup("");
-
-               UUID result = fixture.getRequestID();
-
-               // add additional test code here
-               assertNotNull(result);
-               assertEquals("482e90e2-2ad7-4265-9893-4cfe08ef1e3d", result.toString());
-               assertEquals(4, result.version());
-               assertEquals(2, result.variant());
-               assertEquals(-7452528304412746179L, result.getLeastSignificantBits());
-               assertEquals(5201253920715260517L, result.getMostSignificantBits());
-       }
-
-       /**
-        * Run the void setDeleteCondition(DeletePolicyCondition) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test
-       public void testSetDeleteCondition_1()
-               throws Exception {
-               DeletePolicyParameters fixture = new DeletePolicyParameters();
-               fixture.setPolicyComponent("");
-               fixture.setPolicyName("");
-               fixture.setDeleteCondition(DeletePolicyCondition.ALL);
-               fixture.setRequestID(UUID.randomUUID());
-               fixture.setPdpGroup("");
-               DeletePolicyCondition deleteCondition = DeletePolicyCondition.ALL;
-
-               fixture.setDeleteCondition(deleteCondition);
-
-               // add additional test code here
-       }
-
-       /**
-        * Run the void setPdpGroup(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test
-       public void testSetPdpGroup_1()
-               throws Exception {
-               DeletePolicyParameters fixture = new DeletePolicyParameters();
-               fixture.setPolicyComponent("");
-               fixture.setPolicyName("");
-               fixture.setDeleteCondition(DeletePolicyCondition.ALL);
-               fixture.setRequestID(UUID.randomUUID());
-               fixture.setPdpGroup("");
-               String pdpGroup = "";
-
-               fixture.setPdpGroup(pdpGroup);
-
-               // add additional test code here
-       }
-
-       /**
-        * Run the void setPolicyComponent(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test
-       public void testSetPolicyComponent_1()
-               throws Exception {
-               DeletePolicyParameters fixture = new DeletePolicyParameters();
-               fixture.setPolicyComponent("");
-               fixture.setPolicyName("");
-               fixture.setDeleteCondition(DeletePolicyCondition.ALL);
-               fixture.setRequestID(UUID.randomUUID());
-               fixture.setPdpGroup("");
-               String policyComponent = "";
-
-               fixture.setPolicyComponent(policyComponent);
-
-               // add additional test code here
-       }
-
-       /**
-        * Run the void setPolicyName(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test
-       public void testSetPolicyName_1()
-               throws Exception {
-               DeletePolicyParameters fixture = new DeletePolicyParameters();
-               fixture.setPolicyComponent("");
-               fixture.setPolicyName("");
-               fixture.setDeleteCondition(DeletePolicyCondition.ALL);
-               fixture.setRequestID(UUID.randomUUID());
-               fixture.setPdpGroup("");
-               String policyName = "";
-
-               fixture.setPolicyName(policyName);
-
-               // add additional test code here
-       }
-
-       /**
-        * Run the void setRequestID(UUID) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test
-       public void testSetRequestID_1()
-               throws Exception {
-               DeletePolicyParameters fixture = new DeletePolicyParameters();
-               fixture.setPolicyComponent("");
-               fixture.setPolicyName("");
-               fixture.setDeleteCondition(DeletePolicyCondition.ALL);
-               fixture.setRequestID(UUID.randomUUID());
-               fixture.setPdpGroup("");
-               UUID requestID = UUID.randomUUID();
-
-               fixture.setRequestID(requestID);
-
-               // add additional test code here
-       }
-
-       /**
-        * Perform pre-test initialization.
-        *
-        * @throws Exception
-        *         if the initialization fails for some reason
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @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 6/1/16 1:40 PM
-        */
-       @After
-       public void tearDown()
-               throws Exception {
-               // Add additional tear down code here
-       }
-
-       /**
-        * Launch the test.
-        *
-        * @param args the command line arguments
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       public static void main(String[] args) {
-               new org.junit.runner.JUnitCore().run(DeletePolicyParametersTest.class);
-       }
+    private static final String POLICY_TYPE = "POLICYTYPE";
+
+    private static final String PDP_GROUP = "PDPGROUP";
+
+    private static final String POLICY_NAME = "Apex";
+
+    private static final String POLICY_COMPONENT = "ApexComponent";
+
+    /**
+     * Run the DeletePolicyCondition getDeleteCondition() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:40 PM
+     */
+    @Test
+    public void testGetDeleteCondition_1() throws Exception {
+        final DeletePolicyParameters fixture = new DeletePolicyParameters();
+        fixture.setPolicyComponent("");
+        fixture.setPolicyName("");
+        fixture.setDeleteCondition(DeletePolicyCondition.ALL);
+        fixture.setRequestID(UUID.randomUUID());
+        fixture.setPdpGroup("");
+
+        final DeletePolicyCondition result = fixture.getDeleteCondition();
+
+        // add additional test code here
+        assertNotNull(result);
+        assertEquals("All Versions", result.toString());
+        assertEquals("ALL", result.name());
+        assertEquals(1, result.ordinal());
+    }
+
+    /**
+     * Run the String getPdpGroup() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:40 PM
+     */
+    @Test
+    public void testGetPdpGroup_1() throws Exception {
+        final DeletePolicyParameters fixture = new DeletePolicyParameters();
+        fixture.setPolicyComponent("");
+        fixture.setPolicyName("");
+        fixture.setDeleteCondition(DeletePolicyCondition.ALL);
+        fixture.setRequestID(UUID.randomUUID());
+        fixture.setPdpGroup("");
+
+        final String result = fixture.getPdpGroup();
+
+        // add additional test code here
+        assertEquals("", result);
+    }
+
+    /**
+     * Run the String getPolicyComponent() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:40 PM
+     */
+    @Test
+    public void testGetPolicyComponent_1() throws Exception {
+        final DeletePolicyParameters fixture = new DeletePolicyParameters();
+        fixture.setPolicyComponent("");
+        fixture.setPolicyName("");
+        fixture.setDeleteCondition(DeletePolicyCondition.ALL);
+        fixture.setRequestID(UUID.randomUUID());
+        fixture.setPdpGroup("");
+
+        final String result = fixture.getPolicyComponent();
+
+        // add additional test code here
+        assertEquals("", result);
+    }
+
+    /**
+     * Run the UUID getRequestID() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:40 PM
+     */
+    @Test
+    public void testGetRequestID_1() throws Exception {
+        final UUID requestID = UUID.fromString("482e90e2-2ad7-4265-9893-4cfe08ef1e3d");
+
+        final DeletePolicyParameters objUnderTest = new DeletePolicyParameters();
+        objUnderTest.setPolicyComponent(POLICY_COMPONENT);
+        objUnderTest.setPolicyName(POLICY_NAME);
+        objUnderTest.setDeleteCondition(DeletePolicyCondition.ALL);
+        objUnderTest.setRequestID(requestID);
+        objUnderTest.setPdpGroup(PDP_GROUP);
+        objUnderTest.setPolicyType(POLICY_TYPE);
+
+        final UUID result = objUnderTest.getRequestID();
+
+        // add additional test code here
+        assertNotNull(result);
+        assertEquals("482e90e2-2ad7-4265-9893-4cfe08ef1e3d", result.toString());
+        assertEquals(4, result.version());
+        assertEquals(2, result.variant());
+        assertEquals(-7452528304412746179L, result.getLeastSignificantBits());
+        assertEquals(5201253920715260517L, result.getMostSignificantBits());
+    }
+
+    /**
+     * Run the void setDeleteCondition(DeletePolicyCondition) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:40 PM
+     */
+    @Test
+    public void testSetDeleteCondition_1() throws Exception {
+        final UUID requestID = UUID.fromString("482e90e2-2ad7-4265-9893-4cfe08ef1e3d");
+
+        final DeletePolicyParameters objUnderTest = new DeletePolicyParameters();
+        objUnderTest.setPolicyComponent(POLICY_COMPONENT);
+        objUnderTest.setPolicyName(POLICY_NAME);
+        objUnderTest.setDeleteCondition(DeletePolicyCondition.ALL);
+        objUnderTest.setRequestID(requestID);
+        objUnderTest.setPdpGroup(PDP_GROUP);
+        objUnderTest.setPolicyType(POLICY_TYPE);
+
+        assertEquals(POLICY_COMPONENT, objUnderTest.getPolicyComponent());
+        assertEquals(POLICY_NAME, objUnderTest.getPolicyName());
+        assertEquals(POLICY_TYPE, objUnderTest.getPolicyType());
+        assertEquals(DeletePolicyCondition.ALL, objUnderTest.getDeleteCondition());
+        assertEquals(requestID, objUnderTest.getRequestID());
+    }
+
+    /**
+     * Perform pre-test initialization.
+     *
+     * @throws Exception
+     *             if the initialization fails for some reason
+     *
+     * @generatedBy CodePro at 6/1/16 1:40 PM
+     */
+    @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 6/1/16 1:40 PM
+     */
+    @After
+    public void tearDown() throws Exception {
+        // Add additional tear down code here
+    }
+
+    /**
+     * Launch the test.
+     *
+     * @param args
+     *            the command line arguments
+     *
+     * @generatedBy CodePro at 6/1/16 1:40 PM
+     */
+    public static void main(final String[] args) {
+        new org.junit.runner.JUnitCore().run(DeletePolicyParametersTest.class);
+    }
 }
index bbab6d3..ca85f69 100644 (file)
  */
 package org.onap.policy.test;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
 
-import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
 import org.onap.policy.api.DictionaryType;
 
 public class DictionaryTypeTest {
 
-       @Before
-       public void setUp() throws Exception {
-       }
+    @Test
+    public void testCreate_EnumName_DictionaryTypeEnum() {
+        for (final DictionaryType dictionaryType : DictionaryType.values()) {
+            final DictionaryType actualDictionaryType = DictionaryType.create(dictionaryType.name());
+            assertEquals(dictionaryType, actualDictionaryType);
+            assertEquals(dictionaryType.toString(), actualDictionaryType.toString());
+        }
+    }
 
-       @After
-       public void tearDown() throws Exception {
-       }
+    @Test
+    public void testCreate_StringValue_DictionaryTypeEnum() {
+        for (final DictionaryType dictionaryType : DictionaryType.values()) {
+            final DictionaryType actualDictionaryType = DictionaryType.create(dictionaryType.toString());
+            assertEquals(dictionaryType, actualDictionaryType);
+        }
+    }
 
-       @Test(expected = IllegalArgumentException.class)
-       public void test() {
-               assertEquals(DictionaryType.Action, DictionaryType.create(DictionaryType.Action.toString()));
-               DictionaryType.create("foobar");
-       }
+    @Test(expected = IllegalArgumentException.class)
+    public void test() {
+        assertEquals(DictionaryType.Action, DictionaryType.create(DictionaryType.Action.toString()));
+        DictionaryType.create("foobar");
+    }
 
 }
index b4aaa64..88b3bc8 100644 (file)
 
 package org.onap.policy.test;
 
-import org.junit.*;
-import org.onap.policy.api.PolicyClass;
+import static org.junit.Assert.assertEquals;
 
-import static org.junit.Assert.*;
+import org.junit.Test;
+import org.onap.policy.api.PolicyClass;
 
 /**
- * The class <code>PolicyClassTest</code> contains tests for the class <code>{@link PolicyClass}</code>.
+ * The class <code>PolicyClassTest</code> contains tests for the class
+ * <code>{@link PolicyClass}</code>.
  *
  * @generatedBy CodePro at 6/1/16 1:40 PM
  * @version $Revision: 1.0 $
  */
 public class PolicyClassTest {
-       /**
-        * Run the String toString() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Test
-       public void testToString_1() {
-               PolicyClass fixture = PolicyClass.Action;
 
-               String result = fixture.toString();
+    @Test
+    public void testToString_1() {
+        final PolicyClass fixture = PolicyClass.Action;
+
+        final String result = fixture.toString();
+
+        // add additional test code here
+        assertEquals("Action", result);
+
+        assertEquals(PolicyClass.Decision, PolicyClass.create(PolicyClass.Decision.toString()));
+    }
 
-               // add additional test code here
-               assertEquals("Action", result);
-               
-               assertEquals(PolicyClass.Decision, PolicyClass.create(PolicyClass.Decision.toString()));
-       }
+    @Test
+    public void testCreate_EnumName_PolicyClassEnum() {
+        for (final PolicyClass policyClass : PolicyClass.values()) {
+            final PolicyClass actualPolicyClass = PolicyClass.create(policyClass.name());
+            assertEquals(policyClass, actualPolicyClass);
+            assertEquals(policyClass.toString(), actualPolicyClass.toString());
+        }
+    }
 
-       @Test(expected = IllegalArgumentException.class)
-       public void testException() {
-               PolicyClass.create("foobar");
-       }
-       
-       /**
-        * Perform pre-test initialization.
-        *
-        * @throws Exception
-        *         if the initialization fails for some reason
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @Before
-       public void setUp()
-               throws Exception {
-               // add additional set up code here
-       }
+    @Test
+    public void testCreate_StringValue_PolicyClassEnum() {
+        for (final PolicyClass policyClass : PolicyClass.values()) {
+            final PolicyClass actualPolicyClass = PolicyClass.create(policyClass.toString());
+            assertEquals(policyClass, actualPolicyClass);
+        }
+    }
 
-       /**
-        * Perform post-test clean-up.
-        *
-        * @throws Exception
-        *         if the clean-up fails for some reason
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       @After
-       public void tearDown()
-               throws Exception {
-               // Add additional tear down code here
-       }
+    @Test(expected = IllegalArgumentException.class)
+    public void testException() {
+        PolicyClass.create("foobar");
+    }
 
-       /**
-        * Launch the test.
-        *
-        * @param args the command line arguments
-        *
-        * @generatedBy CodePro at 6/1/16 1:40 PM
-        */
-       public static void main(String[] args) {
-               new org.junit.runner.JUnitCore().run(PolicyClassTest.class);
-       }
+    /**
+     * Launch the test.
+     *
+     * @param args
+     *            the command line arguments
+     *
+     * @generatedBy CodePro at 6/1/16 1:40 PM
+     */
+    public static void main(final String[] args) {
+        new org.junit.runner.JUnitCore().run(PolicyClassTest.class);
+    }
 }
index 4969172..e7d8249 100644 (file)
 
 package org.onap.policy.test;
 
-import org.junit.*;
-import org.onap.policy.api.PolicyConfigStatus;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
-import static org.junit.Assert.*;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.api.PolicyConfigStatus;
 
 /**
- * The class <code>PolicyConfigStatusTest</code> contains tests for the class <code>{@link PolicyConfigStatus}</code>.
+ * The class <code>PolicyConfigStatusTest</code> contains tests for the class
+ * <code>{@link PolicyConfigStatus}</code>.
  *
  * @generatedBy CodePro at 6/1/16 1:41 PM
  * @version $Revision: 1.0 $
  */
 public class PolicyConfigStatusTest {
-       /**
-        * Run the PolicyConfigStatus getStatus(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testGetStatus_1()
-               throws Exception {
-               String configStatus = "";
-
-               PolicyConfigStatus result = PolicyConfigStatus.getStatus(configStatus);
+    /**
+     * Run the PolicyConfigStatus getStatus(String) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testGetStatus_1() throws Exception {
+        final String configStatus = "";
 
-               // add additional test code here
-               assertNotNull(result);
-               assertEquals("not_found", result.toString());
-               assertEquals("CONFIG_NOT_FOUND", result.name());
-               assertEquals(1, result.ordinal());
-               
-               assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED, PolicyConfigStatus.create("retrieved"));
-       }
+        final PolicyConfigStatus result = PolicyConfigStatus.getStatus(configStatus);
 
-       /**
-        * Run the PolicyConfigStatus getStatus(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testGetStatus_2()
-               throws Exception {
-               String configStatus = "retrieved";
+        // add additional test code here
+        assertNotNull(result);
+        assertEquals("not_found", result.toString());
+        assertEquals("CONFIG_NOT_FOUND", result.name());
+        assertEquals(1, result.ordinal());
 
-               PolicyConfigStatus result = PolicyConfigStatus.getStatus(configStatus);
+        assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED, PolicyConfigStatus.create("retrieved"));
+    }
 
-               // add additional test code here
-               assertNotNull(result);
-               assertEquals("retrieved", result.toString());
-               assertEquals("CONFIG_RETRIEVED", result.name());
-               assertEquals(0, result.ordinal());
-       }
+    /**
+     * Run the PolicyConfigStatus getStatus(String) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testGetStatus_2() throws Exception {
+        final String configStatus = "retrieved";
 
-       /**
-        * Run the String toString() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testToString_1()
-               throws Exception {
-               PolicyConfigStatus fixture = PolicyConfigStatus.CONFIG_NOT_FOUND;
+        final PolicyConfigStatus result = PolicyConfigStatus.getStatus(configStatus);
 
-               String result = fixture.toString();
+        // add additional test code here
+        assertNotNull(result);
+        assertEquals("retrieved", result.toString());
+        assertEquals("CONFIG_RETRIEVED", result.name());
+        assertEquals(0, result.ordinal());
+    }
 
-               // add additional test code here
-               assertEquals("not_found", result);
-       }
+    @Test
+    public void testCreate_EnumName_PolicyConfigStatusEnum() {
+        for (final PolicyConfigStatus policyConfigStatus : PolicyConfigStatus.values()) {
+            final PolicyConfigStatus actualPolicyConfigStatus = PolicyConfigStatus.create(policyConfigStatus.name());
+            assertEquals(policyConfigStatus, actualPolicyConfigStatus);
+            assertEquals(policyConfigStatus.toString(), actualPolicyConfigStatus.toString());
+        }
+    }
 
-       @Test(expected = IllegalArgumentException.class)
-       public void testException () {
-               PolicyConfigStatus.create("foobar");
-       }
-       /**
-        * Perform pre-test initialization.
-        *
-        * @throws Exception
-        *         if the initialization fails for some reason
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Before
-       public void setUp()
-               throws Exception {
-               // add additional set up code here
-       }
+    @Test
+    public void testCreate_StringValue_PolicyClassEnum() {
+        for (final PolicyConfigStatus policyConfigStatus : PolicyConfigStatus.values()) {
+            final PolicyConfigStatus actualPolicyClass = PolicyConfigStatus.create(policyConfigStatus.toString());
+            assertEquals(policyConfigStatus, actualPolicyClass);
+        }
+    }
 
-       /**
-        * Perform post-test clean-up.
-        *
-        * @throws Exception
-        *         if the clean-up fails for some reason
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @After
-       public void tearDown()
-               throws Exception {
-               // Add additional tear down code here
-       }
+    @Test(expected = IllegalArgumentException.class)
+    public void testException() {
+        PolicyConfigStatus.create("foobar");
+    }
 
-       /**
-        * Launch the test.
-        *
-        * @param args the command line arguments
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       public static void main(String[] args) {
-               new org.junit.runner.JUnitCore().run(PolicyConfigStatusTest.class);
-       }
+    /**
+     * Launch the test.
+     *
+     * @param args
+     *            the command line arguments
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    public static void main(final String[] args) {
+        new org.junit.runner.JUnitCore().run(PolicyConfigStatusTest.class);
+    }
 }
index a639170..a63094a 100644 (file)
 
 package org.onap.policy.test;
 
-import org.junit.*;
-import org.onap.policy.api.PolicyDecision;
+import static org.junit.Assert.assertEquals;
 
-import static org.junit.Assert.*;
+import org.junit.Test;
+import org.onap.policy.api.PolicyDecision;
 
 /**
- * The class <code>PolicyDecisionTest</code> contains tests for the class <code>{@link PolicyDecision}</code>.
+ * The class <code>PolicyDecisionTest</code> contains tests for the class
+ * <code>{@link PolicyDecision}</code>.
  *
  * @generatedBy CodePro at 6/1/16 1:41 PM
  * @version $Revision: 1.0 $
  */
 public class PolicyDecisionTest {
-       /**
-        * Run the String toString() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testToString_1()
-               throws Exception {
-               PolicyDecision fixture = PolicyDecision.DENY;
-
-               String result = fixture.toString();
 
-               // add additional test code here
-               assertEquals("deny", result);
-               
-               assertEquals(PolicyDecision.PERMIT, PolicyDecision.create(PolicyDecision.PERMIT.name()));
-       }
-       
-       @Test(expected = IllegalArgumentException.class)
-       public void testException() {
-               PolicyDecision.create("foobar");
-       }
+    @Test
+    public void testCreate_EnumName_PolicyDecisionEnum() {
+        for (final PolicyDecision policyDecision : PolicyDecision.values()) {
+            final PolicyDecision actualPolicyDecision = PolicyDecision.create(policyDecision.name());
+            assertEquals(policyDecision, actualPolicyDecision);
+            assertEquals(policyDecision.toString(), actualPolicyDecision.toString());
+        }
+    }
 
-       /**
-        * Perform pre-test initialization.
-        *
-        * @throws Exception
-        *         if the initialization fails for some reason
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Before
-       public void setUp()
-               throws Exception {
-               // add additional set up code here
-       }
+    @Test
+    public void testCreate_StringValue_PolicyDecisionEnum() {
+        for (final PolicyDecision policyDecision : PolicyDecision.values()) {
+            final PolicyDecision autalPolicyDecision = PolicyDecision.create(policyDecision.toString());
+            assertEquals(policyDecision, autalPolicyDecision);
+        }
+    }
 
-       /**
-        * Perform post-test clean-up.
-        *
-        * @throws Exception
-        *         if the clean-up fails for some reason
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @After
-       public void tearDown()
-               throws Exception {
-               // Add additional tear down code here
-       }
+    @Test(expected = IllegalArgumentException.class)
+    public void testException() {
+        PolicyDecision.create("foobar");
+    }
 
-       /**
-        * Launch the test.
-        *
-        * @param args the command line arguments
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       public static void main(String[] args) {
-               new org.junit.runner.JUnitCore().run(PolicyDecisionTest.class);
-       }
+    /**
+     * Launch the test.
+     *
+     * @param args
+     *            the command line arguments
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    public static void main(final String[] args) {
+        new org.junit.runner.JUnitCore().run(PolicyDecisionTest.class);
+    }
 }
index 4803a8e..587b193 100644 (file)
 
 package org.onap.policy.test;
 
-import org.junit.*;
-import org.onap.policy.api.PolicyResponseStatus;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
-import static org.junit.Assert.*;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.api.PolicyResponseStatus;
 
 /**
- * The class <code>PolicyResponseStatusTest</code> contains tests for the class <code>{@link PolicyResponseStatus}</code>.
+ * The class <code>PolicyResponseStatusTest</code> contains tests for the class
+ * <code>{@link PolicyResponseStatus}</code>.
  *
  * @generatedBy CodePro at 6/1/16 1:41 PM
  * @version $Revision: 1.0 $
  */
 public class PolicyResponseStatusTest {
-       /**
-        * Run the PolicyResponseStatus getStatus(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testGetStatus_1()
-               throws Exception {
-               String responseStatus = "";
-
-               PolicyResponseStatus result = PolicyResponseStatus.getStatus(responseStatus);
-
-               // add additional test code here
-               assertNotNull(result);
-               assertEquals("no_action", result.toString());
-               assertEquals("NO_ACTION_REQUIRED", result.name());
-               assertEquals(0, result.ordinal());
-       }
-
-       /**
-        * Run the PolicyResponseStatus getStatus(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testGetStatus_2()
-               throws Exception {
-               String responseStatus = "action_advised";
-
-               PolicyResponseStatus result = PolicyResponseStatus.getStatus(responseStatus);
-
-               // add additional test code here
-               assertNotNull(result);
-               assertEquals("action_advised", result.toString());
-               assertEquals("ACTION_ADVISED", result.name());
-               assertEquals(1, result.ordinal());
-       }
-
-       /**
-        * Run the PolicyResponseStatus getStatus(String) method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testGetStatus_3()
-               throws Exception {
-               String responseStatus = "action_taken";
-
-               PolicyResponseStatus result = PolicyResponseStatus.getStatus(responseStatus);
-
-               // add additional test code here
-               assertNotNull(result);
-               assertEquals("action_taken", result.toString());
-               assertEquals("ACTION_TAKEN", result.name());
-               assertEquals(2, result.ordinal());
-       }
-
-       /**
-        * Run the String toString() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testToString_1()
-               throws Exception {
-               PolicyResponseStatus fixture = PolicyResponseStatus.ACTION_ADVISED;
-
-               String result = fixture.toString();
-
-               // add additional test code here
-               assertEquals("action_advised", result);
-
-               assertEquals(PolicyResponseStatus.ACTION_ADVISED, PolicyResponseStatus.create("ACTION_ADVISED"));
-       }
-       
-       @Test(expected = IllegalArgumentException.class)
-       public void testTheRest() {
-               PolicyResponseStatus.create("foobar");
-       }
-
-       /**
-        * Perform pre-test initialization.
-        *
-        * @throws Exception
-        *         if the initialization fails for some reason
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @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 6/1/16 1:41 PM
-        */
-       @After
-       public void tearDown()
-               throws Exception {
-               // Add additional tear down code here
-       }
-
-       /**
-        * Launch the test.
-        *
-        * @param args the command line arguments
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       public static void main(String[] args) {
-               new org.junit.runner.JUnitCore().run(PolicyResponseStatusTest.class);
-       }
+    /**
+     * Run the PolicyResponseStatus getStatus(String) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testGetStatus_1() throws Exception {
+        final String responseStatus = "";
+
+        final PolicyResponseStatus result = PolicyResponseStatus.getStatus(responseStatus);
+
+        // add additional test code here
+        assertNotNull(result);
+        assertEquals("no_action", result.toString());
+        assertEquals("NO_ACTION_REQUIRED", result.name());
+        assertEquals(0, result.ordinal());
+    }
+
+    @Test
+    public void testCreate_EnumName_PolicyResponseStatusEnum() {
+        for (final PolicyResponseStatus policyResponseStatus : PolicyResponseStatus.values()) {
+            final PolicyResponseStatus actualPolicyResponseStatus = PolicyResponseStatus
+                    .create(policyResponseStatus.name());
+            assertEquals(policyResponseStatus, actualPolicyResponseStatus);
+            assertEquals(policyResponseStatus.toString(), actualPolicyResponseStatus.toString());
+        }
+    }
+
+    @Test
+    public void testCreate_StringValue_PolicyResponseStatusEnum() {
+        for (final PolicyResponseStatus policyResponseStatus : PolicyResponseStatus.values()) {
+            final PolicyResponseStatus actualPolicyResponseStatus = PolicyResponseStatus
+                    .create(policyResponseStatus.toString());
+            assertEquals(policyResponseStatus, actualPolicyResponseStatus);
+        }
+    }
+
+    /**
+     * Run the PolicyResponseStatus getStatus(String) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testGetStatus_2() throws Exception {
+        final String responseStatus = "action_advised";
+
+        final PolicyResponseStatus result = PolicyResponseStatus.getStatus(responseStatus);
+
+        // add additional test code here
+        assertNotNull(result);
+        assertEquals("action_advised", result.toString());
+        assertEquals("ACTION_ADVISED", result.name());
+        assertEquals(1, result.ordinal());
+    }
+
+    /**
+     * Run the PolicyResponseStatus getStatus(String) method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testGetStatus_3() throws Exception {
+        final String responseStatus = "action_taken";
+
+        final PolicyResponseStatus result = PolicyResponseStatus.getStatus(responseStatus);
+
+        // add additional test code here
+        assertNotNull(result);
+        assertEquals("action_taken", result.toString());
+        assertEquals("ACTION_TAKEN", result.name());
+        assertEquals(2, result.ordinal());
+    }
+
+    /**
+     * Run the String toString() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testToString_1() throws Exception {
+        final PolicyResponseStatus fixture = PolicyResponseStatus.ACTION_ADVISED;
+
+        final String result = fixture.toString();
+
+        // add additional test code here
+        assertEquals("action_advised", result);
+
+        assertEquals(PolicyResponseStatus.ACTION_ADVISED, PolicyResponseStatus.create("ACTION_ADVISED"));
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testTheRest() {
+        PolicyResponseStatus.create("foobar");
+    }
+
+    /**
+     * Perform pre-test initialization.
+     *
+     * @throws Exception
+     *             if the initialization fails for some reason
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @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 6/1/16 1:41 PM
+     */
+    @After
+    public void tearDown() throws Exception {
+        // Add additional tear down code here
+    }
+
+    /**
+     * Launch the test.
+     *
+     * @param args
+     *            the command line arguments
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    public static void main(final String[] args) {
+        new org.junit.runner.JUnitCore().run(PolicyResponseStatusTest.class);
+    }
 }
index 267dd97..49bdfe8 100644 (file)
 
 package org.onap.policy.test;
 
-import org.junit.*;
-import org.onap.policy.api.PolicyType;
+import static org.junit.Assert.assertEquals;
 
-import static org.junit.Assert.*;
+import org.junit.Test;
+import org.onap.policy.api.PolicyType;
 
 /**
- * The class <code>PolicyTypeTest</code> contains tests for the class <code>{@link PolicyType}</code>.
+ * The class <code>PolicyTypeTest</code> contains tests for the class
+ * <code>{@link PolicyType}</code>.
  *
  * @generatedBy CodePro at 6/1/16 1:41 PM
  * @version $Revision: 1.0 $
  */
 public class PolicyTypeTest {
-       /**
-        * Run the String toString() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testToString_1()
-               throws Exception {
-               PolicyType fixture = PolicyType.JSON;
+    /**
+     * Run the String toString() method test.
+     *
+     * @throws Exception
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    @Test
+    public void testToString_1() throws Exception {
+        final PolicyType fixture = PolicyType.JSON;
+
+        final String result = fixture.toString();
+
+        // add additional test code here
+        assertEquals("json", result);
 
-               String result = fixture.toString();
+        assertEquals(PolicyType.JSON, PolicyType.create("json"));
+    }
 
-               // add additional test code here
-               assertEquals("json", result);
-               
-               assertEquals(PolicyType.JSON, PolicyType.create("json"));
-       }
-       
-       @Test(expected = IllegalArgumentException.class)
-       public void testException() {
-               PolicyType.create("foobar");
-       }
+    @Test
+    public void testCreate_EnumName_PolicyTypeEnum() {
+        for (final PolicyType policyType : PolicyType.values()) {
+            final PolicyType actualPolicyType = PolicyType.create(policyType.name());
+            assertEquals(policyType, actualPolicyType);
+            assertEquals(policyType.toString(), actualPolicyType.toString());
+        }
+    }
 
-       /**
-        * Perform pre-test initialization.
-        *
-        * @throws Exception
-        *         if the initialization fails for some reason
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Before
-       public void setUp()
-               throws Exception {
-               // add additional set up code here
-       }
+    @Test
+    public void testCreate_StringValue_PolicyTypeEnum() {
+        for (final PolicyType policyType : PolicyType.values()) {
+            final PolicyType actualPolicyType = PolicyType.create(policyType.toString());
+            assertEquals(policyType, actualPolicyType);
+        }
+    }
 
-       /**
-        * Perform post-test clean-up.
-        *
-        * @throws Exception
-        *         if the clean-up fails for some reason
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @After
-       public void tearDown()
-               throws Exception {
-               // Add additional tear down code here
-       }
+    @Test(expected = IllegalArgumentException.class)
+    public void testException() {
+        PolicyType.create("foobar");
+    }
 
-       /**
-        * Launch the test.
-        *
-        * @param args the command line arguments
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       public static void main(String[] args) {
-               new org.junit.runner.JUnitCore().run(PolicyTypeTest.class);
-       }
+    /**
+     * Launch the test.
+     *
+     * @param args
+     *            the command line arguments
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    public static void main(final String[] args) {
+        new org.junit.runner.JUnitCore().run(PolicyTypeTest.class);
+    }
 }
index 2335323..756997e 100644 (file)
  */
 package org.onap.policy.test;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
 
 import org.junit.Test;
 import org.onap.policy.api.RuleProvider;
 
 public class RuleProviderTest {
 
-       @Test
-       public void test() {
-               assertEquals(RuleProvider.RAINY_DAY, RuleProvider.create(RuleProvider.RAINY_DAY.name()));
-       }
-       
-       @Test(expected = IllegalArgumentException.class)
-       public void testException() {
-               RuleProvider.create("foobar");
-       }
+    @Test
+    public void test() {
+        assertEquals(RuleProvider.RAINY_DAY, RuleProvider.create(RuleProvider.RAINY_DAY.name()));
+    }
+
+    @Test
+    public void testCreate_EnumName_RuleProviderEnum() {
+        for (final RuleProvider ruleProvider : RuleProvider.values()) {
+            final RuleProvider actualRuleProvider = RuleProvider.create(ruleProvider.name());
+            assertEquals(ruleProvider, actualRuleProvider);
+            assertEquals(ruleProvider.toString(), actualRuleProvider.toString());
+        }
+    }
+
+    @Test
+    public void testCreate_StringValue_RuleProviderEnum() {
+        for (final RuleProvider ruleProvider : RuleProvider.values()) {
+            final RuleProvider actualRuleProvider = RuleProvider.create(ruleProvider.toString());
+            assertEquals(ruleProvider, actualRuleProvider);
+        }
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testException() {
+        RuleProvider.create("foobar");
+    }
 
 }