added test case to TestConvertNode.java 52/73652/3
authorSandeep J <sandeejh@in.ibm.com>
Tue, 27 Nov 2018 11:04:58 +0000 (16:34 +0530)
committerTakamune Cho <takamune.cho@att.com>
Wed, 28 Nov 2018 01:44:01 +0000 (01:44 +0000)
to increase code coverage

Issue-ID: APPC-1086
Change-Id: Ia5890e45849fad0a17753fe03c217a60777a8945
Signed-off-by: Sandeep J <sandeejh@in.ibm.com>
appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/convert/TestConvertNode.java

index b084ba3..c9cdad7 100644 (file)
@@ -6,7 +6,7 @@
  * ================================================================================
  * Copyright (C) 2017 Amdocs
  * =============================================================================
- * Modification Copyright (C) 2018 IBM.
+ * 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.
@@ -162,6 +162,29 @@ public class TestConvertNode {
 
     }
     
+    @Test(expected = SvcLogicException.class)
+    public void testunEscapeDataForInvalidDataType() throws Exception {
+        ConvertNode convertNode = new ConvertNode();
+        Map<String, String> inParams = new HashMap<String, String>();
+        SvcLogicContext ctx = new SvcLogicContext();
+        inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, "tmp");
+        inParams.put(ConfigGeneratorConstant.INPUT_PARAM_UNESCAPE_DATA, "//");
+        inParams.put(ConfigGeneratorConstant.INPUT_PARAM_DATA_TYPE, "TXT");
+        convertNode.escapeData(inParams, ctx);
+
+    }
+    
+    @Test(expected = SvcLogicException.class)
+    public void testunEscapeDataForEmptyDataType() throws Exception {
+        ConvertNode convertNode = new ConvertNode();
+        Map<String, String> inParams = new HashMap<String, String>();
+        SvcLogicContext ctx = new SvcLogicContext();
+        inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, "tmp");
+        inParams.put(ConfigGeneratorConstant.INPUT_PARAM_UNESCAPE_DATA, "//");
+        convertNode.escapeData(inParams, ctx);
+
+    }
+    
     @Test
     public void testEscapeDataForValidUnescapeDataString() throws Exception {
         SvcLogicContext ctx = new SvcLogicContext();
@@ -175,4 +198,32 @@ public class TestConvertNode {
         convertNode.escapeData(inParams, ctx);
         assertEquals(unescapeData, ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_ESCAPE_DATA));
     }
+  
+     @Test
+    public void testunEscapeDataForJsonDataType() throws Exception {
+        ConvertNode convertNode = new ConvertNode();
+        Map<String, String> inParams = new HashMap<String, String>();
+        SvcLogicContext ctx = new SvcLogicContext();
+        log.trace("Received unEscapeData call with params : " + inParams);
+        inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, "tmp");
+        inParams.put(ConfigGeneratorConstant.INPUT_PARAM_ESCAPE_DATA, "//");
+        inParams.put(ConfigGeneratorConstant.INPUT_PARAM_DATA_TYPE, "JSON");
+        convertNode.unEscapeData(inParams, ctx);
+        assertEquals(ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS,ctx.getAttribute("tmp." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS));
+
+    }
+    
+    @Test
+    public void testunEscapeDataForXmlDataType() throws Exception {
+        ConvertNode convertNode = new ConvertNode();
+        Map<String, String> inParams = new HashMap<String, String>();
+        SvcLogicContext ctx = new SvcLogicContext();
+        log.trace("Received unEscapeData call with params : " + inParams);
+        inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, "tmp");
+        inParams.put(ConfigGeneratorConstant.INPUT_PARAM_ESCAPE_DATA, "//");
+        inParams.put(ConfigGeneratorConstant.INPUT_PARAM_DATA_TYPE, "XML");
+        convertNode.unEscapeData(inParams, ctx);
+        assertEquals(ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS,ctx.getAttribute("tmp." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS));
+    }
+    
 }