Search in sources :

Example 81 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshallerTest method testMarshallMagnetDockers.

@Test
public void testMarshallMagnetDockers() throws Exception {
    Diagram<Graph, Metadata> diagram1 = unmarshall(BPMN_MAGNETDOCKERS);
    String result = tested.marshall(diagram1);
    assertDiagram(result, 1, 8, 7);
    Diagram<Graph, Metadata> diagram2 = unmarshall(new ByteArrayInputStream(result.getBytes()));
    testMagnetDockers(diagram2);
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) ByteArrayInputStream(java.io.ByteArrayInputStream) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Test(org.junit.Test)

Example 82 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshallerTest method testMarshallMagnetsInlane.

@Test
public void testMarshallMagnetsInlane() throws Exception {
    Diagram<Graph, Metadata> diagram1 = unmarshall(BPMN_MAGNETSINLANE);
    String result = tested.marshall(diagram1);
    assertDiagram(result, 1, 6, 4);
    // Check the waypoints are as in the original process
    assertTrue(result.contains("<di:waypoint xsi:type=\"dc:Point\" x=\"371.0\" y=\"86.0\"/>"));
    assertTrue(result.contains("<di:waypoint xsi:type=\"dc:Point\" x=\"406.0\" y=\"324.0\"/>"));
    assertTrue(result.contains("<di:waypoint xsi:type=\"dc:Point\" x=\"692.0\" y=\"276.0\"/>"));
    assertTrue(result.contains("<di:waypoint xsi:type=\"dc:Point\" x=\"805.0\" y=\"76.0\"/>"));
    assertTrue(result.contains("<di:waypoint xsi:type=\"dc:Point\" x=\"81.0\" y=\"86.0\"/>"));
    assertTrue(result.contains("<di:waypoint xsi:type=\"dc:Point\" x=\"235.0\" y=\"86.0\"/>"));
    assertTrue(result.contains("<di:waypoint xsi:type=\"dc:Point\" x=\"474.0\" y=\"372.0\"/>"));
    assertTrue(result.contains("<di:waypoint xsi:type=\"dc:Point\" x=\"556.0\" y=\"276.0\"/>"));
    // Test unmarshall
    Diagram<Graph, Metadata> diagram2 = unmarshall(new ByteArrayInputStream(result.getBytes()));
    testMagnetsInLane(diagram2);
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) ByteArrayInputStream(java.io.ByteArrayInputStream) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Test(org.junit.Test)

Example 83 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshallerTest method testUnmarshallSequenceFlow.

@Test
public void testUnmarshallSequenceFlow() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_SEQUENCEFLOW);
    SequenceFlow sequenceFlow1 = null;
    SequenceFlow sequenceFlow2 = null;
    Iterator<Element> it = nodesIterator(diagram);
    while (it.hasNext()) {
        Element element = it.next();
        if (element.getContent() instanceof View) {
            Object oDefinition = ((View) element.getContent()).getDefinition();
            if (oDefinition instanceof ExclusiveGateway) {
                List<Edge> outEdges = ((NodeImpl) element).getOutEdges();
                for (Edge edge : outEdges) {
                    SequenceFlow flow = (SequenceFlow) ((ViewConnectorImpl) edge.getContent()).getDefinition();
                    if ("route1".equals(flow.getGeneral().getName().getValue())) {
                        sequenceFlow1 = flow;
                    }
                    if ("route2".equals(flow.getGeneral().getName().getValue())) {
                        sequenceFlow2 = flow;
                    }
                }
            }
        }
    }
    assertNotNull(sequenceFlow1);
    assertNotNull(sequenceFlow1.getExecutionSet());
    assertNotNull(sequenceFlow1.getExecutionSet().getConditionExpression());
    assertNotNull(sequenceFlow1.getExecutionSet().getPriority());
    assertNotNull(sequenceFlow1.getGeneral());
    assertNotNull(sequenceFlow1.getGeneral().getName());
    assertEquals("route1", sequenceFlow1.getGeneral().getName().getValue());
    assertEquals("age >= 10;", sequenceFlow1.getExecutionSet().getConditionExpression().getValue().getScript());
    assertEquals("javascript", sequenceFlow1.getExecutionSet().getConditionExpression().getValue().getLanguage());
    assertEquals("2", sequenceFlow1.getExecutionSet().getPriority().getValue());
    assertNotNull(sequenceFlow2);
    assertNotNull(sequenceFlow2.getExecutionSet());
    assertNotNull(sequenceFlow2.getExecutionSet().getConditionExpression());
    assertNotNull(sequenceFlow2.getExecutionSet().getPriority());
    assertNotNull(sequenceFlow2.getGeneral());
    assertNotNull(sequenceFlow2.getGeneral().getName());
    assertEquals("route2", sequenceFlow2.getGeneral().getName().getValue());
    assertEquals("age\n" + "<\n" + "10;", sequenceFlow2.getExecutionSet().getConditionExpression().getValue().getScript());
    assertEquals("java", sequenceFlow2.getExecutionSet().getConditionExpression().getValue().getLanguage());
    assertEquals("1", sequenceFlow2.getExecutionSet().getPriority().getValue());
}
Also used : ExclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway) Graph(org.kie.workbench.common.stunner.core.graph.Graph) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) FlowElement(org.eclipse.bpmn2.FlowElement) RootElement(org.eclipse.bpmn2.RootElement) Element(org.kie.workbench.common.stunner.core.graph.Element) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 84 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshallerTest method testUnmarshallEndSignalEvent.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallEndSignalEvent() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_ENDSIGNALEVENT);
    assertDiagram(diagram, 2);
    assertEquals("EndEventAssignments", diagram.getMetadata().getTitle());
    Node<? extends Definition, ?> endSignalEventNode = diagram.getGraph().getNode("_C9151E0C-2E3E-4558-AFC2-34038E3A8552");
    EndSignalEvent endSignalEvent = (EndSignalEvent) endSignalEventNode.getContent().getDefinition();
    DataIOSet dataIOSet = endSignalEvent.getDataIOSet();
    AssignmentsInfo assignmentsinfo = dataIOSet.getAssignmentsinfo();
    assertEquals("EndSignalEventInput1:String||||[din]employee->EndSignalEventInput1", assignmentsinfo.getValue());
    assertEquals("project", endSignalEvent.getExecutionSet().getSignalScope().getValue());
    assertEquals("employee", endSignalEvent.getExecutionSet().getSignalRef().getValue());
}
Also used : DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) Graph(org.kie.workbench.common.stunner.core.graph.Graph) EndSignalEvent(org.kie.workbench.common.stunner.bpmn.definition.EndSignalEvent) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Test(org.junit.Test)

Example 85 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshallerTest method testUnmarshallEventSubprocess.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallEventSubprocess() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_EVENT_SUBPROCESS);
    assertDiagram(diagram, 2);
    assertEquals("EventSubProcess", diagram.getMetadata().getTitle());
    Node<? extends Definition, ?> eventSubprocessNode = diagram.getGraph().getNode("_DF031493-5F1C-4D2B-9916-2FEABB1FADFF");
    EventSubprocess eventSubprocess = (EventSubprocess) eventSubprocessNode.getContent().getDefinition();
    assertTrue(eventSubprocess.getIsAsync().getValue());
    assertEquals(eventSubprocess.getProcessData().getProcessVariables().getValue(), "Var1:String");
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) EventSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EventSubprocess) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Test(org.junit.Test)

Aggregations

Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)175 Graph (org.kie.workbench.common.stunner.core.graph.Graph)158 Test (org.junit.Test)156 Matchers.anyString (org.mockito.Matchers.anyString)53 View (org.kie.workbench.common.stunner.core.graph.content.view.View)32 AssignmentsInfo (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo)30 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)28 RootElement (org.eclipse.bpmn2.RootElement)28 DataIOSet (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet)28 Element (org.kie.workbench.common.stunner.core.graph.Element)27 FlowElement (org.eclipse.bpmn2.FlowElement)26 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)16 UserTask (org.kie.workbench.common.stunner.bpmn.definition.UserTask)14 Edge (org.kie.workbench.common.stunner.core.graph.Edge)14 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)11 StartErrorEvent (org.kie.workbench.common.stunner.bpmn.definition.StartErrorEvent)10 MessageRef (org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef)10 StartSignalEvent (org.kie.workbench.common.stunner.bpmn.definition.StartSignalEvent)9 StartTimerEvent (org.kie.workbench.common.stunner.bpmn.definition.StartTimerEvent)9 Node (org.kie.workbench.common.stunner.core.graph.Node)9