Fix serialization of 'und', 'oder', and 'nicht' in Cosmas II
Change-Id: Idc16a73bfa6ed649e913889310f157933c4f2b05
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/CollectionQueryDuplicateTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/CollectionQueryDuplicateTest.java
index ed8e40f..f7c4dd1 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/CollectionQueryDuplicateTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/CollectionQueryDuplicateTest.java
@@ -17,16 +17,20 @@
public class CollectionQueryDuplicateTest {
@Test
- public void testCollectionQueryDuplicateThrowsAssertionException() throws IOException {
+ public void testCollectionQueryDuplicateThrowsAssertionException ()
+ throws IOException {
QuerySerializer serializer = new QuerySerializer();
serializer.setQuery("[base=Haus]", "poliqarp");
serializer.setCollection("textClass=politik & corpusID=WPD");
ObjectMapper m = new ObjectMapper();
JsonNode first = m.readTree(serializer.toJSON());
assertNotNull(first);
- assertEquals(first.at("/collection"), m.readTree(serializer.toJSON()).at("/collection"));
- assertEquals(first.at("/collection"), m.readTree(serializer.toJSON()).at("/collection"));
- assertEquals(first.at("/collection"), m.readTree(serializer.toJSON()).at("/collection"));
+ assertEquals(first.at("/collection"), m.readTree(serializer.toJSON())
+ .at("/collection"));
+ assertEquals(first.at("/collection"), m.readTree(serializer.toJSON())
+ .at("/collection"));
+ assertEquals(first.at("/collection"), m.readTree(serializer.toJSON())
+ .at("/collection"));
}
}
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessorTest.java
index 1a24352..0e91058 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessorTest.java
@@ -22,8 +22,9 @@
ObjectMapper mapper = new ObjectMapper();
JsonNode res;
+
@Test
- public void testContext() throws JsonProcessingException, IOException {
+ public void testContext () throws JsonProcessingException, IOException {
collection = "textClass=politik";
String contextString = "http://korap.ids-mannheim.de/ns/koral/0.3/context.jsonld";
qs.setQuery(query, ql);
@@ -32,8 +33,9 @@
assertEquals(contextString, res.get("@context").asText());
}
+
@Test
- public void testSimple() throws JsonProcessingException, IOException {
+ public void testSimple () throws JsonProcessingException, IOException {
collection = "textClass=politik";
qs.setQuery(query, ql);
qs.setCollection(collection);
@@ -53,9 +55,10 @@
assertEquals("match:ne", res.at("/collection/match").asText());
}
+
@Test
- public void testSpecialCharacters()
- throws JsonProcessingException, IOException {
+ public void testSpecialCharacters () throws JsonProcessingException,
+ IOException {
collection = "[base/n=alt]";
qs.setQuery(query, ql);
qs.setCollection(collection);
@@ -71,8 +74,9 @@
;
+
@Test
- public void testContains() throws JsonProcessingException, IOException {
+ public void testContains () throws JsonProcessingException, IOException {
collection = "title~Mannheim";
qs.setQuery(query, ql);
qs.setCollection(collection);
@@ -101,8 +105,9 @@
assertEquals("match:contains", res.at("/collection/match").asText());
}
+
@Test
- public void testNotDate() throws JsonProcessingException, IOException {
+ public void testNotDate () throws JsonProcessingException, IOException {
collection = "author=\"firefighter1974\"";
qs.setQuery(query, ql);
qs.setCollection(collection);
@@ -115,29 +120,29 @@
assertEquals("", res.at("/warnings/0/0").asText());
}
+
@Test
- public void testTwoConjuncts() throws JsonProcessingException, IOException {
+ public void testTwoConjuncts () throws JsonProcessingException, IOException {
collection = "textClass=Sport & pubDate in 2014";
qs.setQuery(query, ql);
qs.setCollection(collection);
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:and", res.at("/collection/operation").asText());
- assertEquals("koral:doc",
- res.at("/collection/operands/0/@type").asText());
- assertEquals("textClass",
- res.at("/collection/operands/0/key").asText());
+ assertEquals("koral:doc", res.at("/collection/operands/0/@type")
+ .asText());
+ assertEquals("textClass", res.at("/collection/operands/0/key").asText());
assertEquals("Sport", res.at("/collection/operands/0/value").asText());
- assertEquals("match:eq",
- res.at("/collection/operands/0/match").asText());
- assertEquals("koral:doc",
- res.at("/collection/operands/1/@type").asText());
+ assertEquals("match:eq", res.at("/collection/operands/0/match")
+ .asText());
+ assertEquals("koral:doc", res.at("/collection/operands/1/@type")
+ .asText());
assertEquals("pubDate", res.at("/collection/operands/1/key").asText());
assertEquals("2014", res.at("/collection/operands/1/value").asText());
- assertEquals("type:date",
- res.at("/collection/operands/1/type").asText());
- assertEquals("match:eq",
- res.at("/collection/operands/1/match").asText());
+ assertEquals("type:date", res.at("/collection/operands/1/type")
+ .asText());
+ assertEquals("match:eq", res.at("/collection/operands/1/match")
+ .asText());
collection = "textClass=Sport & pubDate=2014";
qs.setQuery(query, ql);
@@ -146,166 +151,165 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:and", res.at("/collection/operation").asText());
- assertEquals("koral:doc",
- res.at("/collection/operands/0/@type").asText());
- assertEquals("textClass",
- res.at("/collection/operands/0/key").asText());
+ assertEquals("koral:doc", res.at("/collection/operands/0/@type")
+ .asText());
+ assertEquals("textClass", res.at("/collection/operands/0/key").asText());
assertEquals("Sport", res.at("/collection/operands/0/value").asText());
- assertEquals("match:eq",
- res.at("/collection/operands/0/match").asText());
- assertEquals("koral:doc",
- res.at("/collection/operands/1/@type").asText());
+ assertEquals("match:eq", res.at("/collection/operands/0/match")
+ .asText());
+ assertEquals("koral:doc", res.at("/collection/operands/1/@type")
+ .asText());
assertEquals("pubDate", res.at("/collection/operands/1/key").asText());
assertEquals("2014", res.at("/collection/operands/1/value").asText());
- assertEquals(true,
- res.at("/collection/operands/1/type").isMissingNode());
- assertEquals("match:eq",
- res.at("/collection/operands/1/match").asText());
+ assertEquals(true, res.at("/collection/operands/1/type")
+ .isMissingNode());
+ assertEquals("match:eq", res.at("/collection/operands/1/match")
+ .asText());
assertTrue(res.at("/warnings/0").isMissingNode());
// assertTrue(res.at("/warnings/0/0").asText().startsWith(
// "The collection query contains a value that looks like a date"));
}
+
@Test
- public void testThreeConjuncts()
- throws JsonProcessingException, IOException {
+ public void testThreeConjuncts () throws JsonProcessingException,
+ IOException {
collection = "textClass=Sport & pubDate in 2014 & corpusId=WPD";
qs.setQuery(query, ql);
qs.setCollection(collection);
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:and", res.at("/collection/operation").asText());
- assertEquals("koral:doc",
- res.at("/collection/operands/0/@type").asText());
- assertEquals("textClass",
- res.at("/collection/operands/0/key").asText());
+ assertEquals("koral:doc", res.at("/collection/operands/0/@type")
+ .asText());
+ assertEquals("textClass", res.at("/collection/operands/0/key").asText());
assertEquals("Sport", res.at("/collection/operands/0/value").asText());
- assertEquals("match:eq",
- res.at("/collection/operands/0/match").asText());
- assertEquals("koral:docGroup",
- res.at("/collection/operands/1/@type").asText());
- assertEquals("operation:and",
- res.at("/collection/operands/1/operation").asText());
+ assertEquals("match:eq", res.at("/collection/operands/0/match")
+ .asText());
+ assertEquals("koral:docGroup", res.at("/collection/operands/1/@type")
+ .asText());
+ assertEquals("operation:and", res
+ .at("/collection/operands/1/operation").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/0/@type").asText());
- assertEquals("pubDate",
- res.at("/collection/operands/1/operands/0/key").asText());
- assertEquals("2014",
- res.at("/collection/operands/1/operands/0/value").asText());
+ assertEquals("pubDate", res.at("/collection/operands/1/operands/0/key")
+ .asText());
+ assertEquals("2014", res.at("/collection/operands/1/operands/0/value")
+ .asText());
assertEquals("type:date",
res.at("/collection/operands/1/operands/0/type").asText());
assertEquals("match:eq",
res.at("/collection/operands/1/operands/0/match").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/1/@type").asText());
- assertEquals("corpusId",
- res.at("/collection/operands/1/operands/1/key").asText());
- assertEquals("WPD",
- res.at("/collection/operands/1/operands/1/value").asText());
+ assertEquals("corpusId", res
+ .at("/collection/operands/1/operands/1/key").asText());
+ assertEquals("WPD", res.at("/collection/operands/1/operands/1/value")
+ .asText());
assertEquals("match:eq",
res.at("/collection/operands/1/operands/1/match").asText());
}
+
@Test
- public void testTwoDisjuncts() throws JsonProcessingException, IOException {
+ public void testTwoDisjuncts () throws JsonProcessingException, IOException {
collection = "textClass=Sport | pubDate in 2014";
qs.setQuery(query, ql);
qs.setCollection(collection);
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:or", res.at("/collection/operation").asText());
- assertEquals("koral:doc",
- res.at("/collection/operands/0/@type").asText());
- assertEquals("textClass",
- res.at("/collection/operands/0/key").asText());
+ assertEquals("koral:doc", res.at("/collection/operands/0/@type")
+ .asText());
+ assertEquals("textClass", res.at("/collection/operands/0/key").asText());
assertEquals("Sport", res.at("/collection/operands/0/value").asText());
- assertEquals("match:eq",
- res.at("/collection/operands/0/match").asText());
- assertEquals("koral:doc",
- res.at("/collection/operands/1/@type").asText());
+ assertEquals("match:eq", res.at("/collection/operands/0/match")
+ .asText());
+ assertEquals("koral:doc", res.at("/collection/operands/1/@type")
+ .asText());
assertEquals("pubDate", res.at("/collection/operands/1/key").asText());
assertEquals("2014", res.at("/collection/operands/1/value").asText());
- assertEquals("type:date",
- res.at("/collection/operands/1/type").asText());
- assertEquals("match:eq",
- res.at("/collection/operands/1/match").asText());
+ assertEquals("type:date", res.at("/collection/operands/1/type")
+ .asText());
+ assertEquals("match:eq", res.at("/collection/operands/1/match")
+ .asText());
}
+
@Test
- public void testThreeDisjuncts()
- throws JsonProcessingException, IOException {
+ public void testThreeDisjuncts () throws JsonProcessingException,
+ IOException {
collection = "textClass=Sport | pubDate in 2014 | corpusId=WPD";
qs.setQuery(query, ql);
qs.setCollection(collection);
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:or", res.at("/collection/operation").asText());
- assertEquals("koral:doc",
- res.at("/collection/operands/0/@type").asText());
- assertEquals("textClass",
- res.at("/collection/operands/0/key").asText());
+ assertEquals("koral:doc", res.at("/collection/operands/0/@type")
+ .asText());
+ assertEquals("textClass", res.at("/collection/operands/0/key").asText());
assertEquals("Sport", res.at("/collection/operands/0/value").asText());
- assertEquals("match:eq",
- res.at("/collection/operands/0/match").asText());
- assertEquals("koral:docGroup",
- res.at("/collection/operands/1/@type").asText());
- assertEquals("operation:or",
- res.at("/collection/operands/1/operation").asText());
+ assertEquals("match:eq", res.at("/collection/operands/0/match")
+ .asText());
+ assertEquals("koral:docGroup", res.at("/collection/operands/1/@type")
+ .asText());
+ assertEquals("operation:or", res.at("/collection/operands/1/operation")
+ .asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/0/@type").asText());
- assertEquals("pubDate",
- res.at("/collection/operands/1/operands/0/key").asText());
- assertEquals("2014",
- res.at("/collection/operands/1/operands/0/value").asText());
+ assertEquals("pubDate", res.at("/collection/operands/1/operands/0/key")
+ .asText());
+ assertEquals("2014", res.at("/collection/operands/1/operands/0/value")
+ .asText());
assertEquals("type:date",
res.at("/collection/operands/1/operands/0/type").asText());
assertEquals("match:eq",
res.at("/collection/operands/1/operands/0/match").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/1/@type").asText());
- assertEquals("corpusId",
- res.at("/collection/operands/1/operands/1/key").asText());
- assertEquals("WPD",
- res.at("/collection/operands/1/operands/1/value").asText());
+ assertEquals("corpusId", res
+ .at("/collection/operands/1/operands/1/key").asText());
+ assertEquals("WPD", res.at("/collection/operands/1/operands/1/value")
+ .asText());
assertEquals("match:eq",
res.at("/collection/operands/1/operands/1/match").asText());
}
+
@Test
- public void testMixed() throws JsonProcessingException, IOException {
+ public void testMixed () throws JsonProcessingException, IOException {
collection = "textClass=Sport | (pubDate in 2014 & corpusId=WPD)";
qs.setQuery(query, ql);
qs.setCollection(collection);
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:or", res.at("/collection/operation").asText());
- assertEquals("koral:doc",
- res.at("/collection/operands/0/@type").asText());
- assertEquals("textClass",
- res.at("/collection/operands/0/key").asText());
+ assertEquals("koral:doc", res.at("/collection/operands/0/@type")
+ .asText());
+ assertEquals("textClass", res.at("/collection/operands/0/key").asText());
assertEquals("Sport", res.at("/collection/operands/0/value").asText());
- assertEquals("match:eq",
- res.at("/collection/operands/0/match").asText());
- assertEquals("koral:docGroup",
- res.at("/collection/operands/1/@type").asText());
- assertEquals("operation:and",
- res.at("/collection/operands/1/operation").asText());
+ assertEquals("match:eq", res.at("/collection/operands/0/match")
+ .asText());
+ assertEquals("koral:docGroup", res.at("/collection/operands/1/@type")
+ .asText());
+ assertEquals("operation:and", res
+ .at("/collection/operands/1/operation").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/0/@type").asText());
- assertEquals("pubDate",
- res.at("/collection/operands/1/operands/0/key").asText());
- assertEquals("2014",
- res.at("/collection/operands/1/operands/0/value").asText());
+ assertEquals("pubDate", res.at("/collection/operands/1/operands/0/key")
+ .asText());
+ assertEquals("2014", res.at("/collection/operands/1/operands/0/value")
+ .asText());
assertEquals("type:date",
res.at("/collection/operands/1/operands/0/type").asText());
assertEquals("match:eq",
res.at("/collection/operands/1/operands/0/match").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/1/@type").asText());
- assertEquals("corpusId",
- res.at("/collection/operands/1/operands/1/key").asText());
- assertEquals("WPD",
- res.at("/collection/operands/1/operands/1/value").asText());
+ assertEquals("corpusId", res
+ .at("/collection/operands/1/operands/1/key").asText());
+ assertEquals("WPD", res.at("/collection/operands/1/operands/1/value")
+ .asText());
assertEquals("match:eq",
res.at("/collection/operands/1/operands/1/match").asText());
@@ -315,33 +319,32 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:or", res.at("/collection/operation").asText());
- assertEquals("koral:doc",
- res.at("/collection/operands/0/@type").asText());
- assertEquals("textClass",
- res.at("/collection/operands/0/key").asText());
+ assertEquals("koral:doc", res.at("/collection/operands/0/@type")
+ .asText());
+ assertEquals("textClass", res.at("/collection/operands/0/key").asText());
assertEquals("Sport", res.at("/collection/operands/0/value").asText());
- assertEquals("match:eq",
- res.at("/collection/operands/0/match").asText());
- assertEquals("koral:docGroup",
- res.at("/collection/operands/1/@type").asText());
- assertEquals("operation:and",
- res.at("/collection/operands/1/operation").asText());
+ assertEquals("match:eq", res.at("/collection/operands/0/match")
+ .asText());
+ assertEquals("koral:docGroup", res.at("/collection/operands/1/@type")
+ .asText());
+ assertEquals("operation:and", res
+ .at("/collection/operands/1/operation").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/0/@type").asText());
- assertEquals("pubDate",
- res.at("/collection/operands/1/operands/0/key").asText());
- assertEquals("2014",
- res.at("/collection/operands/1/operands/0/value").asText());
+ assertEquals("pubDate", res.at("/collection/operands/1/operands/0/key")
+ .asText());
+ assertEquals("2014", res.at("/collection/operands/1/operands/0/value")
+ .asText());
assertEquals("type:date",
res.at("/collection/operands/1/operands/0/type").asText());
assertEquals("match:eq",
res.at("/collection/operands/1/operands/0/match").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/1/@type").asText());
- assertEquals("corpusId",
- res.at("/collection/operands/1/operands/1/key").asText());
- assertEquals("WPD",
- res.at("/collection/operands/1/operands/1/value").asText());
+ assertEquals("corpusId", res
+ .at("/collection/operands/1/operands/1/key").asText());
+ assertEquals("WPD", res.at("/collection/operands/1/operands/1/value")
+ .asText());
assertEquals("match:eq",
res.at("/collection/operands/1/operands/1/match").asText());
@@ -351,16 +354,16 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:and", res.at("/collection/operation").asText());
- assertEquals("koral:docGroup",
- res.at("/collection/operands/0/@type").asText());
- assertEquals("operation:or",
- res.at("/collection/operands/0/operation").asText());
+ assertEquals("koral:docGroup", res.at("/collection/operands/0/@type")
+ .asText());
+ assertEquals("operation:or", res.at("/collection/operands/0/operation")
+ .asText());
assertEquals("koral:doc",
res.at("/collection/operands/0/operands/0/@type").asText());
assertEquals("koral:doc",
res.at("/collection/operands/0/operands/1/@type").asText());
- assertEquals("koral:doc",
- res.at("/collection/operands/1/@type").asText());
+ assertEquals("koral:doc", res.at("/collection/operands/1/@type")
+ .asText());
collection = "(textClass=Sport & pubDate in 2014) & corpusId=WPD";
qs.setQuery(query, ql);
@@ -368,16 +371,16 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:and", res.at("/collection/operation").asText());
- assertEquals("koral:docGroup",
- res.at("/collection/operands/0/@type").asText());
- assertEquals("operation:and",
- res.at("/collection/operands/0/operation").asText());
+ assertEquals("koral:docGroup", res.at("/collection/operands/0/@type")
+ .asText());
+ assertEquals("operation:and", res
+ .at("/collection/operands/0/operation").asText());
assertEquals("koral:doc",
res.at("/collection/operands/0/operands/0/@type").asText());
assertEquals("koral:doc",
res.at("/collection/operands/0/operands/1/@type").asText());
- assertEquals("koral:doc",
- res.at("/collection/operands/1/@type").asText());
+ assertEquals("koral:doc", res.at("/collection/operands/1/@type")
+ .asText());
collection = "(textClass=Sport & textClass=ausland) | (corpusID=WPD & author=White)";
qs.setQuery(query, ql);
@@ -385,30 +388,30 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:or", res.at("/collection/operation").asText());
- assertEquals("koral:docGroup",
- res.at("/collection/operands/0/@type").asText());
- assertEquals("operation:and",
- res.at("/collection/operands/0/operation").asText());
- assertEquals("koral:docGroup",
- res.at("/collection/operands/1/@type").asText());
- assertEquals("operation:and",
- res.at("/collection/operands/1/operation").asText());
+ assertEquals("koral:docGroup", res.at("/collection/operands/0/@type")
+ .asText());
+ assertEquals("operation:and", res
+ .at("/collection/operands/0/operation").asText());
+ assertEquals("koral:docGroup", res.at("/collection/operands/1/@type")
+ .asText());
+ assertEquals("operation:and", res
+ .at("/collection/operands/1/operation").asText());
assertEquals("koral:doc",
res.at("/collection/operands/0/operands/0/@type").asText());
- assertEquals("Sport",
- res.at("/collection/operands/0/operands/0/value").asText());
+ assertEquals("Sport", res.at("/collection/operands/0/operands/0/value")
+ .asText());
assertEquals("koral:doc",
res.at("/collection/operands/0/operands/1/@type").asText());
assertEquals("ausland",
res.at("/collection/operands/0/operands/1/value").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/0/@type").asText());
- assertEquals("WPD",
- res.at("/collection/operands/1/operands/0/value").asText());
+ assertEquals("WPD", res.at("/collection/operands/1/operands/0/value")
+ .asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/1/@type").asText());
- assertEquals("White",
- res.at("/collection/operands/1/operands/1/value").asText());
+ assertEquals("White", res.at("/collection/operands/1/operands/1/value")
+ .asText());
collection = "(textClass=Sport & textClass=ausland) | (corpusID=WPD & author=White & pubDate in 2000)";
qs.setQuery(query, ql);
@@ -416,26 +419,26 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:or", res.at("/collection/operation").asText());
- assertEquals("koral:docGroup",
- res.at("/collection/operands/0/@type").asText());
- assertEquals("operation:and",
- res.at("/collection/operands/0/operation").asText());
- assertEquals("koral:docGroup",
- res.at("/collection/operands/1/@type").asText());
- assertEquals("operation:and",
- res.at("/collection/operands/1/operation").asText());
+ assertEquals("koral:docGroup", res.at("/collection/operands/0/@type")
+ .asText());
+ assertEquals("operation:and", res
+ .at("/collection/operands/0/operation").asText());
+ assertEquals("koral:docGroup", res.at("/collection/operands/1/@type")
+ .asText());
+ assertEquals("operation:and", res
+ .at("/collection/operands/1/operation").asText());
assertEquals("koral:doc",
res.at("/collection/operands/0/operands/0/@type").asText());
- assertEquals("Sport",
- res.at("/collection/operands/0/operands/0/value").asText());
+ assertEquals("Sport", res.at("/collection/operands/0/operands/0/value")
+ .asText());
assertEquals("koral:doc",
res.at("/collection/operands/0/operands/1/@type").asText());
assertEquals("ausland",
res.at("/collection/operands/0/operands/1/value").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/0/@type").asText());
- assertEquals("WPD",
- res.at("/collection/operands/1/operands/0/value").asText());
+ assertEquals("WPD", res.at("/collection/operands/1/operands/0/value")
+ .asText());
assertEquals("koral:docGroup",
res.at("/collection/operands/1/operands/1/@type").asText());
assertEquals("operation:and",
@@ -448,8 +451,9 @@
.asText());
}
+
@Test
- public void testDateYear() throws JsonProcessingException, IOException {
+ public void testDateYear () throws JsonProcessingException, IOException {
collection = "pubDate in 2000";
qs.setQuery(query, ql);
qs.setCollection(collection);
@@ -491,8 +495,9 @@
assertEquals("match:leq", res.at("/collection/match").asText());
}
+
@Test
- public void testDateMonthDay() throws JsonProcessingException, IOException {
+ public void testDateMonthDay () throws JsonProcessingException, IOException {
collection = "pubDate in 2000-02";
qs.setQuery(query, ql);
qs.setCollection(collection);
@@ -534,8 +539,9 @@
assertEquals("match:leq", res.at("/collection/match").asText());
}
+
@Test
- public void testDateValidate() {
+ public void testDateValidate () {
String fake_date = "fireStorm2014";
String fake_date_2 = "2014-12Date";
String date = "2015";
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessorTest.java
index 802ba9e..9db30b9 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessorTest.java
@@ -305,11 +305,17 @@
@Test
public void testOPORAND () throws JsonProcessingException, IOException {
+
+ // Query
query = "(Sonne oder Mond) und scheint";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
+
+ assertEquals(false, res.at("/query/inOrder").isMissingNode());
+ assertEquals(false, res.at("/query/inOrder").asBoolean());
+
assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
.asText());
assertEquals("t", res.at("/query/distances/0/key").asText());
@@ -318,6 +324,10 @@
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:disjunction",
res.at("/query/operands/0/operation").asText());
+
+ assertEquals(false, res.at("/query/operands/0/inOrder").isMissingNode());
+ assertEquals(false, res.at("/query/operands/0/inOrder").asBoolean());
+
assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key")
.asText());
assertEquals("Mond", res.at("/query/operands/0/operands/1/wrap/key")
@@ -325,10 +335,15 @@
assertEquals("koral:token", res.at("/query/operands/1/@type").asText());
assertEquals("scheint", res.at("/query/operands/1/wrap/key").asText());
+ // Query
query = "scheint und (Sonne oder Mond)";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
+
+ assertEquals(false, res.at("/query/inOrder").isMissingNode());
+ assertEquals(false, res.at("/query/inOrder").asBoolean());
+
assertEquals("operation:sequence", res.at("/query/operation").asText());
assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
.asText());
@@ -340,16 +355,25 @@
assertEquals("koral:group", res.at("/query/operands/1/@type").asText());
assertEquals("operation:disjunction",
res.at("/query/operands/1/operation").asText());
+
+ assertEquals(false, res.at("/query/operands/1/inOrder").isMissingNode());
+ assertEquals(false, res.at("/query/operands/1/inOrder").asBoolean());
+
assertEquals("Sonne", res.at("/query/operands/1/operands/0/wrap/key")
.asText());
assertEquals("Mond", res.at("/query/operands/1/operands/1/wrap/key")
.asText());
+ // Query
query = "Regen und scheint und (Sonne oder Mond)";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
+
+ assertEquals(false, res.at("/query/inOrder").isMissingNode());
+ assertEquals(false, res.at("/query/inOrder").asBoolean());
+
assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
.asText());
assertEquals("t", res.at("/query/distances/0/key").asText());
@@ -357,8 +381,14 @@
assertEquals(0, res.at("/query/distances/0/max").asInt());
assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
assertEquals("Regen", res.at("/query/operands/0/wrap/key").asText());
- assertEquals("koral:group", res.at("/query/@type").asText());
- assertEquals("operation:sequence", res.at("/query/operation").asText());
+
+ assertEquals("koral:group", res.at("/query/operands/1/@type").asText());
+ assertEquals("operation:sequence", res
+ .at("/query/operands/1/operation").asText());
+
+ assertEquals(false, res.at("/query/operands/1/inOrder").isMissingNode());
+ assertEquals(false, res.at("/query/operands/1/inOrder").asBoolean());
+
assertEquals("cosmas:distance",
res.at("/query/operands/1/distances/0/@type").asText());
assertEquals("t", res.at("/query/operands/1/distances/0/key").asText());
@@ -368,6 +398,12 @@
.asText());
assertEquals("koral:group", res
.at("/query/operands/1/operands/1/@type").asText());
+
+ assertEquals(false, res.at("/query/operands/1/operands/1/inOrder")
+ .isMissingNode());
+ assertEquals(false, res.at("/query/operands/1/operands/1/inOrder")
+ .asBoolean());
+
assertEquals("operation:disjunction",
res.at("/query/operands/1/operands/1/operation").asText());
assertEquals("Sonne",
@@ -728,8 +764,9 @@
assertEquals("koral:span",
res.at("/query/operands/0/operands/0/operands/0/@type")
.asText());
- assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/wrap/key")
- .asText());
+ assertEquals("s",
+ res.at("/query/operands/0/operands/0/operands/0/wrap/key")
+ .asText());
assertEquals("koral:group", res
.at("/query/operands/0/operands/1/@type").asText());
assertEquals("operation:class",
@@ -1401,7 +1438,8 @@
.asText());
assertEquals("koral:span", res.at("/query/operands/0/operands/0/@type")
.asText());
- assertEquals("s", res.at("/query/operands/0/operands/0/wrap/key").asText());
+ assertEquals("s", res.at("/query/operands/0/operands/0/wrap/key")
+ .asText());
query = "#BED(der Mann , +pe)";
qs.setQuery(query, "cosmas2");
@@ -1425,8 +1463,9 @@
assertEquals("koral:span",
res.at("/query/operands/0/operands/0/operands/0/@type")
.asText());
- assertEquals("p", res.at("/query/operands/0/operands/0/operands/0/wrap/key")
- .asText());
+ assertEquals("p",
+ res.at("/query/operands/0/operands/0/operands/0/wrap/key")
+ .asText());
assertEquals("koral:reference",
res.at("/query/operands/0/operands/1/@type").asText());
assertEquals("operation:focus",
@@ -1478,8 +1517,9 @@
assertEquals("koral:span",
res.at("/query/operands/0/operands/0/operands/0/@type")
.asText());
- assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/wrap/key")
- .asText());
+ assertEquals("s",
+ res.at("/query/operands/0/operands/0/operands/0/wrap/key")
+ .asText());
assertEquals("koral:group",
res.at("/query/operands/0/operands/0/operands/1/@type")
.asText());
@@ -1513,8 +1553,9 @@
assertEquals("koral:span",
res.at("/query/operands/0/operands/1/operands/0/@type")
.asText());
- assertEquals("p", res.at("/query/operands/0/operands/1/operands/0/wrap/key")
- .asText());
+ assertEquals("p",
+ res.at("/query/operands/0/operands/1/operands/0/wrap/key")
+ .asText());
assertEquals("koral:group",
res.at("/query/operands/0/operands/1/operands/1/@type")
.asText());
@@ -1567,7 +1608,8 @@
.asText());
assertEquals("koral:span", res.at("/query/operands/0/operands/0/@type")
.asText());
- assertEquals("s", res.at("/query/operands/0/operands/0/wrap/key").asText());
+ assertEquals("s", res.at("/query/operands/0/operands/0/wrap/key")
+ .asText());
query = "der:sa,-pa";
qs.setQuery(query, "cosmas2");
@@ -1589,8 +1631,9 @@
assertEquals("koral:span",
res.at("/query/operands/0/operands/0/operands/0/@type")
.asText());
- assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/wrap/key")
- .asText());
+ assertEquals("s",
+ res.at("/query/operands/0/operands/0/operands/0/wrap/key")
+ .asText());
assertEquals("koral:group",
res.at("/query/operands/0/operands/0/operands/1/@type")
.asText());
@@ -1615,8 +1658,9 @@
assertEquals("koral:span",
res.at("/query/operands/0/operands/1/operands/0/@type")
.asText());
- assertEquals("p", res.at("/query/operands/0/operands/1/operands/0/wrap/key")
- .asText());
+ assertEquals("p",
+ res.at("/query/operands/0/operands/1/operands/0/wrap/key")
+ .asText());
assertEquals("koral:group",
res.at("/query/operands/0/operands/1/operands/1/@type")
.asText());
@@ -1651,8 +1695,9 @@
assertEquals("koral:span",
res.at("/query/operands/0/operands/0/operands/0/@type")
.asText());
- assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/wrap/key")
- .asText());
+ assertEquals("s",
+ res.at("/query/operands/0/operands/0/operands/0/wrap/key")
+ .asText());
assertEquals("koral:group",
res.at("/query/operands/0/operands/0/operands/1/@type")
.asText());
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/EmptyResultsTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/EmptyResultsTest.java
index 58d775b..264ca67 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/EmptyResultsTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/EmptyResultsTest.java
@@ -15,8 +15,9 @@
private static ObjectMapper mapper = new ObjectMapper();
+
@Test
- public void testEmptyQueryObject() {
+ public void testEmptyQueryObject () {
QuerySerializer s = new QuerySerializer();
s.setQuery("prox/unit=word/distance<=5", "cql");
JsonNode node = mapper.valueToTree(s.build());
@@ -24,8 +25,9 @@
assertEquals(node.has("collection"), false);
}
+
@Test
- public void testEmptyCollectionObject() {
+ public void testEmptyCollectionObject () {
QuerySerializer s = new QuerySerializer();
s.setQuery("[base=Wort]", "poliqarp");
@@ -34,8 +36,9 @@
assertEquals(node.has("collection"), false);
}
+
@Test
- public void testEmptyMetaObject() {
+ public void testEmptyMetaObject () {
QuerySerializer s = new QuerySerializer();
s.setQuery("[base=Wort]", "poliqarp");
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessorTest.java
index 7e3c9f3..221c0bc 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessorTest.java
@@ -148,7 +148,7 @@
query = "z.B./x";
qs.setQuery(query, "poliqarpplus");
res = mapper.readTree(qs.toJSON());
- System.out.println("QUERY IS "+ res);
+ System.out.println("QUERY IS " + res);
assertEquals("koral:token", res.at("/query/@type").asText());
assertEquals("koral:term", res.at("/query/wrap/@type").asText());
assertEquals(".*?z\\.B\\..*?", res.at("/query/wrap/key").asText());
@@ -160,7 +160,7 @@
query = "\"a\\.\"";
qs.setQuery(query, "poliqarpplus");
res = mapper.readTree(qs.toJSON());
- System.out.println("QUERY IS "+ res);
+ System.out.println("QUERY IS " + res);
assertEquals("koral:token", res.at("/query/@type").asText());
assertEquals("koral:term", res.at("/query/wrap/@type").asText());
assertEquals("type:regex", res.at("/query/wrap/type").asText());
@@ -1703,8 +1703,10 @@
assertEquals("VVFIN", res.at("/query/operands/1/wrap/key").asText());
}
+
@Test
- public void testSpanSerialization () throws JsonProcessingException, IOException {
+ public void testSpanSerialization () throws JsonProcessingException,
+ IOException {
// Both constructs should be serialized identically
query = "contains(<s>, der)";