added test case to TestPropertyDefinitionNode.java 45/58945/3
authorSandeep J <sandeejh@in.ibm.com>
Fri, 3 Aug 2018 13:41:30 +0000 (19:11 +0530)
committerTakamune Cho <tc012c@att.com>
Fri, 3 Aug 2018 20:57:11 +0000 (20:57 +0000)
to increase code coverage

Issue-ID: APPC-1086
Change-Id: I74760fd2d97c4ef429e5f9d6f6eff0297ccec17e
Signed-off-by: Sandeep J <sandeejh@in.ibm.com>
appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/parser/TestPropertyDefinitionNode.java

index 40cc00c..dbadef8 100644 (file)
@@ -6,7 +6,7 @@
  * ================================================================================
  * Copyright (C) 2017 Amdocs
  * =============================================================================
- * Modifications Copyright (C) 2018 IBM
+ * Modification 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.
 
 package org.onap.sdnc.config.params.parser;
 
-
-
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
 import java.nio.charset.Charset;
 import java.util.HashMap;
 import java.util.Map;
@@ -37,6 +37,7 @@ import org.apache.commons.lang.StringUtils;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
 import org.onap.sdnc.config.params.ParamsHandlerConstant;
 import org.onap.sdnc.config.params.data.PropertyDefinition;
 import org.onap.sdnc.config.params.transformer.ArtificatTransformer;
@@ -116,6 +117,22 @@ public class TestPropertyDefinitionNode {
         assertEquals(ctx.getAttribute("test." + ParamsHandlerConstant.OUTPUT_PARAM_STATUS),
                 ParamsHandlerConstant.OUTPUT_STATUS_SUCCESS);
     }
+    
+    @Test
+    public void mergeJsonDataForEmptyParams() throws SvcLogicException, IOException {
+        
+        PropertyDefinitionNode propertyDefinitionNode = new PropertyDefinitionNode();
+        Map<String, String> inParams = new HashMap<String, String>();
+        inParams.put(ParamsHandlerConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test");
+        String mergeJsonData = IOUtils.toString(TestPropertyDefinitionNode.class.getClassLoader()
+                .getResourceAsStream("parser/merge-param.json"), Charset.defaultCharset());
+        inParams.put(ParamsHandlerConstant.INPUT_PARAM_MERGE__JSON_DATA, mergeJsonData);
+        SvcLogicContext ctx = new SvcLogicContext();
+        propertyDefinitionNode.mergeJsonData(inParams, ctx);
+        String status= ctx.getAttribute("test.status");
+        assertEquals(ParamsHandlerConstant.OUTPUT_STATUS_SUCCESS,status);
+                
+    }
 
     @Test
     public void testArtificatTransformer() throws Exception {