diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks/src')
2 files changed, 20 insertions, 123 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index a162088cb2..7e5cf19b21 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -45,9 +45,7 @@ import java.util.Map; @Component public class AAIUpdateTasks { private static final Logger logger = LoggerFactory.getLogger(AAIUpdateTasks.class); - private static final String ALACARTE = "aLaCarte"; - private static final String MULTI_STAGE_DESIGN_OFF = "false"; - private static final String MULTI_STAGE_DESIGN_ON = "true"; + @Autowired private AAIServiceInstanceResources aaiServiceInstanceResources; @Autowired @@ -149,8 +147,6 @@ public class AAIUpdateTasks { /** * BPMN access method to update HeatStackId and VolumeGroup in AAI - * - * @param execution */ public void updateHeatStackIdVolumeGroup(BuildingBlockExecution execution) { try { @@ -172,87 +168,27 @@ public class AAIUpdateTasks { /** * BPMN access method to update status of VfModule to Assigned in AAI - * - * @param execution */ public void updateOrchestrationStatusAssignedVfModule(BuildingBlockExecution execution) { - try { - VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); - vfModule.setHeatStackId(""); - GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); - aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ASSIGNED); - } catch (Exception ex) { - logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusAssignedVfModule", ex); - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); - } + updateOrchestrationStatusForVfModule(execution, OrchestrationStatus.ASSIGNED); } /** * BPMN access method to update status of VfModule to PendingActivation in AAI - * - * @param execution */ public void updateOrchestrationStatusPendingActivationVfModule(BuildingBlockExecution execution) { - try { - VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); - GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); - aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, - OrchestrationStatus.PENDING_ACTIVATION); - } catch (Exception ex) { - logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusPendingActivationVfModule", ex); - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); - } - } - - /** - * BPMN access method to update status of VfModule to AssignedOrPendingActivation in AAI - * - * @param execution - */ - public void updateOrchestrationStatusAssignedOrPendingActivationVfModule(BuildingBlockExecution execution) { - try { - VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); - vfModule.setHeatStackId(""); - GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); - String multiStageDesign = MULTI_STAGE_DESIGN_OFF; - if (vnf.getModelInfoGenericVnf() != null) { - multiStageDesign = vnf.getModelInfoGenericVnf().getMultiStageDesign(); - } - boolean aLaCarte = (boolean) execution.getVariable(ALACARTE); - if (aLaCarte && multiStageDesign != null && multiStageDesign.equalsIgnoreCase(MULTI_STAGE_DESIGN_ON)) { - aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, - OrchestrationStatus.PENDING_ACTIVATION); - } else { - aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ASSIGNED); - } - } catch (Exception ex) { - logger.error( - "Exception occurred in AAIUpdateTasks updateOrchestrationStatusAssignedOrPendingActivationVfModule", - ex); - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); - } + updateOrchestrationStatusForVfModule(execution, OrchestrationStatus.PENDING_ACTIVATION); } /** * BPMN access method to update status of VfModule to Created in AAI - * - * @param execution */ public void updateOrchestrationStatusCreatedVfModule(BuildingBlockExecution execution) { - try { - VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); - GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); - aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.CREATED); - } catch (Exception ex) { - logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusCreatedVfModule", ex); - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); - } + updateOrchestrationStatusForVfModule(execution, OrchestrationStatus.CREATED); } /** * BPMN access method to update aaiDeactivateVfModuleRollback to true for deactivating the VfModule - * - * @param execution */ public void updateOrchestrationStatusDeactivateVfModule(BuildingBlockExecution execution) { execution.setVariable("aaiDeactivateVfModuleRollback", false); @@ -800,4 +736,20 @@ public class AAIUpdateTasks { } } + private void updateOrchestrationStatusForVfModule(BuildingBlockExecution execution, OrchestrationStatus status) { + try { + VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); + if (status.equals(OrchestrationStatus.ASSIGNED)) { + vfModule.setHeatStackId(""); + } + GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, status); + } catch (Exception ex) { + logger.error( + "Exception occurred in AAIUpdateTasks during update orchestration status to {} for " + "vf module", + status, ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java index e26009a1de..e5b003a437 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java @@ -40,7 +40,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; -import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.db.catalog.beans.OrchestrationStatus; import java.util.HashMap; @@ -258,60 +257,6 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleNoMultiStageTest() throws Exception { - execution.setVariable("aLaCarte", true); - ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); - modelInfoGenericVnf.setMultiStageDesign("false"); - genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf); - doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, - OrchestrationStatus.ASSIGNED); - aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution); - verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, - OrchestrationStatus.ASSIGNED); - assertEquals("", vfModule.getHeatStackId()); - } - - @Test - public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleMultiStageButNotAlacarteTest() - throws Exception { - execution.setVariable("aLaCarte", false); - ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); - modelInfoGenericVnf.setMultiStageDesign("true"); - genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf); - doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, - OrchestrationStatus.ASSIGNED); - aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution); - verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, - OrchestrationStatus.ASSIGNED); - assertEquals("", vfModule.getHeatStackId()); - } - - @Test - public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleWithMultiStageTest() throws Exception { - execution.setVariable("aLaCarte", true); - ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); - modelInfoGenericVnf.setMultiStageDesign("true"); - genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf); - doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, - OrchestrationStatus.PENDING_ACTIVATION); - aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution); - verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, - OrchestrationStatus.PENDING_ACTIVATION); - assertEquals("", vfModule.getHeatStackId()); - } - - @Test - public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleExceptionTest() throws Exception { - execution.setVariable("aLaCarte", true); - doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, - genericVnf, OrchestrationStatus.ASSIGNED); - - expectedException.expect(BpmnError.class); - - aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution); - } - - @Test public void updateOrchestrationStatusCreatedVfModuleTest() throws Exception { doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED); |