use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testMagnetsInLane.
private void testMagnetsInLane(Diagram<Graph, Metadata> diagram) throws Exception {
Node userTaskNode = (Node) findElementByContentType(diagram, UserTask.class);
Node scriptTaskNode = (Node) findElementByContentType(diagram, ScriptTask.class);
assertNotNull(userTaskNode);
assertNotNull(scriptTaskNode);
ViewConnector userTaskInEdgeConnector = getInEdgeViewConnector(userTaskNode);
ViewConnector scriptTaskInEdgeConnector = getInEdgeViewConnector(scriptTaskNode);
assertNotNull(userTaskInEdgeConnector);
assertNotNull(scriptTaskInEdgeConnector);
ViewConnector userTaskOutEdgeConnector = getOutEdgeViewConnector(userTaskNode);
ViewConnector scriptTaskOutEdgeConnector = getOutEdgeViewConnector(scriptTaskNode);
assertNotNull(userTaskOutEdgeConnector);
assertNotNull(scriptTaskOutEdgeConnector);
// userTaskInEdgeConnector is from magnet right-middle to middle-top
assertTrue(userTaskInEdgeConnector.getSourceConnection().isPresent());
assertTrue(userTaskInEdgeConnector.getTargetConnection().isPresent());
Connection sourceConnection = (Connection) userTaskInEdgeConnector.getSourceConnection().get();
Connection targetConnection = (Connection) userTaskInEdgeConnector.getTargetConnection().get();
assertEquals(136d, sourceConnection.getLocation().getX(), 0.1d);
assertEquals(24d, sourceConnection.getLocation().getY(), 0.1d);
assertEquals(68d, targetConnection.getLocation().getX(), 0.1d);
assertEquals(0d, targetConnection.getLocation().getY(), 0.1d);
// scriptTaskInEdgeConnector is from magnet right-bottom to left-top
assertTrue(scriptTaskInEdgeConnector.getSourceConnection().isPresent());
assertTrue(scriptTaskInEdgeConnector.getTargetConnection().isPresent());
sourceConnection = (Connection) scriptTaskInEdgeConnector.getSourceConnection().get();
targetConnection = (Connection) scriptTaskInEdgeConnector.getTargetConnection().get();
assertEquals(136d, sourceConnection.getLocation().getX(), 0.1d);
assertEquals(48d, sourceConnection.getLocation().getY(), 0.1d);
assertEquals(0d, targetConnection.getLocation().getX(), 0.1d);
assertEquals(0d, targetConnection.getLocation().getY(), 0.1d);
// userTaskOutEdgeConnector is from magnet right-bottom to left-top
assertTrue(userTaskOutEdgeConnector.getSourceConnection().isPresent());
assertTrue(userTaskOutEdgeConnector.getTargetConnection().isPresent());
sourceConnection = (Connection) userTaskOutEdgeConnector.getSourceConnection().get();
targetConnection = (Connection) userTaskOutEdgeConnector.getTargetConnection().get();
assertEquals(136d, sourceConnection.getLocation().getX(), 0.1d);
assertEquals(48d, sourceConnection.getLocation().getY(), 0.1d);
assertEquals(0d, targetConnection.getLocation().getX(), 0.1d);
assertEquals(0d, targetConnection.getLocation().getY(), 0.1d);
// scriptTaskOutEdgeConnector is from magnet right-top to left-middle
assertTrue(scriptTaskOutEdgeConnector.getSourceConnection().isPresent());
assertTrue(scriptTaskOutEdgeConnector.getTargetConnection().isPresent());
sourceConnection = (Connection) scriptTaskOutEdgeConnector.getSourceConnection().get();
targetConnection = (Connection) scriptTaskOutEdgeConnector.getTargetConnection().get();
assertEquals(136d, sourceConnection.getLocation().getX(), 0.1d);
assertEquals(0d, sourceConnection.getLocation().getY(), 0.1d);
assertEquals(0d, targetConnection.getLocation().getX(), 0.1d);
assertEquals(14d, targetConnection.getLocation().getY(), 0.1d);
}
use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.
the class MigrationDiagramMarshallerTest method assertNodeEquals.
private void assertNodeEquals(Diagram<Graph, Metadata> oldDiagram, Diagram<Graph, Metadata> newDiagram, String fileName) {
Map<String, Node<View, ?>> oldNodes = asNodeMap(oldDiagram.getGraph().nodes());
Map<String, Node<View, ?>> newNodes = asNodeMap(newDiagram.getGraph().nodes());
assertEquals(fileName + ": Number of nodes should match", oldNodes.size(), newNodes.size());
for (Node<View, ?> o : oldNodes.values()) {
Node<View, ?> n = newNodes.get(o.getUUID());
View oldContent = o.getContent();
View newContent = n.getContent();
Bounds oldBounds = oldContent.getBounds();
Bounds newBounds = newContent.getBounds();
assertEquals(fileName + ": Bounds should match for " + o.getUUID(), oldBounds, newBounds);
Object oldDefinition = oldContent.getDefinition();
Object newDefinition = newContent.getDefinition();
assertEquals(fileName + ": Definitions should match for " + o.getUUID(), oldDefinition, newDefinition);
}
}
use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.
the class MigrationDiagramMarshallerTest method asNodeMap.
private Map<String, Node<View, ?>> asNodeMap(Iterable nodes) {
Map<String, Node<View, ?>> oldNodes = new HashMap<>();
nodes.forEach(n -> {
Node n1 = (Node) n;
oldNodes.put(n1.getUUID(), n1);
});
return oldNodes;
}
use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.
the class Unmarshalling method unmarshall.
public static Diagram<Graph, Metadata> unmarshall(DiagramMarshaller tested, InputStream is) throws Exception {
Metadata metadata = new MetadataImpl.MetadataImplBuilder(BindableAdapterUtils.getDefinitionSetId(BPMNDefinitionSet.class)).build();
DiagramImpl diagram = new DiagramImpl(UUID.uuid(), metadata);
Graph<DefinitionSet, Node> graph = tested.unmarshall(metadata, is);
diagram.setGraph(graph);
return diagram;
}
use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerBase method assertNodeEquals.
private void assertNodeEquals(Diagram<Graph, Metadata> oldDiagram, Diagram<Graph, Metadata> newDiagram, String fileName) {
Map<String, Node<View, ?>> oldNodes = asNodeMap(oldDiagram.getGraph().nodes());
Map<String, Node<View, ?>> newNodes = asNodeMap(newDiagram.getGraph().nodes());
assertEquals(fileName + ": Number of nodes should match", oldNodes.size(), newNodes.size());
for (Node<View, ?> o : oldNodes.values()) {
Node<View, ?> n = newNodes.get(o.getUUID());
View oldContent = o.getContent();
View newContent = n.getContent();
Bounds oldBounds = oldContent.getBounds();
Bounds newBounds = newContent.getBounds();
assertEquals(fileName + ": Bounds should match for " + o.getUUID(), oldBounds, newBounds);
Object oldDefinition = oldContent.getDefinition();
Object newDefinition = newContent.getDefinition();
assertEquals(fileName + ": Definitions should match for " + o.getUUID(), oldDefinition, newDefinition);
}
}
Aggregations