summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcus Williams <marcus.williams@intel.com>2018-12-05 18:14:09 +0000
committerGerrit Code Review <gerrit@onap.org>2018-12-05 18:14:09 +0000
commit3b22842f0065b5fb3b8bc28974f974646d4b46cc (patch)
tree793682282d95bb1ec80d71bc2bcba749ce6471c8
parentd2589e832d2235e5ae5b8b376467eb6427f821e6 (diff)
parentc5876cf77fc71e11f2f66dc308cde68d729261b4 (diff)
Merge "Always UnAssign"
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java29
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java57
2 files changed, 4 insertions, 82 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java
index 13639daa44..ab4a7f8a2c 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java
@@ -24,6 +24,7 @@ import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
@@ -31,17 +32,14 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.client.orchestration.SDNCNetworkResources;
import org.onap.so.client.orchestration.SDNCServiceInstanceResources;
import org.onap.so.client.orchestration.SDNCVfModuleResources;
import org.onap.so.client.orchestration.SDNCVnfResources;
-import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.logger.MsoLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
-import org.onap.so.client.orchestration.SDNCNetworkResources;
-
@Component
public class SDNCUnassignTasks {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, SDNCUnassignTasks.class);
@@ -61,12 +59,7 @@ public class SDNCUnassignTasks {
public void unassignServiceInstance(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
-
- if (serviceInstance.getOrchestrationStatus() == OrchestrationStatus.INVENTORIED) {
- return; // If INVENTORIED then SDNC unassign is not necessary
- }
-
+ ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
RequestContext requestContext = gBBInput.getRequestContext();
Customer customer = gBBInput.getCustomer();
String sdncUnassignResponse = sdncSIResources.unassignServiceInstance(serviceInstance, customer, requestContext);
@@ -81,13 +74,7 @@ public class SDNCUnassignTasks {
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID));
-
- if (OrchestrationStatus.INVENTORIED == vfModule.getOrchestrationStatus() || OrchestrationStatus.PENDING_CREATE == vfModule.getOrchestrationStatus()) {
- return; // If INVENTORIED or PENDING_CREATE then SDNC unassign is not necessary
- }
-
execution.setVariable("sdncVfModuleRollback", false);
-
String response = sdncVfModuleResources.unassignVfModule(vfModule, vnf, serviceInstance);
execution.setVariable("SDNCResponse", response);
execution.setVariable("sdncVfModuleRollback", true);
@@ -101,11 +88,6 @@ public class SDNCUnassignTasks {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
-
- if (OrchestrationStatus.INVENTORIED == vnf.getOrchestrationStatus() || OrchestrationStatus.CREATED == vnf.getOrchestrationStatus()) {
- return; // If INVENTORIED or CREATED then SDNC unassign is not necessary
- }
-
RequestContext requestContext = gBBInput.getRequestContext();
Customer customer = gBBInput.getCustomer();
CloudRegion cloudRegion = gBBInput.getCloudRegion();
@@ -121,11 +103,6 @@ public class SDNCUnassignTasks {
public void unassignNetwork(BuildingBlockExecution execution) throws Exception {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID));
-
- if (OrchestrationStatus.INVENTORIED == network.getOrchestrationStatus()) {
- return; // If INVENTORIED then SDNC unassign is not necessary
- }
-
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
Customer customer = gBBInput.getCustomer();
RequestContext requestContext = gBBInput.getRequestContext();
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java
index da8ea8f58c..07f03b592b 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java
@@ -88,16 +88,7 @@ public class SDNCUnassignTasksTest extends BaseTaskTest{
verify(sdncServiceInstanceResources, times(1)).unassignServiceInstance(serviceInstance, customer, requestContext);
}
- @Test
- public void unassignServiceInstanceTest_inventoried() throws Exception {
- doReturn("test").when(sdncServiceInstanceResources).unassignServiceInstance(serviceInstance, customer, requestContext);
-
- serviceInstance.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
-
- sdncUnassignTasks.unassignServiceInstance(execution);
-
- verify(sdncServiceInstanceResources, times(0)).unassignServiceInstance(serviceInstance, customer, requestContext);
- }
+
@Test
public void unassignServiceInstanceExceptionTest() throws Exception {
@@ -118,26 +109,9 @@ public class SDNCUnassignTasksTest extends BaseTaskTest{
assertEquals("response", execution.getVariable("SDNCResponse"));
}
- @Test
- public void unassignVfModuleTest_inventoried() throws Exception {
- vfModule.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
-
- sdncUnassignTasks.unassignVfModule(execution);
- verify(sdncVfModuleResources, times(0)).unassignVfModule(vfModule, genericVnf, serviceInstance);
- assertNull(execution.getVariable("SDNCResponse"));
- }
- @Test
- public void unassignVfModuleTest_pendingCreate() throws Exception {
- vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_CREATE);
-
- sdncUnassignTasks.unassignVfModule(execution);
- verify(sdncVfModuleResources, times(0)).unassignVfModule(vfModule, genericVnf, serviceInstance);
- assertNull(execution.getVariable("SDNCResponse"));
- }
-
@Test
public void unassignVfModuleExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
@@ -157,25 +131,6 @@ public class SDNCUnassignTasksTest extends BaseTaskTest{
assertTrue(execution.getVariable("sdncUnassignVnfResponse").equals("response"));
}
- @Test
- public void unassignVnfTest_inventoried() throws Exception {
- genericVnf.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
-
- sdncUnassignTasks.unassignVnf(execution);
-
- verify(sdncVnfResources, times(0)).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- assertNull(execution.getVariable("sdncUnassignVnfResponse"));
- }
-
- @Test
- public void unassignVnfTest_created() throws Exception {
- genericVnf.setOrchestrationStatus(OrchestrationStatus.CREATED);
-
- sdncUnassignTasks.unassignVnf(execution);
-
- verify(sdncVnfResources, times(0)).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- assertNull(execution.getVariable("sdncUnassignVnfResponse"));
- }
@Test
public void unassignVnfExceptionTest() throws Exception {
@@ -201,14 +156,4 @@ public class SDNCUnassignTasksTest extends BaseTaskTest{
assertEquals("response", execution.getVariable("SDNCUnAssignNetworkResponse"));
assertEquals(cloudRegionSdnc, cloudRegion.getLcpCloudRegionId());
}
-
- @Test
- public void unassignNetworkTest_inventoried() throws Exception {
- network.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
-
- sdncUnassignTasks.unassignNetwork(execution);
-
- verify(sdncNetworkResources, times(0)).unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- assertNull(execution.getVariable("SDNCUnAssignNetworkResponse"));
- }
}