aboutsummaryrefslogtreecommitdiffstats
path: root/appc-config/appc-config-generator/provider/src/test
diff options
context:
space:
mode:
authorSandeep J <sandeejh@in.ibm.com>2018-11-23 17:13:23 +0530
committerTakamune Cho <takamune.cho@att.com>2018-11-29 01:19:32 +0000
commitaf8f1395f7d6a87b413d1445f145ea2ec149d3eb (patch)
tree60f8dfcd06fd7b1f9b8f0d4d1b87478b2d6031ad /appc-config/appc-config-generator/provider/src/test
parent975556b8704e5ea2e3e509e2e2081774d17af48e (diff)
added test cases to TestMergeNode.java
to increase code coverage Issue-ID: APPC-1086 Change-Id: I7113c096993247135d54dcb9b686f1006907ca33 Signed-off-by: Sandeep J <sandeejh@in.ibm.com>
Diffstat (limited to 'appc-config/appc-config-generator/provider/src/test')
-rw-r--r--appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/merge/TestMergeNode.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/merge/TestMergeNode.java b/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/merge/TestMergeNode.java
index e56b29be4..a51c603ff 100644
--- a/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/merge/TestMergeNode.java
+++ b/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/merge/TestMergeNode.java
@@ -31,11 +31,18 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.sdnc.config.generator.ConfigGeneratorConstant;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+@RunWith(PowerMockRunner.class)
public class TestMergeNode {
@Test(expected = Exception.class)
@@ -55,8 +62,41 @@ public class TestMergeNode {
ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS);
}
+
+ @Test(expected = Exception.class)
+ public void testMergeJsonDataOnTemplateForEmptyParamData() throws Exception {
+ MergeNode mergeNode = new MergeNode();
+ Map<String, String> inParams = new HashMap<String, String>();
+ inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test");
+ String templateData = IOUtils.toString(TestMergeNode.class.getClassLoader()
+ .getResourceAsStream("merge/vdbe_template.xml"));
+ inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_DATA, templateData);
+ SvcLogicContext ctx = new SvcLogicContext();
+ expectedEx.expect(SvcLogicException.class);
+ expectedEx.expectMessage("Param Data is missing..");
+ mergeNode.mergeJsonDataOnTemplate(inParams, ctx);
+
+ }
+
+ @Rule
+ public ExpectedException expectedEx = ExpectedException.none();
@Test(expected = Exception.class)
+ public void testMergeJsonDataOnTemplateForEmptyTemplateData() throws Exception {
+ MergeNode mergeNode = new MergeNode();
+ Map<String, String> inParams = new HashMap<String, String>();
+ inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test");
+ String jsonData = IOUtils.toString(
+ TestMergeNode.class.getClassLoader().getResourceAsStream("merge/vdbe_data.json"));
+ inParams.put(ConfigGeneratorConstant.INPUT_PARAM_JSON_DATA, jsonData);
+ SvcLogicContext ctx = new SvcLogicContext();
+ expectedEx.expect(SvcLogicException.class);
+ expectedEx.expectMessage("Template data or Template file is missing");
+ mergeNode.mergeJsonDataOnTemplate(inParams, ctx);
+ }
+
+
+ @Test(expected = Exception.class)
public void testMergeComplexJsonDataOnTemplate() throws Exception {
MergeNode mergeNode = new MergeNode();
Map<String, String> inParams = new HashMap<String, String>();