Commit 2cc8dd1d authored by duminil's avatar duminil
Browse files

RegionChooser: Updated tests

parent bcf8c689
......@@ -4,14 +4,22 @@
import static org.junit.Assert.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 eu.simstadt.regionchooser.RegionExtractor;
public class RegionExtractorTests
{
public static int countSubstring(String str, String subStr) {
return (str.length() - str.replace(subStr, "").length()) / subStr.length();
public static int countRegexMatches(String str, String subStr) {
Pattern pattern = Pattern.compile(subStr);
Matcher matcher = pattern.matcher(str);
int count = 0;
while (matcher.find()) {
count++;
}
return count;
}
@Test
......@@ -21,7 +29,7 @@ public void testExtract3BuildingsFromGSK3Model() throws Throwable {
Path repo = Paths.get("../TestRepository");
Path citygmlPath = repo.resolve("Gruenbuehl.proj\\20140218_Gruenbuehl_LOD2.gml");
String churchGMLString = RegionExtractor.selectRegionDirectlyFromCityGML(citygmlPath, wktPolygon).toString();
assertEquals(countSubstring(churchGMLString, "<core:cityObjectMember"), 3);
assertEquals(countRegexMatches(churchGMLString, "<(core:)?cityObjectMember"), 3);
assertTrue(churchGMLString.contains("Donaustr"));
assertTrue(churchGMLString.contains("DEBW_LOD2_203056"));
assertTrue(churchGMLString.contains("DEBW_LOD2_2869"));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment