From 96373fe1aad4f832845611736eec01a2f2b57a7e Mon Sep 17 00:00:00 2001
From: Mark Prins <1165786+mprins@users.noreply.github.com>
Date: Wed, 30 Oct 2024 14:13:18 +0100
Subject: [PATCH] HTM-1293: Use Hamcrest 3 test utilities
also cleanup and check used dependencies
---
README.md | 11 +-
pom.xml | 378 ++++++++++--------
.../processing/GeometryProcessorTest.java | 17 +-
.../ApplicationRepositoryIntegrationTest.java | 2 +-
.../api/scheduling/TMJobDataMapTest.java | 18 +-
5 files changed, 245 insertions(+), 181 deletions(-)
diff --git a/README.md b/README.md
index 0c2a39074..d24a6bcf5 100644
--- a/README.md
+++ b/README.md
@@ -170,17 +170,18 @@ layers).
Some quick points of attention:
-* [Google Java Style](https://google.github.io/styleguide/javaguide.html) formatting is enforced. This is the style of the Android Open Source Project
- (AOSP) with 2-space indent and different import ordering.
- Run the following command to reformat your code (an IntelliJ plugin is also available):
+* [Google Java Style](https://google.github.io/styleguide/javaguide.html) and pom formatting is enforced.
+ This is the style of the Android Open Source Project (AOSP) with 2-space indent and different import ordering.
+ Run the following command to reformat your code (an [IntelliJ plugin](https://plugins.jetbrains.com/plugin/8527-google-java-format) is also available) and pom file:
```
- mvn com.spotify.fmt:fmt-maven-plugin:format
+ mvn fmt:format
+ mvn sortpom:sort
```
* PMD checks are enforced. Run `mvn pmd:check` to verify your code.
* The ErrorProne compiler is used
* A current release of Maven is required
* Java 17
-* JUnit 4 is forbidden
+* JUnit 3 and 4 are forbidden
* Code is reviewed before merge to the main branch
* Javadoc must be valid
diff --git a/pom.xml b/pom.xml
index 7b9fce641..87f1167fa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -120,6 +120,7 @@ SPDX-License-Identifier: MIT
-->
3.17.0
10.20.1
+ 3.0
6.5.3.Final
2.17.2
5.11.3
@@ -172,6 +173,15 @@ SPDX-License-Identifier: MIT
+
+
+ org.eclipse.jetty.ee10
+ jetty-ee10-bom
+ 12.0.14
+ pom
+ import
+
org.junit
junit-bom
@@ -184,68 +194,17 @@ SPDX-License-Identifier: MIT
modernizer-maven-annotations
${modernizer-maven-plugin.version}
-
-
- org.eclipse.jetty.ee10
- jetty-ee10-bom
- 12.0.14
- pom
- import
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-data-jpa
-
-
- org.springframework.data
- spring-data-rest-webmvc
-
-
- org.springframework.boot
- spring-boot-starter-quartz
-
-
- org.quartz-scheduler
- quartz
-
-
- org.springframework.boot
- spring-boot-starter-actuator
-
-
- io.micrometer
- micrometer-registry-prometheus
-
-
- org.hibernate.orm
- hibernate-micrometer
-
-
- org.apache.solr
- solr-solrj
- ${solr.version}
-
-
- org.apache.solr
- solr-solrj-zookeeper
-
-
-
-
- org.flywaydb
- flyway-core
+ ch.rasc
+ sse-eventbus
+ 2.0.1
- org.flywaydb
- flyway-database-postgresql
+ com.fasterxml.jackson.core
+ jackson-annotations
com.fasterxml.jackson.core
@@ -256,13 +215,17 @@ SPDX-License-Identifier: MIT
jackson-databind
- com.fasterxml.jackson.core
- jackson-annotations
+ com.microsoft.sqlserver
+ mssql-jdbc
- io.hypersistence
- hypersistence-utils-hibernate-63
- 3.8.3
+ com.oracle.database.jdbc
+ ojdbc11
+
+
+ commons-io
+ commons-io
+ 2.17.0
io.hypersistence
@@ -272,93 +235,83 @@ SPDX-License-Identifier: MIT
2.1.2
- org.springframework.boot
- spring-boot-starter-aop
-
-
- org.springframework.boot
- spring-boot-starter-validation
+ io.hypersistence
+ hypersistence-utils-hibernate-63
+ 3.8.3
- org.springframework.boot
- spring-boot-starter-test
- test
+ io.micrometer
+ micrometer-registry-prometheus
- org.springframework.boot
- spring-boot-configuration-processor
- true
+ io.sentry
+ sentry
+ ${sentry.version}
- org.springframework.boot
- spring-boot-starter-security
+ io.sentry
+ sentry-jdbc
+ ${sentry.version}
- org.springframework.boot
- spring-boot-starter-oauth2-client
+ io.sentry
+ sentry-quartz
+ ${sentry.version}
- org.springframework.hateoas
- spring-hateoas
+ io.sentry
+ sentry-spring-boot-starter-jakarta
+ ${sentry.version}
- org.springframework.security
- spring-security-test
- test
+ io.swagger.core.v3
+ swagger-annotations
+ 2.2.25
- org.junit-pioneer
- junit-pioneer
- 2.3.0
- test
+ jakarta.annotation
+ jakarta.annotation-api
- com.github.romankh3
- image-comparison
- 4.4.0
- test
+ jakarta.persistence
+ jakarta.persistence-api
- com.squareup.okhttp3
- mockwebserver3
- test
+ jakarta.validation
+ jakarta.validation-api
- com.squareup.okhttp3
- mockwebserver3-junit5
- test
+ me.gosimple
+ nbvcxz
+ 1.5.1
-
- org.gaul
- modernizer-maven-annotations
+ org.apache.commons
+ commons-lang3
- org.postgresql
- postgresql
+ org.apache.solr
+ solr-solrj
+ ${solr.version}
- org.checkerframework
- checker-qual
+ org.apache.solr
+ solr-solrj-zookeeper
- com.microsoft.sqlserver
- mssql-jdbc
-
-
- com.oracle.database.jdbc
- ojdbc11
+ org.flywaydb
+ flyway-core
- org.apache.commons
- commons-lang3
+ org.flywaydb
+ flyway-database-postgresql
- org.locationtech.jts
- jts-core
- ${jts.version}
+
+ org.gaul
+ modernizer-maven-annotations
org.geotools
@@ -367,72 +320,62 @@ SPDX-License-Identifier: MIT
org.geotools
- gt-main
+ gt-cql
${geotools.version}
org.geotools
- gt-geojson-core
+ gt-epsg-hsql
${geotools.version}
org.geotools
- gt-wfs-ng
+ gt-geojson-core
${geotools.version}
org.geotools
- gt-metadata
- ${geotools.version}
-
-
- org.geotools.xsd
- gt-xsd-core
- ${geotools.version}
-
-
- org.geotools.xsd
- gt-xsd-gml3
+ gt-http
${geotools.version}
org.geotools
- gt-http
+ gt-jdbc
${geotools.version}
org.geotools
- gt-cql
+ gt-main
${geotools.version}
org.geotools
- gt-xml
+ gt-metadata
${geotools.version}
org.geotools
- gt-wms
+ gt-referencing
${geotools.version}
org.geotools
- gt-wmts
+ gt-wfs-ng
${geotools.version}
org.geotools
- gt-referencing
+ gt-wms
${geotools.version}
org.geotools
- gt-epsg-hsql
+ gt-wmts
${geotools.version}
org.geotools
- gt-jdbc
+ gt-xml
${geotools.version}
@@ -473,9 +416,93 @@ SPDX-License-Identifier: MIT
- io.swagger.core.v3
- swagger-annotations
- 2.2.25
+ org.geotools.xsd
+ gt-xsd-core
+ ${geotools.version}
+
+
+ org.geotools.xsd
+ gt-xsd-gml3
+ ${geotools.version}
+
+
+ org.hibernate
+ hibernate-core
+ ${hibernate.version}
+
+
+ org.hibernate.orm
+ hibernate-micrometer
+
+
+
+ org.immutables
+ value
+ 2.10.1
+
+
+ org.locationtech.jts
+ jts-core
+ ${jts.version}
+
+
+ org.postgresql
+ postgresql
+
+
+ org.checkerframework
+ checker-qual
+
+
+
+
+ org.quartz-scheduler
+ quartz
+
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+ org.springframework.boot
+ spring-boot-starter-aop
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-oauth2-client
+
+
+ org.springframework.boot
+ spring-boot-starter-quartz
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.data
+ spring-data-rest-webmvc
+
+
+ org.springframework.hateoas
+ spring-hateoas
org.webjars
@@ -487,40 +514,62 @@ SPDX-License-Identifier: MIT
webjars-locator-core
- io.sentry
- sentry-spring-boot-starter-jakarta
- ${sentry.version}
+ com.github.romankh3
+ image-comparison
+ 4.4.0
+ test
- io.sentry
- sentry-jdbc
- ${sentry.version}
+ com.jayway.jsonpath
+ json-path
+ test
- io.sentry
- sentry-quartz
- ${sentry.version}
+ com.squareup.okhttp3
+ mockwebserver3
+ test
- io.sentry
- sentry
- ${sentry.version}
+ com.squareup.okhttp3
+ mockwebserver3-junit5
+ test
- me.gosimple
- nbvcxz
- 1.5.1
+ com.squareup.okhttp3
+ okhttp
+ test
- ch.rasc
- sse-eventbus
- 2.0.1
+ org.hamcrest
+ hamcrest
+ test
-
- org.immutables
- value
- 2.10.1
+ org.junit-pioneer
+ junit-pioneer
+ 2.3.0
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.assertj
+ assertj-core
+
+
+
+
+ org.springframework.security
+ spring-security-test
+ test
@@ -1138,6 +1187,7 @@ SPDX-License-Identifier: MIT
false
4
false
+ scope,groupId,artifactId
@@ -1171,8 +1221,10 @@ SPDX-License-Identifier: MIT
junit:junit
org.hamcrest:hamcrest-core
+ org.hamcrest:hamcrest-all
log4j:log4j
joda-time:joda-time
+ org.assertj:assertj-core
@@ -1189,6 +1241,8 @@ SPDX-License-Identifier: MIT
org.springframework.boot:spring-boot-starter-quartz
org.quartz-scheduler:quartz
org.springframework.security:spring-security-test
+ org.hibernate.orm:hibernate-core
+ jakarta.persistence:jakarta.persistence-api
io.hypersistence:hypersistence-utils-hibernate-63
org.webjars:webjars-locator-core
org.springframework.boot:spring-boot-starter-aop
@@ -1209,6 +1263,8 @@ SPDX-License-Identifier: MIT
org.flywaydb:flyway-core
ch.rasc:sse-eventbus
org.apache.solr:solr-solrj
+ com.jayway.jsonpath
+ org.junit.jupiter:junit-jupiter-api
diff --git a/src/test/java/org/tailormap/api/geotools/processing/GeometryProcessorTest.java b/src/test/java/org/tailormap/api/geotools/processing/GeometryProcessorTest.java
index cffacd962..bd5ec85d9 100644
--- a/src/test/java/org/tailormap/api/geotools/processing/GeometryProcessorTest.java
+++ b/src/test/java/org/tailormap/api/geotools/processing/GeometryProcessorTest.java
@@ -5,8 +5,8 @@
*/
package org.tailormap.api.geotools.processing;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.within;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.closeTo;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -95,10 +95,15 @@ void simplifyPolygon() throws ParseException {
final Geometry p2 = new WKTReader2().read(simplified);
assertTrue(p.overlaps(p2), "source polygon should overlap simplified");
- /* PMD.JUnitAssertionsShouldIncludeMessage */
- assertThat(100 * p2.intersection(p).getArea() / p.getArea()) // NOPMD
- .as("intersection area should be about 99% of original")
- .isCloseTo(99, within(1d));
+ // /* PMD.JUnitAssertionsShouldIncludeMessage */
+ // assertThat(100 * p2.intersection(p).getArea() / p.getArea())
+ // .as("intersection area should be about 99% of original")
+ // .isCloseTo(99, within(1d));
+ assertThat(
+ "intersection area should be about 99% of original",
+ 100 * p2.intersection(p).getArea() / p.getArea(), closeTo(99, 1d));
+
+ // .isCloseTo(99, within(1d));
}
@Test
diff --git a/src/test/java/org/tailormap/api/repository/ApplicationRepositoryIntegrationTest.java b/src/test/java/org/tailormap/api/repository/ApplicationRepositoryIntegrationTest.java
index 6fb458e51..341dea5ff 100644
--- a/src/test/java/org/tailormap/api/repository/ApplicationRepositoryIntegrationTest.java
+++ b/src/test/java/org/tailormap/api/repository/ApplicationRepositoryIntegrationTest.java
@@ -5,8 +5,8 @@
*/
package org.tailormap.api.repository;
-import static org.hibernate.validator.internal.util.Contracts.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.jupiter.api.Test;
diff --git a/src/test/java/org/tailormap/api/scheduling/TMJobDataMapTest.java b/src/test/java/org/tailormap/api/scheduling/TMJobDataMapTest.java
index f849ddf89..588cec2b7 100644
--- a/src/test/java/org/tailormap/api/scheduling/TMJobDataMapTest.java
+++ b/src/test/java/org/tailormap/api/scheduling/TMJobDataMapTest.java
@@ -5,8 +5,8 @@
*/
package org.tailormap.api.scheduling;
-import static org.hibernate.validator.internal.util.Contracts.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.Map;
@@ -18,7 +18,9 @@ class TMJobDataMapTest {
@Test
void testInvalidMap() {
assertThrows(
- IllegalArgumentException.class, () -> new TMJobDataMap(Map.of(Task.TYPE_KEY, "test")));
+ IllegalArgumentException.class,
+ () -> new TMJobDataMap(Map.of(Task.TYPE_KEY, "test")),
+ "JobDataMap should not be created for missing parameters");
}
/** Test the creation using a map with all required parameters. */
@@ -26,9 +28,9 @@ void testInvalidMap() {
void testMap() {
TMJobDataMap jobDataMap =
new TMJobDataMap(Map.of(Task.TYPE_KEY, "test", Task.DESCRIPTION_KEY, "test"));
- assertNotNull(jobDataMap);
- assertEquals("NONE", jobDataMap.getState().name());
- assertEquals(5, jobDataMap.getPriority());
+ assertNotNull(jobDataMap, "JobDataMap should not be null");
+ assertEquals("NONE", jobDataMap.getState().name(), "State should be NONE");
+ assertEquals(5, jobDataMap.getPriority(), "Priority should be 5");
}
/** Test the creation using a map with required parameters and negative priority. */
@@ -37,8 +39,8 @@ void testMapWithPriority() {
TMJobDataMap jobDataMap =
new TMJobDataMap(
Map.of(Task.TYPE_KEY, "test", Task.DESCRIPTION_KEY, "test", Task.PRIORITY_KEY, -1));
- assertNotNull(jobDataMap);
- assertEquals("NONE", jobDataMap.getState().name());
- assertEquals(0, jobDataMap.getPriority());
+ assertNotNull(jobDataMap, "JobDataMap should not be null");
+ assertEquals("NONE", jobDataMap.getState().name(), "State should be NONE");
+ assertEquals(0, jobDataMap.getPriority(), "Priority should be 0");
}
}