use of org.kie.workbench.common.stunner.core.graph.Graph in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest method testMarshallEndMessageEvent.
@Test
public void testMarshallEndMessageEvent() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_ENDMESSAGEEVENT);
String result = tested.marshall(diagram);
assertDiagram(result, 1, 1, 0);
assertTrue(result.contains("<bpmn2:endEvent id=\"_4A8A0A9E-D4A5-4B6E-94A6-20817A57B3C6\""));
assertTrue(result.contains(" name=\"EndMessageEvent\""));
assertTrue(result.contains("<bpmn2:message "));
assertTrue(result.contains(" name=\"msgref\""));
assertTrue(result.contains("<bpmn2:messageEventDefinition"));
}
use of org.kie.workbench.common.stunner.core.graph.Graph 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);
}
use of org.kie.workbench.common.stunner.core.graph.Graph 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);
}
use of org.kie.workbench.common.stunner.core.graph.Graph 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());
}
use of org.kie.workbench.common.stunner.core.graph.Graph in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method getNodes.
private List<Node> getNodes(Diagram<Graph, Metadata> diagram) {
Graph graph = diagram.getGraph();
assertNotNull(graph);
Iterator<Node> nodesIterable = graph.nodes().iterator();
List<Node> nodes = new ArrayList<>();
nodesIterable.forEachRemaining(nodes::add);
return nodes;
}
Aggregations