Skip to content

Commit 581db1c

Browse files
author
Jegors Cemisovs
committed
Add tests
1 parent cf457fc commit 581db1c

12 files changed

+116
-31
lines changed

docs/assets/append-01C.png

168 KB
Loading

docs/spock-reports/aggregated_report.json

+1-1
Large diffs are not rendered by default.

docs/spock-reports/index.html

+27-14
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ <h2>Specification run results</h2>
8484
</div>
8585
<div class='summary-report'>
8686
<h3>Specifications summary:</h3>
87-
<div class='date-test-ran'>Created on Tue Feb 01 22:33:34 EET 2022 by jegors</div>
87+
<div class='date-test-ran'>Created on Wed Feb 02 18:54:54 EET 2022 by jegors.cemisovs</div>
8888
<table class='summary-table'>
8989
<thead>
9090
<tr>
@@ -102,16 +102,16 @@ <h3>Specifications summary:</h3>
102102
</thead>
103103
<tbody>
104104
<tr>
105-
<td>7</td>
106-
<td>7</td>
105+
<td>8</td>
106+
<td>8</td>
107107
<td>0</td>
108108
<td>0</td>
109-
<td>29</td>
110-
<td>29</td>
109+
<td>32</td>
110+
<td>32</td>
111111
<td>0</td>
112112
<td>0</td>
113113
<td>100.0%</td>
114-
<td>1.183 seconds</td>
114+
<td>1.124 seconds</td>
115115
</tr>
116116
</tbody>
117117
</table>
@@ -142,7 +142,7 @@ <h3>Specifications:</h3>
142142
<td>0</td>
143143
<td>0</td>
144144
<td>100.0%</td>
145-
<td>0.189 seconds</td>
145+
<td>0.312 seconds</td>
146146
</tr>
147147
<tr>
148148
<td>
@@ -155,7 +155,7 @@ <h3>Specifications:</h3>
155155
<td>0</td>
156156
<td>0</td>
157157
<td>100.0%</td>
158-
<td>0.173 seconds</td>
158+
<td>0.116 seconds</td>
159159
</tr>
160160
<tr>
161161
<td>
@@ -168,20 +168,20 @@ <h3>Specifications:</h3>
168168
<td>0</td>
169169
<td>0</td>
170170
<td>100.0%</td>
171-
<td>0.284 seconds</td>
171+
<td>0.169 seconds</td>
172172
</tr>
173173
<tr>
174174
<td>
175175
<a href='metro.repository.AppendSpec.html'>metro.repository.AppendSpec</a>
176-
<div class='spec-title'>Repository 'append' command specifications</div>
176+
<div class='spec-title'>Command 'append' specifications</div>
177177
</td>
178178
<td>4</td>
179179
<td>4</td>
180180
<td>0</td>
181181
<td>0</td>
182182
<td>0</td>
183183
<td>100.0%</td>
184-
<td>0.290 seconds</td>
184+
<td>0.278 seconds</td>
185185
</tr>
186186
<tr>
187187
<td>
@@ -193,7 +193,20 @@ <h3>Specifications:</h3>
193193
<td>0</td>
194194
<td>0</td>
195195
<td>100.0%</td>
196-
<td>0.095 seconds</td>
196+
<td>0.101 seconds</td>
197+
</tr>
198+
<tr>
199+
<td>
200+
<a href='metro.repository.RepositoryGraphSpec.html'>metro.repository.RepositoryGraphSpec</a>
201+
<div class='spec-title'>Command 'getGraph' specifications</div>
202+
</td>
203+
<td>3</td>
204+
<td>3</td>
205+
<td>0</td>
206+
<td>0</td>
207+
<td>0</td>
208+
<td>100.0%</td>
209+
<td>0.032 seconds</td>
197210
</tr>
198211
<tr>
199212
<td>
@@ -205,7 +218,7 @@ <h3>Specifications:</h3>
205218
<td>0</td>
206219
<td>0</td>
207220
<td>100.0%</td>
208-
<td>0.052 seconds</td>
221+
<td>0.069 seconds</td>
209222
</tr>
210223
<tr>
211224
<td>
@@ -217,7 +230,7 @@ <h3>Specifications:</h3>
217230
<td>0</td>
218231
<td>0</td>
219232
<td>100.0%</td>
220-
<td>0.100 seconds</td>
233+
<td>0.047 seconds</td>
221234
</tr>
222235
</tbody>
223236
</table>

docs/spock-reports/metro.algorithm.BreadthFirstSearchSpec.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ <h2>Report for metro.algorithm.BreadthFirstSearchSpec</h2>
251251
</div>
252252
<div class='summary-report'>
253253
<h3>Summary:</h3>
254-
<div class='date-test-ran'>Created on Tue Feb 01 22:33:30 EET 2022 by jegors</div>
254+
<div class='date-test-ran'>Created on Wed Feb 02 18:54:50 EET 2022 by jegors.cemisovs</div>
255255
<table class='summary-table'>
256256
<thead>
257257
<tr>
@@ -272,7 +272,7 @@ <h3>Summary:</h3>
272272
<td>0</td>
273273
<td>0</td>
274274
<td>100.0%</td>
275-
<td>0.189 seconds</td>
275+
<td>0.312 seconds</td>
276276
</tr>
277277
</tbody>
278278
</table>

docs/spock-reports/metro.algorithm.DijkstrasAlgorithmSpec.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ <h2>Report for metro.algorithm.DijkstrasAlgorithmSpec</h2>
251251
</div>
252252
<div class='summary-report'>
253253
<h3>Summary:</h3>
254-
<div class='date-test-ran'>Created on Tue Feb 01 22:33:31 EET 2022 by jegors</div>
254+
<div class='date-test-ran'>Created on Wed Feb 02 18:54:51 EET 2022 by jegors.cemisovs</div>
255255
<table class='summary-table'>
256256
<thead>
257257
<tr>
@@ -272,7 +272,7 @@ <h3>Summary:</h3>
272272
<td>0</td>
273273
<td>0</td>
274274
<td>100.0%</td>
275-
<td>0.173 seconds</td>
275+
<td>0.116 seconds</td>
276276
</tr>
277277
</tbody>
278278
</table>

docs/spock-reports/metro.algorithm.GraphSpec.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ <h2>Report for metro.algorithm.GraphSpec</h2>
251251
</div>
252252
<div class='summary-report'>
253253
<h3>Summary:</h3>
254-
<div class='date-test-ran'>Created on Tue Feb 01 22:33:32 EET 2022 by jegors</div>
254+
<div class='date-test-ran'>Created on Wed Feb 02 18:54:51 EET 2022 by jegors.cemisovs</div>
255255
<table class='summary-table'>
256256
<thead>
257257
<tr>
@@ -272,7 +272,7 @@ <h3>Summary:</h3>
272272
<td>0</td>
273273
<td>0</td>
274274
<td>100.0%</td>
275-
<td>0.284 seconds</td>
275+
<td>0.169 seconds</td>
276276
</tr>
277277
</tbody>
278278
</table>

docs/spock-reports/metro.repository.AppendSpec.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ <h2>Report for metro.repository.AppendSpec</h2>
251251
</div>
252252
<div class='summary-report'>
253253
<h3>Summary:</h3>
254-
<div class='date-test-ran'>Created on Tue Feb 01 22:33:32 EET 2022 by jegors</div>
254+
<div class='date-test-ran'>Created on Wed Feb 02 18:54:52 EET 2022 by jegors.cemisovs</div>
255255
<table class='summary-table'>
256256
<thead>
257257
<tr>
@@ -272,12 +272,12 @@ <h3>Summary:</h3>
272272
<td>0</td>
273273
<td>0</td>
274274
<td>100.0%</td>
275-
<td>0.290 seconds</td>
275+
<td>0.278 seconds</td>
276276
</tr>
277277
</tbody>
278278
</table>
279279
</div>
280-
<pre class='title'>Repository 'append' command specifications</pre>
280+
<pre class='title'>Command 'append' specifications</pre>
281281
<h3>Features:</h3>
282282
<table class='features-table'>
283283
<colgroup>

docs/spock-reports/metro.repository.MetroRepositoryJsonSpec.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ <h2>Report for metro.repository.MetroRepositoryJsonSpec</h2>
251251
</div>
252252
<div class='summary-report'>
253253
<h3>Summary:</h3>
254-
<div class='date-test-ran'>Created on Tue Feb 01 22:33:33 EET 2022 by jegors</div>
254+
<div class='date-test-ran'>Created on Wed Feb 02 18:54:52 EET 2022 by jegors.cemisovs</div>
255255
<table class='summary-table'>
256256
<thead>
257257
<tr>
@@ -272,7 +272,7 @@ <h3>Summary:</h3>
272272
<td>0</td>
273273
<td>0</td>
274274
<td>100.0%</td>
275-
<td>0.095 seconds</td>
275+
<td>0.101 seconds</td>
276276
</tr>
277277
</tbody>
278278
</table>

docs/spock-reports/metro.shell.MetroCommandsSpec.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ <h2>Report for metro.shell.MetroCommandsSpec</h2>
251251
</div>
252252
<div class='summary-report'>
253253
<h3>Summary:</h3>
254-
<div class='date-test-ran'>Created on Tue Feb 01 22:33:33 EET 2022 by jegors</div>
254+
<div class='date-test-ran'>Created on Wed Feb 02 18:54:52 EET 2022 by jegors.cemisovs</div>
255255
<table class='summary-table'>
256256
<thead>
257257
<tr>
@@ -272,7 +272,7 @@ <h3>Summary:</h3>
272272
<td>0</td>
273273
<td>0</td>
274274
<td>100.0%</td>
275-
<td>0.052 seconds</td>
275+
<td>0.069 seconds</td>
276276
</tr>
277277
</tbody>
278278
</table>

docs/spock-reports/metro.shell.PromptSpec.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ <h2>Report for metro.shell.PromptSpec</h2>
251251
</div>
252252
<div class='summary-report'>
253253
<h3>Summary:</h3>
254-
<div class='date-test-ran'>Created on Tue Feb 01 22:33:33 EET 2022 by jegors</div>
254+
<div class='date-test-ran'>Created on Wed Feb 02 18:54:52 EET 2022 by jegors.cemisovs</div>
255255
<table class='summary-table'>
256256
<thead>
257257
<tr>
@@ -272,7 +272,7 @@ <h3>Summary:</h3>
272272
<td>0</td>
273273
<td>0</td>
274274
<td>100.0%</td>
275-
<td>0.100 seconds</td>
275+
<td>0.047 seconds</td>
276276
</tr>
277277
</tbody>
278278
</table>

src/test/groovy/metro/repository/AppendSpec.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package metro.repository
33
import metro.model.Station
44
import spock.lang.Title
55

6-
@Title("Repository 'append' command specifications")
6+
@Title("Command 'append' specifications")
77
class AppendSpec extends MetroRepositorySpec {
88

99
def 'should thrown an exception for non existing metro line'() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package metro.repository
2+
3+
import metro.model.Station
4+
import metro.model.StationId
5+
import spock.lang.Specification
6+
import spock.lang.Subject
7+
import spock.lang.Title
8+
9+
@Title("Command 'getGraph' specifications")
10+
class RepositoryGraphSpec extends Specification {
11+
@Subject
12+
def repository = new MetroRepositoryJson()
13+
14+
def 'should create an empty graph from the empty metro schema'() {
15+
given: 'an empty metro map'
16+
repository.metroMap = [:]
17+
18+
when: 'we create a graph from the metro map'
19+
def graph = repository.getGraph()
20+
21+
then: 'we get an empty graph'
22+
graph.schema().isEmpty()
23+
}
24+
25+
def 'should create a graph from one line, one station metro schema'() {
26+
given: 'a one line, one station metro schema'
27+
repository.metroMap = [(line): [new Station(station, 5)] as ArrayDeque]
28+
29+
when: 'we create a graph from the metro map'
30+
def graph = repository.getGraph()
31+
32+
then: 'the graph schema is not empty'
33+
graph.schema()
34+
35+
and: 'it has only one vertex'
36+
graph.schema().size() == 1
37+
38+
and: 'the only vertex in the graph has correct Station ID'
39+
graph.schema().keySet().contains new StationId(line, station)
40+
41+
where: 'metro line and metro station as'
42+
line | station
43+
'Bakerloo line' | 'Waterloo'
44+
'Central line' | 'White City'
45+
}
46+
47+
def 'should create a graph from one line and three stations'() {
48+
given: 'three stations creating a open-ended line'
49+
def A1 = new Station('A1', 7, ['A2'] as Set, [] as Set, [] as Set)
50+
def A2 = new Station('A2', 5, ['A3'] as Set, ['A1'] as Set, [] as Set)
51+
def A3 = new Station('A3', 9, [] as Set, ['A2'] as Set, [] as Set)
52+
53+
and: 'a metro line with these stations'
54+
def L1 = [A1, A2, A3] as ArrayDeque
55+
56+
and: 'a metro schema with one line'
57+
repository.metroMap = [one: L1]
58+
59+
when: 'we create a graph from the metro map'
60+
def graph = repository.getGraph()
61+
62+
then: 'the graph schema is not empty'
63+
graph.schema()
64+
65+
and: 'it has three vertexes'
66+
graph.schema().size() == 3
67+
}
68+
69+
StationId sid(line, name) {
70+
new StationId(line, name)
71+
}
72+
}

0 commit comments

Comments
 (0)