forked from exercism/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphTest.java
More file actions
135 lines (113 loc) · 4.41 KB
/
Copy pathGraphTest.java
File metadata and controls
135 lines (113 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import static java.util.Collections.emptyMap;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Map;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
public class GraphTest {
@Test
@DisplayName("empty graph")
public void testEmptyGraph() {
Graph graph = new Graph();
assertThat(graph.getNodes()).isEmpty();
assertThat(graph.getEdges()).isEmpty();
assertThat(graph.getAttributes()).isEmpty();
}
@Test
@Disabled
@DisplayName("graph with one node")
public void testGraphWithOneNode() {
Graph graph = new Graph().node("a");
assertThat(graph.getNodes()).containsExactly(new Node("a", emptyMap()));
assertThat(graph.getEdges()).isEmpty();
assertThat(graph.getAttributes()).isEmpty();
}
@Test
@Disabled
@DisplayName("graph with one node with attribute")
public void testGraphWithOneNodeWithAttribute() {
Graph graph = new Graph().node("a", Map.of("color", "green"));
assertThat(graph.getNodes())
.containsExactly(new Node("a", Map.of("color", "green")));
assertThat(graph.getEdges()).isEmpty();
assertThat(graph.getAttributes()).isEmpty();
}
@Test
@Disabled
@DisplayName("graph with one edge")
public void testGraphWithOneEdge() {
Graph graph = new Graph().edge("a", "b");
assertThat(graph.getNodes()).isEmpty();
assertThat(graph.getEdges())
.containsExactly(new Edge("a", "b"));
assertThat(graph.getAttributes()).isEmpty();
}
@Test
@Disabled
@DisplayName("graph with one edge with attribute")
public void testGraphWithOneEdgeWithAttribute() {
Graph graph = new Graph().edge("a", "b", Map.of("color", "blue"));
assertThat(graph.getNodes()).isEmpty();
assertThat(graph.getEdges())
.containsExactly(new Edge("a", "b", Map.of("color", "blue")));
assertThat(graph.getAttributes()).isEmpty();
}
@Test
@Disabled
@DisplayName("graph with one attribute")
public void testGraphWithOneAttribute() {
Graph graph = new Graph(Map.of("foo", "1"));
assertThat(graph.getNodes()).isEmpty();
assertThat(graph.getEdges()).isEmpty();
assertThat(graph.getAttributes()).containsEntry("foo", "1");
}
@Test
@Disabled
@DisplayName("graph with nodes, edges, and attributes")
public void testGraphWithNodesEdgesAndAttributes() {
Graph graph = new Graph(Map.of("foo", "1", "title", "Testing Attrs", "bar", "true"))
.node("a", Map.of("color", "green"))
.node("c")
.node("b", Map.of("label", "Beta!"))
.edge("b", "c")
.edge("a", "b", Map.of("color", "blue"));
assertThat(graph.getNodes())
.containsExactlyInAnyOrder(
new Node("a", Map.of("color", "green")),
new Node("c"),
new Node("b", Map.of("label", "Beta!")));
assertThat(graph.getEdges())
.containsExactlyInAnyOrder(
new Edge("a", "b", Map.of("color", "blue")),
new Edge("b", "c"));
assertThat(graph.getAttributes())
.containsExactlyInAnyOrderEntriesOf(
Map.of("foo", "1", "title", "Testing Attrs", "bar", "true"));
}
@Test
@Disabled
@DisplayName("multiple edges on one line")
public void testMultipleEdgesOnOneLine() {
Graph graph = new Graph()
.node("a")
.node("b")
.node("c")
.node("d")
.edge("a", "b", Map.of("style", "dotted"))
.edge("b", "c", Map.of("style", "dotted"))
.edge("c", "d", Map.of("style", "dotted"));
assertThat(graph.getNodes()).containsExactlyInAnyOrder(
new Node("a"),
new Node("b"),
new Node("c"),
new Node("d")
);
assertThat(graph.getEdges())
.containsExactlyInAnyOrder(
new Edge("a", "b", Map.of("style", "dotted")),
new Edge("b", "c", Map.of("style", "dotted")),
new Edge("c", "d", Map.of("style", "dotted"))
);
assertThat(graph.getAttributes()).isEmpty();
}
}