Search in sources :

Example 36 with Task

use of com.google.cloud.tasks.v2.Task in project kie-wb-common by kiegroup.

the class ProcessConverterDelegateTest method mockTask.

private static Task mockTask(String id) {
    Task task = Bpmn2Factory.eINSTANCE.createTask();
    task.setId(id);
    return task;
}
Also used : Task(org.eclipse.bpmn2.Task) ManualTask(org.eclipse.bpmn2.ManualTask)

Example 37 with Task

use of com.google.cloud.tasks.v2.Task in project kie-wb-common by kiegroup.

the class ProcessConverterDelegateTest method testConvertLanes.

@Test
public void testConvertLanes() {
    Task task0_1 = mockTask("TASK0_1");
    Task task0_2 = mockTask("TASK0_2");
    Task task0_3 = mockTask("TASK0_3");
    Task task1_1 = mockTask("TASK1_1");
    Lane lane1 = mockLane("Lane1", "Lane1Name", task1_1);
    Task task2_1 = mockTask("TASK2_1");
    Lane lane2 = mockLane("Lane2", "Lane2Name", task2_1);
    LaneSet laneSet1 = mockLaneSet("LaneSet1", lane1, lane2);
    Task task3_2_1 = mockTask("TASK3_2_1");
    Task task3_2_2 = mockTask("TASK3_2_2");
    Lane lane3_2 = mockLane("Lane3_2", "Lane3_2Name", task3_2_1, task3_2_2);
    Task task3_1_2_1 = mockTask("TASK3_1_2_1");
    Lane lane3_1_2 = mockLane("Lane3_1_2", "Lane3_1_2Name", task3_1_2_1);
    Task task3_1_1_1_1 = mockTask("task3_1_1_1_1");
    Lane lane3_1_1_1 = mockLane("Lane3_1_1_1", "lane3_1_1_1Name", task3_1_1_1_1);
    Task task3_1_1_2_1 = mockTask("task3_1_1_2_1");
    Lane lane3_1_1_2 = mockLane("Lane3_1_1_2", "lane3_1_1_2Name", task3_1_1_2_1);
    Lane lane3_1_1 = mockLane("Lane3_1_1", "Lane3_1_1Name", mockLaneSet("laneSet3_1_1", lane3_1_1_1, lane3_1_1_2));
    Lane lane3_1 = mockLane("Lane3_1", "Lane3_1Name", mockLaneSet("laneSet3_1", lane3_1_1, lane3_1_2));
    Lane lane3 = mockLane("Lane3", "Lane3Name", mockLaneSet("LaneSet3", lane3_1, lane3_2));
    LaneSet laneSet2 = mockLaneSet("LaneSet2", lane3);
    List<FlowElement> flowElements = Arrays.asList(task0_1, task0_2, task0_3, task1_1, task2_1, task3_1_1_1_1, task3_1_1_2_1, task3_1_2_1, task3_2_1, task3_2_2);
    List<LaneSet> laneSets = Arrays.asList(laneSet1, laneSet2);
    Result<Map<String, BpmnNode>> result = converterDelegate.convertChildNodes(parentNode, flowElements, laneSets);
    Map<String, BpmnNode> nodes = result.value();
    assertEquals(16, nodes.size());
    assertEquals(9, parentNode.getChildren().size());
    assertHasChildren(parentNode, task0_1.getId(), task0_2.getId(), task0_3.getId(), lane1.getId(), lane2.getId(), lane3_2.getId(), lane3_1_2.getId(), lane3_1_1_1.getId(), lane3_1_1_2.getId());
    BpmnNode lane1Node = getChildById(parentNode, lane1.getId());
    assertNotNull(lane1Node);
    assertHasChildren(lane1Node, task1_1.getId());
    BpmnNode lane2Node = getChildById(parentNode, lane2.getId());
    assertNotNull(lane2Node);
    assertHasChildren(lane2Node, task2_1.getId());
    BpmnNode lane3_1_1_1Node = getChildById(parentNode, lane3_1_1_1.getId());
    assertNotNull(lane3_1_1_1Node);
    assertHasChildren(lane3_1_1_1Node, task3_1_1_1_1.getId());
    BpmnNode lane3_1_1_2Node = getChildById(parentNode, lane3_1_1_2.getId());
    assertNotNull(lane3_1_1_2Node);
    assertHasChildren(lane3_1_1_2Node, task3_1_1_2_1.getId());
    BpmnNode lane3_1_2Node = getChildById(parentNode, lane3_1_2.getId());
    assertNotNull(lane3_1_2Node);
    assertHasChildren(lane3_1_2Node, task3_1_2_1.getId());
    BpmnNode lane3_2Node = getChildById(parentNode, lane3_2.getId());
    assertHasChildren(lane3_2Node);
    assertHasChildren(lane3_2Node, task3_2_1.getId(), task3_2_2.getId());
    // assert messages for converted lane sets
    List<MarshallingMessage> messages = result.messages();
    assertEquals(4, messages.size());
    assertTrue(messages.stream().map(MarshallingMessage::getMessageKey).allMatch(MarshallingMessageKeys.childLaneSetConverted::equals));
}
Also used : MarshallingMessage(org.kie.workbench.common.stunner.core.marshaller.MarshallingMessage) Task(org.eclipse.bpmn2.Task) ManualTask(org.eclipse.bpmn2.ManualTask) Lane(org.eclipse.bpmn2.Lane) LaneSet(org.eclipse.bpmn2.LaneSet) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) FlowElement(org.eclipse.bpmn2.FlowElement) MarshallingMessageKeys(org.kie.workbench.common.stunner.core.marshaller.MarshallingMessageKeys) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 38 with Task

use of com.google.cloud.tasks.v2.Task in project kie-wb-common by kiegroup.

the class ProcessConverterDelegateTest method testConvertEdges.

@Test
public void testConvertEdges() {
    Task task1 = mockTask("1");
    Task task2 = mockTask("2");
    BpmnNode task1Node = mockTaskNode(task1);
    BpmnNode task2Node = mockTaskNode(task2);
    SequenceFlow sequenceFlow = mockSequenceFlow("seq1", task1, task2);
    List<BaseElement> elements = Arrays.asList(sequenceFlow, task1, task2);
    // ignored because there the tasks are not on the nodes map
    assertFalse(converterDelegate.convertEdges(parentNode, elements, new HashMap<>()).value());
    // convert with all nodes
    Map<String, BpmnNode> nodes = new Maps.Builder<String, BpmnNode>().put(task1.getId(), task1Node).put(task2.getId(), task2Node).build();
    assertTrue(converterDelegate.convertEdges(parentNode, elements, nodes).value());
}
Also used : BaseElement(org.eclipse.bpmn2.BaseElement) Task(org.eclipse.bpmn2.Task) ManualTask(org.eclipse.bpmn2.ManualTask) Maps(org.kie.soup.commons.util.Maps) SequenceFlow(org.eclipse.bpmn2.SequenceFlow) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) Test(org.junit.Test)

Example 39 with Task

use of com.google.cloud.tasks.v2.Task in project openstack4j by ContainX.

the class ImageV2Tests method getTask.

public void getTask() throws IOException {
    respondWith(TASK_JSON);
    String id = "78925244-2951-462d-b979-773a49274d7f";
    Task task = osv3().imagesV2().tasks().get(id);
    assertNotNull(task);
    assertEquals(task.getId(), id);
    assertEquals(task.getType(), "import");
}
Also used : Task(org.openstack4j.model.image.v2.Task)

Example 40 with Task

use of com.google.cloud.tasks.v2.Task in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method revisitTaskAssociations.

public void revisitTaskAssociations(Definitions def) {
    List<RootElement> rootElements = def.getRootElements();
    for (RootElement root : rootElements) {
        if (root instanceof Process) {
            Process process = (Process) root;
            List<FlowElement> flowElements = process.getFlowElements();
            for (FlowElement fe : flowElements) {
                if (fe instanceof Task) {
                    Task t = (Task) fe;
                    if (t.getDataInputAssociations() != null) {
                        List<DataInputAssociation> inputList = t.getDataInputAssociations();
                        if (inputList != null) {
                            for (DataInputAssociation input : inputList) {
                                List<ItemAwareElement> sourceRef = input.getSourceRef();
                                if (sourceRef != null) {
                                    for (ItemAwareElement iae : sourceRef) {
                                        String[] iaeParts = iae.getId().split("\\.");
                                        if (iaeParts.length > 1) {
                                        // FormalExpression dataInputTransformationExpression = Bpmn2Factory.eINSTANCE.createFormalExpression();
                                        // dataInputTransformationExpression.setBody(iae.getId());
                                        // input.setTransformation(dataInputTransformationExpression);
                                        // iae.setId(iaeParts[0]);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (t.getDataOutputAssociations() != null) {
                        List<DataOutputAssociation> outputList = t.getDataOutputAssociations();
                        if (outputList != null) {
                            for (DataOutputAssociation output : outputList) {
                                ItemAwareElement targetEle = output.getTargetRef();
                                if (targetEle != null) {
                                    String[] targetEleParts = targetEle.getId().split("\\.");
                                    if (targetEleParts.length > 1) {
                                    // FormalExpression dataOutputTransformationExpression = Bpmn2Factory.eINSTANCE.createFormalExpression();
                                    // dataOutputTransformationExpression.setBody(targetEle.getId());
                                    // output.setTransformation(dataOutputTransformationExpression);
                                    // targetEle.setId(targetEleParts[0]);
                                    }
                                }
                            }
                        }
                    }
                    if (t.getIoSpecification() != null) {
                        InputOutputSpecification ios = t.getIoSpecification();
                        if (ios.getInputSets() == null || ios.getInputSets().size() < 1) {
                            InputSet inset = Bpmn2Factory.eINSTANCE.createInputSet();
                            ios.getInputSets().add(inset);
                        }
                        if (ios.getOutputSets() == null) {
                            if (ios.getOutputSets() == null || ios.getOutputSets().size() < 1) {
                                OutputSet outset = Bpmn2Factory.eINSTANCE.createOutputSet();
                                ios.getOutputSets().add(outset);
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : OutputSet(org.eclipse.bpmn2.OutputSet) ServiceTask(org.eclipse.bpmn2.ServiceTask) ReceiveTask(org.eclipse.bpmn2.ReceiveTask) SendTask(org.eclipse.bpmn2.SendTask) GlobalTask(org.eclipse.bpmn2.GlobalTask) BusinessRuleTask(org.eclipse.bpmn2.BusinessRuleTask) Task(org.eclipse.bpmn2.Task) ScriptTask(org.eclipse.bpmn2.ScriptTask) UserTask(org.eclipse.bpmn2.UserTask) InputOutputSpecification(org.eclipse.bpmn2.InputOutputSpecification) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process) InputSet(org.eclipse.bpmn2.InputSet) RootElement(org.eclipse.bpmn2.RootElement) FlowElement(org.eclipse.bpmn2.FlowElement) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation)

Aggregations

Task (com.google.cloud.tasks.v2.Task)33 Test (org.junit.jupiter.api.Test)23 Task (org.eclipse.bpmn2.Task)17 Test (org.junit.Test)14 CloudTasksClient (com.google.cloud.tasks.v2.CloudTasksClient)11 Task (io.fabric8.tekton.pipeline.v1beta1.Task)8 ByteString (com.google.protobuf.ByteString)7 IOException (java.io.IOException)6 Optional (java.util.Optional)5 FlowElement (org.eclipse.bpmn2.FlowElement)5 InputSet (org.eclipse.bpmn2.InputSet)5 AssignmentsInfo (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo)5 Queue (com.google.cloud.tasks.v2.Queue)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)4 BusinessRuleTask (org.eclipse.bpmn2.BusinessRuleTask)4 GlobalTask (org.eclipse.bpmn2.GlobalTask)4 OutputSet (org.eclipse.bpmn2.OutputSet)4 Process (org.eclipse.bpmn2.Process)4