Search in sources :

Example 26 with DelegateExecutionImpl

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

the class OrchestrationStatusValidatorUnitTest method skipValidationTest.

@Test
public void skipValidationTest() {
    BuildingBlockDetail bbDetail = new BuildingBlockDetail();
    bbDetail.setBuildingBlockName("customBB");
    bbDetail.setResourceType(ResourceType.NO_VALIDATE);
    bbDetail.setTargetAction(OrchestrationAction.CUSTOM);
    when(catalogDbClient.getBuildingBlockDetail("customBB")).thenReturn(bbDetail);
    BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
    execution.setVariable("flowToBeCalled", "customBB");
    execution.setVariable("aLaCarte", false);
    validator.validateOrchestrationStatus(execution);
    assertThat(execution.getVariable("orchestrationStatusValidationResult"), equalTo(OrchestrationStatusValidationDirective.VALIDATION_SKIPPED));
}
Also used : BuildingBlockDetail(org.onap.so.db.catalog.beans.BuildingBlockDetail) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) DelegateExecutionFake(org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake) Test(org.junit.Test)

Example 27 with DelegateExecutionImpl

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

the class MultiStageSkipListenerTest method testTrigger.

@Test
public void testTrigger() {
    BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
    execution.setVariable(BBConstants.G_ALACARTE, true);
    assertTrue("should be triggered", multiStageSkipListener.shouldRunFor("AssignVfModuleBB", true, execution));
    execution.setVariable(BBConstants.G_ALACARTE, false);
    assertFalse("should not be triggered", multiStageSkipListener.shouldRunFor("AssignVfModuleBB", true, execution));
    execution.setVariable(BBConstants.G_ALACARTE, true);
    assertFalse("should not be triggered", multiStageSkipListener.shouldRunFor("AssignVfModuleBB2", true, execution));
    execution.setVariable("multiStageDesign", true);
    assertTrue("should be triggered", multiStageSkipListener.shouldRunFor(execution));
    execution.setVariable("multiStageDesign", false);
    assertFalse("should not be triggered", multiStageSkipListener.shouldRunFor(execution));
    execution.setVariable("multiStageDesign", null);
    assertFalse("should not be triggered", multiStageSkipListener.shouldRunFor(execution));
}
Also used : BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) DelegateExecutionFake(org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake) Test(org.junit.Test)

Example 28 with DelegateExecutionImpl

use of org.onap.so.bpmn.common.DelegateExecutionImpl 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 29 with DelegateExecutionImpl

use of org.onap.so.bpmn.common.DelegateExecutionImpl 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)

Aggregations

DelegateExecutionImpl (org.onap.so.bpmn.common.DelegateExecutionImpl)29 DelegateExecutionFake (org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake)17 BuildingBlockExecution (org.onap.so.bpmn.common.BuildingBlockExecution)11 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)9 Before (org.junit.Before)9 Test (org.junit.Test)9 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)8 ExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl)6 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)6 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 EntityNotFoundException (javax.persistence.EntityNotFoundException)3 BpmnError (org.camunda.bpm.engine.delegate.BpmnError)2 WorkflowException (org.onap.so.bpmn.core.WorkflowException)2 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)2 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)2 ExtractPojosForBB (org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB)2