Search in sources :

Example 16 with BuildingBlockDetail

use of org.onap.so.db.catalog.beans.BuildingBlockDetail 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 17 with BuildingBlockDetail

use of org.onap.so.db.catalog.beans.BuildingBlockDetail 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 18 with BuildingBlockDetail

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

the class BuildingBlockDetailTest method BuildingBlockDetailSingleLookupValidationTest.

@Test
public void BuildingBlockDetailSingleLookupValidationTest() {
    String buildingBlockName = "AssignServiceInstanceBB";
    BuildingBlockDetail buildingBlockDetail = buildingBlockDetailRepository.findOneByBuildingBlockName(buildingBlockName);
    assertEquals(buildingBlockName, buildingBlockDetail.getBuildingBlockName());
    assertEquals(ResourceType.SERVICE, buildingBlockDetail.getResourceType());
    assertEquals(OrchestrationAction.ASSIGN, buildingBlockDetail.getTargetAction());
}
Also used : BuildingBlockDetail(org.onap.so.db.catalog.beans.BuildingBlockDetail) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Aggregations

BuildingBlockDetail (org.onap.so.db.catalog.beans.BuildingBlockDetail)18 Test (org.junit.Test)16 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)13 OrchestrationStatusStateTransitionDirective (org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective)13 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 DelegateExecutionFake (org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake)1 CatalogDbAdapterBaseTest (org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest)1 BuildingBlockExecution (org.onap.so.bpmn.common.BuildingBlockExecution)1 DelegateExecutionImpl (org.onap.so.bpmn.common.DelegateExecutionImpl)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