From 91a12713611ef604a5e301315ad0896e829cd6c0 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Mon, 10 Sep 2018 02:08:25 +0530 Subject: refactored code for TestCompareNodeJson added object creation to setup method using before annotation Issue-ID: APPC-1086 Change-Id: I136191ab61d7b39751ccffa63a711d9ef14add7d Signed-off-by: Sandeep J --- .../config/audit/node/TestCompareNodeJson.java | 32 ++++++++++------------ 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeJson.java b/appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeJson.java index 2cb1976a5..8ebe3b538 100644 --- a/appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeJson.java +++ b/appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeJson.java @@ -24,9 +24,10 @@ */ 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 org.onap.ccsdk.sli.core.sli.SvcLogicException; public class TestCompareNodeJson { private static final Logger log = LoggerFactory.getLogger(TestCompareNodeJson.class); - + private CompareNode cmp; + private SvcLogicContext ctx; + private HashMap testMap; + + @Before + public void setUp() + { + cmp = new CompareNode(); + ctx = new SvcLogicContext(); + testMap = new HashMap(); + + } + @Test public void TestCompareJsonForSamePayload() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - HashMap testMap = new HashMap(); - CompareNode cmp = new CompareNode(); String controlJson = "{\n\"input\": {\n \"appc-request-header\": {\n \"svc-request-id\": \"000000000\", \n \"svc-action\": \"prepare\" \n }, \n\"request-information\": {\n \"request-id\": \"000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\", \n \"source\": \"Version2\" \n} \n} \n}"; String testJson = "{\n\"input\": {\n \"appc-request-header\": {\n \"svc-request-id\": \"000000000\", \n \"svc-action\": \"prepare\" \n }, \n\"request-information\": {\n \"request-id\": \"000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\", \n \"source\": \"Version2\" \n} \n} \n}"; testMap.put("compareDataType", "RestConf"); @@ -55,18 +65,12 @@ public class TestCompareNodeJson { @Test public void TestCompareCliForNoPayload() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - HashMap testMap = new HashMap(); - CompareNode cmp = new CompareNode(); cmp.compare(testMap, ctx); assertEquals ("FAILURE",ctx.getAttribute("STATUS")); } @Test public void TestCompareCliForNullCompareType() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - HashMap testMap = new HashMap(); - CompareNode cmp = new CompareNode(); testMap.put("compareDataType", "RestConf"); cmp.compare(testMap, ctx); assertEquals ("FAILURE",ctx.getAttribute("STATUS")); @@ -74,9 +78,6 @@ public class TestCompareNodeJson { @Test public void TestCompareJsonFordifferentPayload() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - HashMap testMap = new HashMap(); - CompareNode cmp = new CompareNode(); String controlJson = "{\n\"input\": {\n \"appc-request-header\": {\n \"svc-request-id\": \"000000000\", \n \"svc-action\": \"prepare\" \n }, \n\"request-information\": {\n \"request-id\": \"000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\", \n \"source\": \"Version2\" \n} \n} \n}"; String testJson = "{\n\"input\": {\n \"appc-request-header\": { \n \"svc-action\": \"prepare\" \n }, \n\"request-information\": {\n \"request-id\": \"0000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\", \n \"source\": \"Version2\" \n} \n} \n}"; testMap.put("compareDataType", "RestConf"); @@ -88,9 +89,6 @@ public class TestCompareNodeJson { @Test public void TestCompareJsonFordifferentPayloadWithXMLDataType() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - HashMap testMap = new HashMap(); - CompareNode cmp = new CompareNode(); String controlJson = "{\n\"input\": {\n \"appc-request-header\": {\n \"svc-request-id\": \"000000000\", \n \"svc-action\": \"prepare\" \n }, \n\"request-information\": {\n \"request-id\": \"000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\", \n \"source\": \"Version2\" \n} \n} \n}"; String testJson = "{\n\"input\": {\n \"appc-request-header\": { \n \"svc-action\": \"prepare\" \n }, \n\"request-information\": {\n \"request-id\": \"0000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\", \n \"source\": \"Version2\" \n} \n} \n}"; testMap.put("compareDataType", "XML"); -- cgit 1.2.3-korg