Search in sources :

Example 81 with Graph

use of org.kie.workbench.common.stunner.core.graph.Graph in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testUnmarshallNotBoundaryEvents.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallNotBoundaryEvents() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_NOT_BOUNDARY_EVENTS);
    assertEquals("Not Boundary Event", diagram.getMetadata().getTitle());
    assertDiagram(diagram, 6);
    // Assert than the intermediate event is connected using a view connector,
    // so not boundary to the task ( not docked ).
    Node event = diagram.getGraph().getNode("_CB178D55-8DC2-4CAA-8C42-4F5028D4A1F6");
    List<Edge> inEdges = event.getInEdges();
    boolean foundViewConnector = false;
    for (Edge e : inEdges) {
        if (e.getContent() instanceof ViewConnector) {
            foundViewConnector = true;
        }
    }
    assertTrue(foundViewConnector);
    // Assert absolute position as the node is not docked.
    Bounds bounds = ((View) event.getContent()).getBounds();
    Bounds.Bound ul = bounds.getUpperLeft();
    Bounds.Bound lr = bounds.getLowerRight();
    assertEquals(305, ul.getX(), 0);
    assertEquals(300, ul.getY(), 0);
    assertEquals(335, lr.getX(), 0);
    assertEquals(330, lr.getY(), 0);
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) Node(org.kie.workbench.common.stunner.core.graph.Node) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Edge(org.kie.workbench.common.stunner.core.graph.Edge) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 82 with Graph

use of org.kie.workbench.common.stunner.core.graph.Graph in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testMarshallIntermediateMessageEventCatching.

@Test
public void testMarshallIntermediateMessageEventCatching() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_INTERMEDIATE_MESSAGE_EVENTCATCHING);
    String result = tested.marshall(diagram);
    assertDiagram(result, 1, 1, 0);
    assertTrue(result.contains("<bpmn2:intermediateCatchEvent"));
    assertTrue(result.contains(" name=\"IntermediateMessageEventCatching\""));
    assertTrue(result.contains("<bpmn2:message "));
    assertTrue(result.contains(" name=\"msgref1\""));
    assertTrue(result.contains("<bpmn2:messageEventDefinition"));
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 83 with Graph

use of org.kie.workbench.common.stunner.core.graph.Graph in project kie-wb-common by kiegroup.

the class BPMNGraphGenerator method createGraph.

public Graph<DefinitionSet, Node> createGraph() {
    Graph<DefinitionSet, Node> graph = (Graph<DefinitionSet, Node>) factoryManager.newElement(UUID.uuid(), diagramDefinitionSetClass);
    // TODO: Where are the BPMN diagram bounds in the Oryx json structure? Exist?
    if (null == graph.getContent().getBounds()) {
        graph.getContent().setBounds(new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(BPMNGraphFactory.GRAPH_DEFAULT_WIDTH, BPMNGraphFactory.GRAPH_DEFAULT_HEIGHT)));
    }
    builderContext.init(graph).execute(builderContext.getCommandFactory().clearGraph());
    NodeObjectBuilder diagramBuilder = getDiagramBuilder(builderContext);
    if (diagramBuilder == null) {
        throw new RuntimeException("No diagrams found!");
    }
    Node<View<BPMNDefinition>, Edge> diagramNode = (Node<View<BPMNDefinition>, Edge>) diagramBuilder.build(builderContext);
    graph.addNode(diagramNode);
    logBuilders();
    return graph;
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) TreeNode(com.fasterxml.jackson.core.TreeNode) Node(org.kie.workbench.common.stunner.core.graph.Node) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) BPMNDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNDefinition) DefinitionSet(org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSet) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge)

Example 84 with Graph

use of org.kie.workbench.common.stunner.core.graph.Graph in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testUnmarshallStartTimerEvent.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallStartTimerEvent() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_STARTTIMEREVENT);
    assertDiagram(diagram, 4);
    assertEquals("StartTimerEvent", diagram.getMetadata().getTitle());
    Node<? extends Definition, ?> startTimerEventNode = diagram.getGraph().getNode("_49ADC988-B63D-4AEB-B811-67969F305FD0");
    StartTimerEvent startTimerEvent = (StartTimerEvent) startTimerEventNode.getContent().getDefinition();
    IsInterrupting isInterrupting = startTimerEvent.getExecutionSet().getIsInterrupting();
    assertEquals(false, isInterrupting.getValue());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) StartTimerEvent(org.kie.workbench.common.stunner.bpmn.definition.StartTimerEvent) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) IsInterrupting(org.kie.workbench.common.stunner.bpmn.definition.property.event.IsInterrupting) Test(org.junit.Test)

Example 85 with Graph

use of org.kie.workbench.common.stunner.core.graph.Graph in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testMarshallIntermediatErrorEventCatching.

@Test
public void testMarshallIntermediatErrorEventCatching() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_INTERMEDIATE_ERROR_EVENTCATCHING);
    String result = tested.marshall(diagram);
    assertDiagram(result, 1, 1, 0);
    assertTrue(result.contains("<bpmn2:intermediateCatchEvent"));
    assertTrue(result.contains(" name=\"MyErrorCatchingEvent\""));
    assertTrue(result.contains("<bpmn2:errorEventDefinition"));
    assertTrue(result.contains("errorRef=\"MyError\""));
    assertTrue(result.contains("<bpmn2:error"));
    assertTrue(result.contains("id=\"MyError\""));
    assertTrue(result.contains("errorCode=\"MyError\""));
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

Graph (org.kie.workbench.common.stunner.core.graph.Graph)190 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)162 Test (org.junit.Test)152 Matchers.anyString (org.mockito.Matchers.anyString)54 View (org.kie.workbench.common.stunner.core.graph.content.view.View)45 Element (org.kie.workbench.common.stunner.core.graph.Element)31 AssignmentsInfo (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo)30 Node (org.kie.workbench.common.stunner.core.graph.Node)30 Edge (org.kie.workbench.common.stunner.core.graph.Edge)29 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)28 RootElement (org.eclipse.bpmn2.RootElement)28 DataIOSet (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet)28 FlowElement (org.eclipse.bpmn2.FlowElement)26 UserTask (org.kie.workbench.common.stunner.bpmn.definition.UserTask)17 ArrayList (java.util.ArrayList)14 List (java.util.List)13 ViewConnector (org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector)13 MessageRef (org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef)10 Optional (java.util.Optional)9 Definitions (org.eclipse.bpmn2.Definitions)9