diff options
author | Steve Smokowski <ss835w@att.com> | 2019-09-10 11:57:54 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-09-10 11:57:54 +0000 |
commit | d6d0a05998f981bfc48f71c713f5b1f9797bf56e (patch) | |
tree | 33a9f3acd218e3a996af33609b53fd2a6d24a6d6 /bpmn/so-bpmn-tasks/src | |
parent | a50be1862d4dbe9ea338faecb078237f05824658 (diff) | |
parent | 1e4c53932a656cebee58ac404dfe14b9cebb856d (diff) |
Merge "Added ACTIVATED Orchestration Status same as"
Diffstat (limited to 'bpmn/so-bpmn-tasks/src')
2 files changed, 91 insertions, 33 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java index 8822bc39dd..64f0072991 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java @@ -153,16 +153,6 @@ public class OrchestrationStatusValidator { .getOrchestrationStatusStateTransitionDirective(buildingBlockDetail.getResourceType(), orchestrationStatus, buildingBlockDetail.getTargetAction()); - if (aLaCarte && ResourceType.VF_MODULE.equals(buildingBlockDetail.getResourceType()) - && OrchestrationAction.CREATE.equals(buildingBlockDetail.getTargetAction()) - && OrchestrationStatus.PENDING_ACTIVATION.equals(orchestrationStatus)) { - org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf genericVnf = - extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); - orchestrationStatusStateTransitionDirective = processPossibleSecondStageofVfModuleCreate(execution, - previousOrchestrationStatusValidationResult, genericVnf, - orchestrationStatusStateTransitionDirective); - } - if (orchestrationStatusStateTransitionDirective .getFlowDirective() == OrchestrationStatusValidationDirective.FAIL) { throw new OrchestrationStatusValidationException( @@ -187,23 +177,4 @@ public class OrchestrationStatusValidator { exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e); } } - - private OrchestrationStatusStateTransitionDirective processPossibleSecondStageofVfModuleCreate( - BuildingBlockExecution execution, - OrchestrationStatusValidationDirective previousOrchestrationStatusValidationResult, - org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf genericVnf, - OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective) { - if (previousOrchestrationStatusValidationResult != null && previousOrchestrationStatusValidationResult - .equals(OrchestrationStatusValidationDirective.SILENT_SUCCESS)) { - String multiStageDesign = MULTI_STAGE_DESIGN_OFF; - if (genericVnf.getModelInfoGenericVnf() != null) { - multiStageDesign = genericVnf.getModelInfoGenericVnf().getMultiStageDesign(); - } - if (multiStageDesign != null && multiStageDesign.equalsIgnoreCase(MULTI_STAGE_DESIGN_ON)) { - orchestrationStatusStateTransitionDirective - .setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE); - } - } - return orchestrationStatusStateTransitionDirective; - } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java index b371e3a48a..ffe48876c4 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java @@ -21,6 +21,7 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; @@ -50,7 +51,6 @@ import org.onap.so.db.catalog.beans.OrchestrationStatusValidationDirective; import org.onap.so.db.catalog.beans.ResourceType; import org.springframework.beans.factory.annotation.Autowired; -@Ignore public class OrchestrationStatusValidatorTest extends BaseTaskTest { @InjectMocks protected OrchestrationStatusValidator orchestrationStatusValidator = new OrchestrationStatusValidator(); @@ -72,6 +72,13 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); + org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstance = + new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + serviceInstance.setOrchestrationStatus(OrchestrationStatus.PRECREATED); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))) + .thenReturn(serviceInstance); + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective(); orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE); @@ -115,6 +122,13 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); + org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration configuration = + new org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration(); + configuration.setConfigurationId("configurationId"); + configuration.setOrchestrationStatus(OrchestrationStatus.PRECREATED); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID))) + .thenReturn(configuration); + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective(); orchestrationStatusStateTransitionDirective @@ -134,6 +148,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { execution.getVariable("orchestrationStatusValidationResult")); } + @Ignore @Test public void test_validateOrchestrationStatus_buildingBlockDetailNotFound() throws Exception { expectedException.expect(BpmnError.class); @@ -147,6 +162,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { orchestrationStatusValidator.validateOrchestrationStatus(execution); } + @Ignore @Test public void test_validateOrchestrationStatus_orchestrationValidationFail() throws Exception { expectedException.expect(BpmnError.class); @@ -178,6 +194,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { orchestrationStatusValidator.validateOrchestrationStatus(execution); } + @Ignore @Test public void test_validateOrchestrationStatus_orchestrationValidationNotFound() throws Exception { expectedException.expect(BpmnError.class); @@ -228,8 +245,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { orchestrationStatusValidator.validateOrchestrationStatus(execution); - assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, - execution.getVariable("orchestrationStatusValidationResult")); + assertNull(execution.getVariable("orchestrationStatusValidationResult")); } @Test @@ -247,6 +263,12 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf); setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = + new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); + vfModule.setVfModuleId("vfModuleId"); + vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); + BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB"); buildingBlockDetail.setId(1); @@ -257,7 +279,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.FAIL); + orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE); orchestrationStatusStateTransitionDirective.setId(1); orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); @@ -288,6 +310,12 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf); setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = + new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); + vfModule.setVfModuleId("vfModuleId"); + vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); + BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB"); buildingBlockDetail.setId(1); @@ -338,6 +366,12 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = + new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); + vfModule.setVfModuleId("vfModuleId"); + vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective(); orchestrationStatusStateTransitionDirective @@ -380,6 +414,12 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = + new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); + vfModule.setVfModuleId("vfModuleId"); + vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective(); orchestrationStatusStateTransitionDirective @@ -422,6 +462,12 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = + new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); + vfModule.setVfModuleId("vfModuleId"); + vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective(); orchestrationStatusStateTransitionDirective @@ -464,6 +510,12 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = + new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); + vfModule.setVfModuleId("vfModuleId"); + vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective(); orchestrationStatusStateTransitionDirective @@ -482,4 +534,39 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult")); } + + @Test + public void continueValidationActivatedTest() throws Exception { + String flowToBeCalled = "DeactivateVnfBB"; + BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); + buildingBlockDetail.setBuildingBlockName(flowToBeCalled); + buildingBlockDetail.setId(1); + buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); + buildingBlockDetail.setTargetAction(OrchestrationAction.DEACTIVATE); + when(catalogDbClient.getBuildingBlockDetail(flowToBeCalled)).thenReturn(buildingBlockDetail); + + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = + new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); + vfModule.setVfModuleId("vfModuleId"); + vfModule.setOrchestrationStatus(OrchestrationStatus.ACTIVATED); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); + + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = + new OrchestrationStatusStateTransitionDirective(); + orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE); + orchestrationStatusStateTransitionDirective.setId(1); + orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.ACTIVATED); + orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); + orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.DEACTIVATE); + doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) + .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.ACTIVATED, + OrchestrationAction.DEACTIVATE); + + execution.setVariable("aLaCarte", true); + execution.setVariable("flowToBeCalled", flowToBeCalled); + orchestrationStatusValidator.validateOrchestrationStatus(execution); + + assertEquals(OrchestrationStatusValidationDirective.CONTINUE, + execution.getVariable("orchestrationStatusValidationResult")); + } } |