From 87c95be02a8a4d77e165dede90777e811b59dcae Mon Sep 17 00:00:00 2001 From: Ravindra Bakkamanthala Date: Tue, 23 May 2017 14:56:12 -0400 Subject: Commit includes ControlLoopPolicy API and bugfixes Change-Id: I3e18bb8b4c31a0d908bb0cff4c85e2a3fb450a63 Signed-off-by: Ravindra Bakkamanthala --- PolicyEngineClient/config.properties | 4 ++-- .../org/openecomp/policyEngine/ActionPolicyClient.java | 12 ++++++------ .../org/openecomp/policyEngine/BrmsParamPolicyClient.java | 7 ++----- .../org/openecomp/policyEngine/BrmsRawPolicyClient.java | 4 ++-- .../org/openecomp/policyEngine/ConfigBasePolicyClient.java | 4 ++-- .../org/openecomp/policyEngine/DecisionPolicyClient.java | 14 +++++++------- .../java/org/openecomp/policyEngine/GeneralTestClient.java | 10 +++++----- .../openecomp/policyEngine/ListConfigPoliciesClient.java | 2 +- .../main/java/org/openecomp/policyEngine/MainClient.java | 10 +++++----- .../org/openecomp/policyEngine/PolicyEngineTestClient.java | 6 +++--- 10 files changed, 35 insertions(+), 38 deletions(-) (limited to 'PolicyEngineClient') diff --git a/PolicyEngineClient/config.properties b/PolicyEngineClient/config.properties index 62099050e..12d7e3287 100644 --- a/PolicyEngineClient/config.properties +++ b/PolicyEngineClient/config.properties @@ -39,7 +39,7 @@ ENVIRONMENT=TEST #PDP_URL2=http://localhost:8081/pdp/ , testpdp, alpha123 #NOTIFICATION_TYPE=ueb #NOTIFICATION_UEB_SERVERS= -#CLIENT_ID=PyPDPServer +#CLIENT_ID=PDPServer #CLIENT_KEY=test @@ -50,5 +50,5 @@ ENVIRONMENT=TEST #PAP_URL = http://localhost:9091/pap/, testpap, alpha123 #NOTIFICATION_TYPE=websocket #NOTIFICATION_UEB_SERVERS= -#CLIENT_ID=PyPDPServer +#CLIENT_ID=PDPServer #CLIENT_KEY=test diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ActionPolicyClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ActionPolicyClient.java index 37d25f2b9..18de85bd4 100644 --- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ActionPolicyClient.java +++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ActionPolicyClient.java @@ -46,21 +46,21 @@ public class ActionPolicyClient { //policyParameters.setPolicyScope("MikeAPItesting"); //Directory will be created where the Policies are saved... this displays a a subscope on the GUI //Set the Component Attributes... These are Optional - Map configAttributes = new HashMap(); + Map configAttributes = new HashMap<>(); configAttributes.put("Template", "UpdateTemplate"); configAttributes.put("controller", "default"); configAttributes.put("SamPoll", "30"); configAttributes.put("value", "abcd"); - Map> attributes = new HashMap>(); + Map> attributes = new HashMap<>(); attributes.put(AttributeType.MATCHING, configAttributes); policyParameters.setAttributes(attributes); - List dynamicRuleAlgorithmLabels = new LinkedList(); - List dynamicRuleAlgorithmFunctions = new LinkedList(); - List dynamicRuleAlgorithmField1 = new LinkedList(); - List dynamicRuleAlgorithmField2 = new LinkedList(); + List dynamicRuleAlgorithmLabels = new LinkedList<>(); + List dynamicRuleAlgorithmFunctions = new LinkedList<>(); + List dynamicRuleAlgorithmField1 = new LinkedList<>(); + List dynamicRuleAlgorithmField2 = new LinkedList<>(); //Example of a complex Rule algorithm /* label field1 function field2 diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/BrmsParamPolicyClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/BrmsParamPolicyClient.java index 3d80fe2ef..790c8e893 100644 --- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/BrmsParamPolicyClient.java +++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/BrmsParamPolicyClient.java @@ -62,16 +62,13 @@ public class BrmsParamPolicyClient { // Set description of the policy(Optional) policyParameters.setPolicyDescription("This is a sample BRMS Param policy creation example"); - //Set Scope folder where the policy needs to be created(Mandatory) - //policyParameters.setPolicyScope("Lakshman"); - // Set BRMS Param Template Attributes(Mandatory) - Map ruleAttributes = new HashMap(); + Map ruleAttributes = new HashMap<>(); ruleAttributes.put("templateName", "Sample"); // This sampleTemplate is the Template name from dictionary. ruleAttributes.put("controller", "default"); // Set Rule to a PDP Controller, default is the controller name. ruleAttributes.put("SamPoll", "300"); // Template specific key and value set by us. ruleAttributes.put("value", "abcd"); // Template specific key and value set by us. - Map> attributes = new HashMap>(); + Map> attributes = new HashMap<>(); attributes.put(AttributeType.RULE, ruleAttributes); policyParameters.setAttributes(attributes); diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/BrmsRawPolicyClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/BrmsRawPolicyClient.java index 478b7e96a..c144e1989 100644 --- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/BrmsRawPolicyClient.java +++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/BrmsRawPolicyClient.java @@ -66,10 +66,10 @@ public class BrmsRawPolicyClient { try { PolicyEngine policyEngine = new PolicyEngine("config.properties"); PolicyParameters policyParameters = new PolicyParameters(); - Map attrib= new HashMap(); + Map attrib= new HashMap<>(); attrib.put("cpu","80"); attrib.put("memory", "50"); - Map> attributes = new HashMap>(); + Map> attributes = new HashMap<>(); attributes.put(AttributeType.RULE, attrib); // Set Policy Type diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ConfigBasePolicyClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ConfigBasePolicyClient.java index dcaaaf188..a3903806c 100644 --- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ConfigBasePolicyClient.java +++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ConfigBasePolicyClient.java @@ -50,12 +50,12 @@ public class ConfigBasePolicyClient{ //policyParameters.setPolicyScope("MikeConsole"); //Directory will be created where the Policies are saved... this displays a a subscope on the GUI //Set the Config Attributes... These are Optional - Map configAttributes = new HashMap(); + Map configAttributes = new HashMap<>(); configAttributes.put("Template", "SampleTemplate"); configAttributes.put("controller", "default"); configAttributes.put("SamPoll", "30"); configAttributes.put("value", "abcd"); - Map> attributes = new HashMap>(); + Map> attributes = new HashMap<>(); attributes.put(AttributeType.MATCHING, configAttributes); policyParameters.setAttributes(attributes); policyParameters.setRequestID(UUID.randomUUID()); diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/DecisionPolicyClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/DecisionPolicyClient.java index 6b0b02eee..428a2ca03 100644 --- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/DecisionPolicyClient.java +++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/DecisionPolicyClient.java @@ -47,27 +47,27 @@ public class DecisionPolicyClient { //policyParameters.setPolicyScope("MikeAPItests"); //Directory will be created where the Policies are saved... this displays a a subscope on the GUI //Set the Component Attributes... These are Optional - Map configAttributes = new HashMap(); + Map configAttributes = new HashMap<>(); configAttributes.put("Template", "UpdateTemplate"); configAttributes.put("controller", "default"); configAttributes.put("SamPoll", "30"); configAttributes.put("value", "abcd"); - Map> attributes = new HashMap>(); + Map> attributes = new HashMap<>(); attributes.put(AttributeType.MATCHING, configAttributes); //Set the settings... These are Optional - Map settingsMap = new HashMap(); + Map settingsMap = new HashMap<>(); settingsMap.put("server", "5"); attributes.put(AttributeType.SETTINGS, settingsMap); policyParameters.setAttributes(attributes); - List dynamicRuleAlgorithmLabels = new LinkedList(); - List dynamicRuleAlgorithmFunctions = new LinkedList(); - List dynamicRuleAlgorithmField1 = new LinkedList(); - List dynamicRuleAlgorithmField2 = new LinkedList(); + List dynamicRuleAlgorithmLabels = new LinkedList<>(); + List dynamicRuleAlgorithmFunctions = new LinkedList<>(); + List dynamicRuleAlgorithmField1 = new LinkedList<>(); + List dynamicRuleAlgorithmField2 = new LinkedList<>(); //Example of a complex Rule algorithm using the settings in the Field1 /* label field1 function field2 diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/GeneralTestClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/GeneralTestClient.java index 6ca340efe..4298e8167 100644 --- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/GeneralTestClient.java +++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/GeneralTestClient.java @@ -126,8 +126,8 @@ public class GeneralTestClient { for (Object jsonObject : jsonObjectArray) { totalTC++; totalTCforFile++; - ArrayList expectedResult = new ArrayList(); - ArrayList resultReceived = new ArrayList(); + ArrayList expectedResult = new ArrayList<>(); + ArrayList resultReceived = new ArrayList<>(); JSONObject testCase = (JSONObject) jsonObject; // get a String from the JSON object long id = (long) testCase.get("id"); @@ -155,7 +155,7 @@ public class GeneralTestClient { .get("ECOMPName"); String configName = (String) testCase .get("ConfigName"); - Map configAttributes = new HashMap(); + Map configAttributes = new HashMap<>(); configAttributes.put("key", "value"); JSONArray configAttributesJSON = (JSONArray) testCase .get("configAttributes"); @@ -191,7 +191,7 @@ public class GeneralTestClient { break; case "getAction": - Map eventAttributes = new HashMap(); + Map eventAttributes = new HashMap<>(); eventAttributes.put("Key", "Value"); JSONArray eventAttributesJSON = (JSONArray) testCase .get("eventAttributes"); @@ -228,7 +228,7 @@ public class GeneralTestClient { case "getDecision": eCOMPComponentName = (String) testCase .get("ECOMPName"); - Map decisionAttributes = new HashMap(); + Map decisionAttributes = new HashMap<>(); decisionAttributes.put("Key", "Value"); JSONArray decisionAttributesJSON = (JSONArray) testCase .get("decisionAttributes"); diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ListConfigPoliciesClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ListConfigPoliciesClient.java index b9fd15282..497ff84a1 100644 --- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ListConfigPoliciesClient.java +++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ListConfigPoliciesClient.java @@ -48,7 +48,7 @@ public class ListConfigPoliciesClient { parameters.setEcompName(".*"); parameters.setConfigName(".*"); - Map configAttributes = new HashMap(); + Map configAttributes = new HashMap<>(); configAttributes.put("java", "java"); configAttributes.put("peach", "Tar"); configAttributes.put("true", "false"); diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/MainClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/MainClient.java index eb6197041..d17f0c649 100644 --- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/MainClient.java +++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/MainClient.java @@ -53,15 +53,15 @@ public class MainClient { PolicyEngine policyEngine; try { policyEngine = new PolicyEngine("config.properties"); - Map configAttributes = new HashMap(); + Map configAttributes = new HashMap<>(); configAttributes.put("java", "java"); configAttributes.put("peach", "Tar"); configAttributes.put("true", "false"); configAttributes.put("small", "testPass"); - Map eventAttributes = new HashMap(); + Map eventAttributes = new HashMap<>(); eventAttributes.put("true", "true"); eventAttributes.put("cpu", "91"); - Map decisionAttributes = new HashMap(); + Map decisionAttributes = new HashMap<>(); decisionAttributes.put("Key", "Value"); // Config Example @@ -102,11 +102,11 @@ public class MainClient { try { System.in.read(); } catch (IOException e) { - // + System.err.println("Exception Occured"+e); } } catch (PolicyEngineException e1) { - e1.printStackTrace(); + System.err.println("Exception Occured"+e1); } } diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/PolicyEngineTestClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/PolicyEngineTestClient.java index ecdb1666f..a56145214 100644 --- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/PolicyEngineTestClient.java +++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/PolicyEngineTestClient.java @@ -71,7 +71,7 @@ public class PolicyEngineTestClient { public static ArrayList getConfig(PolicyEngine policyEngine, String eCOMPComponentName, String configName, Map configAttributes) { - ArrayList resultReceived = new ArrayList(); + ArrayList resultReceived = new ArrayList<>(); try { UUID requestID = UUID.randomUUID(); Collection policyConfigs; @@ -114,7 +114,7 @@ public class PolicyEngineTestClient { */ public static ArrayList getDecision(PolicyEngine policyEngine, String eCOMPComponentName, Map decisionAttributes) { - ArrayList resultReceived = new ArrayList(); + ArrayList resultReceived = new ArrayList<>(); // Decision example try { UUID requestID = UUID.randomUUID(); @@ -139,7 +139,7 @@ public class PolicyEngineTestClient { */ public static ArrayList getAction(PolicyEngine policyEngine, Map eventAttributes) { - ArrayList resultReceived = new ArrayList(); + ArrayList resultReceived = new ArrayList<>(); try { UUID requestID = UUID.randomUUID(); @SuppressWarnings("deprecation") -- cgit 1.2.3-korg