diff options
author | Joss Armstrong <joss.armstrong@ericsson.com> | 2019-02-21 15:19:07 +0000 |
---|---|---|
committer | Takamune Cho <takamune.cho@att.com> | 2019-04-10 12:54:57 +0000 |
commit | c8c612b74cf3599d36b66db4ef33302b45f3ff54 (patch) | |
tree | 5b14b457d54cbe61f0e0618d756579b4c445ee49 /appc-config/appc-config-generator | |
parent | b45d4528f2c563cdff2e78837a4164deb4152283 (diff) |
Fix for Ansible Healthcheck bug
Update to directed graph and merge JSON template code
Issue-ID: APPC-1472
Change-Id: I4332ad74d34f455261b1c001339d0542be4514fc
Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
Diffstat (limited to 'appc-config/appc-config-generator')
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 |