Improve fields test for missing meta fields
Change-Id: I1babc71e175e9584e27085fd10325dab381c1ca7
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java b/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java
index 2042175..516d486 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java
@@ -216,6 +216,22 @@
// assertEquals("372-377", res.at("/matches/0/pages").asText());
assertEquals("match-GOE_AGX.00002-p7-8",
res.at("/matches/0/matchID").asText());
+
+
+ // Missing field
+ jsonString = getJsonString(getClass()
+ .getResource("/queries/metas/fields_missing.jsonld").getFile());
+
+ ks = new Krill(jsonString);
+ kr = ks.apply(ki);
+ mapper = new ObjectMapper();
+ res = mapper.readTree(kr.toJsonString());
+
+ assertTrue(res.at("/matches/0/publisher").isMissingNode());
+ assertEquals("Goethe-Korpus", res.at("/matches/0/corpusTitle").asText());
+ assertTrue(res.at("/matches/0/textType").isMissingNode());
+ assertEquals("", res.at("/matches/0/UID").asText());
+ assertTrue(res.at("/matches/0/namespace.new").isMissingNode());
};
diff --git a/src/test/resources/queries/metas/fields_missing.jsonld b/src/test/resources/queries/metas/fields_missing.jsonld
new file mode 100644
index 0000000..2d7218e
--- /dev/null
+++ b/src/test/resources/queries/metas/fields_missing.jsonld
@@ -0,0 +1,24 @@
+{
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld",
+ "announcements" : [],
+ "errors" : [],
+ "meta" : {
+ "count":9,
+ "fields": [
+ "UID",
+ "namespace.new",
+ "corpusTitle"
+ ]
+ },
+ "query" : {
+ "@type" : "koral:token",
+ "wrap" : {
+ "@type" : "koral:term",
+ "key" : "VERB",
+ "foundry" : "xip",
+ "layer" : "pos",
+ "match" : "match:eq"
+ }
+ },
+ "warnings" : []
+}