Skip to content

Commit 0443ae5

Browse files
authored
Update dot dsl exercise (exercism#3143)
* Update dot dsl exercise * Fix formating
1 parent 86fe0ae commit 0443ae5

2 files changed

Lines changed: 127 additions & 7 deletions

File tree

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
11+
12+
[3a50c618-2571-466b-9ee9-346d9943912e]
13+
description = "empty graph"
14+
15+
[5067feea-e49b-4a9d-865e-4502d6b0540c]
16+
description = "graph with one node"
17+
18+
[b66cf871-88c6-489a-b0b9-7c79b6819c45]
19+
description = "graph with one node with attribute"
20+
21+
[f7841da3-c0f8-4541-b594-21b626a764d2]
22+
description = "graph with one edge"
23+
24+
[bbee70e1-6b0d-4f3a-bd4e-41cd2cfc0e39]
25+
description = "graph with one attribute"
26+
27+
[ac736158-6684-418d-93d5-7b284e43294e]
28+
description = "graph with comments"
29+
comment = "Not possible to create scenario in test"
30+
include = false
31+
32+
[69068da9-7690-4d4d-a728-f5c2bf132a33]
33+
description = "graph with nodes, edges, and attributes"
34+
35+
[f6c53993-3937-4959-bcde-dc16411113ae]
36+
description = "multiple edges on one line"
37+
38+
[b853dfc1-1f05-45aa-bc98-b0fc6b57529b]
39+
description = "only 1 edge between nodes"
40+
include = false
41+
42+
[bdc0fdac-aa46-457f-8385-65736ccdc1c7]
43+
description = "malformed input"
44+
comment = "Not possible to create the scenario in test"
45+
include = false
46+
47+
[f5c4f77d-359c-434a-9c33-b9eb795bafdd]
48+
description = "malformed edge"
49+
comment = "Not possible to create the scenario in test"
50+
include = false
51+
52+
[2238f6b8-20bb-489f-8ca0-084d1771d758]
53+
description = "malformed edge 2"
54+
comment = "Not possible to create the scenario in test"
55+
include = false
56+
57+
[4e3a4386-9e80-4315-b70f-253a06a2234e]
58+
description = "invalid edge type"
59+
comment = "Not possible to create the scenario in test"
60+
include = false
61+
62+
[793adce3-bd19-4458-ac41-c989f7f8d9db]
63+
description = "multiple edges missing a node"
64+
comment = "Not possible to create the scenario in test"
65+
include = false
66+
67+
[e2930b2c-3a03-4d8f-abe9-78a125a915a7]
68+
description = "multiple edges missing a connector"
69+
comment = "Not possible to create the scenario in test"
70+
include = false
71+
72+
[55d3f722-f9f1-46e1-b308-da61607952ab]
73+
description = "empty attribute"
74+
comment = "Not possible to create the scenario in test"
75+
include = false
76+
77+
[4ee2a9c3-54b1-4825-bd58-2b78c2c53953]
78+
description = "malformed attribute"
79+
comment = "Not possible to create the scenario in test"
80+
include = false
81+
82+
[382a13c8-6419-4286-8dd2-eac708f3e2a8]
83+
description = "empty attribute name"
84+
comment = "Not possible to create the scenario in test"
85+
include = false
86+
87+
[a6f9e6ab-8c3e-4475-a9fe-5dd061cadec6]
88+
description = "non-alphanumeric node name"
89+
comment = "Not possible to create the scenario in test"
90+
include = false

exercises/practice/dot-dsl/src/test/java/GraphTest.java

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import static org.assertj.core.api.Assertions.assertThat;
33

44
import java.util.Map;
5+
56
import org.junit.jupiter.api.Disabled;
67
import org.junit.jupiter.api.DisplayName;
78
import org.junit.jupiter.api.Test;
@@ -31,8 +32,8 @@ public void testGraphWithOneNode() {
3132

3233
@Test
3334
@Disabled
34-
@DisplayName("graph with one node with keywords")
35-
public void testGraphWithOneNodeWithKeywords() {
35+
@DisplayName("graph with one node with attribute")
36+
public void testGraphWithOneNodeWithAttribute() {
3637
Graph graph = new Graph().node("a", Map.of("color", "green"));
3738

3839
assertThat(graph.getNodes())
@@ -55,8 +56,8 @@ public void testGraphWithOneEdge() {
5556

5657
@Test
5758
@Disabled
58-
@DisplayName("graph with one edge with keywords")
59-
public void testGraphWithOneEdgeWithKeywords() {
59+
@DisplayName("graph with one edge with attribute")
60+
public void testGraphWithOneEdgeWithAttribute() {
6061
Graph graph = new Graph().edge("a", "b", Map.of("color", "blue"));
6162

6263
assertThat(graph.getNodes()).isEmpty();
@@ -78,8 +79,8 @@ public void testGraphWithOneAttribute() {
7879

7980
@Test
8081
@Disabled
81-
@DisplayName("graph with attributes")
82-
public void testGraphWithAttributes() {
82+
@DisplayName("graph with nodes, edges, and attributes")
83+
public void testGraphWithNodesEdgesAndAttributes() {
8384
Graph graph = new Graph(Map.of("foo", "1", "title", "Testing Attrs", "bar", "true"))
8485
.node("a", Map.of("color", "green"))
8586
.node("c")
@@ -95,11 +96,40 @@ public void testGraphWithAttributes() {
9596

9697
assertThat(graph.getEdges())
9798
.containsExactlyInAnyOrder(
98-
new Edge("a", "b", Map.of("color", "blue")),
99+
new Edge("a", "b", Map.of("color", "blue")),
99100
new Edge("b", "c"));
100101

101102
assertThat(graph.getAttributes())
102103
.containsExactlyInAnyOrderEntriesOf(
103104
Map.of("foo", "1", "title", "Testing Attrs", "bar", "true"));
104105
}
106+
107+
@Test
108+
@Disabled
109+
@DisplayName("multiple edges on one line")
110+
public void testMultipleEdgesOnOneLine() {
111+
Graph graph = new Graph()
112+
.node("a")
113+
.node("b")
114+
.node("c")
115+
.node("d")
116+
.edge("a", "b", Map.of("style", "dotted"))
117+
.edge("b", "c", Map.of("style", "dotted"))
118+
.edge("c", "d", Map.of("style", "dotted"));
119+
120+
assertThat(graph.getNodes()).containsExactlyInAnyOrder(
121+
new Node("a"),
122+
new Node("b"),
123+
new Node("c"),
124+
new Node("d")
125+
);
126+
127+
assertThat(graph.getEdges())
128+
.containsExactlyInAnyOrder(
129+
new Edge("a", "b", Map.of("style", "dotted")),
130+
new Edge("b", "c", Map.of("style", "dotted")),
131+
new Edge("c", "d", Map.of("style", "dotted"))
132+
);
133+
assertThat(graph.getAttributes()).isEmpty();
134+
}
105135
}

0 commit comments

Comments
 (0)