added test cases to TestPropertyDefinitionNode 15/73415/5
authorSandeep J <sandeejh@in.ibm.com>
Fri, 23 Nov 2018 11:14:36 +0000 (16:44 +0530)
committerTakamune Cho <takamune.cho@att.com>
Thu, 29 Nov 2018 01:24:42 +0000 (01:24 +0000)
to increase code coverage

Issue-ID: APPC-1086
Change-Id: Ib2e6bcd3a479ed9c8335461ddbfe4e3fd36a7bab
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 569fb9e..2a09997 100644 (file)
@@ -36,7 +36,9 @@ import java.util.Map;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
 import org.onap.sdnc.config.params.ParamsHandlerConstant;
@@ -116,6 +118,50 @@ public class TestPropertyDefinitionNode {
         assertEquals(ctx.getAttribute("test." + ParamsHandlerConstant.OUTPUT_PARAM_STATUS),
                 ParamsHandlerConstant.OUTPUT_STATUS_SUCCESS);
     }
+    
+    @Test
+    public void testProcessExternalSystemParamKeysForEmptyParamData() throws Exception {
+        Map<String, String> inParams = new HashMap<String, String>();
+        inParams.put(ParamsHandlerConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test");
+
+        String yamlData = IOUtils.toString(
+                TestPropertyDefinitionNode.class.getClassLoader().getResourceAsStream("parser/pd.yaml"),
+                Charset.defaultCharset());
+        inParams.put(ParamsHandlerConstant.INPUT_PARAM_PD_CONTENT, yamlData);
+        inParams.put(ParamsHandlerConstant.INPUT_PARAM_SYSTEM_NAME, "SOURCE");
+
+        SvcLogicContext ctx = new SvcLogicContext();
+        propertyDefinitionNode.processExternalSystemParamKeys(inParams, ctx);
+        assertEquals(ctx.getAttribute("test." + ParamsHandlerConstant.OUTPUT_PARAM_STATUS),
+                ParamsHandlerConstant.OUTPUT_STATUS_SUCCESS);
+
+      
+    }
+
+    @Rule
+    public ExpectedException expectedEx = ExpectedException.none();
+
+    @Test
+    public void testProcessExternalSystemParamKeysForEmptySystemName() throws Exception {
+        Map<String, String> inParams = new HashMap<String, String>();
+        inParams.put(ParamsHandlerConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test");
+
+        String yamlData = IOUtils.toString(
+                TestPropertyDefinitionNode.class.getClassLoader().getResourceAsStream("parser/pd.yaml"),
+                Charset.defaultCharset());
+        inParams.put(ParamsHandlerConstant.INPUT_PARAM_PD_CONTENT, yamlData);
+
+        String jsonData = IOUtils.toString(
+                TestPropertyDefinitionNode.class.getClassLoader().getResourceAsStream("parser/request-param.json"),
+                Charset.defaultCharset());
+        inParams.put(ParamsHandlerConstant.INPUT_PARAM_JSON_DATA, jsonData);
+
+        SvcLogicContext ctx = new SvcLogicContext();
+        expectedEx.expect(SvcLogicException.class);
+        expectedEx.expectMessage("Request Param (systemName) is Missing ..");
+        propertyDefinitionNode.processExternalSystemParamKeys(inParams, ctx);
+
+    }
 
     @Test(expected = SvcLogicException.class)
     public void testProcessExternalSystemParamKeysForEmptyPdContent() throws Exception {