|
Lines 52-58
Link Here
|
| 52 |
|
52 |
|
| 53 |
@Test |
53 |
@Test |
| 54 |
public void digraphType() { |
54 |
public void digraphType() { |
| 55 |
Graph graph = interpreter.interpret(parse("digraph Sample{1;2;1->2}")) //$NON-NLS-1$ |
55 |
Graph graph = interpreter |
|
|
56 |
.interpret(parse(DotSampleGraphs.TWO_NODES_ONE_DIRECTED_EDGE)) |
| 56 |
.get(0); |
57 |
.get(0); |
| 57 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
58 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 58 |
Assert.assertEquals(DotAttributes._TYPE__G__DIGRAPH, |
59 |
Assert.assertEquals(DotAttributes._TYPE__G__DIGRAPH, |
|
Lines 61-68
Link Here
|
| 61 |
|
62 |
|
| 62 |
@Test |
63 |
@Test |
| 63 |
public void graphType() { |
64 |
public void graphType() { |
| 64 |
Graph graph = interpreter.interpret(parse("graph Sample{1;2;1--2}")) //$NON-NLS-1$ |
65 |
Graph graph = interpreter |
| 65 |
.get(0); |
66 |
.interpret(parse(DotSampleGraphs.TWO_NODES_ONE_EDGE)).get(0); |
| 66 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
67 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 67 |
Assert.assertEquals(DotAttributes._TYPE__G__GRAPH, |
68 |
Assert.assertEquals(DotAttributes._TYPE__G__GRAPH, |
| 68 |
DotAttributes._getType(graph)); |
69 |
DotAttributes._getType(graph)); |
|
Lines 70-76
Link Here
|
| 70 |
|
71 |
|
| 71 |
@Test |
72 |
@Test |
| 72 |
public void nodeDefaultLabel() { |
73 |
public void nodeDefaultLabel() { |
| 73 |
Graph graph = interpreter.interpret(parse("graph Sample{1}")).get(0); //$NON-NLS-1$ |
74 |
Graph graph = interpreter.interpret(parse(DotSampleGraphs.ONE_NODE)) |
|
|
75 |
.get(0); |
| 74 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
76 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 75 |
Assert.assertEquals("1", //$NON-NLS-1$ |
77 |
Assert.assertEquals("1", //$NON-NLS-1$ |
| 76 |
DotAttributes._getName(graph.getNodes().get(0))); |
78 |
DotAttributes._getName(graph.getNodes().get(0))); |
|
Lines 78-84
Link Here
|
| 78 |
|
80 |
|
| 79 |
@Test |
81 |
@Test |
| 80 |
public void nodeCount() { |
82 |
public void nodeCount() { |
| 81 |
Graph graph = interpreter.interpret(parse("graph Sample{1;2}")).get(0); //$NON-NLS-1$ |
83 |
Graph graph = interpreter.interpret(parse(DotSampleGraphs.TWO_NODES)) |
|
|
84 |
.get(0); |
| 82 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
85 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 83 |
Assert.assertEquals(2, graph.getNodes().size()); |
86 |
Assert.assertEquals(2, graph.getNodes().size()); |
| 84 |
} |
87 |
} |
|
Lines 86-92
Link Here
|
| 86 |
@Test |
89 |
@Test |
| 87 |
public void edgeCount() { |
90 |
public void edgeCount() { |
| 88 |
Graph graph = interpreter |
91 |
Graph graph = interpreter |
| 89 |
.interpret(parse("graph Sample{1;2;1--2;2--2;1--1}")).get(0); //$NON-NLS-1$ |
92 |
.interpret(parse(DotSampleGraphs.TWO_NODES_AND_THREE_EDGES)) |
|
|
93 |
.get(0); |
| 90 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
94 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 91 |
Assert.assertEquals(3, graph.getEdges().size()); |
95 |
Assert.assertEquals(3, graph.getEdges().size()); |
| 92 |
} |
96 |
} |
|
Lines 94-100
Link Here
|
| 94 |
@Test |
98 |
@Test |
| 95 |
public void nodeLabel() { |
99 |
public void nodeLabel() { |
| 96 |
Graph graph = interpreter |
100 |
Graph graph = interpreter |
| 97 |
.interpret(parse("graph Sample{1[label=\"Node1\"];}")).get(0); //$NON-NLS-1$ |
101 |
.interpret(parse(DotSampleGraphs.NODE_LABEL_LOCAL)).get(0); |
| 98 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
102 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 99 |
Assert.assertEquals("Node1", //$NON-NLS-1$ |
103 |
Assert.assertEquals("Node1", //$NON-NLS-1$ |
| 100 |
DotAttributes.getLabel(graph.getNodes().get(0))); |
104 |
DotAttributes.getLabel(graph.getNodes().get(0))); |
|
Lines 103-110
Link Here
|
| 103 |
@Test |
107 |
@Test |
| 104 |
public void edgeLabel() { |
108 |
public void edgeLabel() { |
| 105 |
Graph graph = interpreter |
109 |
Graph graph = interpreter |
| 106 |
.interpret(parse("graph Sample{1;2;1--2[label=\"Edge1\"]}")) //$NON-NLS-1$ |
110 |
.interpret(parse(DotSampleGraphs.EDGE_LABEL_LOCAL)).get(0); |
| 107 |
.get(0); |
|
|
| 108 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
111 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 109 |
Assert.assertEquals("Edge1", DotAttributes.getLabel(graph.getEdges() //$NON-NLS-1$ |
112 |
Assert.assertEquals("Edge1", DotAttributes.getLabel(graph.getEdges() //$NON-NLS-1$ |
| 110 |
.get(0))); |
113 |
.get(0))); |
|
Lines 113-120
Link Here
|
| 113 |
@Test |
116 |
@Test |
| 114 |
public void edgeStyle() { |
117 |
public void edgeStyle() { |
| 115 |
Graph graph = interpreter |
118 |
Graph graph = interpreter |
| 116 |
.interpret(parse("graph Sample{1;2;1->2[style=dashed]}")) //$NON-NLS-1$ |
119 |
.interpret(parse(DotSampleGraphs.EDGE_STYLE_LOCAL)).get(0); |
| 117 |
.get(0); |
|
|
| 118 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
120 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 119 |
Assert.assertEquals(EdgeStyle.DASHED.toString(), |
121 |
Assert.assertEquals(EdgeStyle.DASHED.toString(), |
| 120 |
DotAttributes.getStyle(graph.getEdges().get(0))); |
122 |
DotAttributes.getStyle(graph.getEdges().get(0))); |
|
Lines 123-130
Link Here
|
| 123 |
@Test |
125 |
@Test |
| 124 |
public void globalEdgeStyle() { |
126 |
public void globalEdgeStyle() { |
| 125 |
Graph graph = interpreter |
127 |
Graph graph = interpreter |
| 126 |
.interpret(parse("graph Sample{edge[style=dashed];1;2;1--2}")) //$NON-NLS-1$ |
128 |
.interpret(parse(DotSampleGraphs.EDGE_STYLE_GLOBAL)).get(0); |
| 127 |
.get(0); |
|
|
| 128 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
129 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 129 |
Assert.assertEquals(EdgeStyle.DASHED.toString(), |
130 |
Assert.assertEquals(EdgeStyle.DASHED.toString(), |
| 130 |
DotAttributes.getStyle(graph.getEdges().get(0))); |
131 |
DotAttributes.getStyle(graph.getEdges().get(0))); |
|
Lines 133-141
Link Here
|
| 133 |
@Test |
134 |
@Test |
| 134 |
public void globalEdgeLabel() { |
135 |
public void globalEdgeLabel() { |
| 135 |
Graph graph = interpreter |
136 |
Graph graph = interpreter |
| 136 |
.interpret( |
137 |
.interpret(parse(DotSampleGraphs.EDGE_LABEL_GLOBAL)).get(0); |
| 137 |
parse("graph Sample{edge[label=\"Edge1\"];1;2;1--2}")) //$NON-NLS-1$ |
|
|
| 138 |
.get(0); |
| 139 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
138 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 140 |
Assert.assertEquals("Edge1", DotAttributes.getLabel(graph.getEdges() //$NON-NLS-1$ |
139 |
Assert.assertEquals("Edge1", DotAttributes.getLabel(graph.getEdges() //$NON-NLS-1$ |
| 141 |
.get(0))); |
140 |
.get(0))); |
|
Lines 144-151
Link Here
|
| 144 |
@Test |
143 |
@Test |
| 145 |
public void globalNodeLabel() { |
144 |
public void globalNodeLabel() { |
| 146 |
Graph graph = interpreter |
145 |
Graph graph = interpreter |
| 147 |
.interpret(parse("graph Sample{node[label=\"Node1\"];1;}")) //$NON-NLS-1$ |
146 |
.interpret(parse(DotSampleGraphs.NODE_LABEL_GLOBAL)).get(0); |
| 148 |
.get(0); |
|
|
| 149 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
147 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 150 |
Assert.assertEquals("Node1", //$NON-NLS-1$ |
148 |
Assert.assertEquals("Node1", //$NON-NLS-1$ |
| 151 |
DotAttributes.getLabel(graph.getNodes().get(0))); |
149 |
DotAttributes.getLabel(graph.getNodes().get(0))); |
|
Lines 154-160
Link Here
|
| 154 |
@Test |
152 |
@Test |
| 155 |
public void layoutSpring() { |
153 |
public void layoutSpring() { |
| 156 |
Graph graph = interpreter |
154 |
Graph graph = interpreter |
| 157 |
.interpret(parse("graph Sample{graph[layout=fdp];1;}")).get(0); //$NON-NLS-1$ |
155 |
.interpret(parse(DotSampleGraphs.GRAPH_LAYOUT_FDP)).get(0); |
| 158 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
156 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 159 |
Assert.assertEquals(Layout.FDP.toString(), |
157 |
Assert.assertEquals(Layout.FDP.toString(), |
| 160 |
DotAttributes.getLayout(graph)); |
158 |
DotAttributes.getLayout(graph)); |
|
Lines 163-170
Link Here
|
| 163 |
@Test |
161 |
@Test |
| 164 |
public void layoutGrid() { |
162 |
public void layoutGrid() { |
| 165 |
Graph graph = interpreter |
163 |
Graph graph = interpreter |
| 166 |
.interpret(parse("graph Sample{graph[layout=osage];1;}")) //$NON-NLS-1$ |
164 |
.interpret(parse(DotSampleGraphs.GRAPH_LAYOUT_OSAGE)).get(0); |
| 167 |
.get(0); |
|
|
| 168 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
165 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 169 |
Assert.assertEquals(Layout.OSAGE.toString(), |
166 |
Assert.assertEquals(Layout.OSAGE.toString(), |
| 170 |
DotAttributes.getLayout(graph)); |
167 |
DotAttributes.getLayout(graph)); |
|
Lines 173-180
Link Here
|
| 173 |
@Test |
170 |
@Test |
| 174 |
public void layoutRadial() { |
171 |
public void layoutRadial() { |
| 175 |
Graph graph = interpreter |
172 |
Graph graph = interpreter |
| 176 |
.interpret(parse("graph Sample{graph[layout=twopi];1;}")) //$NON-NLS-1$ |
173 |
.interpret(parse(DotSampleGraphs.GRAPH_LAYOUT_TWOPI)).get(0); |
| 177 |
.get(0); |
|
|
| 178 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
174 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 179 |
Assert.assertEquals(Layout.TWOPI.toString(), |
175 |
Assert.assertEquals(Layout.TWOPI.toString(), |
| 180 |
DotAttributes.getLayout(graph)); |
176 |
DotAttributes.getLayout(graph)); |
|
Lines 183-189
Link Here
|
| 183 |
@Test |
179 |
@Test |
| 184 |
public void layoutTree() { |
180 |
public void layoutTree() { |
| 185 |
Graph graph = interpreter |
181 |
Graph graph = interpreter |
| 186 |
.interpret(parse("graph Sample{graph[layout=dot];1;}")).get(0); //$NON-NLS-1$ |
182 |
.interpret(parse(DotSampleGraphs.GRAPH_LAYOUT_DOT)).get(0); |
| 187 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
183 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 188 |
Assert.assertEquals(Layout.DOT.toString(), |
184 |
Assert.assertEquals(Layout.DOT.toString(), |
| 189 |
DotAttributes.getLayout(graph)); |
185 |
DotAttributes.getLayout(graph)); |
|
Lines 192-199
Link Here
|
| 192 |
@Test |
188 |
@Test |
| 193 |
public void layoutHorizontalTreeViaLayout() { |
189 |
public void layoutHorizontalTreeViaLayout() { |
| 194 |
Graph graph = interpreter |
190 |
Graph graph = interpreter |
| 195 |
.interpret( |
191 |
.interpret(parse(DotSampleGraphs.GRAPH_LAYOUT_DOT_HORIZONTAL)) |
| 196 |
parse("graph Sample{graph[layout=dot];rankdir=LR;1;}")) //$NON-NLS-1$ |
|
|
| 197 |
.get(0); |
192 |
.get(0); |
| 198 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
193 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 199 |
Assert.assertEquals(Layout.DOT.toString(), |
194 |
Assert.assertEquals(Layout.DOT.toString(), |
|
Lines 204-210
Link Here
|
| 204 |
@Test |
199 |
@Test |
| 205 |
public void layoutHorizontalTreeViaAttribute() { |
200 |
public void layoutHorizontalTreeViaAttribute() { |
| 206 |
Graph graph = interpreter |
201 |
Graph graph = interpreter |
| 207 |
.interpret(parse("graph Sample{rankdir=LR;1;}")).get(0); //$NON-NLS-1$ |
202 |
.interpret(parse(DotSampleGraphs.GRAPH_RANKDIR_LR)).get(0); |
| 208 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
203 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 209 |
Assert.assertEquals(Rankdir.LR, DotAttributes.getRankdirParsed(graph)); |
204 |
Assert.assertEquals(Rankdir.LR, DotAttributes.getRankdirParsed(graph)); |
| 210 |
} |
205 |
} |
|
Lines 212-218
Link Here
|
| 212 |
@Test |
207 |
@Test |
| 213 |
public void globalNodeAttributeAdHocNodes() { |
208 |
public void globalNodeAttributeAdHocNodes() { |
| 214 |
Graph graph = interpreter |
209 |
Graph graph = interpreter |
| 215 |
.interpret(parse("graph{node[label=\"TEXT\"];1--2}")).get(0); //$NON-NLS-1$ |
210 |
.interpret( |
|
|
211 |
parse(DotSampleGraphs.GLOBAL_NODE_LABEL_AD_HOC_NODES)) |
| 212 |
.get(0); |
| 216 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
213 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 217 |
Assert.assertEquals("TEXT", //$NON-NLS-1$ |
214 |
Assert.assertEquals("TEXT", //$NON-NLS-1$ |
| 218 |
DotAttributes.getLabel(graph.getNodes().get(0))); |
215 |
DotAttributes.getLabel(graph.getNodes().get(0))); |
|
Lines 221-227
Link Here
|
| 221 |
@Test |
218 |
@Test |
| 222 |
public void globalEdgeAttributeAdHocNodes() { |
219 |
public void globalEdgeAttributeAdHocNodes() { |
| 223 |
Graph graph = interpreter |
220 |
Graph graph = interpreter |
| 224 |
.interpret(parse("graph{edge[label=\"TEXT\"];1--2}")).get(0); //$NON-NLS-1$ |
221 |
.interpret( |
|
|
222 |
parse(DotSampleGraphs.GLOBAL_EDGE_LABEL_AD_HOC_NODES)) |
| 223 |
.get(0); |
| 225 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
224 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 226 |
Assert.assertEquals("TEXT", DotAttributes.getLabel(graph.getEdges() //$NON-NLS-1$ |
225 |
Assert.assertEquals("TEXT", DotAttributes.getLabel(graph.getEdges() //$NON-NLS-1$ |
| 227 |
.get(0))); |
226 |
.get(0))); |
|
Lines 230-236
Link Here
|
| 230 |
@Test |
229 |
@Test |
| 231 |
public void headerCommentGraph() { |
230 |
public void headerCommentGraph() { |
| 232 |
Graph graph = interpreter |
231 |
Graph graph = interpreter |
| 233 |
.interpret(parse("/*A header comment*/\ngraph{1--2}")).get(0); //$NON-NLS-1$ |
232 |
.interpret(parse(DotSampleGraphs.HEADER_COMMENT)).get(0); |
| 234 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
233 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 235 |
Assert.assertEquals(2, graph.getNodes().size()); |
234 |
Assert.assertEquals(2, graph.getNodes().size()); |
| 236 |
Assert.assertEquals(1, graph.getEdges().size()); |
235 |
Assert.assertEquals(1, graph.getEdges().size()); |
|
Lines 239-245
Link Here
|
| 239 |
@Test |
238 |
@Test |
| 240 |
public void nodesBeforeEdges() { |
239 |
public void nodesBeforeEdges() { |
| 241 |
Graph graph = interpreter |
240 |
Graph graph = interpreter |
| 242 |
.interpret(parse("graph{1;2;3;4; 1--2;2--3;2--4}")).get(0); //$NON-NLS-1$ |
241 |
.interpret(parse(DotSampleGraphs.NODES_BEFORE_EDGES)).get(0); |
| 243 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
242 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 244 |
Assert.assertEquals(4, graph.getNodes().size()); |
243 |
Assert.assertEquals(4, graph.getNodes().size()); |
| 245 |
Assert.assertEquals(3, graph.getEdges().size()); |
244 |
Assert.assertEquals(3, graph.getEdges().size()); |
|
Lines 248-256
Link Here
|
| 248 |
@Test |
247 |
@Test |
| 249 |
public void nodesAfterEdges() { |
248 |
public void nodesAfterEdges() { |
| 250 |
Graph graph = interpreter |
249 |
Graph graph = interpreter |
| 251 |
.interpret( |
250 |
.interpret(parse(DotSampleGraphs.NODES_AFTER_EDGES)).get(0); |
| 252 |
parse("graph{1--2;2--3;2--4;1[label=\"node\"];2;3;4}")) //$NON-NLS-1$ |
|
|
| 253 |
.get(0); |
| 254 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
251 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 255 |
Assert.assertEquals(4, graph.getNodes().size()); |
252 |
Assert.assertEquals(4, graph.getNodes().size()); |
| 256 |
Assert.assertEquals(3, graph.getEdges().size()); |
253 |
Assert.assertEquals(3, graph.getEdges().size()); |
|
Lines 260-266
Link Here
|
| 260 |
|
257 |
|
| 261 |
@Test |
258 |
@Test |
| 262 |
public void useInterpreterTwice() { |
259 |
public void useInterpreterTwice() { |
| 263 |
String dot = "graph{1;2;3;4; 1--2;2--3;2--4}"; //$NON-NLS-1$ |
260 |
String dot = DotSampleGraphs.NODES_AFTER_EDGES; |
| 264 |
Graph graph = interpreter.interpret(parse(dot)).get(0); |
261 |
Graph graph = interpreter.interpret(parse(dot)).get(0); |
| 265 |
graph = interpreter.interpret(parse(dot)).get(0); |
262 |
graph = interpreter.interpret(parse(dot)).get(0); |
| 266 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
263 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
|
Lines 270-277
Link Here
|
| 270 |
|
267 |
|
| 271 |
@Test |
268 |
@Test |
| 272 |
public void idsWithQuotes() { |
269 |
public void idsWithQuotes() { |
| 273 |
String dot = "graph{\"node 1\";\"node 2\"}"; //$NON-NLS-1$ |
270 |
Graph graph = interpreter |
| 274 |
Graph graph = interpreter.interpret(parse(dot)).get(0); |
271 |
.interpret(parse(DotSampleGraphs.IDS_WITH_QUOTES)).get(0); |
| 275 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
272 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 276 |
List<Node> list = graph.getNodes(); |
273 |
List<Node> list = graph.getNodes(); |
| 277 |
Assert.assertEquals("node 1", //$NON-NLS-1$ |
274 |
Assert.assertEquals("node 1", //$NON-NLS-1$ |
|
Lines 282-289
Link Here
|
| 282 |
|
279 |
|
| 283 |
@Test |
280 |
@Test |
| 284 |
public void escapedQuotes() { |
281 |
public void escapedQuotes() { |
| 285 |
String dot = "graph{n1[label=\"node \\\"1\\\"\"]}"; //$NON-NLS-1$ |
282 |
Graph graph = interpreter |
| 286 |
Graph graph = interpreter.interpret(parse(dot)).get(0); |
283 |
.interpret(parse(DotSampleGraphs.ESCAPED_QUOTES_LABEL)).get(0); |
| 287 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
284 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 288 |
Assert.assertEquals("node \"1\"", //$NON-NLS-1$ |
285 |
Assert.assertEquals("node \"1\"", //$NON-NLS-1$ |
| 289 |
DotAttributes.getLabel(graph.getNodes().get(0))); |
286 |
DotAttributes.getLabel(graph.getNodes().get(0))); |
|
Lines 291-298
Link Here
|
| 291 |
|
288 |
|
| 292 |
@Test |
289 |
@Test |
| 293 |
public void fullyQuoted() { |
290 |
public void fullyQuoted() { |
| 294 |
String dot = "graph{\"n1\";\"n2\";\"n1\"--\"n2\"}"; //$NON-NLS-1$ |
291 |
Graph graph = interpreter |
| 295 |
Graph graph = interpreter.interpret(parse(dot)).get(0); |
292 |
.interpret(parse(DotSampleGraphs.FULLY_QUOTED_IDS)).get(0); |
| 296 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
293 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 297 |
Assert.assertEquals(2, graph.getNodes().size()); |
294 |
Assert.assertEquals(2, graph.getNodes().size()); |
| 298 |
Assert.assertEquals(1, graph.getEdges().size()); |
295 |
Assert.assertEquals(1, graph.getEdges().size()); |
|
Lines 305-312
Link Here
|
| 305 |
|
302 |
|
| 306 |
@Test |
303 |
@Test |
| 307 |
public void labelsWithQuotes() { |
304 |
public void labelsWithQuotes() { |
| 308 |
String dot = "graph{n1[label=\"node 1\"];n2[label=\"node 2\"];n1--n2[label=\"edge 1\"]}"; //$NON-NLS-1$ |
305 |
Graph graph = interpreter |
| 309 |
Graph graph = interpreter.interpret(parse(dot)).get(0); |
306 |
.interpret(parse(DotSampleGraphs.QUOTED_LABELS)).get(0); |
| 310 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
307 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 311 |
List<Node> list = graph.getNodes(); |
308 |
List<Node> list = graph.getNodes(); |
| 312 |
Assert.assertEquals("node 1", //$NON-NLS-1$ |
309 |
Assert.assertEquals("node 1", //$NON-NLS-1$ |
|
Lines 319-334
Link Here
|
| 319 |
|
316 |
|
| 320 |
@Test |
317 |
@Test |
| 321 |
public void newLinesInLabels() { |
318 |
public void newLinesInLabels() { |
| 322 |
String dot = "graph{n1[label=\"node\n1\"]}"; //$NON-NLS-1$ |
319 |
Graph graph = interpreter |
| 323 |
Graph graph = interpreter.interpret(parse(dot)).get(0); |
320 |
.interpret(parse(DotSampleGraphs.NEW_LINES_IN_LABELS)).get(0); |
| 324 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
321 |
Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$ |
| 325 |
Assert.assertEquals("node\n1", //$NON-NLS-1$ |
322 |
Assert.assertEquals("node" + System.lineSeparator() + "1", //$NON-NLS-1$ |
| 326 |
DotAttributes.getLabel(graph.getNodes().get(0))); |
323 |
DotAttributes.getLabel(graph.getNodes().get(0))); |
| 327 |
} |
324 |
} |
| 328 |
|
325 |
|
| 329 |
@Test |
326 |
@Test |
| 330 |
public void multiEdgeStatements() { |
327 |
public void multiEdgeStatements() { |
| 331 |
Graph graph = new DotImport().importDot("digraph{1->2->3->4}"); //$NON-NLS-1$ |
328 |
Graph graph = new DotImport() |
|
|
329 |
.importDot(DotSampleGraphs.MULTI_EDGE_STATEMENTS); |
| 332 |
assertEquals(4, graph.getNodes().size()); |
330 |
assertEquals(4, graph.getNodes().size()); |
| 333 |
assertEquals(3, graph.getEdges().size()); |
331 |
assertEquals(3, graph.getEdges().size()); |
| 334 |
/* Each node should be connected to one other, the previous node: */ |
332 |
/* Each node should be connected to one other, the previous node: */ |
|
Lines 350-356
Link Here
|
| 350 |
@Test |
348 |
@Test |
| 351 |
/* see http://www.graphviz.org/doc/info/attrs.html#d:style */ |
349 |
/* see http://www.graphviz.org/doc/info/attrs.html#d:style */ |
| 352 |
public void edgeStyleInvis() { |
350 |
public void edgeStyleInvis() { |
| 353 |
Graph graph = new DotImport().importDot("digraph{1->2[style=invis]}"); |
351 |
Graph graph = new DotImport() |
|
|
352 |
.importDot(DotSampleGraphs.EDGE_STYLE_INVIS); |
| 354 |
assertEquals(2, graph.getNodes().size()); |
353 |
assertEquals(2, graph.getNodes().size()); |
| 355 |
assertEquals(1, graph.getEdges().size()); |
354 |
assertEquals(1, graph.getEdges().size()); |
| 356 |
} |
355 |
} |