Search in sources :

Example 11 with OrchestrationStatusStateTransitionDirective

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());
}
Also used : ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) OrchestrationStatusStateTransitionDirective(org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective) BuildingBlockDetail(org.onap.so.db.catalog.beans.BuildingBlockDetail) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 12 with OrchestrationStatusStateTransitionDirective

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);
}
Also used : OrchestrationStatusStateTransitionDirective(org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective) BuildingBlockDetail(org.onap.so.db.catalog.beans.BuildingBlockDetail) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 13 with OrchestrationStatusStateTransitionDirective

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;
}
Also used : OrchestrationStatusStateTransitionDirective(org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective)

Example 14 with 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);
}
Also used : Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) ArrayList(java.util.ArrayList) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) OrchestrationStatusStateTransitionDirective(org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective) BuildingBlockDetail(org.onap.so.db.catalog.beans.BuildingBlockDetail) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 15 with OrchestrationStatusStateTransitionDirective

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());
}
Also used : OrchestrationStatusStateTransitionDirective(org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

OrchestrationStatusStateTransitionDirective (org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective)15 Test (org.junit.Test)13 BuildingBlockDetail (org.onap.so.db.catalog.beans.BuildingBlockDetail)13 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)12 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)7 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)7 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)6 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)2 ArrayList (java.util.ArrayList)1 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)1 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)1 OrchestrationStatusValidationException (org.onap.so.client.exception.OrchestrationStatusValidationException)1 OrchestrationStatus (org.onap.so.db.catalog.beans.OrchestrationStatus)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)1