diff options
Diffstat (limited to 'appc-outbound/appc-aai-client/provider')
2 files changed, 49 insertions, 3 deletions
diff --git a/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/node/AAIResourceNode.java b/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/node/AAIResourceNode.java index 073ca12f4..d15431cc7 100644 --- a/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/node/AAIResourceNode.java +++ b/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/node/AAIResourceNode.java @@ -311,7 +311,7 @@ public class AAIResourceNode implements SvcLogicJavaPlugin { } } - private void processCheckForVfModule(String vfModuleIdFromRequest, SvcLogicContext ctx, + public void processCheckForVfModule(String vfModuleIdFromRequest, SvcLogicContext ctx, String responsePrefix, int vnfcRefLen) throws ResourceNodeInternalException { log.info("processCheckForVfModule()::vfModuleId From Request"+vfModuleIdFromRequest+"-"+vnfcRefLen); @@ -500,7 +500,7 @@ public class AAIResourceNode implements SvcLogicJavaPlugin { } public void processForVfModuleModelInfo(AaiService aaiService, Map<String, String> inParams, SvcLogicContext ctx) { - log.info("processForVfModuleModelInfo()::Retrieving vf-module information :" + inParams.toString()); + log.info("processForVfModuleModelInfo()::Retrieving vf-module information :" + inParams); String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX); try { responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : ""; @@ -542,5 +542,25 @@ public class AAIResourceNode implements SvcLogicJavaPlugin { log.error("Failed in vfModuleInfo", e); } -} + } + + public void getFormattedValue(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException { + log.info("getFormattedValue()::Formatting values :" + inParams.toString()); + String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX); + try { + responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : ""; + String inputValue = inParams.get("inputParameter"); + if (StringUtils.isBlank(inputValue)) { + return; + } + String outputValue = StringUtils.replace(inputValue, "/", "_");//change / to _ + outputValue = StringUtils.replace(outputValue," ","");//remove space + ctx.setAttribute("template-model-id", outputValue); + } catch (Exception e) { + ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS, + AppcAaiClientConstant.OUTPUT_STATUS_FAILURE); + ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage()); + log.error("Failed in getFormattedValue", e); + } + } } diff --git a/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/node/TestAAIResourceNode.java b/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/node/TestAAIResourceNode.java index e509a3403..f82370f1f 100644 --- a/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/node/TestAAIResourceNode.java +++ b/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/node/TestAAIResourceNode.java @@ -285,4 +285,30 @@ Map<String, String> inParams =new HashMap<String, String>(); assertEquals(ctx.getAttribute("test.vm.vnfc.vnfc-function-code"), "vnfcFuncCode2"); assertEquals(ctx.getAttribute("test.vm.vnfc.vnfc-group-notation"), "vnfcGrpNot2"); } + + @Test + public final void testGetFormattedValue() throws Exception{ + MockAAIResourceNode aairn = new MockAAIResourceNode(); + SvcLogicContext ctx = new SvcLogicContext(); + Map<String,String> inParams = new HashMap<String, String>(); + inParams.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX, "test"); + inParams.put("inputParameter", "Some/Value/With/ Many Spaces"); + aairn.getFormattedValue(inParams, ctx); + assertEquals(ctx.getAttribute("template-model-id"),"Some_Value_With_ManySpaces"); + + } + + @Test + public final void testProcessCheckForVfModule() throws Exception{ + MockAAIResourceNode aairn = new MockAAIResourceNode(); + SvcLogicContext ctx = new SvcLogicContext(); + Map<String,String> inParams = new HashMap<String, String>(); + inParams.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX, "test"); + inParams.put("inputParameter", "Some/Value/With/ Many Spaces"); + ctx.setAttribute("test.vnf.vm-with-no-vnfcs-count-vf-module", "0"); + ctx.setAttribute("test.vnf.vm-count-for-vf-module", "2"); + aairn.processCheckForVfModule("vfmoduleId1", ctx, "test.", 2); + + + } } |