diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2018-08-13 17:20:21 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-08-13 17:20:21 +0000 |
commit | 5368a1d66dce2a1029e947a43e8ccdcfad98fbc8 (patch) | |
tree | 6b9824f65696a21cbbe9bfdf9b02e5064c36f665 /ONAP-XACML/src | |
parent | a54ec0fce0cb5032d373e811d830cdd027b0dd9c (diff) | |
parent | 84223fab05c1493df05db20016a83687bdaee975 (diff) |
Merge "Modify std pap policy to use builder in constr"
Diffstat (limited to 'ONAP-XACML/src')
3 files changed, 190 insertions, 68 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..435e3c347 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. @@ -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.dyanamicFieldConfigAttributes = stdPAPPolicyParams.getDyanamicFieldConfigAttributes(); + this.dynamicSettingsMap = stdPAPPolicyParams.getDynamicSettingsMap(); this.configType = stdPAPPolicyParams.getConfigType(); this.configBodyData = stdPAPPolicyParams.getConfigBodyData(); this.editPolicy = stdPAPPolicyParams.getEditPolicy(); @@ -120,55 +128,16 @@ 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; + 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(); } //convenience constructor 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..0e183e08a 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> dyanamicFieldConfigAttributes; private String configType; private String configBodyData; private Boolean editPolicy; @@ -38,7 +42,22 @@ 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; + + /** + * Default constructor + */ private StdPAPPolicyParams() { super(); } @@ -71,8 +90,8 @@ public class StdPAPPolicyParams { return configName; } - public Map<String, String> getAttributes() { - return attributes; + public Map<String, String> getDyanamicFieldConfigAttributes() { + return dyanamicFieldConfigAttributes; } public String getConfigType() { @@ -107,6 +126,57 @@ 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; + } + + /** + * Builder class for the Policy parameters + */ public static class StdPAPPolicyParamsBuilder { StdPAPPolicyParams m = new StdPAPPolicyParams(); @@ -140,8 +210,8 @@ public class StdPAPPolicyParams { return this; } - public StdPAPPolicyParamsBuilder attributes(Map<String, String> attributes) { - m.attributes = attributes; + public StdPAPPolicyParamsBuilder dyanamicFieldConfigAttributes(Map<String, String> attributes) { + m.dyanamicFieldConfigAttributes = attributes; return this; } @@ -189,5 +259,65 @@ 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; + } } } 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..4a9370c41 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 @@ -586,7 +586,7 @@ public class StdPAPPolicyTest { .description("description") .onapName("onapName") .configName("configName") - .attributes(attributes) + .dyanamicFieldConfigAttributes(attributes) .configType("configType") .configBodyData("body") .editPolicy(true) @@ -624,10 +624,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") + .dyanamicFieldConfigAttributes(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 +672,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") + .dyanamicFieldConfigAttributes(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()); |