From 343df73f2b2dd2a39d090244c091371edbd2127f Mon Sep 17 00:00:00 2001 From: Krishnajinka Date: Tue, 14 Aug 2018 14:09:59 +0900 Subject: 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 --- .../org/onap/policy/pap/test/XACMLPAPTest.java | 41 +++++++++++++++++----- 1 file changed, 32 insertions(+), 9 deletions(-) (limited to 'ONAP-PAP-REST/src/test/java') 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 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) -- cgit 1.2.3-korg