refactored code for TestCompareNodeCli 05/65405/4
authorSandeep J <sandeejh@in.ibm.com>
Sun, 9 Sep 2018 20:29:39 +0000 (01:59 +0530)
committerTakamune Cho <tc012c@att.com>
Tue, 11 Sep 2018 15:02:46 +0000 (15:02 +0000)
added object creation to setup method using before annotation

Issue-ID: APPC-1086
Change-Id: Ia125c53807d4f255686d4f2ff6af818c1b08ca4d
Signed-off-by: Sandeep J <sandeejh@in.ibm.com>
appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeCli.java

index bd28ef7..1e8c4f8 100644 (file)
@@ -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<String, String> testMap;
+        
+    
+    @Before
+    public void setUp()
+    {
+        cmp = new CompareNode();
+        ctx = new SvcLogicContext();
+        testMap = new HashMap<String, String>();
+    }
+    
     @Test
     public void TestCompareCliForSamePayload() throws SvcLogicException {
-        SvcLogicContext ctx = new SvcLogicContext();
-        HashMap<String, String> testMap = new HashMap<String, String>();
-        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<String, String> testMap = new HashMap<String, String>();
-        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<String, String> testMap = new HashMap<String, String>();
-        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<String, String> testMap = new HashMap<String, String>();
-        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);