From 83d927c64f697767ac83188a64ed5177cfc4adbc Mon Sep 17 00:00:00 2001
From: Eric Duminil <eric.duminil@gmail.com>
Date: Mon, 10 Oct 2022 11:51:58 +0200
Subject: [PATCH] More test

---
 .../RegionChooserCommandLineInterface.java    |  1 -
 ...RegionChooserCommandLineInterfaceTest.java | 29 ++++++++++++++++---
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/main/java/eu/simstadt/regionchooser/RegionChooserCommandLineInterface.java b/src/main/java/eu/simstadt/regionchooser/RegionChooserCommandLineInterface.java
index 7dd29e3..1589440 100644
--- a/src/main/java/eu/simstadt/regionchooser/RegionChooserCommandLineInterface.java
+++ b/src/main/java/eu/simstadt/regionchooser/RegionChooserCommandLineInterface.java
@@ -46,7 +46,6 @@ class RegionChooserCommandLineInterface implements Callable<Integer>
 
 	@Override
 	public Integer call() throws Exception {
-		//TODO: Test
 		CoordinateReferenceSystem localCRS;
 
 		if (espgId == null) {
diff --git a/src/test/java/eu/simstadt/regionchooser/RegionChooserCommandLineInterfaceTest.java b/src/test/java/eu/simstadt/regionchooser/RegionChooserCommandLineInterfaceTest.java
index dd61dcf..6ca78b8 100644
--- a/src/test/java/eu/simstadt/regionchooser/RegionChooserCommandLineInterfaceTest.java
+++ b/src/test/java/eu/simstadt/regionchooser/RegionChooserCommandLineInterfaceTest.java
@@ -40,7 +40,7 @@ public void restoreStreams() {
 	@Test
 	void testNoInput() {
 		new CommandLine(new RegionChooserCommandLineInterface()).execute("");
-		originalOut.println(err.toString());
+		//		originalOut.println(err.toString());
 		String expectedErr = "Missing required options: '--input=input.gml', '--output=output.gml', '--wkt=polygon.wkt'";
 		assertTrue(err.toString().contains(expectedErr), err.toString() + " should contain " + expectedErr);
 	}
@@ -57,10 +57,31 @@ void testExtractRegionFromTwoCitygmls() throws IOException {
 		}
 		new CommandLine(new RegionChooserCommandLineInterface()).execute("--input=" + citygml1 + "," + citygml2,
 				"--output=" + outGML, "--wkt=" + inWKT, "--epsg=31463", "--local");
-		String expectedErr = "Buildings found in selected region 20";
-		assertTrue(err.toString().contains(expectedErr), err.toString() + " should contain " + expectedErr);
-		originalOut.println(Files.size(outGML));
+		String expectedLog = "Buildings found in selected region 20";
+		assertTrue(err.toString().contains(expectedLog), err.toString() + " should contain " + expectedLog);
 		assertTrue(Files.size(outGML) > 600_000);
 	}
+
+
+	@Test
+	void testExtractRegionFromTwoCitygmlsInWGS84() throws IOException {
+		String wktPolygon = "POLYGON((9.18991539528286 48.79067456353269, 9.195580220722313 48.7873947720947, 9.172062612079735 48.78241812742368, 9.170946813129538 48.78569824412753, 9.18991539528286 48.79067456353269))";
+		Path citygml1 = TEST_REPOSITORY.resolve("Stuttgart.proj/Stuttgart_LOD0_LOD1_small.gml");
+		Path citygml2 = TEST_REPOSITORY.resolve("Stuttgart.proj/Stöckach_überarbeitete GML-NoBuildingPart.gml");
+		Path outGML = Files.createTempFile("output", ".gml");
+		Path inWKT = Files.createTempFile("polygon", ".wkt");
+		try (BufferedWriter wkt = Files.newBufferedWriter(inWKT)) {
+			wkt.write(wktPolygon);
+		}
+		new CommandLine(new RegionChooserCommandLineInterface()).execute("--input=" + citygml1 + "," + citygml2,
+				"--output=" + outGML, "--wkt=" + inWKT);
+		originalOut.println(err.toString());
+		String expectedLog = "EPSG:31463";
+		assertTrue(err.toString().contains(expectedLog), err.toString() + " should contain " + expectedLog);
+		expectedLog = "Buildings found in selected region 22";
+		assertTrue(err.toString().contains(expectedLog), err.toString() + " should contain " + expectedLog);
+		assertTrue(Files.size(outGML) > 300_000);
+	}
+	//TODO: Test with stdin
 }
 
-- 
GitLab