@Test public void layoutRadial() { Graph graph = interpreter.create(new Shell(), SWT.NONE, "graph Sample{graph[layout=radial];1;}"); Assert.assertNotNull("Created graph must not be null", graph); Assert.assertEquals(RadialLayoutAlgorithm.class, graph.getLayoutAlgorithm().getClass()); }
@Test public void globalNodeLabel() { Graph graph = interpreter.create(new Shell(), SWT.NONE, "graph Sample{node[label=\"Node1\"];1;}"); Assert.assertNotNull("Created graph must not be null", graph); Assert.assertEquals("Node1", ((GraphNode) graph.getNodes().get(0)).getText()); }
@Test public void globalEdgeLabel() { Graph graph = interpreter.create(new Shell(), SWT.NONE, "graph Sample{edge[label=\"Edge1\"];1;2;1->2}"); Assert.assertNotNull("Created graph must not be null", graph); Assert.assertEquals("Edge1", ((GraphConnection) graph.getConnections().get(0)).getText()); }
@Test public void digraphType() { Shell shell = new Shell(); Graph graph = interpreter.create(shell, SWT.NONE, "digraph Sample{1;2;1->2}"); Assert.assertNotNull("Created graph must not be null", graph); Assert.assertEquals(ZestStyles.CONNECTIONS_DIRECTED, graph.getConnectionStyle()); // open(shell); }
@Test public void globalEdgeStyle() { Shell parent = new Shell(); Graph graph = interpreter.create(parent, SWT.NONE, "graph Sample{edge[style=dashed];1;2;1->2}"); Assert.assertNotNull("Created graph must not be null", graph); Assert.assertEquals( SWT.LINE_DASH, ((GraphConnection) graph.getConnections().get(0)).getLineStyle()); // open(parent); }
@Test public void edgeCount() { Graph graph = interpreter.create(new Shell(), SWT.NONE, "graph Sample{1;2;1->2;2->2;1->1}"); Assert.assertNotNull("Created graph must not be null", graph); Assert.assertEquals(3, graph.getConnections().size()); }
@Test public void nodeCount() { Graph graph = interpreter.create(new Shell(), SWT.NONE, "graph Sample{1;2}"); Assert.assertNotNull("Created graph must not be null", graph); Assert.assertEquals(2, graph.getNodes().size()); }
@Test public void nodeDefaultLabel() { Graph graph = interpreter.create(new Shell(), SWT.NONE, "graph Sample{1}"); Assert.assertNotNull("Created graph must not be null", graph); Assert.assertEquals("1", ((GraphNode) graph.getNodes().get(0)).getText()); }
@Test(expected = IllegalArgumentException.class) public void faultyStyle() { interpreter.create(new Shell(), SWT.NONE, "graph Sample{1;2;1->2[style=\"dashed++\"]}"); }
@Test(expected = IllegalArgumentException.class) public void faultyLayout() { interpreter.create(new Shell(), SWT.NONE, "graph Sample{graph[layout=cool];1;}"); }