From 0f47d062f99fcc67f0cc0f2b4ff13ded67a552f5 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 23 Nov 2018 16:44:36 +0530 Subject: added test cases to TestPropertyDefinitionNode to increase code coverage Issue-ID: APPC-1086 Change-Id: Ib2e6bcd3a479ed9c8335461ddbfe4e3fd36a7bab Signed-off-by: Sandeep J --- .../params/parser/TestPropertyDefinitionNode.java | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'appc-config/appc-config-params/provider/src') diff --git a/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/parser/TestPropertyDefinitionNode.java b/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/parser/TestPropertyDefinitionNode.java index 569fb9eb2..2a0999783 100644 --- a/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/parser/TestPropertyDefinitionNode.java +++ b/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/parser/TestPropertyDefinitionNode.java @@ -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 inParams = new HashMap(); + 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 inParams = new HashMap(); + 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 { -- cgit 1.2.3-korg