aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
authorBrittany Plummer (bp896r) <bp896r@att.com>2018-11-06 09:51:10 -0500
committerBrittany Plummer (bp896r) <bp896r@att.com>2018-11-06 09:51:10 -0500
commitce37ae979311ed4e55150426d477db262773beb0 (patch)
tree4ff30e2fdc71a1a80c84ffed774d55491efaa559 /bpmn/so-bpmn-tasks
parent5d660cbc1a5028f52d63185ab7db0b1b465a981b (diff)
Removed slashes and added catch block
Issue-ID: SO-1183 Change-Id: Ib8581393d782f078fc844cf96cbf7a0228133581 Signed-off-by: Brittany Plummer (bp896r) <bp896r@att.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java10
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java36
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientResponseIncorrectPath.json29
3 files changed, 65 insertions, 10 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java
index d13c5db871..58dd5a1df6 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java
@@ -95,10 +95,13 @@ public class ConfigurationScaleOut {
for (Map.Entry<String,String> entry : param.entrySet()) {
key = entry.getKey();
paramValue = entry.getValue();
- configScaleOutParam = JsonPath.parse(sdncVfModuleQueryResponse).read(paramValue);
- if(configScaleOutParam != null){
- paramsMap.put(key, configScaleOutParam);
+ try{
+ configScaleOutParam = JsonPath.parse(sdncVfModuleQueryResponse).read(paramValue);
+ }catch(ClassCastException e){
+ configScaleOutParam = null;
+ msoLogger.warnSimple("Incorrect JSON path. Path points to object rather than value causing: ", e);
}
+ paramsMap.put(key, configScaleOutParam);
}
}
}
@@ -107,7 +110,6 @@ public class ConfigurationScaleOut {
configPayload.setConfigurationParameters(paramsMap);
configPayload.setRequestParameters(requestParameters);
configScaleOutPayloadString = mapper.writeValueAsString(configPayload);
- configScaleOutPayloadString = configScaleOutPayloadString.replaceAll("\"", "\\\\\"");
execution.setVariable(ACTION, actionCategory);
execution.setVariable(MSO_REQUEST_ID, gBBInput.getRequestContext().getMsoRequestId());
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java
index dabdc6811c..8577de2537 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java
@@ -79,9 +79,9 @@ public class ConfigurationScaleOutTest extends BaseTaskTest {
controllerSelectionReference.setActionCategory("testAction");
controllerSelectionReference.setVnfType("testVnfType");
String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientGetResponse.json")));
- String expectedPayload = "{\\\"request-parameters\\\":{\\\"vnf-host-ip-address\\\":\\\"10.222.22.2\\\","
- + "\\\"vf-module-id\\\":\\\"testVfModuleId1\\\"},\\\"configuration-parameters\\\""
- + ":{\\\"vnf-id\\\":\\\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\\\",\\\"availability-zone\\\":\\\"AZ-MN02\\\"}}";
+ String expectedPayload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
+ + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
+ + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":\"AZ-MN02\"}}";
execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncResponse);
doReturn(controllerSelectionReference).when(catalogDbClient).getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(), Action.ConfigScaleOut.toString());
@@ -101,9 +101,9 @@ public class ConfigurationScaleOutTest extends BaseTaskTest {
Action action = Action.ConfigScaleOut;
String vnfId = genericVnf.getVnfId();
String controllerType = "testType";
- String payload = "{\\\"request-parameters\\\":{\\\"vnf-host-ip-address\\\":\\\"10.222.22.2\\\","
- + "\\\"vf-module-id\\\":\\\"testVfModuleId1\\\"},\\\"configuration-parameters\\\""
- + ":{\\\"vnf-id\\\":\\\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\\\",\\\"availability-zone\\\":\\\"AZ-MN02\\\"}}";
+ String payload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
+ + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
+ + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":\"AZ-MN02\"}}";
HashMap<String, String> payloadInfo = new HashMap<String, String>();
payloadInfo.put("vnfName", "testVnfName");
payloadInfo.put("vfModuleId", "testVfModuleId");
@@ -121,5 +121,29 @@ public class ConfigurationScaleOutTest extends BaseTaskTest {
configurationScaleOut.callAppcClient(execution);
verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
}
+ @Test
+ public void setParamsForConfigurationScaleOutBadPathTest() throws Exception {
+ ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
+ controllerSelectionReference.setControllerName("testName");
+ controllerSelectionReference.setActionCategory("testAction");
+ controllerSelectionReference.setVnfType("testVnfType");
+ String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientResponseIncorrectPath.json")));
+ String expectedPayload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
+ + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
+ + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":null}}";
+ execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncResponse);
+
+ doReturn(controllerSelectionReference).when(catalogDbClient).getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(), Action.ConfigScaleOut.toString());
+
+ configurationScaleOut.setParamsForConfigurationScaleOut(execution);
+
+ assertEquals(genericVnf.getVnfId(), execution.getVariable("vnfId"));
+ assertEquals(genericVnf.getVnfName(), execution.getVariable("vnfName"));
+ assertEquals("ConfigScaleOut", execution.getVariable("action"));
+ assertEquals(requestContext.getMsoRequestId(), execution.getVariable("msoRequestId"));
+ assertEquals(controllerSelectionReference.getControllerName(), execution.getVariable("controllerType"));
+ assertEquals(vfModule.getVfModuleId(), execution.getVariable("vfModuleId"));
+ assertEquals(expectedPayload, execution.getVariable("payload"));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientResponseIncorrectPath.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientResponseIncorrectPath.json
new file mode 100644
index 0000000000..7e263b4465
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientResponseIncorrectPath.json
@@ -0,0 +1,29 @@
+{
+ "vnf-topology": {
+ "tenant": "0422ffb57ba042c0800a29dc85ca70f8",
+ "vnf-topology-identifier-structure": {
+ "vnf-id": "66dac89b-2a5b-4cb9-b22e-a7e4488fb3db",
+ "vnf-type": "InfraMSO_vSAMP10a_Service/InfraMSO_vSAMP10a-2 0",
+ "vnf-name": "MSO-DEV-VNF-1806HF1-InfraMSO_vSAMP10a-1XXX-GR_21"
+ },
+ "aic-clli": "AUSTTXGR",
+ "vnf-resource-assignments": {
+ "availability-zones": {
+ "availability-zone": [
+ {
+ "test":"AZ-MN02"
+ }
+ ],
+ "max-count": 1
+ }
+ },
+ "aic-cloud-region": "mtn6",
+ "onap-model-information": {
+ "model-customization-uuid": "034226ae-879a-46b5-855c-d02babcb6cb6",
+ "model-uuid": "cb79c25f-b30d-4d95-afb5-97be4021f3db",
+ "model-invariant-uuid": "e93d3a7a-446d-486b-ae48-d474a9156064",
+ "model-name": "InfraMSO_vSAMP10a-2",
+ "model-version": "1.0"
+ }
+ }
+} \ No newline at end of file