diff options
Diffstat (limited to 'ONAP-XACML/src')
3 files changed, 421 insertions, 307 deletions
diff --git a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java index 264b2b784..74ded6d43 100644 --- a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java +++ b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java @@ -3,6 +3,7 @@ * ONAP-XACML * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +36,7 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { private String policyDescription = null; private String onapName = null; private String configName = null; - private Map<String, String> dyanamicFieldConfigAttributes = new HashMap<>(); + private Map<String, String> dynamicFieldConfigAttributes = new HashMap<>(); private Map<String, String> treatments = new HashMap<>(); private Map<String, String> dropDownMap = new HashMap<>(); private Map<String, String> dynamicSettingsMap = new HashMap<>(); @@ -101,16 +102,23 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { this.configPolicyType = configPolicyType; } - //Constructor for Create Config Policies from API and Admin Console - //Constructor for Updating Config Policies from the API - //convenience constructor + /** + * Constructor for + * Create Config Policies from API and Admin Console + * Updating Config Policies from the API + * Create/Update Action Policies from API + * Create/Update Decision Policies + * @param stdPAPPolicyParams Input params object + */ public StdPAPPolicy(StdPAPPolicyParams stdPAPPolicyParams) { this.configPolicyType=stdPAPPolicyParams.getConfigPolicyType(); this.policyName = stdPAPPolicyParams.getPolicyName(); this.policyDescription = stdPAPPolicyParams.getDescription(); this.onapName = stdPAPPolicyParams.getOnapName(); + this.providerComboBox = stdPAPPolicyParams.getProviderComboBox(); this.configName = stdPAPPolicyParams.getConfigName(); - this.dyanamicFieldConfigAttributes = stdPAPPolicyParams.getAttributes(); + this.dynamicFieldConfigAttributes = stdPAPPolicyParams.getDynamicFieldConfigAttributes(); + this.dynamicSettingsMap = stdPAPPolicyParams.getDynamicSettingsMap(); this.configType = stdPAPPolicyParams.getConfigType(); this.configBodyData = stdPAPPolicyParams.getConfigBodyData(); this.editPolicy = stdPAPPolicyParams.getEditPolicy(); @@ -120,162 +128,29 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { this.riskType = stdPAPPolicyParams.getRiskType(); this.guard = stdPAPPolicyParams.getGuard(); this.ttlDate = stdPAPPolicyParams.getTtlDate(); - } - - //Constructor for Create/Update Action Policies from API - public StdPAPPolicy(String policyName, String description, Map<String, String> attributes, - List<String> dynamicRuleAlgorithmLabels, List<String> dynamicRuleAlgorithmCombo, - List<String> dynamicRuleAlgorithmField1, List<String> dynamicRuleAlgorithmField2, - String actionPerformer, String actionAttribute, Boolean editPolicy, - String domain, int highestVersion) { - - this.policyName = policyName; - this.policyDescription = description; - this.dyanamicFieldConfigAttributes = attributes; - this.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels; - this.dynamicRuleAlgorithmCombo = dynamicRuleAlgorithmCombo; - this.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1; - this.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2; - this.actionPerformer = actionPerformer; - this.actionAttribute = actionAttribute; - this.editPolicy = editPolicy; - this.domain = domain; - this.highestVersion = highestVersion; - - } - - //Constructor for Create/Update Decision Policies - public StdPAPPolicy(String policyName, String description, String onapName, String providerComboBox, - Map<String, String> attributes, Map<String, String> settings, Map<String, String> treatments, - List<String> dynamicRuleAlgorithmLabels, List<String> dynamicRuleAlgorithmCombo, - List<String> dynamicRuleAlgorithmField1, - List<String> dynamicRuleAlgorithmField2, Map<String, String> dropDownMap, - List<Object> dynamicVariableList, - List<String> dataTypeList, Boolean editPolicy, String domain, int highestVersion) { - this.policyName = policyName; - this.policyDescription = description; - this.onapName = onapName; - this.setProviderComboBox(providerComboBox); - this.dyanamicFieldConfigAttributes = attributes; - this.dynamicSettingsMap = settings; - this.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels; - this.dynamicRuleAlgorithmCombo = dynamicRuleAlgorithmCombo; - this.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1; - this.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2; - this.dynamicVariableList = dynamicVariableList; - this.dataTypeList = dataTypeList; - this.dropDownMap = dropDownMap; - this.editPolicy = editPolicy; - this.domain = domain; - this.highestVersion = highestVersion; - this.treatments = treatments; - } - - //convenience constructor - public StdPAPPolicy(String configPolicyType, String policyName, String description, String onapName, - String configName, Map<String, String> attributes, String body, String policyID, - String ruleID, String configType, Boolean editPolicy, String version, String domain, - String riskLevel, String riskType, String guard, String ttlDate) { - this(configPolicyType, policyName, description, onapName, configName, attributes, body, policyID, - ruleID, configType, editPolicy, version, domain, 1, riskLevel, riskType, guard, ttlDate); - } - - //Constructor for Updating Config Policies from Admin Console - public StdPAPPolicy(String configPolicyType, String policyName, String description, String onapName, - String configName, Map<String, String> attributes, String body, String policyID, - String ruleID, String configType, Boolean editPolicy, String version, String domain, - int highestVersion, String riskLevel, String riskType, String guard, String ttlDate) { - - this.configPolicyType = configPolicyType; - this.policyName = policyName; - this.policyDescription = description; - this.onapName = onapName; - this.configName = configName; - this.dyanamicFieldConfigAttributes = attributes; - this.configBodyData = body; - this.policyID = policyID; - this.ruleID = ruleID; - this.configType = configType; - this.editPolicy = editPolicy; - this.version = version; - this.domain = domain; - this.highestVersion = highestVersion; - this.riskLevel = riskLevel; - this.riskType = riskType; - this.guard = guard; - this.ttlDate = ttlDate; - } - - - //Constructor for Creating Config Firewall Policies - public StdPAPPolicy(String configPolicyType, String policyName, String description, String configName, - Boolean editPolicy, String domain, String jsonBody, Integer highestVersion, String riskLevel, - String riskType, String guard, String ttlDate) { - - this.configPolicyType = configPolicyType; - this.policyName = policyName; - this.policyDescription = description; - this.configName = configName; - this.editPolicy = editPolicy; - this.domain = domain; - this.jsonBody = jsonBody; - this.highestVersion = highestVersion; - this.riskLevel = riskLevel; - this.riskType = riskType; - this.guard = guard; - this.ttlDate = ttlDate; - - } - - //Constructor for Creating Goc Policies - public StdPAPPolicy(String configPolicyType, String policyName, String description, String configName, - Boolean editPolicy, String domain, String jsonBody, Integer highestVersion, String eCompName, - String riskLevel, String riskType, String guard, String ttlDate) { - - this.configPolicyType = configPolicyType; - this.policyName = policyName; - this.policyDescription = description; - this.configName = configName; - this.editPolicy = editPolicy; - this.domain = domain; - this.jsonBody = jsonBody; - this.highestVersion = highestVersion; - this.onapName = eCompName; - this.riskLevel = riskLevel; - this.riskType = riskType; - this.guard = guard; - this.ttlDate = ttlDate; - } - - //Constructor for Creating BRMS Policies from the Admin Console - public StdPAPPolicy(String configPolicyType, String policyName, String description, - String configName, Boolean editPolicy, String domain, - Map<String, String> dyanamicFieldConfigAttributes, Integer highestVersion, String eCompName, - String configBodyData, String riskLevel, String riskType, String guard, String ttlDate, - String brmsController, List<String> brmsDependency) { - - this.configPolicyType = configPolicyType; - this.policyName = policyName; - this.policyDescription = description; - this.configName = configName; - this.editPolicy = editPolicy; - this.domain = domain; - this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes; - this.highestVersion = highestVersion; - this.onapName = eCompName; - this.configBodyData = configBodyData; - this.riskLevel = riskLevel; - this.riskType = riskType; - this.guard = guard; - this.ttlDate = ttlDate; - this.brmsController = brmsController; - this.brmsDependency = brmsDependency; + this.dynamicRuleAlgorithmLabels = stdPAPPolicyParams.getDynamicRuleAlgorithmLabels(); + this.dynamicRuleAlgorithmCombo = stdPAPPolicyParams.getDynamicRuleAlgorithmCombo(); + this.dynamicRuleAlgorithmField1 = stdPAPPolicyParams.getDynamicRuleAlgorithmField1(); + this.dynamicRuleAlgorithmField2 = stdPAPPolicyParams.getDynamicRuleAlgorithmField2(); + this.dynamicVariableList = stdPAPPolicyParams.getDynamicVariableList(); + this.dataTypeList = stdPAPPolicyParams.getDataTypeList(); + this.dropDownMap = stdPAPPolicyParams.getDropDownMap(); + this.actionPerformer = stdPAPPolicyParams.getActionPerformer(); + this.actionAttribute = stdPAPPolicyParams.getActionAttribute(); + this.treatments = stdPAPPolicyParams.getTreatments(); + this.policyID = stdPAPPolicyParams.getPolicyID(); + this.ruleID = stdPAPPolicyParams.getRuleID(); + this.version = stdPAPPolicyParams.getVersion(); + this.jsonBody = stdPAPPolicyParams.getJsonBody(); + this.brmsController = stdPAPPolicyParams.getBrmsController(); + this.brmsDependency = stdPAPPolicyParams.getBrmsDependency(); + this.drlRuleAndUIParams = stdPAPPolicyParams.getDrlRuleAndUIParams(); } //Constructor for Creating BRMS Param Policies from the Admin Console public StdPAPPolicy(String configPolicyType, String policyName, String description, String configName, Boolean editPolicy, String domain, - Map<String, String> dyanamicFieldConfigAttributes, Integer highestVersion, String eCompName, + Map<String, String> dynamicFieldConfigAttributes, Integer highestVersion, String eCompName, String configBodyData, Map<String, String> drlRuleAndUIParams, String riskLevel, String riskType, String guard, String ttlDate, String brmsController, List<String> brmsDependency) { @@ -286,7 +161,7 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { this.configName = configName; this.editPolicy = editPolicy; this.domain = domain; - this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes; + this.dynamicFieldConfigAttributes = dynamicFieldConfigAttributes; this.highestVersion = highestVersion; this.onapName = eCompName; this.configBodyData = configBodyData; @@ -323,29 +198,6 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { this.ttlDate = ttlDate; } - //Constructor for Updating Config Firewall Policies from the Admin Console - public StdPAPPolicy(String configPolicyType, String policyName, String description, String configName, - Boolean editPolicy, String domain, String policyID, - String ruleID, String version, String jsonBody, Integer highestVersion, String riskLevel, - String riskType, String guard, String ttlDate) { - - this.configPolicyType = configPolicyType; - this.policyName = policyName; - this.policyDescription = description; - this.configName = configName; - this.editPolicy = editPolicy; - this.domain = domain; - this.policyID = policyID; - this.ruleID = ruleID; - this.version = version; - this.jsonBody = jsonBody; - this.highestVersion = highestVersion; - this.riskLevel = riskLevel; - this.riskType = riskType; - this.guard = guard; - this.ttlDate = ttlDate; - } - //Constructor for Micro Service Creating/Updating Policies from the Admin Console public StdPAPPolicy(String configPolicyType, String policyName, String description, String onapName, String configName, String serviceType, String uuid, @@ -373,84 +225,6 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { this.ttlDate = ttlDate; } - //Constructor for Updating Goc Policies from the Admin Console - public StdPAPPolicy(String configPolicyType, String policyName, String description, - String configName, Boolean editPolicy, String domain, - String policyID, String ruleID, String version, - String jsonBody, Integer highestVersion, String eCompName, String riskLevel, String riskType, - String guard, String ttlDate) { - - this.configPolicyType = configPolicyType; - this.policyName = policyName; - this.policyDescription = description; - this.configName = configName; - this.editPolicy = editPolicy; - this.domain = domain; - this.policyID = policyID; - this.ruleID = ruleID; - this.version = version; - this.jsonBody = jsonBody; - this.highestVersion = highestVersion; - this.onapName = eCompName; - this.riskLevel = riskLevel; - this.riskType = riskType; - this.guard = guard; - this.ttlDate = ttlDate; - } - - //Constructor for Updating Brms Policies from the Admin Console - public StdPAPPolicy(String configPolicyType, String policyName, String description, - String configName, Boolean editPolicy, String domain, - String policyID, String ruleID, String version, - Map<String, String> dyanamicFieldConfigAttributes, Integer highestVersion, String eCompName, - String configBodyData, String riskLevel, String riskType, String guard, String ttlDate - ) { - this.configPolicyType = configPolicyType; - this.policyName = policyName; - this.policyDescription = description; - this.configName = configName; - this.editPolicy = editPolicy; - this.domain = domain; - this.policyID = policyID; - this.ruleID = ruleID; - this.version = version; - this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes; - this.highestVersion = highestVersion; - this.onapName = eCompName; - this.configBodyData = configBodyData; - this.riskLevel = riskLevel; - this.riskType = riskType; - this.guard = guard; - this.ttlDate = ttlDate; - } - - //Constructor for Updating Brms Param Policies from the Admin Console - public StdPAPPolicy(String configPolicyType, String policyName, String description, - String configName, Boolean editPolicy, String domain, - String policyID, String ruleID, String version, - Map<String, String> dyanamicFieldConfigAttributes, Integer highestVersion, String eCompName, - Map<String, String> drlRuleAndUIParams, String riskLevel, String riskType, String guard, - String ttlDate - ) { - this.configPolicyType = configPolicyType; - this.policyName = policyName; - this.policyDescription = description; - this.configName = configName; - this.editPolicy = editPolicy; - this.domain = domain; - this.policyID = policyID; - this.ruleID = ruleID; - this.version = version; - this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes; - this.highestVersion = highestVersion; - this.onapName = eCompName; - this.drlRuleAndUIParams = drlRuleAndUIParams; - this.riskLevel = riskLevel; - this.riskType = riskType; - this.guard = guard; - this.ttlDate = ttlDate; - } - // Constructor for deleting policies from the API public StdPAPPolicy(String policyName, String deleteCondition) { this.policyName = policyName; @@ -486,7 +260,7 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { @Override public Map<String, String> getDynamicFieldConfigAttributes() { - return dyanamicFieldConfigAttributes; + return dynamicFieldConfigAttributes; } @Override @@ -697,8 +471,8 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { @Override public String toString() { return "StdPAPPolicy [policyName=" + policyName + ", policyDescription=" + policyDescription + ", onapName=" - + onapName + ", configName=" + configName + ", dyanamicFieldConfigAttributes=" + - dyanamicFieldConfigAttributes + ", configBodyData=" + configBodyData + + onapName + ", configName=" + configName + ", dynamicFieldConfigAttributes=" + + dynamicFieldConfigAttributes + ", configBodyData=" + configBodyData + ", policyID=" + policyID + ", ruleID=" + ruleID + ", configType=" + configType + ", editPolicy=" + ", version=" + ", domain=" + domain + ", configPolicyType=" + configPolicyType + ", jsonBody=" + jsonBody + ", highestVersion=" + @@ -741,9 +515,9 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { this.configName = configName; } - public void setDyanamicFieldConfigAttributes( - Map<String, String> dyanamicFieldConfigAttributes) { - this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes; + public void setDynamicFieldConfigAttributes( + Map<String, String> dynamicFieldConfigAttributes) { + this.dynamicFieldConfigAttributes = dynamicFieldConfigAttributes; } public void setConfigBodyData(String configBodyData) { diff --git a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java index a9daa9e97..7eb422b99 100644 --- a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java +++ b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java @@ -20,15 +20,19 @@ package org.onap.policy.xacml.std.pap; +import java.util.List; import java.util.Map; +/** + * Std PAP Policy paramters class. + */ public class StdPAPPolicyParams { private String configPolicyType; private String policyName; private String description; private String onapName; private String configName; - private Map<String, String> attributes; + private Map<String, String> dynamicFieldConfigAttributes; private String configType; private String configBodyData; private Boolean editPolicy; @@ -38,7 +42,29 @@ public class StdPAPPolicyParams { private String guard; private String ttlDate; private int highestVersion; - + private List<String> dynamicRuleAlgorithmLabels; + private List<String> dynamicRuleAlgorithmCombo; + private List<String> dynamicRuleAlgorithmField1; + private List<String> dynamicRuleAlgorithmField2; + private String actionPerformer; + private String actionAttribute; + private String providerComboBox; + private Map<String, String> dynamicSettingsMap; + private List<Object> dynamicVariableList; + private List<String> dataTypeList; + private Map<String, String> dropDownMap; + private Map<String,String> treatments; + private String policyID; + private String ruleID; + private String version; + private String jsonBody; + private String brmsController; + private List<String> brmsDependency; + private Map<String,String> drlRuleAndUIParams; + + /** + * Default constructor + */ private StdPAPPolicyParams() { super(); } @@ -71,8 +97,8 @@ public class StdPAPPolicyParams { return configName; } - public Map<String, String> getAttributes() { - return attributes; + public Map<String, String> getDynamicFieldConfigAttributes() { + return dynamicFieldConfigAttributes; } public String getConfigType() { @@ -107,6 +133,85 @@ public class StdPAPPolicyParams { return ttlDate; } + public List<String> getDynamicRuleAlgorithmLabels() { + return dynamicRuleAlgorithmLabels; + } + + public List<String> getDynamicRuleAlgorithmCombo() { + return dynamicRuleAlgorithmCombo; + } + + public List<String> getDynamicRuleAlgorithmField1() { + return dynamicRuleAlgorithmField1; + } + + public List<String> getDynamicRuleAlgorithmField2() { + return dynamicRuleAlgorithmField2; + } + + public String getActionPerformer() { + return actionPerformer; + } + + public String getActionAttribute() { + return actionAttribute; + } + + public String getProviderComboBox() { + return providerComboBox; + } + + public Map<String,String> getDynamicSettingsMap() { + return dynamicSettingsMap; + } + + public List<Object> getDynamicVariableList() { + return dynamicVariableList; + } + + public List<String> getDataTypeList() { + return dataTypeList; + } + + public Map<String,String> getDropDownMap() { + return dropDownMap; + } + + public Map<String,String> getTreatments() { + return treatments; + } + + public String getPolicyID() { + return policyID; + } + + public String getRuleID() { + return ruleID; + } + + public String getVersion() { + return version; + } + + public String getJsonBody() { + return jsonBody; + } + + public String getBrmsController() { + return brmsController; + } + + public List<String> getBrmsDependency() { + return brmsDependency; + } + + public Map<String,String> getDrlRuleAndUIParams() { + return drlRuleAndUIParams; + } + + /** + * Builder class for the Policy parameters + */ public static class StdPAPPolicyParamsBuilder { StdPAPPolicyParams m = new StdPAPPolicyParams(); @@ -140,8 +245,8 @@ public class StdPAPPolicyParams { return this; } - public StdPAPPolicyParamsBuilder attributes(Map<String, String> attributes) { - m.attributes = attributes; + public StdPAPPolicyParamsBuilder dynamicFieldConfigAttributes(Map<String, String> attributes) { + m.dynamicFieldConfigAttributes = attributes; return this; } @@ -189,5 +294,100 @@ public class StdPAPPolicyParams { m.highestVersion = highVer; return this; } + + public StdPAPPolicyParamsBuilder dynamicRuleAlgorithmLabels(List<String> dynamicRuleAlgorithmLabels) { + m.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels; + return this; + } + + public StdPAPPolicyParamsBuilder dynamicRuleAlgorithmCombo(List<String> dynamicRuleAlgorithmCombo) { + m.dynamicRuleAlgorithmCombo = dynamicRuleAlgorithmCombo; + return this; + } + + public StdPAPPolicyParamsBuilder dynamicRuleAlgorithmField1(List<String> dynamicRuleAlgorithmField1) { + m.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1; + return this; + } + + public StdPAPPolicyParamsBuilder dynamicRuleAlgorithmField2(List<String> dynamicRuleAlgorithmField2) { + m.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2; + return this; + } + + public StdPAPPolicyParamsBuilder actionPerformer(String actionPerformer) { + m.actionPerformer = actionPerformer; + return this; + } + + public StdPAPPolicyParamsBuilder actionAttribute(String actionAttribute) { + m.actionAttribute = actionAttribute; + return this; + } + + public StdPAPPolicyParamsBuilder providerComboBox(String providerComboBox) { + m.providerComboBox = providerComboBox; + return this; + } + + public StdPAPPolicyParamsBuilder dynamicVariableList(List<Object> dynamicVariableList) { + m.dynamicVariableList = dynamicVariableList; + return this; + } + + public StdPAPPolicyParamsBuilder dynamicSettingsMap(Map<String, String> dynamicSettingsMap) { + m.dynamicSettingsMap = dynamicSettingsMap; + return this; + } + + public StdPAPPolicyParamsBuilder dataTypeList(List<String> dataTypeList) { + m.dataTypeList = dataTypeList; + return this; + } + + public StdPAPPolicyParamsBuilder dropDownMap(Map<String, String> dropDownMap){ + m.dropDownMap = dropDownMap; + return this; + } + + public StdPAPPolicyParamsBuilder treatments(Map<String,String> treatments) { + m.treatments = treatments; + return this; + } + + public StdPAPPolicyParamsBuilder policyID(String policyID) { + m.policyID = policyID; + return this; + } + + public StdPAPPolicyParamsBuilder ruleID(String ruleID) { + m.ruleID = ruleID; + return this; + } + + public StdPAPPolicyParamsBuilder version(String version) { + m.version = version; + return this; + } + + public StdPAPPolicyParamsBuilder jsonBody(String jsonBody) { + m.jsonBody = jsonBody; + return this; + } + + public StdPAPPolicyParamsBuilder brmsController(String controllerName) { + m.brmsController = controllerName; + return this; + } + + public StdPAPPolicyParamsBuilder brmsDependency(List<String> dependencyNames) { + m.brmsDependency = dependencyNames; + return this; + } + + public StdPAPPolicyParamsBuilder drlRuleAndUIParams(Map<String,String> drlRuleAndUIParams) { + m.drlRuleAndUIParams = drlRuleAndUIParams; + return this; + } } } diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPAPPolicyTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPAPPolicyTest.java index aa57c27f0..2de4a0456 100644 --- a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPAPPolicyTest.java +++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPAPPolicyTest.java @@ -3,6 +3,7 @@ * ONAP-XACML * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -586,7 +587,7 @@ public class StdPAPPolicyTest { .description("description") .onapName("onapName") .configName("configName") - .attributes(attributes) + .dynamicFieldConfigAttributes(attributes) .configType("configType") .configBodyData("body") .editPolicy(true) @@ -624,10 +625,18 @@ public class StdPAPPolicyTest { dynamicRuleAlgorithmField1.add("dynamicRuleAlgorithmField1"); List<String> dynamicRuleAlgorithmField2 = new ArrayList<>(); dynamicRuleAlgorithmField2.add("dynamicRuleAlgorithmField2"); - StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("policyName", "description", attributes, - dynamicRuleAlgorithmLabels, dynamicRuleAlgorithmCombo, dynamicRuleAlgorithmField1, - dynamicRuleAlgorithmField2, - "actionPerformer", "actionAttribute", true, "domain", 1); + StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder().policyName("policyName").description("description") + .dynamicFieldConfigAttributes(attributes) + .dynamicRuleAlgorithmLabels(dynamicRuleAlgorithmLabels) + .dynamicRuleAlgorithmCombo(dynamicRuleAlgorithmCombo) + .dynamicRuleAlgorithmField1(dynamicRuleAlgorithmField1) + .dynamicRuleAlgorithmField2(dynamicRuleAlgorithmField2) + .actionPerformer("actionPerformer") + .actionAttribute("actionAttribute") + .editPolicy(true) + .domain("domain") + .highestVersion(1) + .build()); assertEquals("policyName", stdPAPPolicy.getPolicyName()); assertEquals("description", stdPAPPolicy.getPolicyDescription()); assertEquals(attributes, stdPAPPolicy.getDynamicFieldConfigAttributes()); @@ -664,10 +673,25 @@ public class StdPAPPolicyTest { dynamicVariableList.add("dynamicVariableList"); List<String> dataTypeList = new ArrayList<>(); dataTypeList.add("dataTypeList"); - StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("policyName", "description", "onapName", "providerComboBox", - attributes, settings, treatments, dynamicRuleAlgorithmLabels, dynamicRuleAlgorithmCombo, - dynamicRuleAlgorithmField1, dynamicRuleAlgorithmField2, dropDownMap, dynamicVariableList, - dataTypeList, true, "domain", 1); + StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() + .policyName("policyName") + .description("description") + .onapName("onapName") + .providerComboBox("providerComboBox") + .dynamicFieldConfigAttributes(attributes) + .dynamicSettingsMap(settings) + .treatments(treatments) + .dynamicRuleAlgorithmLabels(dynamicRuleAlgorithmLabels) + .dynamicRuleAlgorithmCombo(dynamicRuleAlgorithmCombo) + .dynamicRuleAlgorithmField1(dynamicRuleAlgorithmField1) + .dynamicRuleAlgorithmField2(dynamicRuleAlgorithmField2) + .dropDownMap(dropDownMap) + .dynamicVariableList(dynamicVariableList) + .dataTypeList(dataTypeList) + .editPolicy(true) + .domain("domain") + .highestVersion(1) + .build()); assertEquals("policyName", stdPAPPolicy.getPolicyName()); assertEquals("description", stdPAPPolicy.getPolicyDescription()); assertEquals("onapName", stdPAPPolicy.getOnapName()); @@ -692,10 +716,26 @@ public class StdPAPPolicyTest { throws URISyntaxException { Map<String, String> attributes = new HashMap<>(); attributes.put("aKey", "aValue"); - StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("configTypePolicy", "policyName", "description", "onapName", - "configName", attributes, - "body", "policyId", "ruleId", "configType", true, "version", "domain", 1, "riskLevel", "riskType", - "guard", "ttlDate"); + StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() + .configPolicyType("configTypePolicy") + .policyName("policyName") + .description("description") + .onapName("onapName") + .configName("configName") + .dynamicFieldConfigAttributes(attributes) + .configBodyData("body") + .policyID("policyId") + .ruleID("ruleId") + .configType("configType") + .editPolicy(true) + .version("version") + .domain("domain") + .highestVersion(1) + .riskLevel("riskLevel") + .riskType("riskType") + .guard("guard") + .ttlDate("ttlDate") + .build()); assertEquals("configTypePolicy", stdPAPPolicy.getConfigPolicyType()); assertEquals("policyName", stdPAPPolicy.getPolicyName()); assertEquals("description", stdPAPPolicy.getPolicyDescription()); @@ -719,9 +759,20 @@ public class StdPAPPolicyTest { @Test public void testConstructorStringStringStringStringBooleanStringStringIntegerStringStringStringString() throws URISyntaxException { - StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("configTypePolicy", "policyName", "description", "configName", - true, - "domain", "jasonBody", 1, "riskLevel", "riskType", "guard", "ttlDate"); + StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() + .configPolicyType("configTypePolicy") + .policyName("policyName") + .description("description") + .configName("configName") + .editPolicy(true) + .domain("domain") + .jsonBody("jasonBody") + .highestVersion(1) + .riskLevel("riskLevel") + .riskType("riskType") + .guard("guard") + .ttlDate("ttlDate") + .build()); assertEquals("configTypePolicy", stdPAPPolicy.getConfigPolicyType()); assertEquals("policyName", stdPAPPolicy.getPolicyName()); assertEquals("description", stdPAPPolicy.getPolicyDescription()); @@ -739,9 +790,21 @@ public class StdPAPPolicyTest { @Test public void testConstructorStringStringStringStringBooleanStringStringIntegerStringStringStringStringString() throws URISyntaxException { - StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("configTypePolicy", "policyName", "description", "configName", - true, - "domain", "jasonBody", 1, "eCompName", "riskLevel", "riskType", "guard", "ttlDate"); + StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() + .configPolicyType("configTypePolicy") + .policyName("policyName") + .description("description") + .configName("configName") + .editPolicy(true) + .domain("domain") + .jsonBody("jasonBody") + .highestVersion(1) + .onapName("eCompName") + .riskLevel("riskLevel") + .riskType("riskType") + .guard("guard") + .ttlDate("ttlDate") + .build()); assertEquals("configTypePolicy", stdPAPPolicy.getConfigPolicyType()); assertEquals("policyName", stdPAPPolicy.getPolicyName()); assertEquals("description", stdPAPPolicy.getPolicyDescription()); @@ -764,10 +827,24 @@ public class StdPAPPolicyTest { dyanamicFieldConfigAttributes.put("aKey", "aValue"); ArrayList<String> brmsDependency = new ArrayList<>(); brmsDependency.add("brmsDependency"); - StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("configTypePolicy", "policyName", "description", "configName", - true, - "domain", dyanamicFieldConfigAttributes, 1, "eCompName", "configBodyData", "riskLevel", "riskType", - "guard", "ttlDate", "brmsController", brmsDependency); + StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() + .configPolicyType("configTypePolicy") + .policyName("policyName") + .description("description") + .configName("configName") + .editPolicy(true) + .domain("domain") + .dynamicFieldConfigAttributes(dyanamicFieldConfigAttributes) + .highestVersion(1) + .onapName("eCompName") + .configBodyData("configBodyData") + .riskLevel("riskLevel") + .riskType("riskType") + .guard("guard") + .ttlDate("ttlDate") + .brmsController("brmsController") + .brmsDependency(brmsDependency) + .build()); assertEquals("configTypePolicy", stdPAPPolicy.getConfigPolicyType()); assertEquals("policyName", stdPAPPolicy.getPolicyName()); assertEquals("description", stdPAPPolicy.getPolicyDescription()); @@ -844,9 +921,24 @@ public class StdPAPPolicyTest { @Test public void testConstructorStringStringStringStringBooleanStringStringStringStringStringIntegerStringStringStringString() throws URISyntaxException { - StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("configTypePolicy", "policyName", "description", "configName", - true, "domain", "policyId", "ruleId", - "version", "jasonBody", 1, "riskLevel", "riskType", "guard", "ttlDate"); + //test for Updating Config Firewall Policies from the Admin Console + StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() + .configPolicyType("configTypePolicy") + .policyName("policyName") + .description("description") + .configName("configName") + .editPolicy(true) + .domain("domain") + .policyID("policyId") + .ruleID("ruleId") + .version("version") + .jsonBody("jasonBody") + .highestVersion(1) + .riskLevel("riskLevel") + .riskType("riskType") + .guard("guard") + .ttlDate("ttlDate") + .build()); assertEquals("configTypePolicy", stdPAPPolicy.getConfigPolicyType()); assertEquals("policyName", stdPAPPolicy.getPolicyName()); assertEquals("description", stdPAPPolicy.getPolicyDescription()); @@ -894,9 +986,25 @@ public class StdPAPPolicyTest { @Test public void testConstructorStringStringStringStringBooleanStringStringStringStringStringIntegerStringStringStringStringString() throws URISyntaxException { - StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("configTypePolicy", "policyName", "description", "configName", - true, "domain", "policyId", "ruleId", "version", - "jasonBody", 1, "ecompName", "riskLevel", "riskType", "guard", "ttlDate"); + //test for Updating Goc Policies from the Admin Console + StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() + .configPolicyType("configTypePolicy") + .policyName("policyName") + .description("description") + .configName("configName") + .editPolicy(true) + .domain("domain") + .policyID("policyId") + .ruleID("ruleId") + .version("version") + .jsonBody("jasonBody") + .highestVersion(1) + .onapName("ecompName") + .riskLevel("riskLevel") + .riskType("riskType") + .guard("guard") + .ttlDate("ttlDate") + .build()); assertEquals("configTypePolicy", stdPAPPolicy.getConfigPolicyType()); assertEquals("policyName", stdPAPPolicy.getPolicyName()); assertEquals("description", stdPAPPolicy.getPolicyDescription()); @@ -918,12 +1026,28 @@ public class StdPAPPolicyTest { @Test public void testConstructorStringStringStringStringBooleanStringStringStringStringMapStringStringIntegerStringStringStringStringString() throws URISyntaxException { + //for Updating Brms Policies from the Admin Console Map<String, String> dyanamicFieldConfigAttributes = new HashMap<>(); dyanamicFieldConfigAttributes.put("aKey", "aValue"); - StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("configTypePolicy", "policyName", "description", "configName", - true, - "domain", "policyId", "ruleId", "version", dyanamicFieldConfigAttributes, 1, "eCompName", - "configBodyData", "riskLevel", "riskType", "guard", "ttlDate"); + StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() + .configPolicyType("configTypePolicy") + .policyName("policyName") + .description("description") + .configName("configName") + .editPolicy(true) + .domain("domain") + .policyID("policyId") + .ruleID("ruleId") + .version("version") + .dynamicFieldConfigAttributes(dyanamicFieldConfigAttributes) + .highestVersion(1) + .onapName("eCompName") + .configBodyData("configBodyData") + .riskLevel("riskLevel") + .riskType("riskType") + .guard("guard") + .ttlDate("ttlDate") + .build()); assertEquals("configTypePolicy", stdPAPPolicy.getConfigPolicyType()); assertEquals("policyName", stdPAPPolicy.getPolicyName()); assertEquals("description", stdPAPPolicy.getPolicyDescription()); @@ -946,14 +1070,30 @@ public class StdPAPPolicyTest { @Test public void testConstructorStringStringStringStringBooleanStringStringStringStringMapStringStringIntegerStringMapStringStringStringStringStringString() throws URISyntaxException { + //for Updating Brms Param Policies from the Admin Console Map<String, String> dyanamicFieldConfigAttributes = new HashMap<>(); dyanamicFieldConfigAttributes.put("aKey", "aValue"); Map<String, String> drlRuleAndUIParams = new HashMap<>(); drlRuleAndUIParams.put("aDrlRuleKey", "aDrlRuleValue"); - StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("configTypePolicy", "policyName", "description", "configName", - true, - "domain", "policyId", "ruleId", "version", dyanamicFieldConfigAttributes, 1, "eCompName", - drlRuleAndUIParams, "riskLevel", "riskType", "guard", "ttlDate"); + StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() + .configPolicyType("configTypePolicy") + .policyName("policyName") + .description("description") + .configName("configName") + .editPolicy(true) + .domain("domain") + .policyID("policyId") + .ruleID("ruleId") + .version("version") + .dynamicFieldConfigAttributes(dyanamicFieldConfigAttributes) + .highestVersion(1) + .onapName("eCompName") + .drlRuleAndUIParams(drlRuleAndUIParams) + .riskLevel("riskLevel") + .riskType("riskType") + .guard("guard") + .ttlDate("ttlDate") + .build()); assertEquals("configTypePolicy", stdPAPPolicy.getConfigPolicyType()); assertEquals("policyName", stdPAPPolicy.getPolicyName()); assertEquals("description", stdPAPPolicy.getPolicyDescription()); |