Search in sources :

Example 26 with BuildingBlockExecution

use of org.onap.so.bpmn.common.BuildingBlockExecution in project so by onap.

the class MultiStageSkipListenerTest method testProcessMultiStageSkip.

@Test
public void testProcessMultiStageSkip() {
    String vfModuleId = "vfModuleId";
    String vnfId = "vnfId";
    List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
    WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
    workflowResourceIds.setServiceInstanceId("serviceInstanceId");
    workflowResourceIds.setVnfId(vnfId);
    BuildingBlock bb = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
    ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setResourceId(vfModuleId).setBuildingBlock(bb).setWorkflowResourceIds(workflowResourceIds);
    flowsToExecute.add(ebb);
    flowsToExecute.add(new ExecuteBuildingBlock());
    flowsToExecute.add(new ExecuteBuildingBlock());
    BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
    org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
    vfModule.setVfModuleId(vfModuleId);
    org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
    vnf.setModelCustomizationId("modelCustomizationUUID");
    VnfResourceCustomization vnfCust = new VnfResourceCustomization();
    vnfCust.setModelCustomizationUUID("modelCustomizationUUID");
    vnfCust.setMultiStageDesign("true");
    when(catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(vnf.getModelCustomizationId())).thenReturn(vnfCust);
    when(bbInputSetupUtils.getAAIVfModule(eq(vnfId), eq(vfModuleId))).thenReturn(null);
    when(bbInputSetupUtils.getAAIGenericVnf(eq(vnfId))).thenReturn(vnf);
    multiStageSkipListener.run(flowsToExecute, flowsToExecute.get(0), execution);
    assertEquals("Flows should only have Assign", flowsToExecute.size(), 1);
    assertEquals("Flows should only have Assign", flowsToExecute.get(0).getBuildingBlock().getBpmnFlowName(), "AssignVfModuleBB");
}
Also used : BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ArrayList(java.util.ArrayList) DelegateExecutionFake(org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) Test(org.junit.Test)

Example 27 with BuildingBlockExecution

use of org.onap.so.bpmn.common.BuildingBlockExecution in project so by onap.

the class MultiStageSkipListenerTest method postCompletionRequestsDbListenerTest.

@Test
public void postCompletionRequestsDbListenerTest() {
    InfraActiveRequests request = new InfraActiveRequests();
    BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
    multiStageSkipListener.run(request, execution);
    assertEquals("Successfully completed Assign Building Block only due to multi-stage-design VNF", request.getFlowStatus());
}
Also used : BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) DelegateExecutionFake(org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) Test(org.junit.Test)

Example 28 with BuildingBlockExecution

use of org.onap.so.bpmn.common.BuildingBlockExecution in project so by onap.

the class UpgradePreWorkflowValidatorTest method validateModelInvariantMismatch.

@Test
public void validateModelInvariantMismatch() throws JsonProcessingException {
    ServiceInstancesRequest sir = new ServiceInstancesRequest();
    sir.setRequestDetails(new RequestDetails());
    sir.getRequestDetails().setModelInfo(new ModelInfo());
    sir.getRequestDetails().getModelInfo().setModelInvariantId(UUID.randomUUID().toString());
    Resource serviceResource = new Resource(WorkflowType.SERVICE, "", false, null);
    String aaiModelInvariantId = UUID.randomUUID().toString();
    serviceResource.setModelInvariantId(aaiModelInvariantId);
    BuildingBlockExecution execution = createExecution(sir, Arrays.asList(serviceResource));
    Optional<String> message = validator.validate(execution);
    assertTrue(message.isPresent());
    assertTrue(message.get().startsWith("Request service modelInvariantId"));
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) Test(org.junit.Test)

Example 29 with BuildingBlockExecution

use of org.onap.so.bpmn.common.BuildingBlockExecution in project so by onap.

the class UpgradePreWorkflowValidatorTest method validateNoVnfsInAAI.

@Test
public void validateNoVnfsInAAI() throws JsonProcessingException {
    ServiceInstancesRequest sir = new ServiceInstancesRequest();
    sir.setRequestDetails(new RequestDetails());
    sir.getRequestDetails().setModelInfo(new ModelInfo());
    String modelInvariantId = UUID.randomUUID().toString();
    sir.getRequestDetails().getModelInfo().setModelInvariantId(modelInvariantId);
    Resource serviceResource = new Resource(WorkflowType.SERVICE, "", false, null);
    serviceResource.setModelInvariantId(modelInvariantId);
    BuildingBlockExecution execution = createExecution(sir, Arrays.asList(serviceResource));
    Optional<String> message = validator.validate(execution);
    assertThat(message).isEmpty();
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) Test(org.junit.Test)

Example 30 with BuildingBlockExecution

use of org.onap.so.bpmn.common.BuildingBlockExecution in project so by onap.

the class HomingV2Test method whenHomingSolutionSetToOofShouldCallOof.

@Test
public void whenHomingSolutionSetToOofShouldCallOof() {
    HashMap<String, Object> userParams = new HashMap<>();
    userParams.put(HOMING_SOLUTION, HOMING_OOF);
    BuildingBlockExecution givenExecution = createBuildingBlockExecutionMock(userParams);
    OofHomingV2 oofHoming = mock(OofHomingV2.class);
    SniroHomingV2 sniroHoming = mock(SniroHomingV2.class);
    HomingV2 homingV2 = new HomingV2(oofHoming, sniroHoming);
    homingV2.callHoming(givenExecution);
    then(oofHoming).should().callOof(givenExecution);
    then(sniroHoming).shouldHaveZeroInteractions();
}
Also used : BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

BuildingBlockExecution (org.onap.so.bpmn.common.BuildingBlockExecution)39 Test (org.junit.Test)27 HashMap (java.util.HashMap)10 DelegateExecutionImpl (org.onap.so.bpmn.common.DelegateExecutionImpl)10 DelegateExecutionFake (org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake)7 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)6 ArrayList (java.util.ArrayList)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 Resource (org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)4 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)4 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)4 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)4 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)4 List (java.util.List)3 Optional (java.util.Optional)3 Collectors (java.util.stream.Collectors)3 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)3 AbstractCDSPropertiesBean (org.onap.so.client.cds.beans.AbstractCDSPropertiesBean)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3