From: Sandeep J Date: Sun, 9 Sep 2018 20:29:39 +0000 (+0530) Subject: refactored code for TestCompareNodeCli X-Git-Tag: 1.4.0~23 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F05%2F65405%2F4;p=appc.git refactored code for TestCompareNodeCli added object creation to setup method using before annotation Issue-ID: APPC-1086 Change-Id: Ia125c53807d4f255686d4f2ff6af818c1b08ca4d Signed-off-by: Sandeep J --- diff --git a/appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeCli.java b/appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeCli.java index bd28ef7a3..1e8c4f8b2 100644 --- a/appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeCli.java +++ b/appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeCli.java @@ -27,6 +27,7 @@ package org.onap.sdnc.config.audit.node; import java.util.HashMap; +import org.junit.Before; import org.junit.Test; import org.onap.sdnc.config.audit.node.CompareNode; import org.slf4j.Logger; @@ -38,12 +39,21 @@ import static org.junit.Assert.assertEquals; public class TestCompareNodeCli { private static final Logger log = LoggerFactory.getLogger(TestCompareNodeCli.class); - + private CompareNode cmp; + SvcLogicContext ctx; + HashMap testMap; + + + @Before + public void setUp() + { + cmp = new CompareNode(); + ctx = new SvcLogicContext(); + testMap = new HashMap(); + } + @Test public void TestCompareCliForSamePayload() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - HashMap testMap = new HashMap(); - CompareNode cmp = new CompareNode(); testMap.put("compareDataType", "Cli"); testMap.put("sourceData", "This is a Text Configuration of Device"); testMap.put("targetData", "This is a Text Configuration of Device"); @@ -53,9 +63,6 @@ public class TestCompareNodeCli { @Test public void TestCompareCliForNoPayload() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - HashMap testMap = new HashMap(); - CompareNode cmp = new CompareNode(); testMap.put("compareDataType", "Cli"); cmp.compare(testMap, ctx); assertEquals ("FAILURE",ctx.getAttribute("STATUS")); @@ -63,9 +70,6 @@ public class TestCompareNodeCli { @Test public void TestCompareCliFordifferentPayload() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - HashMap testMap = new HashMap(); - CompareNode cmp = new CompareNode(); testMap.put("compareDataType", "Cli"); testMap.put("sourceData", "This is a Text Negative test Configuration of Device"); testMap.put("targetData", "This is a Text Configuration of Device"); @@ -75,9 +79,6 @@ public class TestCompareNodeCli { @Test public void TestCompareForMissingInput() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - HashMap testMap = new HashMap(); - CompareNode cmp = new CompareNode(); testMap.put("sourceData", "This is a Text Negative test Configuration of Device"); testMap.put("targetData.configuration-data", "This is a Text Configuration of Device"); cmp.compare(testMap, ctx);