use of org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective in project so by onap.
the class OrchestrationStatusValidatorTest method test_validateOrchestrationStatusSecondStageOfMultiStageWrongAlacarteValueVfModule.
@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 = getBuildingBlockDetail("CreateVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.CREATE);
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 = getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.ACTIVATE);
doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
InfraActiveRequests request = new InfraActiveRequests();
request.setRequestId("testVfModuleId1");
request.setResourceStatusMessage(vfModuleExistExpectedMessage);
Mockito.doNothing().when(requestsDbClient).patchInfraActiveRequests(request);
orchestrationStatusValidator.validateOrchestrationStatus(execution);
assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
ArgumentCaptor<InfraActiveRequests> argument = ArgumentCaptor.forClass(InfraActiveRequests.class);
Mockito.verify(requestsDbClient).patchInfraActiveRequests(argument.capture());
assertEquals(vfModuleExistExpectedMessage, argument.getValue().getResourceStatusMessage());
}
use of org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective in project so by onap.
the class OrchestrationStatusValidatorTest method continueValidationActivatedTest.
@Test
public void continueValidationActivatedTest() throws Exception {
String flowToBeCalled = "DeactivateVnfBB";
BuildingBlockDetail buildingBlockDetail = getBuildingBlockDetail(flowToBeCalled, ResourceType.VF_MODULE, 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 = getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.CONTINUE, OrchestrationStatus.ACTIVATED, ResourceType.VF_MODULE, 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"));
Mockito.verifyZeroInteractions(requestsDbClient);
}
use of org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective in project so by onap.
the class OrchestrationStatusValidatorTest method getOrchestrationStatusStateTransitionDirective.
private OrchestrationStatusStateTransitionDirective getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective aContinue, OrchestrationStatus precreated, ResourceType service, OrchestrationAction assign) {
OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
orchestrationStatusStateTransitionDirective.setFlowDirective(aContinue);
orchestrationStatusStateTransitionDirective.setId(1);
orchestrationStatusStateTransitionDirective.setOrchestrationStatus(precreated);
orchestrationStatusStateTransitionDirective.setResourceType(service);
orchestrationStatusStateTransitionDirective.setTargetAction(assign);
return orchestrationStatusStateTransitionDirective;
}
use of org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective in project so by onap.
the class OrchestrationStatusValidatorTest method test_validateOrchestrationStatusConfiguration.
@Test
public void test_validateOrchestrationStatusConfiguration() throws Exception {
lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
String flowToBeCalled = "UnassignFabricConfigurationBB";
ServiceInstance si = setServiceInstance();
List<Configuration> configurations = new ArrayList<>();
Configuration config = new Configuration();
si.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
config.setConfigurationId("configurationId");
config.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
configurations.add(config);
si.setConfigurations(configurations);
execution.setVariable("flowToBeCalled", flowToBeCalled);
execution.setVariable("aLaCarte", true);
BuildingBlockDetail buildingBlockDetail = getBuildingBlockDetail("UnassignFabricConfigurationBB", ResourceType.CONFIGURATION, OrchestrationAction.UNASSIGN);
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 = getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, OrchestrationStatus.PRECREATED, ResourceType.CONFIGURATION, OrchestrationAction.UNASSIGN);
doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.CONFIGURATION, OrchestrationStatus.PRECREATED, OrchestrationAction.UNASSIGN);
orchestrationStatusValidator.validateOrchestrationStatus(execution);
assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
Mockito.verifyZeroInteractions(requestsDbClient);
}
use of org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective in project so by onap.
the class OrchestrationStatusStateTransitionDirectiveTest method OrchestrationStatusTransitionDBSingleLookupValidationTest.
@Test
public void OrchestrationStatusTransitionDBSingleLookupValidationTest() {
OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = orchestrationStatusStateTransitionDirectiveRepository.findOneByResourceTypeAndOrchestrationStatusAndTargetAction(ResourceType.SERVICE, OrchestrationStatus.ASSIGNED, OrchestrationAction.ASSIGN);
assertEquals(ResourceType.SERVICE, orchestrationStatusStateTransitionDirective.getResourceType());
assertEquals(OrchestrationStatus.ASSIGNED, orchestrationStatusStateTransitionDirective.getOrchestrationStatus());
assertEquals(OrchestrationAction.ASSIGN, orchestrationStatusStateTransitionDirective.getTargetAction());
assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, orchestrationStatusStateTransitionDirective.getFlowDirective());
}
Aggregations