refactored code for TestCompareNodeXml 09/65409/4
authorSandeep J <sandeejh@in.ibm.com>
Sun, 9 Sep 2018 20:45:32 +0000 (02:15 +0530)
committerTakamune Cho <tc012c@att.com>
Tue, 11 Sep 2018 15:04:02 +0000 (15:04 +0000)
added object creation to setup method using before annotation

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

index 7ea9381..808706e 100644 (file)
@@ -6,6 +6,8 @@
  * ================================================================================
  * Copyright (C) 2017 Amdocs
  * =============================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -25,23 +27,31 @@ package org.onap.sdnc.config.audit.node;
 
 import java.io.IOException;
 import java.util.HashMap;
-import org.junit.Test;
-import org.onap.sdnc.config.audit.node.CompareNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
+import org.junit.Before;
+import org.junit.Test;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class TestCompareNodeXml {
     private static final Logger log = LoggerFactory.getLogger(TestCompareNodeXml.class);
-
+    private CompareNode cmp ;
+    private HashMap<String, String> testMap;
+    private SvcLogicContext ctx;
+    
+    @Before
+    public void setUp()
+    {
+        cmp = new CompareNode();
+        ctx = new SvcLogicContext();
+        testMap = new HashMap<String, String>();
+    }
+    
     @Test
     public void TestCompareExtactXML() throws SvcLogicException {
         log.debug("TestCompareNode.TestCompareExtactXML()");
-        SvcLogicContext ctx = new SvcLogicContext();
-        HashMap<String, String> testMap = new HashMap<String, String>();
-        CompareNode cmp = new CompareNode();
         String s = "<configuration xmlns=\"http://xml.juniper.net/xnm/1.1/xnm\" junos:commit-seconds=\"1502141521\" junos:commit-localtime=\"2017-08-07 21:32:03 UTC\" junos:commit-user=\"root\"> </configuration>";
         String t = "<configuration xmlns=\"http://xml.juniper.net/xnm/1.1/xnm\"  junos:commit-localtime=\"2017-08-07 21:12:03 UTC\" junos:commit-seconds=\"15021523\" junos:commit-user=\"root\"> </configuration>";
         testMap.put("compareDataType", "RESTCONF-XML");
@@ -55,9 +65,6 @@ public class TestCompareNodeXml {
     @Test
     public void TestCompareforAttributeOrder() throws IOException, SvcLogicException {
         log.debug("TestCompareNode.TestCompareforAttributeOrder()");
-        SvcLogicContext ctx = new SvcLogicContext();
-        HashMap<String, String> testMap = new HashMap<String, String>();
-        CompareNode cmp = new CompareNode();
         testMap.put("compareDataType", "XML");
         testMap.put("sourceData",
                 "<SipIfTermination><id>2</id><udpPortInUse>true</udpPortInUse><udpPort>5060</udpPort><tcpPortInUse>true</tcpPortInUse><tcpPort>5060</tcpPort></SipIfTermination>");
@@ -70,9 +77,6 @@ public class TestCompareNodeXml {
     @Test
     public void TestCompareForComments() throws SvcLogicException {
         log.debug("TestCompareNode.TestCompareForComments()");
-        SvcLogicContext ctx = new SvcLogicContext();
-        HashMap<String, String> testMap = new HashMap<String, String>();
-        CompareNode cmp = new CompareNode();
         testMap.put("compareDataType", "XML");
         testMap.put("sourceData", "<SipIfTermination><id>2</id><!--this is a commnect --></SipIfTermination>");
         testMap.put("targetData", "<SipIfTermination><id>2</id></SipIfTermination>");