diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN')
2 files changed, 44 insertions, 0 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java index ed31e1d079..fd2054c3d0 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java @@ -30,6 +30,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.constants.Status; import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; @@ -47,6 +48,7 @@ public class ExecuteBuildingBlockRainyDay { private static final Logger logger = LoggerFactory.getLogger(ExecuteBuildingBlockRainyDay.class); public static final String HANDLING_CODE = "handlingCode"; + public static final String ROLLBACK_TARGET_STATE = "rollbackTargetState"; @Autowired private CatalogDbClient catalogDbClient; @@ -167,6 +169,18 @@ public class ExecuteBuildingBlockRainyDay { if (handlingCode.equals("RollbackToAssigned") && !aLaCarte) { handlingCode = "Rollback"; } + if (handlingCode.startsWith("Rollback")) { + String targetState = ""; + if (handlingCode.equalsIgnoreCase("RollbackToAssigned")) { + targetState = Status.ROLLED_BACK_TO_ASSIGNED.toString(); + } else if (handlingCode.equalsIgnoreCase("RollbackToCreated")) { + targetState = Status.ROLLED_BACK_TO_CREATED.toString(); + } else { + targetState = Status.ROLLED_BACK.toString(); + } + execution.setVariable(ROLLBACK_TARGET_STATE, targetState); + logger.debug("Rollback target state is: {}", targetState); + } } logger.debug("RainyDayHandler Status Code is: {}", handlingCode); execution.setVariable(HANDLING_CODE, handlingCode); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java index c5da3cbd51..80373eb760 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java @@ -38,6 +38,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.constants.Status; import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus; import org.springframework.beans.factory.annotation.Autowired; @@ -207,6 +208,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); assertEquals("Rollback", delegateExecution.getVariable("handlingCode")); + assertEquals(Status.ROLLED_BACK.toString(), delegateExecution.getVariable("rollbackTargetState")); } @Test @@ -232,9 +234,37 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); assertEquals("RollbackToAssigned", delegateExecution.getVariable("handlingCode")); + assertEquals(Status.ROLLED_BACK_TO_ASSIGNED.toString(), delegateExecution.getVariable("rollbackTargetState")); } @Test + public void queryRainyDayTableRollbackToCreated() throws Exception { + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); + vnf.setVnfType("vnft1"); + delegateExecution.setVariable("aLaCarte", true); + delegateExecution.setVariable("suppressRollback", false); + delegateExecution.setVariable("WorkflowExceptionCode", "7000"); + RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); + rainyDayHandlerStatus.setErrorCode("7000"); + rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); + rainyDayHandlerStatus.setServiceType("st1"); + rainyDayHandlerStatus.setVnfType("vnft1"); + rainyDayHandlerStatus.setPolicy("RollbackToCreated"); + rainyDayHandlerStatus.setWorkStep(ASTERISK); + rainyDayHandlerStatus.setSecondaryPolicy("Abort"); + + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", + "st1", "vnft1", "7000", "*", "errorMessage"); + + executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); + + assertEquals("RollbackToCreated", delegateExecution.getVariable("handlingCode")); + assertEquals(Status.ROLLED_BACK_TO_CREATED.toString(), delegateExecution.getVariable("rollbackTargetState")); + } + + + @Test public void suppressRollbackTest() throws Exception { delegateExecution.setVariable("suppressRollback", true); delegateExecution.setVariable("aLaCarte", true); |