From 6c422384d36ec912c95ae93b4166e4d90ad97dfe Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Mon, 4 Mar 2019 10:13:11 -0500 Subject: Removed inventoryType field check Removed inventoryType field check instead using identifierType due to sniro defect in their AID. Change-Id: Id18e2e07333bcc10d0f6ea7df2e655177e481211 Issue-ID: SO-1592 Signed-off-by: Benjamin, Max (mb388a) --- .../onap/so/bpmn/buildingblock/SniroHomingV2.java | 68 +++++++++------------- .../flowspecific/tasks/SniroHomingV2IT.java | 25 ++++---- 2 files changed, 40 insertions(+), 53 deletions(-) diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java index 893c67d9df..2e7184b9ff 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java @@ -103,7 +103,6 @@ public class SniroHomingV2 { private static final String RESOURCE_MODULE_NAME = "resourceModuleName"; private static final String RESOURCE_MODEL_INFO = "resourceModelInfo"; private static final String IDENTIFIER_TYPE = "identifierType"; - private static final String INVENTORY_TYPE = "inventoryType"; private static final String SOLUTIONS = "solutions"; private static final String RESOURCE_MISSING_DATA = "Resource does not contain: "; private static final String SERVICE_MISSING_DATA = "Service Instance does not contain: "; @@ -522,51 +521,40 @@ public class SniroHomingV2 { JSONArray assignments = placement.getJSONArray("assignmentInfo"); Map assignmentsMap = jsonUtils.entryArrayToMap(assignments.toString(), "key", "value"); solutionInfo.setRehome(Boolean.parseBoolean(assignmentsMap.get("isRehome"))); - String type = placement.getString(INVENTORY_TYPE); ServiceInstance si = new ServiceInstance(); CloudRegion cloud = setCloud(assignmentsMap); - if(type.equals("service")){ - if(identifierType.equals(CandidateType.SERVICE_INSTANCE_ID.toString())){ - solutionInfo.setHomed(true); - si.setServiceInstanceId(identifierValue); - si.setOrchestrationStatus(OrchestrationStatus.CREATED); - cloud.setLcpCloudRegionId(assignmentsMap.get("cloudRegionId")); - if(assignmentsMap.containsKey("vnfHostName")){ - logger.debug("Resources has been homed to a vnf"); - GenericVnf vnf = setVnf(assignmentsMap); - vnf.setCloudRegion(cloud); - si.getVnfs().add(vnf); - - }else if(assignmentsMap.containsKey("primaryPnfName")){ - logger.debug("Resources has been homed to a pnf"); - Pnf priPnf = setPnf(assignmentsMap, "primary"); - priPnf.setCloudRegion(cloud); - si.getPnfs().add(priPnf); - if(assignmentsMap.containsKey("secondaryPnfName")){ - Pnf secPnf = setPnf(assignmentsMap, "secondary"); - secPnf.setCloudRegion(cloud); - si.getPnfs().add(secPnf); - } + if(identifierType.equals(CandidateType.SERVICE_INSTANCE_ID.toString())){ + solutionInfo.setHomed(true); + si.setServiceInstanceId(identifierValue); + si.setOrchestrationStatus(OrchestrationStatus.CREATED); + cloud.setLcpCloudRegionId(assignmentsMap.get("cloudRegionId")); + if(assignmentsMap.containsKey("vnfHostName")){ + logger.debug("Resources has been homed to a vnf"); + GenericVnf vnf = setVnf(assignmentsMap); + vnf.setCloudRegion(cloud); + si.getVnfs().add(vnf); + + }else if(assignmentsMap.containsKey("primaryPnfName")){ + logger.debug("Resources has been homed to a pnf"); + Pnf priPnf = setPnf(assignmentsMap, "primary"); + priPnf.setCloudRegion(cloud); + si.getPnfs().add(priPnf); + if(assignmentsMap.containsKey("secondaryPnfName")){ + Pnf secPnf = setPnf(assignmentsMap, "secondary"); + secPnf.setCloudRegion(cloud); + si.getPnfs().add(secPnf); } - }else{ - logger.debug(invalidMessage + IDENTIFIER_TYPE); - throw new BpmnError(UNPROCESSABLE, invalidMessage + IDENTIFIER_TYPE); - } - }else if(type.equals("cloud")){ - if(identifierType.equals(CandidateType.CLOUD_REGION_ID.toString())){ - logger.debug("Resources has been homed to a cloud region"); - cloud.setLcpCloudRegionId(identifierValue); - solutionInfo.setHomed(false); - solutionInfo.setTargetedCloudRegion(cloud); - si.setOrchestrationStatus(OrchestrationStatus.PRECREATED); - }else{ - logger.debug(invalidMessage + IDENTIFIER_TYPE); - throw new BpmnError(UNPROCESSABLE, invalidMessage + IDENTIFIER_TYPE); } + }else if(identifierType.equals(CandidateType.CLOUD_REGION_ID.toString())){ + logger.debug("Resources has been homed to a cloud region"); + cloud.setLcpCloudRegionId(identifierValue); + solutionInfo.setHomed(false); + solutionInfo.setTargetedCloudRegion(cloud); + si.setOrchestrationStatus(OrchestrationStatus.PRECREATED); }else{ - logger.debug(invalidMessage + INVENTORY_TYPE); - throw new BpmnError(UNPROCESSABLE, invalidMessage + INVENTORY_TYPE); + logger.debug(invalidMessage + IDENTIFIER_TYPE); + throw new BpmnError(UNPROCESSABLE, invalidMessage + IDENTIFIER_TYPE); } si.setSolutionInfo(solutionInfo); return si; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java index 59fad5cdd6..c4129a3b96 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java @@ -39,7 +39,6 @@ import org.camunda.bpm.engine.delegate.BpmnError; import org.json.JSONArray; import org.json.JSONObject; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource; @@ -211,13 +210,13 @@ public class SniroHomingV2IT extends BaseIntegrationTest{ JSONObject asyncResponse = new JSONObject(); asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState", "completed"); JSONArray solution1 = new JSONArray(); - solution1.put(new JSONObject().put("serviceResourceId", "testProxyId1").put("inventoryType", "service").put("solution", new JSONObject() + solution1.put(new JSONObject().put("serviceResourceId", "testProxyId1").put("solution", new JSONObject() .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId1"))) .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False")) .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1")) .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1")).put(new JSONObject().put("key", "aicVersion").put("value", "3")) .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId1")))); - solution1.put(new JSONObject().put("serviceResourceId", "testProxyId2").put("inventoryType", "service").put("solution", new JSONObject() + solution1.put(new JSONObject().put("serviceResourceId", "testProxyId2").put("solution", new JSONObject() .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId2"))) .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False")) .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName2")) @@ -255,13 +254,13 @@ public class SniroHomingV2IT extends BaseIntegrationTest{ JSONObject asyncResponse = new JSONObject(); asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState", "completed"); JSONArray solution1 = new JSONArray(); - solution1.put(new JSONObject().put("serviceResourceId", "testProxyId1").put("inventoryType", "service").put("solution", new JSONObject() + solution1.put(new JSONObject().put("serviceResourceId", "testProxyId1").put("solution", new JSONObject() .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId1"))) .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False")) .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1")) .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1")).put(new JSONObject().put("key", "aicVersion").put("value", "3")) .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId1")))); - solution1.put(new JSONObject().put("serviceResourceId", "testProxyId2").put("inventoryType", "service").put("solution", new JSONObject() + solution1.put(new JSONObject().put("serviceResourceId", "testProxyId2").put("solution", new JSONObject() .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId2"))) .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False")) .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName2")) @@ -269,13 +268,13 @@ public class SniroHomingV2IT extends BaseIntegrationTest{ .put(new JSONObject().put("key", "secondaryPnfName").put("value", "testSecondaryPnfName2")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId2")))); JSONArray solution2 = new JSONArray(); - solution2.put(new JSONObject().put("serviceResourceId", "testProxyId1").put("inventoryType", "service").put("solution", new JSONObject() + solution2.put(new JSONObject().put("serviceResourceId", "testProxyId1").put("solution", new JSONObject() .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId3"))) .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False")) .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName3")) .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli3")).put(new JSONObject().put("key", "aicVersion").put("value", "3")) .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId3")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId3")))); - solution2.put(new JSONObject().put("serviceResourceId", "testProxyId2").put("inventoryType", "service").put("solution", new JSONObject() + solution2.put(new JSONObject().put("serviceResourceId", "testProxyId2").put("solution", new JSONObject() .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId4"))) .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False")) .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName4")) @@ -335,19 +334,19 @@ public class SniroHomingV2IT extends BaseIntegrationTest{ JSONObject asyncResponse = new JSONObject(); asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState", "completed"); JSONArray solution1 = new JSONArray(); - solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId1").put("inventoryType", "service").put("solution", new JSONObject() + solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId1").put("solution", new JSONObject() .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId1"))) .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True")) .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1")) .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1")).put(new JSONObject().put("key", "aicVersion").put("value", "3")) .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId1")))); - solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId2").put("inventoryType", "service").put("solution", new JSONObject() + solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId2").put("solution", new JSONObject() .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId2"))) .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True")) .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName2")) .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")).put(new JSONObject().put("key", "aicVersion").put("value", "3")) .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId2")))); - solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId3").put("inventoryType", "cloud").put("solution", new JSONObject() + solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId3").put("solution", new JSONObject() .put("identifierType", "cloudRegionId").put("identifiers", new JSONArray().put("testCloudRegionId3"))) .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True")) .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")) @@ -387,19 +386,19 @@ public class SniroHomingV2IT extends BaseIntegrationTest{ asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState", "completed"); JSONArray solution1 = new JSONArray(); JSONArray licenseSolution = new JSONArray(); - solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId1").put("inventoryType", "service").put("solution", new JSONObject() + solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId1").put("solution", new JSONObject() .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId1"))) .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True")) .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1")) .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1")).put(new JSONObject().put("key", "aicVersion").put("value", "3")) .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId1")))); - solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId2").put("inventoryType", "service").put("solution", new JSONObject() + solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId2").put("solution", new JSONObject() .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId2"))) .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True")) .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName2")) .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")).put(new JSONObject().put("key", "aicVersion").put("value", "3")) .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId2")))); - solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId3").put("inventoryType", "cloud").put("solution", new JSONObject() + solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId3").put("solution", new JSONObject() .put("identifierType", "cloudRegionId").put("identifiers", new JSONArray().put("testCloudRegionId3"))) .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True")) .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")) -- cgit 1.2.3-korg