diff --git a/pom.xml b/pom.xml index 9beae6b3967dc4dcc79297fe71c5f01567e324e1..0d014a89ccdecd3f570ecc2a348f07104b419903 100644 --- a/pom.xml +++ b/pom.xml @@ -6,8 +6,12 @@ <artifactId>RegionChooser</artifactId> <version>0.1.0-SNAPSHOT</version> + <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.source>1.8</maven.compiler.source> + <maven.compiler.target>${maven.compiler.source}</maven.compiler.target> + <junit-jupiter.version>5.6.0</junit-jupiter.version> </properties> <scm> @@ -16,13 +20,14 @@ </scm> <dependencies> - <!-- https://mvnrepository.com/artifact/junit/junit --> + <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.12</version> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <version>${junit-jupiter.version}</version> <scope>test</scope> </dependency> + <!-- https://mvnrepository.com/artifact/org.osgeo/proj4j --> <dependency> <groupId>org.osgeo</groupId> @@ -123,7 +128,8 @@ </manifest> <manifestEntries> <Implementation-URL>http://simstadt.hft-stuttgart.de/</Implementation-URL> - <Implementation-Version>${project.version} (${scmBranch}, rev. ${buildNumber}, ${timestamp})</Implementation-Version> + <Implementation-Version>${project.version} (${scmBranch}, rev. + ${buildNumber}, ${timestamp})</Implementation-Version> </manifestEntries> </archive> </configuration> diff --git a/src/test/java/eu/simstadt/geo/fast_xml_parser/CitygmlParserTests.java b/src/test/java/eu/simstadt/geo/fast_xml_parser/CitygmlParserTests.java index 6ce0851ae72c18a8f32648c75cb60394ced49192..5784cbc4c0f28cf2931448feaa8000ff6a68426f 100644 --- a/src/test/java/eu/simstadt/geo/fast_xml_parser/CitygmlParserTests.java +++ b/src/test/java/eu/simstadt/geo/fast_xml_parser/CitygmlParserTests.java @@ -1,11 +1,11 @@ package eu.simstadt.geo.fast_xml_parser; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.nio.file.Path; import java.nio.file.Paths; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.ximpleware.XPathParseException; @@ -18,17 +18,17 @@ private void testNoNanInCoordinates(Path citygmlPath) throws XPathParseException { CityGmlIterator buildingXmlNodes = new CityGmlIterator(citygmlPath); for (BuildingXmlNode buildingXmlNode : buildingXmlNodes) { - assertTrue("Buildings should have coordinates", buildingXmlNode.hasCoordinates()); - assertFalse(COORDINATE_SHOULD_BE_A_DOUBLE, Double.isNaN(buildingXmlNode.x)); - assertFalse(COORDINATE_SHOULD_BE_A_DOUBLE, Double.isNaN(buildingXmlNode.y)); - assertFalse(COORDINATE_SHOULD_BE_A_DOUBLE, Double.isNaN(buildingXmlNode.xMax)); - assertFalse(COORDINATE_SHOULD_BE_A_DOUBLE, Double.isNaN(buildingXmlNode.yMax)); - assertFalse(COORDINATE_SHOULD_BE_A_DOUBLE, Double.isNaN(buildingXmlNode.xMin)); - assertFalse(COORDINATE_SHOULD_BE_A_DOUBLE, Double.isNaN(buildingXmlNode.yMin)); - assertTrue(COORDINATES_SHOULD_BE_PLAUSIBLE, buildingXmlNode.xMax > buildingXmlNode.x); - assertTrue(COORDINATES_SHOULD_BE_PLAUSIBLE, buildingXmlNode.yMax > buildingXmlNode.y); - assertTrue(COORDINATES_SHOULD_BE_PLAUSIBLE, buildingXmlNode.xMin < buildingXmlNode.x); - assertTrue(COORDINATES_SHOULD_BE_PLAUSIBLE, buildingXmlNode.yMin < buildingXmlNode.y); + assertTrue(buildingXmlNode.hasCoordinates(), "Buildings should have coordinates"); + assertFalse(Double.isNaN(buildingXmlNode.x), COORDINATE_SHOULD_BE_A_DOUBLE); + assertFalse(Double.isNaN(buildingXmlNode.y), COORDINATE_SHOULD_BE_A_DOUBLE); + assertFalse(Double.isNaN(buildingXmlNode.xMax), COORDINATE_SHOULD_BE_A_DOUBLE); + assertFalse(Double.isNaN(buildingXmlNode.yMax), COORDINATE_SHOULD_BE_A_DOUBLE); + assertFalse(Double.isNaN(buildingXmlNode.xMin), COORDINATE_SHOULD_BE_A_DOUBLE); + assertFalse(Double.isNaN(buildingXmlNode.yMin), COORDINATE_SHOULD_BE_A_DOUBLE); + assertTrue(buildingXmlNode.xMax > buildingXmlNode.x, COORDINATES_SHOULD_BE_PLAUSIBLE); + assertTrue(buildingXmlNode.yMax > buildingXmlNode.y, COORDINATES_SHOULD_BE_PLAUSIBLE); + assertTrue(buildingXmlNode.xMin < buildingXmlNode.x, COORDINATES_SHOULD_BE_PLAUSIBLE); + assertTrue(buildingXmlNode.yMin < buildingXmlNode.y, COORDINATES_SHOULD_BE_PLAUSIBLE); } } @@ -67,11 +67,11 @@ public void testExtractNoCoordsFromEmptyBuilding() throws XPathParseException { CityGmlIterator buildingXmlNodes = new CityGmlIterator(citygmlPath); int counter = 0; for (BuildingXmlNode buildingXmlNode : buildingXmlNodes) { - assertFalse("Empty Buildings shouldn't have coordinates", buildingXmlNode.hasCoordinates()); - assertTrue("Coordinate should be a Nan", Double.isNaN(buildingXmlNode.x)); - assertTrue("Coordinate should be a Nan", Double.isNaN(buildingXmlNode.y)); + assertFalse(buildingXmlNode.hasCoordinates(), "Empty Buildings shouldn't have coordinates"); + assertTrue(Double.isNaN(buildingXmlNode.x), "Coordinate should be a Nan"); + assertTrue(Double.isNaN(buildingXmlNode.y), "Coordinate should be a Nan"); counter++; } - assertEquals("3 buildings should have been analyzed", counter, 3); + assertEquals(3, counter, "3 buildings should have been analyzed"); } } diff --git a/src/test/java/eu/simstadt/geo/fast_xml_parser/ConvexHullCalculatorTests.java b/src/test/java/eu/simstadt/geo/fast_xml_parser/ConvexHullCalculatorTests.java index 163b6eac788419d6a632a936e44382d0b0b588ed..ace403f666d4487f1f786ba3f64e0d6801939c11 100644 --- a/src/test/java/eu/simstadt/geo/fast_xml_parser/ConvexHullCalculatorTests.java +++ b/src/test/java/eu/simstadt/geo/fast_xml_parser/ConvexHullCalculatorTests.java @@ -1,7 +1,7 @@ package eu.simstadt.geo.fast_xml_parser; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.io.IOException; import java.nio.file.Files; @@ -9,7 +9,7 @@ import java.nio.file.Paths; import java.util.Comparator; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -27,9 +27,9 @@ public void testExtractConvexHullFromOneBuilding() throws IOException, XPathParseException { Path citygmlPath = repository.resolve("Gruenbuehl.proj/20140218_Gruenbuehl_LOD2_1building.gml"); Geometry hull = ConvexHullCalculator.calculateFromCityGML(citygmlPath); - assertEquals(hull.getCoordinates().length, 4 + 1); // Convex hull of a building should be a closed rectangle + assertEquals(4 + 1, hull.getCoordinates().length); // Convex hull of a building should be a closed rectangle Point someBuildingPoint = gf.createPoint(new Coordinate(9.216845, 48.878196)); // WGS84 - assertTrue("Hull should contain every building point", hull.contains(someBuildingPoint)); + assertTrue(hull.contains(someBuildingPoint), "Hull should contain every building point"); } @Test @@ -39,7 +39,7 @@ public void testExtractConvexHullFromOneSmallRegion() throws IOException, XPathP assertTrue(hull.getCoordinates().length > 4); // Convex hull should have at least 4 corners // Point somewhereBetweenBuildings = gf.createPoint(new Coordinate(3515883.6668538367, 5415843.300640578)); // Original coordinates, GSK3 Point somewhereBetweenBuildings = gf.createPoint(new Coordinate(9.21552249084, 48.87980446)); // WGS84 - assertTrue("Hull should contain region between buildings", hull.contains(somewhereBetweenBuildings)); + assertTrue(hull.contains(somewhereBetweenBuildings), "Hull should contain region between buildings"); } @Test @@ -48,7 +48,7 @@ public void testExtractConvexHullFromStoeckachNoBuildingPart() throws IOExceptio Geometry hull = ConvexHullCalculator.calculateFromCityGML(citygmlPath); assertTrue(hull.getCoordinates().length > 4); // Convex hull should have at least 4 corners Point somewhereBetweenBuildings = gf.createPoint(new Coordinate(9.195212, 48.789062)); // WGS84 - assertTrue("Hull should contain region between buildings", hull.contains(somewhereBetweenBuildings)); + assertTrue(hull.contains(somewhereBetweenBuildings), "Hull should contain region between buildings"); } @Test @@ -63,13 +63,13 @@ public void testExtractConvexHullFromEveryCitygmlInRepository() throws IOExcepti long gmlCount = RegionChooserUtils.everyCityGML(repository).count(); AtomicInteger hullCount = new AtomicInteger(0); ConvexHullCalculator.extractHullsForEveryCityGML(repository, kmlHull -> { - assertTrue("KML hull should contain project name", kmlHull.contains("Data name=\"project\"")); - assertTrue("KML hull should contain srs name", kmlHull.contains("Data name=\"srsName\"")); - assertTrue("KML hull should contain epsg id", kmlHull.contains("<value>EPSG:")); - assertTrue("KML hull should contain coordinates", kmlHull.contains("<coordinates>")); + assertTrue(kmlHull.contains("Data name=\"project\""), "KML hull should contain project name"); + assertTrue(kmlHull.contains("Data name=\"srsName\""), "KML hull should contain srs name"); + assertTrue(kmlHull.contains("<value>EPSG:"), "KML hull should contain epsg id"); + assertTrue(kmlHull.contains("<coordinates>"), "KML hull should contain coordinates"); hullCount.getAndIncrement(); }); - assertTrue("At least " + minHullCount + " citygmls should be present in repository", gmlCount >= minHullCount); - assertTrue("At least " + minHullCount + " hulls should have been calculated", hullCount.get() >= minHullCount); + assertTrue(gmlCount >= minHullCount, "At least " + minHullCount + " citygmls should be present in repository"); + assertTrue(hullCount.get() >= minHullCount, "At least " + minHullCount + " hulls should have been calculated"); } } diff --git a/src/test/java/eu/simstadt/regionchooser/CRSfromCityGMLHeaderTests.java b/src/test/java/eu/simstadt/regionchooser/CRSfromCityGMLHeaderTests.java index 5e902fab27e96ffeb581ac6115ee875cd2adc973..06ccc524dfe5b1f9328446415c8c614110bfcdeb 100644 --- a/src/test/java/eu/simstadt/regionchooser/CRSfromCityGMLHeaderTests.java +++ b/src/test/java/eu/simstadt/regionchooser/CRSfromCityGMLHeaderTests.java @@ -1,10 +1,11 @@ package eu.simstadt.regionchooser; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; -import org.junit.Test; +import org.junit.jupiter.api.Test; import eu.simstadt.geo.RegionChooserUtils; @@ -13,17 +14,19 @@ private Path repo = Paths.get("src/test/resources/testdata"); private void testExtractCSRNameFromHeader(Path citygmlPath, String crsName) throws IOException { - assertEquals(crsName, RegionChooserUtils.crsFromCityGMLHeader(citygmlPath).toString()); + assertEquals(RegionChooserUtils.crsFromCityGMLHeader(citygmlPath).toString(), crsName); } @Test public void testExtractCRSFromStuttgart() throws IOException { - testExtractCSRNameFromHeader(repo.resolve("Stuttgart.proj/Stuttgart_LOD0_LOD1_buildings_and_trees.gml"), "EPSG:31463"); + testExtractCSRNameFromHeader(repo.resolve("Stuttgart.proj/Stuttgart_LOD0_LOD1_buildings_and_trees.gml"), + "EPSG:31463"); } @Test public void testExtractCRSFromGruenbuehl() throws IOException { - testExtractCSRNameFromHeader(repo.resolve("Gruenbuehl.proj/20140218_Gruenbuehl_LOD2_1building.gml"), "EPSG:31467"); + testExtractCSRNameFromHeader(repo.resolve("Gruenbuehl.proj/20140218_Gruenbuehl_LOD2_1building.gml"), + "EPSG:31467"); } @Test @@ -46,9 +49,11 @@ public void testExtractCRSFromValladolid() throws IOException { testExtractCSRNameFromHeader(repo.resolve("Others.proj/Valladolid_Spain_only_header.gml"), "EPSG:25830"); } - @Test(expected = IllegalArgumentException.class) + @Test public void testDontExtractCRSFromBrokenCityGML() throws IOException { Path citygmlPath = repo.resolve("Others.proj/SimpleSolid_MSBS.gml"); - testExtractCSRNameFromHeader(citygmlPath, "Nothing found. Should throw an exception"); + assertThrows(IllegalArgumentException.class, () -> { + testExtractCSRNameFromHeader(citygmlPath, "Nothing found. Should throw an exception"); + }); } } diff --git a/src/test/java/eu/simstadt/regionchooser/RegionExtractorTests.java b/src/test/java/eu/simstadt/regionchooser/RegionExtractorTests.java index f178f3999fb1b5e155f1e728f4a430d6815e5ed3..fbe5ed68b3ab8ffa1c83e7ffa28a8536d2ae42cb 100644 --- a/src/test/java/eu/simstadt/regionchooser/RegionExtractorTests.java +++ b/src/test/java/eu/simstadt/regionchooser/RegionExtractorTests.java @@ -1,13 +1,13 @@ package eu.simstadt.regionchooser; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.nio.file.Path; import java.nio.file.Paths; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class RegionExtractorTests @@ -37,19 +37,19 @@ public void testExtract3BuildingsFromGSK3Model() throws Throwable { Path citygmlPath = TEST_REPOSITORY.resolve("Gruenbuehl.proj/20140218_Gruenbuehl_LOD2.gml"); String churchGMLString = RegionExtractor.selectRegionDirectlyFromCityGML(citygmlPath, wktPolygon, "EPSG:31467") .toString(); - assertEquals(countRegexMatches(churchGMLString, CITY_OBJECT_MEMBER_REGEX), 3); + assertEquals(3, countRegexMatches(churchGMLString, CITY_OBJECT_MEMBER_REGEX)); assertTrue(churchGMLString.contains("Donaustr")); assertTrue(churchGMLString.contains("DEBW_LOD2_203056")); assertTrue(churchGMLString.contains("DEBW_LOD2_2869")); assertTrue(churchGMLString.contains("DEBW_LOD2_2909")); assertTrue(churchGMLString.contains(CORE_CITY_MODEL_HEADER)); assertTrue(churchGMLString.contains(CORE_CITY_MODEL_FOOTER)); - assertTrue("The exported CityGML should contain a new envelope with the correct EPSG", churchGMLString - .contains("<gml:Envelope srsName=\"EPSG:31467\" srsDimension=\"3\">")); - assertTrue("The exported CityGML should contain a new envelope", churchGMLString - .contains("<gml:lowerCorner>3515829.0815150724 5415766.204935087 ")); - assertTrue("The exported CityGML should contain a new envelope", churchGMLString - .contains("<gml:upperCorner>3515876.489172751 5415823.108586172 ")); + assertTrue(churchGMLString.contains("<gml:Envelope srsName=\"EPSG:31467\" srsDimension=\"3\">"), + "The exported CityGML should contain a new envelope with the correct EPSG"); + assertTrue(churchGMLString.contains("<gml:lowerCorner>3515829.0815150724 5415766.204935087 "), + "The exported CityGML should contain a new envelope"); + assertTrue(churchGMLString.contains("<gml:upperCorner>3515876.489172751 5415823.108586172 "), + "The exported CityGML should contain a new envelope"); } @Test @@ -65,10 +65,10 @@ public void testExtractBuildingsWithoutCommentsInBetween() throws Throwable { assertTrue(archGMLString.contains("uuid_0985cebb-922d-4b3e-95e5-15dc6089cd28")); assertTrue(archGMLString.contains(CITY_MODEL_HEADER)); assertTrue(archGMLString.contains(CITY_MODEL_FOOTER)); - assertFalse("Comments between buildings shouldn't be extracted", - archGMLString.contains("comment between buildings")); // Comment - assertFalse("Comments after buildings shouldn't be extracted", - archGMLString.contains("comment after last building")); // Comment + assertFalse(archGMLString.contains("comment between buildings"), + "Comments between buildings shouldn't be extracted"); + assertFalse(archGMLString.contains("comment after last building"), + "Comments after buildings shouldn't be extracted"); } @Test @@ -77,18 +77,22 @@ public void testExtractBuildingsAndChangeEnvelope() throws Throwable { Path citygmlPath = TEST_REPOSITORY.resolve("NewYork.proj/FamilyCourt_LOD2_with_PLUTO_attributes.gml"); String familyCourtBuilding = RegionExtractor .selectRegionDirectlyFromCityGML(citygmlPath, wktPolygon, EPSG_32118).toString(); - assertEquals(countRegexMatches(familyCourtBuilding, CITY_OBJECT_MEMBER_REGEX), 1); + assertEquals(1, countRegexMatches(familyCourtBuilding, CITY_OBJECT_MEMBER_REGEX)); assertTrue(familyCourtBuilding.contains("Bldg_12210021066")); - assertFalse("The exported CityGML shouldn't contain the original envelope", familyCourtBuilding - .contains("<gml:lowerCorner>298393.46959639067 59277.34021543693 -11.892070104139751</gml:lowerCorner>")); - assertFalse("The exported CityGML shouldn't contain the original envelope", familyCourtBuilding - .contains("<gml:upperCorner>305641.79529639013 67101.44881543722 547.7591871983744</gml:upperCorner>")); - assertTrue("The exported CityGML should contain a new envelope with the original altitudes", familyCourtBuilding - .contains("<gml:lowerCorner>299721.46983062755 61021.99295737501 -11.89")); - assertTrue("The exported CityGML should contain a new envelope with the original altitudes", familyCourtBuilding - .contains("<gml:upperCorner>299823.9079725632 61122.68126771413 547.75")); - assertTrue("The exported CityGML should contain a new envelope with the correct EPSG", familyCourtBuilding - .contains("<gml:Envelope srsName=\"EPSG:32118\" srsDimension=\"3\">")); + assertFalse( + familyCourtBuilding.contains( + "<gml:lowerCorner>298393.46959639067 59277.34021543693 -11.892070104139751</gml:lowerCorner>"), + "The exported CityGML shouldn't contain the original envelope"); + assertFalse( + familyCourtBuilding.contains( + "<gml:upperCorner>305641.79529639013 67101.44881543722 547.7591871983744</gml:upperCorner>"), + "The exported CityGML shouldn't contain the original envelope"); + assertTrue(familyCourtBuilding.contains("<gml:lowerCorner>299721.46983062755 61021.99295737501 -11.89"), + "The exported CityGML should contain a new envelope with the original altitudes"); + assertTrue(familyCourtBuilding.contains("<gml:upperCorner>299823.9079725632 61122.68126771413 547.75"), + "The exported CityGML should contain a new envelope with the original altitudes"); + assertTrue(familyCourtBuilding.contains("<gml:Envelope srsName=\"EPSG:32118\" srsDimension=\"3\">"), + "The exported CityGML should contain a new envelope with the correct EPSG"); } @Test @@ -98,7 +102,7 @@ public void testExtract0BuildingsWithWrongCoordinates() throws Throwable { Path citygmlPath = TEST_REPOSITORY.resolve("NewYork.proj/ManhattanSmall.gml"); String emptyGMLString = RegionExtractor.selectRegionDirectlyFromCityGML(citygmlPath, wktPolygon, EPSG_32118) .toString(); - assertEquals(countRegexMatches(emptyGMLString, CITY_OBJECT_MEMBER_REGEX), 0); + assertEquals(0, countRegexMatches(emptyGMLString, CITY_OBJECT_MEMBER_REGEX)); assertTrue(emptyGMLString.contains(CITY_MODEL_HEADER)); assertTrue(emptyGMLString.contains(CITY_MODEL_FOOTER)); } @@ -110,7 +114,7 @@ public void testExtract0BuildingsFromEmptyGML() throws Throwable { Path citygmlPath = TEST_REPOSITORY.resolve("NewYork.proj/empty_model.gml"); String emptyGMLString = RegionExtractor.selectRegionDirectlyFromCityGML(citygmlPath, wktPolygon, EPSG_32118) .toString(); - assertEquals(countRegexMatches(emptyGMLString, CITY_OBJECT_MEMBER_REGEX), 0); + assertEquals(0, countRegexMatches(emptyGMLString, CITY_OBJECT_MEMBER_REGEX)); assertTrue(emptyGMLString.contains(CORE_CITY_MODEL_HEADER)); assertTrue(emptyGMLString.contains(CORE_CITY_MODEL_FOOTER)); } @@ -122,7 +126,7 @@ public void testExtract0BuildingsFromWeirdGML() throws Throwable { Path citygmlPath = TEST_REPOSITORY.resolve("NewYork.proj/broken_nyc_lod2.gml"); String emptyGMLString = RegionExtractor.selectRegionDirectlyFromCityGML(citygmlPath, wktPolygon, EPSG_32118) .toString(); - assertEquals(countRegexMatches(emptyGMLString, CITY_OBJECT_MEMBER_REGEX), 0); + assertEquals(0, countRegexMatches(emptyGMLString, CITY_OBJECT_MEMBER_REGEX)); assertTrue(emptyGMLString.contains(CORE_CITY_MODEL_HEADER)); assertTrue(emptyGMLString.contains(CORE_CITY_MODEL_FOOTER)); } @@ -133,6 +137,6 @@ public void testExtractBuildingsFromCitygmlWithoutZinEnvelope() throws Throwable Path citygmlPath = TEST_REPOSITORY.resolve("Stuttgart.proj/Stuttgart_LOD0_LOD1_small.gml"); String emptyGMLString = RegionExtractor.selectRegionDirectlyFromCityGML(citygmlPath, wktPolygon, "EPSG:31463") .toString(); - assertEquals(countRegexMatches(emptyGMLString, "<bldg:Building gml:id"), 2); + assertEquals(2, countRegexMatches(emptyGMLString, "<bldg:Building gml:id")); } } diff --git a/src/test/java/eu/simstadt/regionchooser/RegionExtractorWithDifferentInputTests.java b/src/test/java/eu/simstadt/regionchooser/RegionExtractorWithDifferentInputTests.java index dc0979a701e027d986bc73c59a9358dc615c12f9..3ac529f5bd9a126263fa31da3ce6396bb7e335f1 100644 --- a/src/test/java/eu/simstadt/regionchooser/RegionExtractorWithDifferentInputTests.java +++ b/src/test/java/eu/simstadt/regionchooser/RegionExtractorWithDifferentInputTests.java @@ -1,12 +1,12 @@ package eu.simstadt.regionchooser; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.locationtech.jts.geom.Polygon; import org.locationtech.jts.io.ParseException; import org.locationtech.jts.io.WKTReader; @@ -36,8 +36,8 @@ public void testExtractRegionWithLocalCRS() CoordinateReferenceSystem localCRS = RegionChooserUtils.crsFromCityGMLHeader(citygmlPath); StringBuilder sb = RegionExtractor.selectRegionDirectlyFromCityGML(citygmlPath, wktPolygon, localCRS.getName()); - assertTrue("One weird shaped roof should be inside the region", - sb.toString().contains("gml_ZVHMQQ6BZGRT0O3Q6RGXF12BDOV49QIZ58XB")); + assertTrue(sb.toString().contains("gml_ZVHMQQ6BZGRT0O3Q6RGXF12BDOV49QIZ58XB"), + "One weird shaped roof should be inside the region"); } //NOTE: This test can be adapted to download a region which is too large for the server. Here with WGS84 coordinates @@ -52,11 +52,12 @@ public void testExtractRegionWithWGS84() Polygon wgs84Polygon = (Polygon) WKT_READER.read(wgs84WktPolygon); CoordinateReferenceSystem localCRS = RegionChooserUtils.crsFromCityGMLHeader(citygmlPath); - String localWktPolygon = WKT_WRITER.write(RegionChooserUtils.changePolygonCRS(wgs84Polygon, RegionChooserUtils.WGS84, localCRS)); + String localWktPolygon = WKT_WRITER + .write(RegionChooserUtils.changePolygonCRS(wgs84Polygon, RegionChooserUtils.WGS84, localCRS)); StringBuilder sb = RegionExtractor.selectRegionDirectlyFromCityGML(citygmlPath, localWktPolygon, localCRS.getName()); - assertTrue("One weird shaped roof should be inside the region", - sb.toString().contains("gml_ZVHMQQ6BZGRT0O3Q6RGXF12BDOV49QIZ58XB")); + assertTrue(sb.toString().contains("gml_ZVHMQQ6BZGRT0O3Q6RGXF12BDOV49QIZ58XB"), + "One weird shaped roof should be inside the region"); } //NOTE: This test can be adapted to download a region which is too large for the server. Here with old coordinates from WebSimstadt @@ -100,12 +101,13 @@ public void testExtractRegionWithOldCoordinates() Polygon wgs84Polygon = (Polygon) WKT_READER.read(wgs84WktPolygon); CoordinateReferenceSystem localCRS = RegionChooserUtils.crsFromCityGMLHeader(citygmlPath); - String localWktPolygon = WKT_WRITER.write(RegionChooserUtils.changePolygonCRS(wgs84Polygon, RegionChooserUtils.WGS84, localCRS)); + String localWktPolygon = WKT_WRITER + .write(RegionChooserUtils.changePolygonCRS(wgs84Polygon, RegionChooserUtils.WGS84, localCRS)); StringBuilder sb = RegionExtractor.selectRegionDirectlyFromCityGML(citygmlPath, localWktPolygon, localCRS.getName()); - assertTrue("One weird shaped roof should be inside the region", - sb.toString().contains("gml_ZVHMQQ6BZGRT0O3Q6RGXF12BDOV49QIZ58XB")); + assertTrue(sb.toString().contains("gml_ZVHMQQ6BZGRT0O3Q6RGXF12BDOV49QIZ58XB"), + "One weird shaped roof should be inside the region"); } //TODO: Write a method to merge RegionChooser results from multiple gmls