diff options
author | Krishnajinka <kris.jinka@samsung.com> | 2018-08-14 14:09:59 +0900 |
---|---|---|
committer | Krishnajinka <kris.jinka@samsung.com> | 2018-08-14 14:25:18 +0900 |
commit | 343df73f2b2dd2a39d090244c091371edbd2127f (patch) | |
tree | d137c2e083d22abf54272209632df622c20b450f /ONAP-PAP-REST/src/test | |
parent | 5368a1d66dce2a1029e947a43e8ccdcfad98fbc8 (diff) |
Optimize PAP policy constructor with builder
Fix sonar issue about constructor using more than 7 params.
Use builder parameters object for setting the attributes of
std pap policy.Recommit1
Issue-ID: POLICY-1016
Change-Id: Id9631a42813960baa78df4ab0c0f6706244c3180
Signed-off-by: Krishnajinka <kris.jinka@samsung.com>
Diffstat (limited to 'ONAP-PAP-REST/src/test')
-rw-r--r-- | ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java index ab4f2a00f..bb14ff866 100644 --- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java +++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java @@ -182,8 +182,20 @@ public class XACMLPAPTest { Mockito.when(httpServletRequest.getParameter("operation")).thenReturn("create"); Mockito.when(httpServletRequest.getParameter("policyType")).thenReturn("Config"); StdPAPPolicy newPAPPolicy = - new StdPAPPolicy("Firewall Config", "test", "testDescription", "Test", false, "test", json, 0, - "5", "default", "false", ""); + new StdPAPPolicy(StdPAPPolicyParams.builder() + .configPolicyType("Firewall Config") + .policyName("test") + .description("testDescription") + .configName("Test") + .editPolicy(false) + .domain("test") + .jsonBody(json) + .highestVersion(0) + .riskLevel("5") + .riskType("default") + .guard("false") + .ttlDate("") + .build()); MockServletInputStream mockInput = new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes()); Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput); @@ -239,10 +251,21 @@ public class XACMLPAPTest { Mockito.when(httpServletRequest.getParameter("policyType")).thenReturn("Config"); Map<String, String> ruleAttributes = new HashMap<>(); ruleAttributes.put("value", "test"); - StdPAPPolicy newPAPPolicy = new StdPAPPolicy("BRMS_Raw", "test", "testig description", - "BRMS_RAW_RULE", false, "test", ruleAttributes, 0, "DROOLS", - "test", "4", - "default", "false", null, null, null); + StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() + .configPolicyType("BRMS_Raw") + .policyName("test") + .description("testig description") + .configName("BRMS_RAW_RULE") + .editPolicy(false) + .domain("test") + .dynamicFieldConfigAttributes(ruleAttributes) + .highestVersion(0) + .onapName("DROOLS") + .configBodyData("test") + .riskLevel("4") + .riskType("default") + .guard("false") + .build()); MockServletInputStream mockInput = new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes()); Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput); @@ -338,7 +361,7 @@ public class XACMLPAPTest { .description("test rule") .onapName("PDPD") .providerComboBox("GUARD_YAML") - .dyanamicFieldConfigAttributes(matchingAttributes) + .dynamicFieldConfigAttributes(matchingAttributes) .editPolicy(false) .domain("test") .highestVersion(0) @@ -377,7 +400,7 @@ public class XACMLPAPTest { .description("test rule") .onapName("PDPD") .providerComboBox("GUARD_BL_YAML") - .dyanamicFieldConfigAttributes(matchingAttributes) + .dynamicFieldConfigAttributes(matchingAttributes) .editPolicy(false) .domain("test") .highestVersion(0) @@ -411,7 +434,7 @@ public class XACMLPAPTest { .description("test rule") .onapName("TEST") .configName("config") - .dyanamicFieldConfigAttributes(configAttributes) + .dynamicFieldConfigAttributes(configAttributes) .configType("OTHER") .configBodyData("test body") .editPolicy(false) |