Search in sources :

Example 36 with FlowElement

use of org.eclipse.bpmn2.FlowElement in project kie-wb-common by kiegroup.

the class IntermediateCompensationEventPostConverterTest method testProcessWhenOutEdgeExists.

@Test
@SuppressWarnings("unchecked")
public void testProcessWhenOutEdgeExists() {
    String uuid = "UUID";
    Edge edge = mock(Edge.class);
    Node targetNode = mock(Node.class);
    when(targetNode.getUUID()).thenReturn(uuid);
    List outEdges = new ArrayList<>();
    outEdges.add(edge);
    when(node.getOutEdges()).thenReturn(outEdges);
    Activity activity = mock(Activity.class);
    when(activity.getId()).thenReturn(uuid);
    when(edge.getTargetNode()).thenReturn(targetNode);
    List<FlowElement> flowElements = Collections.singletonList(activity);
    when(process.getFlowElements()).thenReturn(flowElements);
    converter.process(processWriter, nodeWriter, (Node) node);
    verify(activity).setIsForCompensation(true);
}
Also used : FlowElement(org.eclipse.bpmn2.FlowElement) Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) Activity(org.eclipse.bpmn2.Activity) ArrayList(java.util.ArrayList) List(java.util.List) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 37 with FlowElement

use of org.eclipse.bpmn2.FlowElement in project kie-wb-common by kiegroup.

the class ProcessesTest method setUp.

@Before
public void setUp() {
    when(propertyWriter.getRootElements()).thenReturn(propertyWriterRootElements);
    when(propertyWriter.getSimulationParameters()).thenReturn(propertyWriterElementParameters);
    when(propertyWriter.getItemDefinitions()).thenReturn(propertyWriterItemDefinitions);
    when(boundaryEventPropertyWriter.getRootElements()).thenReturn(propertyWriterRootElements);
    when(boundaryEventPropertyWriter.getSimulationParameters()).thenReturn(propertyWriterElementParameters);
    when(boundaryEventPropertyWriter.getItemDefinitions()).thenReturn(propertyWriterItemDefinitions);
    flowElement = new FlowElementImpl() {
    };
    flowElement.setId(ELEMENT_ID);
    artifact = new ArtifactImpl() {
    };
    artifact.setId(ELEMENT_ID);
    when(process.getFlowElements()).thenReturn(flowElements);
    when(process.getArtifacts()).thenReturn(artifacts);
    when(subProcess.getFlowElements()).thenReturn(flowElements);
    when(subProcess.getArtifacts()).thenReturn(artifacts);
}
Also used : ArtifactImpl(org.eclipse.bpmn2.impl.ArtifactImpl) FlowElementImpl(org.eclipse.bpmn2.impl.FlowElementImpl) Before(org.junit.Before)

Example 38 with FlowElement

use of org.eclipse.bpmn2.FlowElement in project kie-wb-common by kiegroup.

the class BPMNElementDecoratorsTest method flowElementDecorator.

@Test
public void flowElementDecorator() {
    MarshallingMessageDecorator<FlowElement> decorator = BPMNElementDecorators.flowElementDecorator();
    FlowElement element = mock(FlowElement.class);
    when(element.getName()).thenReturn(NAME);
    assertEquals(NAME, decorator.getName(element));
    assertEquals(element.getClass().getSimpleName(), decorator.getType(element));
}
Also used : FlowElement(org.eclipse.bpmn2.FlowElement) Test(org.junit.Test)

Example 39 with FlowElement

use of org.eclipse.bpmn2.FlowElement in project kie-wb-common by kiegroup.

the class AssociationsTest method marshallAssociations.

@Test
public void marshallAssociations() throws Exception {
    Diagram<Graph, Metadata> d = unmarshall(marshaller, BPMN_FILE_PATH);
    DefinitionsConverter definitionsConverter = new DefinitionsConverter(d.getGraph());
    Definitions definitions = definitionsConverter.toDefinitions();
    Process p = (Process) definitions.getRootElements().get(0);
    org.eclipse.bpmn2.UserTask flowElement = (org.eclipse.bpmn2.UserTask) p.getFlowElements().stream().filter(e -> e.getId().equals(TASK_ID)).findFirst().get();
    List<DataInputAssociation> associations = flowElement.getDataInputAssociations();
    assertEquals("myprocvar", findVar(associations, "From"));
    assertEquals("<![CDATA[HELLO]]>", findAssignment(associations, "Body"));
}
Also used : StartEvent(org.eclipse.bpmn2.StartEvent) FormalExpression(org.eclipse.bpmn2.FormalExpression) FlatVariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) View(org.kie.workbench.common.stunner.core.graph.content.view.View) HashSet(java.util.HashSet) DataInput(org.eclipse.bpmn2.DataInput) Property(org.eclipse.bpmn2.Property) DefinitionsConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Definitions(org.eclipse.bpmn2.Definitions) Ids(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Ids) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) Process(org.eclipse.bpmn2.Process) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) Factories.bpmn2(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpmn2) Test(org.junit.Test) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) List(java.util.List) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Assignment(org.eclipse.bpmn2.Assignment) CatchEventPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.CatchEventPropertyWriter) BPMNDiagramMarshallerBaseTest(org.kie.workbench.common.stunner.bpmn.backend.service.diagram.marshalling.BPMNDiagramMarshallerBaseTest) Node(org.kie.workbench.common.stunner.core.graph.Node) TestCase.assertEquals(junit.framework.TestCase.assertEquals) Definitions(org.eclipse.bpmn2.Definitions) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) Process(org.eclipse.bpmn2.Process) DefinitionsConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Factories.bpmn2(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpmn2) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) Test(org.junit.Test) BPMNDiagramMarshallerBaseTest(org.kie.workbench.common.stunner.bpmn.backend.service.diagram.marshalling.BPMNDiagramMarshallerBaseTest)

Example 40 with FlowElement

use of org.eclipse.bpmn2.FlowElement 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)

Aggregations

FlowElement (org.eclipse.bpmn2.FlowElement)35 SubProcess (org.eclipse.bpmn2.SubProcess)22 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)19 Process (org.eclipse.bpmn2.Process)19 ArrayList (java.util.ArrayList)16 FlowElementsContainer (org.eclipse.bpmn2.FlowElementsContainer)15 RootElement (org.eclipse.bpmn2.RootElement)14 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)13 Entry (java.util.Map.Entry)12 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)12 Activity (org.eclipse.bpmn2.Activity)9 List (java.util.List)8 CallActivity (org.eclipse.bpmn2.CallActivity)8 DataObject (org.eclipse.bpmn2.DataObject)8 SequenceFlow (org.eclipse.bpmn2.SequenceFlow)8 Artifact (org.eclipse.bpmn2.Artifact)7 FlowNode (org.eclipse.bpmn2.FlowNode)7 Bounds (org.eclipse.dd.dc.Bounds)7 Test (org.junit.Test)7 BoundaryEvent (org.eclipse.bpmn2.BoundaryEvent)6