Skip to content

Commit 4be9013

Browse files
#86370 removed unnecessary dependency on Hamcrest library
1 parent 814cdcf commit 4be9013

File tree

6 files changed

+72
-103
lines changed

6 files changed

+72
-103
lines changed

map-matcher-geometry/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@
3939
<artifactId>mockito-junit-jupiter</artifactId>
4040
<scope>test</scope>
4141
</dependency>
42-
<dependency>
43-
<groupId>org.hamcrest</groupId>
44-
<artifactId>hamcrest-library</artifactId>
45-
<scope>test</scope>
46-
</dependency>
4742
<dependency>
4843
<groupId>org.assertj</groupId>
4944
<artifactId>assertj-core</artifactId>

map-matcher-library/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@
7878
<artifactId>mockito-junit-jupiter</artifactId>
7979
<scope>test</scope>
8080
</dependency>
81-
<dependency>
82-
<groupId>org.hamcrest</groupId>
83-
<artifactId>hamcrest-library</artifactId>
84-
<scope>test</scope>
85-
</dependency>
8681
<dependency>
8782
<groupId>com.fasterxml.jackson.core</groupId>
8883
<artifactId>jackson-databind</artifactId>

map-matcher-library/src/test/java/nu/ndw/nls/routingmapmatcher/singlepoint/PointMatchingServiceIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ void calculateMatches_with_no_matching_bearing_should_produce_no_match() {
182182
.travelDirection(EdgeIteratorTravelDirection.BOTH_DIRECTIONS)
183183
.build();
184184
var matches = pointMatchingService.calculateMatches(request);
185-
assertThat(matches).hasSize(0);
185+
assertThat(matches).isEmpty();
186186
}
187187

188188
@Test

map-matcher-library/src/test/java/nu/ndw/nls/routingmapmatcher/singlepoint/SinglePointMapMatcherIT.java

Lines changed: 66 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
package nu.ndw.nls.routingmapmatcher.singlepoint;
22

33
import static nu.ndw.nls.routingmapmatcher.testutil.TestNetworkProvider.CAR;
4-
import static org.hamcrest.MatcherAssert.assertThat;
5-
import static org.hamcrest.Matchers.closeTo;
6-
import static org.hamcrest.Matchers.containsInAnyOrder;
7-
import static org.hamcrest.Matchers.hasSize;
8-
import static org.hamcrest.Matchers.is;
9-
import static org.hamcrest.Matchers.notNullValue;
10-
import static org.hamcrest.Matchers.nullValue;
11-
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.assertj.core.api.Assertions.assertThat;
5+
import static org.assertj.core.api.Assertions.offset;
126

137
import java.util.List;
148
import java.util.Set;
@@ -68,14 +62,14 @@ void testFraction(String externalId, double x, double y, double expectedFraction
6862
.id(ID)
6963
.point(point)
7064
.build());
71-
assertThat(singlePointMatch, is(notNullValue()));
72-
assertEquals(ID, singlePointMatch.getId());
73-
assertThat(singlePointMatch.getStatus(), is(MatchStatus.MATCH));
65+
assertThat(singlePointMatch).isNotNull();
66+
assertThat(singlePointMatch.getId()).isEqualTo(ID);
67+
assertThat(singlePointMatch.getStatus()).isEqualTo(MatchStatus.MATCH);
7468
List<CandidateMatch> candidateMatches = getNearestCandidateMatches(singlePointMatch.getCandidateMatches());
75-
assertThat(candidateMatches, hasSize(1));
69+
assertThat(candidateMatches).hasSize(1);
7670
assertThatUpstreamAndDownstreamAreNull(candidateMatches);
77-
assertThat(getSnappedPoints(candidateMatches), hasSize(1));
78-
assertThat(singlePointMatch.getCandidateMatches().getFirst().getFraction(), closeTo(expectedFraction, 0.01));
71+
assertThat(getSnappedPoints(candidateMatches)).hasSize(1);
72+
assertThat(singlePointMatch.getCandidateMatches().getFirst().getFraction()).isCloseTo(expectedFraction, offset(0.01));
7973
}
8074

8175
@SneakyThrows
@@ -89,14 +83,14 @@ void testOneWayMatch() {
8983
.id(ID)
9084
.point(point)
9185
.build());
92-
assertThat(singlePointMatch, is(notNullValue()));
93-
assertEquals(ID, singlePointMatch.getId());
94-
assertThat(singlePointMatch.getStatus(), is(MatchStatus.MATCH));
86+
assertThat(singlePointMatch).isNotNull();
87+
assertThat(singlePointMatch.getId()).isEqualTo(ID);
88+
assertThat(singlePointMatch.getStatus()).isEqualTo(MatchStatus.MATCH);
9589
List<CandidateMatch> candidateMatches = getNearestCandidateMatches(singlePointMatch.getCandidateMatches());
96-
assertThat(candidateMatches, hasSize(1));
90+
assertThat(candidateMatches).hasSize(1);
9791
assertThatUpstreamAndDownstreamAreNull(candidateMatches);
98-
assertThat(getSnappedPoints(candidateMatches), hasSize(1));
99-
assertThat(singlePointMatch.getReliability(), is(66.96798791959225));
92+
assertThat(getSnappedPoints(candidateMatches)).hasSize(1);
93+
assertThat(singlePointMatch.getReliability()).isEqualTo(66.96798791959225);
10094
}
10195

10296
@SneakyThrows
@@ -110,14 +104,14 @@ void testBidirectionalWayMatch() {
110104
.id(ID)
111105
.point(point)
112106
.build());
113-
assertThat(singlePointMatch, is(notNullValue()));
114-
assertEquals(ID, singlePointMatch.getId());
115-
assertThat(singlePointMatch.getStatus(), is(MatchStatus.MATCH));
107+
assertThat(singlePointMatch).isNotNull();
108+
assertThat(singlePointMatch.getId()).isEqualTo(ID);
109+
assertThat(singlePointMatch.getStatus()).isEqualTo(MatchStatus.MATCH);
116110
List<CandidateMatch> candidateMatches = getNearestCandidateMatches(singlePointMatch.getCandidateMatches());
117-
assertThat(candidateMatches, hasSize(2));
111+
assertThat(candidateMatches).hasSize(2);
118112
assertThatUpstreamAndDownstreamAreNull(candidateMatches);
119-
assertThat(getSnappedPoints(candidateMatches), hasSize(1));
120-
assertThat(singlePointMatch.getReliability(), is(84.53118547414594));
113+
assertThat(getSnappedPoints(candidateMatches)).hasSize(1);
114+
assertThat(singlePointMatch.getReliability()).isEqualTo(84.53118547414594);
121115
}
122116

123117
@SneakyThrows
@@ -132,14 +126,14 @@ void testBidirectionalWayMatchWithBearingFilter() {
132126
.point(point)
133127
.bearingFilter(new BearingFilter(85, 30))
134128
.build());
135-
assertThat(singlePointMatch, is(notNullValue()));
136-
assertEquals(ID, singlePointMatch.getId());
137-
assertThat(singlePointMatch.getStatus(), is(MatchStatus.MATCH));
129+
assertThat(singlePointMatch).isNotNull();
130+
assertThat(singlePointMatch.getId()).isEqualTo(ID);
131+
assertThat(singlePointMatch.getStatus()).isEqualTo(MatchStatus.MATCH);
138132
List<CandidateMatch> candidateMatches = getNearestCandidateMatches(singlePointMatch.getCandidateMatches());
139-
assertThat(candidateMatches, hasSize(1));
133+
assertThat(candidateMatches).hasSize(1);
140134
assertThatUpstreamAndDownstreamAreNull(candidateMatches);
141-
assertThat(getSnappedPoints(candidateMatches), hasSize(1));
142-
assertThat(singlePointMatch.getReliability(), is(79.55725120440115));
135+
assertThat(getSnappedPoints(candidateMatches)).hasSize(1);
136+
assertThat(singlePointMatch.getReliability()).isEqualTo(79.55725120440115);
143137
}
144138

145139
@SneakyThrows
@@ -153,14 +147,14 @@ void testNodeMatch() {
153147
.id(ID)
154148
.point(point)
155149
.build());
156-
assertThat(singlePointMatch, is(notNullValue()));
157-
assertEquals(ID, singlePointMatch.getId());
158-
assertThat(singlePointMatch.getStatus(), is(MatchStatus.MATCH));
150+
assertThat(singlePointMatch).isNotNull();
151+
assertThat(singlePointMatch.getId()).isEqualTo(ID);
152+
assertThat(singlePointMatch.getStatus()).isEqualTo(MatchStatus.MATCH);
159153
List<CandidateMatch> candidateMatches = getNearestCandidateMatches(singlePointMatch.getCandidateMatches());
160-
assertThat(candidateMatches, hasSize(8));
154+
assertThat(candidateMatches).hasSize(8);
161155
assertThatUpstreamAndDownstreamAreNull(candidateMatches);
162-
assertThat(getSnappedPoints(candidateMatches), hasSize(1));
163-
assertThat(singlePointMatch.getReliability(), is(100.0));
156+
assertThat(getSnappedPoints(candidateMatches)).hasSize(1);
157+
assertThat(singlePointMatch.getReliability()).isEqualTo(100.0);
164158
}
165159

166160
@SneakyThrows
@@ -175,14 +169,14 @@ void testNodeMatchWithBearingFilter() {
175169
.point(point)
176170
.bearingFilter(new BearingFilter(15, 30))
177171
.build());
178-
assertThat(singlePointMatch, is(notNullValue()));
179-
assertEquals(ID, singlePointMatch.getId());
180-
assertThat(singlePointMatch.getStatus(), is(MatchStatus.MATCH));
172+
assertThat(singlePointMatch).isNotNull();
173+
assertThat(singlePointMatch.getId()).isEqualTo(ID);
174+
assertThat(singlePointMatch.getStatus()).isEqualTo(MatchStatus.MATCH);
181175
List<CandidateMatch> candidateMatches = getNearestCandidateMatches(singlePointMatch.getCandidateMatches());
182-
assertThat(candidateMatches, hasSize(2));
176+
assertThat(candidateMatches).hasSize(2);
183177
assertThatUpstreamAndDownstreamAreNull(candidateMatches);
184-
assertThat(getSnappedPoints(candidateMatches), hasSize(1));
185-
assertThat(singlePointMatch.getReliability(), is(97.28721697585911));
178+
assertThat(getSnappedPoints(candidateMatches)).hasSize(1);
179+
assertThat(singlePointMatch.getReliability()).isEqualTo(97.28721697585911);
186180
}
187181

188182
@SneakyThrows
@@ -196,14 +190,14 @@ void testDoubleMatch() {
196190
.id(ID)
197191
.point(point)
198192
.build());
199-
assertThat(singlePointMatch, is(notNullValue()));
200-
assertEquals(ID, singlePointMatch.getId());
201-
assertThat(singlePointMatch.getStatus(), is(MatchStatus.MATCH));
193+
assertThat(singlePointMatch).isNotNull();
194+
assertThat(singlePointMatch.getId()).isEqualTo(ID);
195+
assertThat(singlePointMatch.getStatus()).isEqualTo(MatchStatus.MATCH);
202196
List<CandidateMatch> candidateMatches = getNearestCandidateMatches(singlePointMatch.getCandidateMatches());
203-
assertThat(candidateMatches, hasSize(2));
197+
assertThat(candidateMatches).hasSize(2);
204198
assertThatUpstreamAndDownstreamAreNull(candidateMatches);
205-
assertThat(getSnappedPoints(candidateMatches), hasSize(2));
206-
assertThat(singlePointMatch.getReliability(), is(95.53279394202733));
199+
assertThat(getSnappedPoints(candidateMatches)).hasSize(2);
200+
assertThat(singlePointMatch.getReliability()).isEqualTo(95.53279394202733);
207201
}
208202

209203
@SneakyThrows
@@ -216,11 +210,11 @@ void testNoMatch() {
216210
.id(ID)
217211
.point(point)
218212
.build());
219-
assertThat(singlePointMatch, is(notNullValue()));
220-
assertEquals(ID, singlePointMatch.getId());
221-
assertThat(singlePointMatch.getStatus(), is(MatchStatus.NO_MATCH));
222-
assertThat(singlePointMatch.getCandidateMatches(), hasSize(0));
223-
assertThat(singlePointMatch.getReliability(), is(0.0));
213+
assertThat(singlePointMatch).isNotNull();
214+
assertThat(singlePointMatch.getId()).isEqualTo(ID);
215+
assertThat(singlePointMatch.getStatus()).isEqualTo(MatchStatus.NO_MATCH);
216+
assertThat(singlePointMatch.getCandidateMatches()).isEmpty();
217+
assertThat(singlePointMatch.getReliability()).isEqualTo(0.0);
224218
}
225219

226220
@SneakyThrows
@@ -237,32 +231,26 @@ void testUpstreamDownstream() {
237231
.downstreamIsochrone(30)
238232
.downstreamIsochroneUnit(IsochroneUnit.SECONDS)
239233
.build());
240-
assertThat(singlePointMatch, is(notNullValue()));
241-
assertEquals(ID, singlePointMatch.getId());
242-
assertThat(singlePointMatch.getStatus(), is(MatchStatus.MATCH));
234+
assertThat(singlePointMatch).isNotNull();
235+
assertThat(singlePointMatch.getId()).isEqualTo(ID);
236+
assertThat(singlePointMatch.getStatus()).isEqualTo(MatchStatus.MATCH);
243237
List<CandidateMatch> candidateMatches = getNearestCandidateMatches(singlePointMatch.getCandidateMatches());
244-
assertThat(candidateMatches, hasSize(1));
245-
assertThat(getSnappedPoints(candidateMatches), hasSize(1));
246-
assertThat(singlePointMatch.getReliability(), is(92.4716649970769));
238+
assertThat(candidateMatches).hasSize(1);
239+
assertThat(getSnappedPoints(candidateMatches)).hasSize(1);
240+
assertThat(singlePointMatch.getReliability()).isEqualTo(92.4716649970769);
247241

248242
SinglePointMatch.CandidateMatch candidateMatch = singlePointMatch.getCandidateMatches().getFirst();
249-
assertThat(candidateMatch.getMatchedLinkId(), is(3666958));
243+
assertThat(candidateMatch.getMatchedLinkId()).isEqualTo(3666958);
250244

251245
// TODO upstream and downstream shouldn't contain matched segment itself?
252-
assertThat(
253-
candidateMatch.getUpstreamLinkIds(), containsInAnyOrder(3666958,
254-
3666957, 3666956, 3666955, 3667003, 3667002, 3667001, 3667000, 3666999, 3666998, 3666997,
255-
3666996,
256-
3666256, 3666973, 3666972, 3666971, 3666970, 3666969, 3666968, 3666967, 3666966, 3666974,
257-
3667137,
258-
3667136, 3667135, 3667134, 3666244, 3666243, 3666242, 3666241, 3666240, 3666223, 3667125,
259-
3667124,
260-
3667123, 3667122, 3667121, 3667120));
261-
assertThat(candidateMatch.getDownstreamLinkIds(), containsInAnyOrder(3666958,
262-
3666098, 3666099, 3666100, 3666101, 3666102, 3666103, 3666104, 3666105, 3666106, 3666107, 3666108,
263-
3666109, 3686216, 3686217, 3666945, 3666946, 3666947, 3666948, 3666949, 3666950, 3666951, 3666952,
264-
3666943, 3666944, 3666953, 3666954, 3666123, 3666110, 3666111, 3666112, 3666113, 3666114, 3666130,
265-
3666115, 3666116, 3666117, 3666118, 3666119, 3666120));
246+
assertThat(candidateMatch.getUpstreamLinkIds()).containsExactlyInAnyOrder(3666958, 3666957, 3666956, 3666955, 3667003, 3667002,
247+
3667001, 3667000, 3666999, 3666998, 3666997, 3666996, 3666256, 3666973, 3666972, 3666971, 3666970, 3666969, 3666968,
248+
3666967, 3666966, 3666974, 3667137, 3667136, 3667135, 3667134, 3666244, 3666243, 3666242, 3666241, 3666240, 3666223,
249+
3667125, 3667124, 3667123, 3667122, 3667121, 3667120);
250+
assertThat(candidateMatch.getDownstreamLinkIds()).containsExactlyInAnyOrder(3666958, 3666098, 3666099, 3666100, 3666101, 3666102,
251+
3666103, 3666104, 3666105, 3666106, 3666107, 3666108, 3666109, 3686216, 3686217, 3666945, 3666946, 3666947, 3666948,
252+
3666949, 3666950, 3666951, 3666952, 3666943, 3666944, 3666953, 3666954, 3666123, 3666110, 3666111, 3666112, 3666113,
253+
3666114, 3666130, 3666115, 3666116, 3666117, 3666118, 3666119, 3666120);
266254
}
267255

268256
private List<CandidateMatch> getNearestCandidateMatches(List<CandidateMatch> candidateMatches) {
@@ -272,8 +260,8 @@ private List<CandidateMatch> getNearestCandidateMatches(List<CandidateMatch> can
272260

273261
private void assertThatUpstreamAndDownstreamAreNull(List<CandidateMatch> candidateMatches) {
274262
for (SinglePointMatch.CandidateMatch candidateMatch : candidateMatches) {
275-
assertThat(candidateMatch.getUpstream(), is(nullValue()));
276-
assertThat(candidateMatch.getDownstream(), is(nullValue()));
263+
assertThat(candidateMatch.getUpstream()).isNull();
264+
assertThat(candidateMatch.getDownstream()).isNull();
277265
}
278266
}
279267

map-matcher-library/src/test/java/nu/ndw/nls/routingmapmatcher/singlepoint/SinglePointMapMatcherWithBearingIT.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package nu.ndw.nls.routingmapmatcher.singlepoint;
22

33
import static nu.ndw.nls.routingmapmatcher.testutil.TestNetworkProvider.CAR;
4-
import static org.hamcrest.MatcherAssert.assertThat;
5-
import static org.hamcrest.Matchers.is;
4+
import static org.assertj.core.api.Assertions.assertThat;
65

76
import java.util.List;
87
import lombok.SneakyThrows;
@@ -59,7 +58,7 @@ void match_ok_withBearingFilter() {
5958
.build();
6059
SinglePointMatch result = singlePointMapMatcher.match(request);
6160

62-
assertThat(result, is(SinglePointMatch.builder()
61+
assertThat(result).isEqualTo(SinglePointMatch.builder()
6362
.id(1)
6463
.status(MatchStatus.MATCH)
6564
.reliability(BEARING_RELIABILITY)
@@ -71,7 +70,7 @@ void match_ok_withBearingFilter() {
7170
.bearing(137.88345016490496)
7271
.reliability(BEARING_RELIABILITY)
7372
.build()))
74-
.build()));
73+
.build());
7574
}
7675

7776
@Test
@@ -84,7 +83,7 @@ void match_ok_withBearingFilterAndSnappedPointAtEnd() {
8483
.bearingFilter(new BearingFilter(160, 5))
8584
.build();
8685
SinglePointMatch result = singlePointMapMatcher.match(request);
87-
assertThat(result, is(SinglePointMatch.builder()
86+
assertThat(result).isEqualTo(SinglePointMatch.builder()
8887
.id(1)
8988
.status(MatchStatus.MATCH)
9089
.reliability(SNAPPED_RELIABILITY)
@@ -105,7 +104,7 @@ void match_ok_withBearingFilterAndSnappedPointAtEnd() {
105104
.bearing(161.06168302121978)
106105
.reliability(0)
107106
.build()))
108-
.build()));
107+
.build());
109108
}
110109

111110
private Point createPoint(double x, double y) {

pom.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
<!-- Janino version should match the one used in GraphHopper -->
3737
<janino.version>3.1.12</janino.version>
3838
<jts-core.version>1.19.0</jts-core.version>
39-
<hamcrest.version>3.0</hamcrest.version>
4039
<jacoco.version>0.8.12</jacoco.version>
4140
<geotools.version>30.2</geotools.version>
4241
<jts2geojson.version>0.18.1</jts2geojson.version>
@@ -133,13 +132,6 @@
133132
<version>${commons-io.version}</version>
134133
<scope>compile</scope>
135134
</dependency>
136-
<!-- Testing -->
137-
<dependency>
138-
<groupId>org.hamcrest</groupId>
139-
<artifactId>hamcrest-library</artifactId>
140-
<version>${hamcrest.version}</version>
141-
<scope>test</scope>
142-
</dependency>
143135
</dependencies>
144136
</dependencyManagement>
145137

0 commit comments

Comments
 (0)