11/7: merge casablanca to master
[so.git] / bpmn / so-bpmn-tasks / src / test / java / org / onap / so / bpmn / infrastructure / workflow / tasks / OrchestrationStatusValidatorTest.java
index 5496eed..60d456e 100644 (file)
@@ -63,7 +63,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest {
        public void test_validateOrchestrationStatus() throws Exception {
                String flowToBeCalled = "AssignServiceInstanceBB";
                setServiceInstance().setOrchestrationStatus(OrchestrationStatus.PRECREATED);
-               
+               execution.setVariable("aLaCarte", true);
                execution.setVariable("flowToBeCalled", flowToBeCalled);
                
                BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
@@ -103,6 +103,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest {
                si.setConfigurations(configurations);
                
                execution.setVariable("flowToBeCalled", flowToBeCalled);
+               execution.setVariable("aLaCarte", true);
                
                BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
                buildingBlockDetail.setBuildingBlockName("UnassignFabricConfigurationBB");
@@ -200,6 +201,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest {
                String flowToBeCalled = "UnassignServiceInstanceBB";
                
                execution.setVariable("flowToBeCalled", flowToBeCalled);
+               execution.setVariable("aLaCarte", true);
                
                BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
                buildingBlockDetail.setBuildingBlockName("UnassignServiceInstanceBB");
@@ -221,7 +223,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest {
                String flowToBeCalled = "CreateVfModuleBB";
                                
                execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
-               
+               execution.setVariable("aLaCarte", true);
                execution.setVariable("flowToBeCalled", flowToBeCalled);
                
                GenericVnf genericVnf = buildGenericVnf();
@@ -258,7 +260,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest {
                String flowToBeCalled = "CreateVfModuleBB";
                
                execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.CONTINUE);
-               
+               execution.setVariable("aLaCarte", true);
                execution.setVariable("flowToBeCalled", flowToBeCalled);
                
                GenericVnf genericVnf = buildGenericVnf();
@@ -294,7 +296,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest {
                String flowToBeCalled = "CreateVfModuleBB";             
                
                execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
-               
+               execution.setVariable("aLaCarte", true);
                execution.setVariable("flowToBeCalled", flowToBeCalled);
                
                GenericVnf genericVnf = buildGenericVnf();
@@ -330,7 +332,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest {
                String flowToBeCalled = "CreateVfModuleBB";
                                
                execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
-               
+               execution.setVariable("aLaCarte", true);
                execution.setVariable("flowToBeCalled", flowToBeCalled);
                
                GenericVnf genericVnf = buildGenericVnf();
@@ -366,7 +368,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest {
                String flowToBeCalled = "CreateVfModuleBB";
                                
                execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
-               
+               execution.setVariable("aLaCarte", true);
                execution.setVariable("flowToBeCalled", flowToBeCalled);
                
                GenericVnf genericVnf = buildGenericVnf();
@@ -396,4 +398,40 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest {
                
                assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
        }
+       
+       @Test
+       public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongAlacarteValueVfModule() throws Exception {
+               String flowToBeCalled = "CreateVfModuleBB";
+                               
+               execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+               execution.setVariable("aLaCarte", false);
+               execution.setVariable("flowToBeCalled", flowToBeCalled);
+               
+               GenericVnf genericVnf = buildGenericVnf();
+               ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
+               modelInfoGenericVnf.setMultiStageDesign("true");
+               setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
+               setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+               
+               BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+               buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
+               buildingBlockDetail.setId(1);
+               buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
+               buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
+               
+               doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+               
+               OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
+               orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+               orchestrationStatusStateTransitionDirective.setId(1);
+               orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+               orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
+               orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ACTIVATE);
+               
+               doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
+               
+               orchestrationStatusValidator.validateOrchestrationStatus(execution);
+               
+               assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
+       }
 }