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);
}
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"));
}
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;
}
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());
}
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\""));
}
Aggregations