MCPcopy Create free account
hub / github.com/cschanck/single-file-java / testSimple

Method testSimple

src/test/java/org/sfj/DrawDotTest.java:88–124  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

86 }
87
88 @Test
89 public void testSimple() throws IOException {
90 DrawDot dot = new DrawDot("top");
91 dot.root().add(new Node("a"));
92 dot.root().add(new Node("b"));
93 dot.root().add(new Node("c").label("Happy!"));
94 dot.root().add(new Node("d").recordH("one", "two", "three").color("green"));
95 dot.root().add(new Node("e").recordV("one", "two", "three").color("green"));
96 dot.root().add(new Connection(new Node("a"), new Node("b")).color("red").head(Arrows.CROW.arrow().label("foo arrow")));
97 dot.root().add(new Connection(new Node("a"), new Node("c")));
98 dot.root().add(new Connection(new Node("d"), new Node("c")));
99 dot.root().add(new Connection(new Node("e"), new Node("c")));
100
101 DrawDot.Graph g = dot.root();
102 assertThat(g.getChildren().size(), is(5));
103 assertThat(g.getChildren().get(0).id(), is("a"));
104 assertThat(g.getChildren().get(1).id(), is("b"));
105 assertThat(g.getChildren().get(2).id(), is("c"));
106 assertThat(g.getChildren().get(3).id(), is("d"));
107 assertThat(g.getChildren().get(4).id(), is("e"));
108
109 assertThat(g.getConnections().size(), is(4));
110 assertThat(g.getConnections().get(0).getFrom().id(), is("a"));
111 assertThat(g.getConnections().get(1).getFrom().id(), is("a"));
112 assertThat(g.getConnections().get(2).getFrom().id(), is("d"));
113 assertThat(g.getConnections().get(3).getFrom().id(), is("e"));
114 assertThat(g.getConnections().get(0).getTo().id(), is("b"));
115 assertThat(g.getConnections().get(1).getTo().id(), is("c"));
116 assertThat(g.getConnections().get(2).getTo().id(), is("c"));
117 assertThat(g.getConnections().get(3).getTo().id(), is("c"));
118 StringWriter sw = new StringWriter();
119 dot.emit(sw);
120 LineSource left = source(sw.toString());
121 LineSource right = source(DrawDotTest.this.getClass(), "drawdot1.dot");
122 boolean cmp = stringsCompare(left, right, SKIP_BLANK, TRIM_LEADING_AND_TRAILING_WHITESPACE);
123 assertThat(cmp, is(true));
124 }
125
126 @Test
127 public void testRecursive() throws IOException {

Callers

nothing calls this directly

Calls 15

rootMethod · 0.95
emitMethod · 0.95
labelMethod · 0.80
colorMethod · 0.80
recordHMethod · 0.80
recordVMethod · 0.80
headMethod · 0.80
arrowMethod · 0.80
getChildrenMethod · 0.80
getFromMethod · 0.80
getToMethod · 0.80
sourceMethod · 0.80

Tested by

no test coverage detected