diff options
Diffstat (limited to 'appc-config')
2 files changed, 18 insertions, 18 deletions
diff --git a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/merge/MergeNode.java b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/merge/MergeNode.java index e8c530486..908965ca7 100644 --- a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/merge/MergeNode.java +++ b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/merge/MergeNode.java @@ -53,23 +53,23 @@ public class MergeNode implements SvcLogicJavaPlugin { responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : ""; String jsonData = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_JSON_DATA); if (StringUtils.isBlank(jsonData)) { - throw new ParameterMissingException("JSON Data is missing"); - } - - String templateData = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_DATA); - String templateFile = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_FILE); - - if (StringUtils.isBlank(templateData) && StringUtils.isBlank(templateFile)) { - throw new ParameterMissingException("Template data or Template file is missing"); - } - if (StringUtils.isBlank(templateData)) { - templateData = IOUtils.toString( - MergeNode.class.getClassLoader().getResourceAsStream(templateFile), "UTF-8"); + log.info("No JSON data to merge with template"); + } else { + String templateData = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_DATA); + String templateFile = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_FILE); + + if (StringUtils.isBlank(templateData) && StringUtils.isBlank(templateFile)) { + throw new ParameterMissingException("Template data or Template file is missing"); + } + if (StringUtils.isBlank(templateData)) { + templateData = IOUtils.toString( + MergeNode.class.getClassLoader().getResourceAsStream(templateFile), "UTF-8"); + } + + Map<String, String> dataMap = JSONTool.convertToProperties(jsonData); + log.info("Data Maps created :" + dataMap); + trySetContextAttribute(ctx, responsePrefix, templateData, dataMap); } - - Map<String, String> dataMap = JSONTool.convertToProperties(jsonData); - log.info("Data Maps created :" + dataMap); - trySetContextAttribute(ctx, responsePrefix, templateData, dataMap); ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS, ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS); log.info("Data Merge Successful :" + ctx); 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 85f53fb41..db923d552 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 @@ -69,9 +69,9 @@ public class TestMergeNode { Map<String, String> inParams = new HashMap<String, String>(); inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test"); SvcLogicContext ctx = new SvcLogicContext(); - expectedEx.expect(SvcLogicException.class); - expectedEx.expectMessage("JSON Data is missing"); mergeNode.mergeJsonDataOnTemplate(inParams, ctx); + assertEquals(ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS, + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS)); } @Test |