Test for correct behaviour of unresolved query references
Change-Id: I4b5ccc3145a87d5609dc235733db0fd85e866030
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java
index 0613d31..47a43eb 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java
@@ -776,7 +776,6 @@
};
};
-
@Test
public void queryJSONmerge () throws QueryException {
// treat merging gracefully
@@ -788,4 +787,32 @@
"spanNext(tokens:s:der, tokens:s:Baum)");
assertEquals(kq.getWarning(0).getCode(), 774);
};
+
+ @Test
+ public void queryJSONqueryref1 () {
+ try {
+ String json = getJsonString(getClass()
+ .getResource("/queries/queryref1.jsonld")
+ .getFile());
+ new KrillQuery("tokens").fromKoral(json);
+ }
+ catch (QueryException e) {
+ assertEquals(713, e.getErrorCode());
+ assertEquals("Query type is not supported", e.getMessage());
+ };
+ };
+
+ @Test
+ public void queryJSONqueryref2 () {
+ try {
+ String json = getJsonString(getClass()
+ .getResource("/queries/queryref2.jsonld")
+ .getFile());
+ new KrillQuery("tokens").fromKoral(json);
+ }
+ catch (QueryException e) {
+ // assertEquals(713, e.getErrorCode());
+ assertEquals("Query type is not supported", e.getMessage());
+ };
+ };
};
diff --git a/src/test/resources/queries/queryref1.jsonld b/src/test/resources/queries/queryref1.jsonld
new file mode 100644
index 0000000..96483d2
--- /dev/null
+++ b/src/test/resources/queries/queryref1.jsonld
@@ -0,0 +1,7 @@
+{
+ "query":{
+ "@type":"koral:queryRef",
+ "ref":"admin/example"
+ },
+ "@context":"http://korap.ids-mannheim.de/ns/koral/0.3/context.jsonld"
+}
diff --git a/src/test/resources/queries/queryref2.jsonld b/src/test/resources/queries/queryref2.jsonld
new file mode 100644
index 0000000..ade1992
--- /dev/null
+++ b/src/test/resources/queries/queryref2.jsonld
@@ -0,0 +1,29 @@
+{
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query" : {
+ "@type" : "koral:group",
+ "operation" : "operation:sequence",
+ "operands" : [
+ {
+ "@type" : "koral:token",
+ "wrap" : {
+ "@type" : "koral:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p"
+ }
+ },
+ {
+ "@type" : "koral:queryRef",
+ "ref" : "admin/example"
+ },
+ {
+ "@type" : "koral:token",
+ "wrap" : {
+ "@type" : "koral:term",
+ "key" : "Baum"
+ }
+ }
+ ]
+ }
+}