Fix bug in simple test
Which resulted in always pass
Change-Id: I672fa850bbd908cdfa9978e08d9febdcd684d6a9
diff --git a/src/test/java/org/ids_mannheim/WorkerTest.java b/src/test/java/org/ids_mannheim/WorkerTest.java
index d18460a..af934b7 100644
--- a/src/test/java/org/ids_mannheim/WorkerTest.java
+++ b/src/test/java/org/ids_mannheim/WorkerTest.java
@@ -249,8 +249,9 @@
Path path = FileSystems.getDefault().getPath(tempFreqFile.getAbsolutePath());
Map<String, Integer> gold = Files.lines(path)
- .filter(s -> s.matches(splitFreqlistRegex))
+ .filter(s -> s.matches(".*\\t.*"))
.collect(Collectors.toMap(k -> k.split(splitFreqlistRegex)[0], v -> Integer.parseInt(v.split(splitFreqlistRegex)[1])));
+ assertTrue(gold.size() > 0, "Gold frequency test file '"+goldFileName + "' is parsed correctly");
map = new ConcurrentHashMap<>();
LinkedBlockingQueue<Integer> queue = new LinkedBlockingQueue<>(2);
@@ -271,7 +272,17 @@
queue.add(0);
queue.add(-1);
worker.run();
- gold.forEach((key, value) -> assertEquals(value, map.get(key).intValue()));
+ String conditionDescription = " like in " +goldFileName + " for simple.conllu in condition: "
+ + (with_padding ? "padding" : "no padding") + ", "
+ + (with_lemma_and_pos ? "with lemma and POS" : "without lemma or pos");
+ gold.forEach((key, value) -> {
+ assertNotNull(map.get(key), "Key " + key + " exists " + conditionDescription);
+ assertEquals(value, map.get(key).intValue(),
+ "Frequency for " + key + " is correct " + conditionDescription);
+ });
+
+ assertEquals(map.size(), gold.size(), "Actual map should not contain more keys than gold map, in "
+ + conditionDescription);
}
}
}