From 5db773715b158ab9194051e7a60c366f1114bc19 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Mon, 10 Sep 2018 01:59:39 +0530 Subject: 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 --- .../sdnc/config/audit/node/TestCompareNodeCli.java | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'appc-config/appc-config-audit/provider/src') 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); -- cgit 1.2.3-korg