Search in sources :

Example 6 with OrchestrationStatusStateTransitionDirective

use of org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective in project so by onap.

the class OrchestrationStatusValidatorTest method test_validateOrchestrationStatusSecondStageOfMultiStageWrongTargetActionVfModule.

@Test
public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongTargetActionVfModule() throws Exception {
    String flowToBeCalled = "CreateVfModuleBB";
    execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
    execution.setVariable("aLaCarte", true);
    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.ACTIVATE);
    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.ACTIVATE);
    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 7 with OrchestrationStatusStateTransitionDirective

use of org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective in project so by onap.

the class OrchestrationStatusValidator method validateOrchestrationStatus.

/**
 * This method validate's the status of the OrchestrationStatus against the buildingBlockDetail ResourceType
 */
public void validateOrchestrationStatus(BuildingBlockExecution execution) {
    try {
        execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, null);
        String buildingBlockFlowName = execution.getFlowToBeCalled();
        BuildingBlockDetail buildingBlockDetail = catalogDbClient.getBuildingBlockDetail(buildingBlockFlowName);
        if (buildingBlockDetail == null) {
            throw new OrchestrationStatusValidationException(String.format(BUILDING_BLOCK_DETAIL_NOT_FOUND, buildingBlockFlowName));
        }
        OrchestrationStatus orchestrationStatus = getOrchestrationStatus(execution, buildingBlockFlowName, buildingBlockDetail);
        if (buildingBlockDetail.getResourceType().equals(ResourceType.NO_VALIDATE)) {
            return;
        }
        if (orchestrationStatus == null) {
            throw new OrchestrationStatusValidationException("The resource's orchstration status is null. Cannot perform task on a null orchestration status");
        }
        OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = catalogDbClient.getOrchestrationStatusStateTransitionDirective(buildingBlockDetail.getResourceType(), orchestrationStatus, buildingBlockDetail.getTargetAction());
        if (orchestrationStatusStateTransitionDirective.getFlowDirective() == OrchestrationStatusValidationDirective.FAIL) {
            throw new OrchestrationStatusValidationException(String.format(ORCHESTRATION_VALIDATION_FAIL, buildingBlockDetail.getResourceType(), buildingBlockDetail.getTargetAction(), orchestrationStatus));
        }
        execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, orchestrationStatusStateTransitionDirective.getFlowDirective());
        if (buildingBlockFlowName.matches("Create(.*)|Delete(.*)") && orchestrationStatusStateTransitionDirective.getFlowDirective() == OrchestrationStatusValidationDirective.SILENT_SUCCESS) {
            updatedResourceStatus(execution, buildingBlockDetail);
        }
    } catch (BBObjectNotFoundException ex) {
        logger.error("Error occurred for bb object notfound in OrchestrationStatusValidator validateOrchestrationStatus ", ex);
        if (execution.getFlowToBeCalled().contains("Unassign")) {
            execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, OrchestrationStatusValidationDirective.SILENT_SUCCESS);
        } else {
            exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, ex);
        }
    } catch (Exception e) {
        logger.error("Exception occurred", e);
        exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e);
    }
}
Also used : OrchestrationStatusStateTransitionDirective(org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) BuildingBlockDetail(org.onap.so.db.catalog.beans.BuildingBlockDetail) OrchestrationStatusValidationException(org.onap.so.client.exception.OrchestrationStatusValidationException) OrchestrationStatus(org.onap.so.db.catalog.beans.OrchestrationStatus) OrchestrationStatusValidationException(org.onap.so.client.exception.OrchestrationStatusValidationException) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException)

Example 8 with OrchestrationStatusStateTransitionDirective

use of org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective in project so by onap.

the class OrchestrationStatusValidatorTest method test_validateOrchestrationStatusSecondStageOfMultiStageEnabledVfModule.

@Test
public void test_validateOrchestrationStatusSecondStageOfMultiStageEnabledVfModule() throws Exception {
    String flowToBeCalled = "CreateVfModuleBB";
    execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
    execution.setVariable("aLaCarte", true);
    execution.setVariable("flowToBeCalled", flowToBeCalled);
    GenericVnf genericVnf = buildGenericVnf();
    ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
    modelInfoGenericVnf.setMultiStageDesign("true");
    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 = getBuildingBlockDetail("CreateVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.CREATE);
    doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
    OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.CONTINUE, OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.CREATE);
    doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
    orchestrationStatusValidator.validateOrchestrationStatus(execution);
    assertEquals(OrchestrationStatusValidationDirective.CONTINUE, execution.getVariable("orchestrationStatusValidationResult"));
    Mockito.verifyZeroInteractions(requestsDbClient);
}
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) 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 9 with OrchestrationStatusStateTransitionDirective

use of org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective in project so by onap.

the class OrchestrationStatusValidatorTest method test_validateOrchestrationStatusSecondStageOfMultiStageWrongOrchStatusVfModule.

@Test
public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongOrchStatusVfModule() throws Exception {
    String flowToBeCalled = "CreateVfModuleBB";
    execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
    execution.setVariable("aLaCarte", true);
    execution.setVariable("flowToBeCalled", flowToBeCalled);
    GenericVnf genericVnf = buildGenericVnf();
    ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
    modelInfoGenericVnf.setMultiStageDesign("true");
    setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
    setVfModule().setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
    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.ASSIGNED);
    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.CREATE);
    doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.ASSIGNED, 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 10 with OrchestrationStatusStateTransitionDirective

use of org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective in project so by onap.

the class OrchestrationStatusValidatorTest method test_validateOrchestrationStatus.

@Test
public void test_validateOrchestrationStatus() throws Exception {
    String flowToBeCalled = "AssignServiceInstanceBB";
    setServiceInstance().setOrchestrationStatus(OrchestrationStatus.PRECREATED);
    execution.setVariable("aLaCarte", true);
    execution.setVariable("flowToBeCalled", flowToBeCalled);
    BuildingBlockDetail buildingBlockDetail = getBuildingBlockDetail("AssignServiceInstanceBB", ResourceType.SERVICE, OrchestrationAction.ASSIGN);
    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 = getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.CONTINUE, OrchestrationStatus.PRECREATED, ResourceType.SERVICE, OrchestrationAction.ASSIGN);
    doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.SERVICE, OrchestrationStatus.PRECREATED, OrchestrationAction.ASSIGN);
    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) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

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