Merge "Use character classes instead of alternations in regexes"
diff --git a/pom.xml b/pom.xml
index cde601d..062c8dc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -95,7 +95,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.11</version>
+ <version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -137,7 +137,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <version>1.7.25</version>
+ <version>1.7.30</version>
</dependency>
<dependency>
<groupId>eu.clarin.sru.fcs</groupId>
@@ -182,7 +182,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.22.1</version>
+ <version>2.22.2</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<excludes>
@@ -193,7 +193,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <version>3.7.0</version>
+ <version>3.8.1</version>
<configuration>
<!-- <verbose>true</verbose>
<fork>true</fork> -->
@@ -201,7 +201,6 @@
<compilerVersion>2.0</compilerVersion>
<source>${java.version}</source>
<target>${java.version}</target>
- <argLine>-Xms512m</argLine>
</configuration>
</plugin>
<!-- <plugin>
diff --git a/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/FCSSRUQueryParser.java b/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/FCSSRUQueryParser.java
index c4d0fa1..3babf9c 100644
--- a/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/FCSSRUQueryParser.java
+++ b/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/FCSSRUQueryParser.java
@@ -2,6 +2,7 @@
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import de.ids_mannheim.korap.query.object.KoralContext;
@@ -125,7 +126,7 @@
private KoralGroup parseWithinQuery(QueryWithWithin queryNode)
throws KoralException {
KoralGroup koralGroup = new KoralGroup(KoralOperation.POSITION);
- koralGroup.setFrames(Arrays.asList(KoralFrame.IS_AROUND));
+ koralGroup.setFrames(Collections.singletonList(KoralFrame.IS_AROUND));
List<KoralObject> operands = new ArrayList<KoralObject>();
operands.add(parseQueryNode(queryNode.getWithin()));
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessor.java
index 5689705..4ccf2a6 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessor.java
@@ -995,7 +995,6 @@
}
- @SuppressWarnings("unchecked")
private Map<String, Object> parseOperatorNode (ParseTree operatorNode) {
Map<String, Object> relation = null;
String operator = getNodeCat(operatorNode);
@@ -1131,7 +1130,6 @@
}
- @SuppressWarnings("unchecked")
private Map<String, Object> parseEdgeSpec (ParseTree edgeSpec) {
List<ParseTree> annos = getChildrenWithCat(edgeSpec, "edgeAnno");
if (annos.size() != 1) {
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
index 1ce1635..69a6293 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
@@ -1550,14 +1550,13 @@
Pattern.compile("([+\\-])?(sa|se|pa|pe|ta|te)");
Matcher conditionMatcher =
conditionPattern.matcher(conditionsString);
- String replacement = "#BED(" + m.group(1) + " , ";
+ StringBuilder replacement = new StringBuilder("#BED(" + m.group(1) + " , ");
while (conditionMatcher.find()) {
- replacement = replacement + conditionMatcher.group() + ",";
+ replacement.append(conditionMatcher.group()).append(",");
}
// remove trailing comma and close parenthesis
- replacement =
- replacement.substring(0, replacement.length() - 1) + ")";
- rewrittenQuery = rewrittenQuery.replace(match, replacement);
+ replacement = new StringBuilder(replacement.substring(0, replacement.length() - 1) + ")");
+ rewrittenQuery = rewrittenQuery.replace(match, replacement.toString());
}
return rewrittenQuery;
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessor.java
index aed8c3d..7cde9c1 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessor.java
@@ -639,9 +639,7 @@
CollectionQueryProcessor cq = new CollectionQueryProcessor(
node.getChild(1).getText());
requestMap.put("collection", cq.getRequestMap().get("collection"));
- for (ParseTree child : getChildren(node)) {
- visited.add(child);
- }
+ visited.addAll(getChildren(node));
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/QueryUtils.java b/src/main/java/de/ids_mannheim/korap/query/serialize/QueryUtils.java
index 84932e8..0bfdc73 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/QueryUtils.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/QueryUtils.java
@@ -73,87 +73,86 @@
break;
}
- StringBuffer buffer = new StringBuffer();
- buffer.append("<query><cypher><![CDATA[");
- buffer.append(cypher);
- buffer.append("]]></cypher>");
- buffer.append("<wordAliasPrefix>wtok_</wordAliasPrefix>");
- buffer.append("<contextColumn>sent</contextColumn>");
- buffer.append("<contextIdColumn>sid</contextIdColumn>");
- buffer.append("<textColumn>txt</textColumn>");
- buffer.append("<startIndex>");
- buffer.append(page);
- buffer.append("</startIndex>");
- buffer.append("<itemsPerPage>");
- buffer.append(limit);
- buffer.append("</itemsPerPage>");
- buffer.append("<context>");
- buffer.append("<left>");
- buffer.append("<" + sctypel + ">");
- buffer.append(cl);
- buffer.append("</" + sctypel + ">");
- buffer.append("</left>");
- buffer.append("<right>");
- buffer.append("<" + sctyper + ">");
- buffer.append(cr);
- buffer.append("</" + sctyper + ">");
- buffer.append("</right>");
- buffer.append("</context>");
- buffer.append("</query>");
- return buffer.toString();
+ return new StringBuffer()
+ .append("<query><cypher><![CDATA[")
+ .append(cypher)
+ .append("]]></cypher>")
+ .append("<wordAliasPrefix>wtok_</wordAliasPrefix>")
+ .append("<contextColumn>sent</contextColumn>")
+ .append("<contextIdColumn>sid</contextIdColumn>")
+ .append("<textColumn>txt</textColumn>")
+ .append("<startIndex>")
+ .append(page)
+ .append("</startIndex>")
+ .append("<itemsPerPage>")
+ .append(limit)
+ .append("</itemsPerPage>")
+ .append("<context>")
+ .append("<left>")
+ .append("<").append(sctypel).append(">")
+ .append(cl)
+ .append("</").append(sctypel).append(">")
+ .append("</left>")
+ .append("<right>")
+ .append("<").append(sctyper).append(">")
+ .append(cr)
+ .append("</").append(sctyper).append(">")
+ .append("</right>")
+ .append("</context>")
+ .append("</query>")
+ .toString();
}
public static String buildDotQuery (long sid, String graphdb_id) {
- StringBuffer b = new StringBuffer();
- b.append("<query>");
- b.append("<sentenceId>");
- b.append(sid);
- b.append("</sentenceId>");
- b.append("<gdbId>");
- b.append(graphdb_id);
- b.append("</gdbId>");
- b.append("<hls>");
- b.append("<hl>");
- b.append(40857);
- b.append("</hl>");
- b.append("<hl>");
- b.append(40856);
- b.append("</hl>");
- b.append("</hls>");
- b.append("</query>");
-
- return b.toString();
+ return new StringBuffer()
+ .append("<query>")
+ .append("<sentenceId>")
+ .append(sid)
+ .append("</sentenceId>")
+ .append("<gdbId>")
+ .append(graphdb_id)
+ .append("</gdbId>")
+ .append("<hls>")
+ .append("<hl>")
+ .append(40857)
+ .append("</hl>")
+ .append("<hl>")
+ .append(40856)
+ .append("</hl>")
+ .append("</hls>")
+ .append("</query>")
+ .toString();
}
public String buildaggreQuery (String query) {
- StringBuffer b = new StringBuffer();
- b.append("<query><cypher><![CDATA[");
- b.append(query);
- b.append("]]></cypher>");
- b.append("<columns>");
- b.append("<column agg='true' sum='false'>");
- b.append("<cypherAlias>");
- b.append("aggBy");
- b.append("</cypherAlias>");
- b.append("<displayName>");
- b.append("Aggregate");
- b.append("</displayName>");
- b.append("</column>");
+ return new StringBuffer()
+ .append("<query><cypher><![CDATA[")
+ .append(query)
+ .append("]]></cypher>")
+ .append("<columns>")
+ .append("<column agg='true' sum='false'>")
+ .append("<cypherAlias>")
+ .append("aggBy")
+ .append("</cypherAlias>")
+ .append("<displayName>")
+ .append("Aggregate")
+ .append("</displayName>")
+ .append("</column>")
- b.append("<column agg='fals' sum='true'>");
- b.append("<cypherAlias>");
- b.append("cnt");
- b.append("</cypherAlias>");
- b.append("<displayName>");
- b.append("Count");
- b.append("</displayName>");
- b.append("</column>");
- b.append("</columns>");
+ .append("<column agg='fals' sum='true'>")
+ .append("<cypherAlias>")
+ .append("cnt")
+ .append("</cypherAlias>")
+ .append("<displayName>")
+ .append("Count")
+ .append("</displayName>")
+ .append("</column>")
+ .append("</columns>")
- b.append("</query>");
- return b.toString();
+ .append("</query>")
+ .toString();
}
diff --git a/src/test/java/de/ids_mannheim/korap/query/test/EmptyResultsTest.java b/src/test/java/de/ids_mannheim/korap/query/test/EmptyResultsTest.java
index a1a202f..eb0c9ec 100644
--- a/src/test/java/de/ids_mannheim/korap/query/test/EmptyResultsTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/test/EmptyResultsTest.java
@@ -10,8 +10,7 @@
import java.util.List;
import java.util.ArrayList;
-
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
/**
* @author hanl
@@ -27,8 +26,8 @@
QuerySerializer s = new QuerySerializer();
s.setQuery("prox/unit=word/distance<=5", "cql");
JsonNode node = mapper.valueToTree(s.build());
- assertEquals(node.has("query"), false);
- assertEquals(node.has("collection"), false);
+ assertFalse(node.has("query"));
+ assertFalse(node.has("collection"));
}
@@ -38,8 +37,8 @@
s.setQuery("[base=Wort]", "poliqarp");
JsonNode node = mapper.valueToTree(s.build());
- assertEquals(node.has("query"), true);
- assertEquals(node.has("collection"), false);
+ assertTrue(node.has("query"));
+ assertFalse(node.has("collection"));
}
@@ -49,7 +48,7 @@
s.setQuery("[base=Wort]", "poliqarp");
JsonNode node = mapper.valueToTree(s.build());
- assertEquals(node.has("meta"), false);
+ assertFalse(node.has("meta"));
}
@Test
@@ -62,12 +61,12 @@
s.addWarning(16, "Beispiel 2", null);
JsonNode node = mapper.valueToTree(s.build());
- assertEquals(true, node.has("warnings"));
+ assertTrue(node.has("warnings"));
assertEquals(14, node.at("/warnings/0/0").asInt());
assertEquals("Beispiel", node.at("/warnings/0/1").asText());
assertEquals("Hui", node.at("/warnings/0/2").asText());
assertEquals(16, node.at("/warnings/1/0").asInt());
assertEquals("Beispiel 2", node.at("/warnings/1/1").asText());
- assertEquals(false, node.has("/warnings/1/2"));
+ assertFalse(node.has("/warnings/1/2"));
}
}
diff --git a/src/test/java/de/ids_mannheim/korap/query/test/annis/AnnisQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/test/annis/AnnisQueryProcessorTest.java
index 58a1ea5..12da8b6 100644
--- a/src/test/java/de/ids_mannheim/korap/query/test/annis/AnnisQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/test/annis/AnnisQueryProcessorTest.java
@@ -1,7 +1,5 @@
package de.ids_mannheim.korap.query.test.annis;
-import static org.junit.Assert.assertEquals;
-
import java.io.IOException;
import org.junit.Test;
@@ -13,6 +11,8 @@
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
import de.ids_mannheim.korap.query.serialize.util.StatusCodes;
+import static org.junit.Assert.*;
+
/**
* Tests for JSON-LD serialization of ANNIS QL queries.
*
@@ -214,8 +214,8 @@
assertEquals("operation:sequence", res.at("/query/operation").asText());
assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
assertEquals("die", res.at("/query/operands/1/wrap/key").asText());
- assertEquals(true, res.at("/query/inOrder").asBoolean());
- assertEquals(true, res.at("/query/operands/2").isMissingNode());
+ assertTrue(res.at("/query/inOrder").asBoolean());
+ assertTrue(res.at("/query/operands/2").isMissingNode());
query = "tok=\"der\" & tok=\"die\" & #1 .2,3 #2";
qs.setQuery(query, "annis");
@@ -224,8 +224,8 @@
assertEquals("operation:sequence", res.at("/query/operation").asText());
assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
assertEquals("die", res.at("/query/operands/1/wrap/key").asText());
- assertEquals(true, res.at("/query/inOrder").asBoolean());
- assertEquals(true, res.at("/query/operands/2").isMissingNode());
+ assertTrue(res.at("/query/inOrder").asBoolean());
+ assertTrue(res.at("/query/operands/2").isMissingNode());
assertEquals("koral:distance", res.at("/query/distances/0/@type")
.asText());
assertEquals("koral:boundary",
@@ -240,14 +240,14 @@
assertEquals("operation:sequence", res.at("/query/operation").asText());
assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
assertEquals("die", res.at("/query/operands/1/wrap/key").asText());
- assertEquals(true, res.at("/query/inOrder").asBoolean());
- assertEquals(true, res.at("/query/operands/2").isMissingNode());
+ assertTrue(res.at("/query/inOrder").asBoolean());
+ assertTrue(res.at("/query/operands/2").isMissingNode());
assertEquals("koral:distance", res.at("/query/distances/0/@type")
.asText());
assertEquals("koral:boundary",
res.at("/query/distances/0/boundary/@type").asText());
assertEquals(1, res.at("/query/distances/0/boundary/min").asInt());
- assertEquals(true, res.at("/query/distances/0/boundary/max")
+ assertTrue(res.at("/query/distances/0/boundary/max")
.isMissingNode());
query = "tok=\"der\" & tok=\"die\" & #1 .* #2";
@@ -256,7 +256,7 @@
assertEquals("koral:boundary",
res.at("/query/distances/0/boundary/@type").asText());
assertEquals(0, res.at("/query/distances/0/boundary/min").asInt());
- assertEquals(true, res.at("/query/distances/0/boundary/max")
+ assertTrue(res.at("/query/distances/0/boundary/max")
.isMissingNode());
}
@@ -270,8 +270,8 @@
assertEquals("operation:sequence", res.at("/query/operation").asText());
assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
assertEquals("die", res.at("/query/operands/1/wrap/key").asText());
- assertEquals(false, res.at("/query/inOrder").asBoolean());
- assertEquals(true, res.at("/query/operands/2").isMissingNode());
+ assertFalse(res.at("/query/inOrder").asBoolean());
+ assertTrue(res.at("/query/operands/2").isMissingNode());
query = "tok=\"der\" & tok=\"die\" & #1 ^2,3 #2";
qs.setQuery(query, "annis");
@@ -280,8 +280,8 @@
assertEquals("operation:sequence", res.at("/query/operation").asText());
assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
assertEquals("die", res.at("/query/operands/1/wrap/key").asText());
- assertEquals(false, res.at("/query/inOrder").asBoolean());
- assertEquals(true, res.at("/query/operands/2").isMissingNode());
+ assertFalse(res.at("/query/inOrder").asBoolean());
+ assertTrue(res.at("/query/operands/2").isMissingNode());
assertEquals("koral:distance", res.at("/query/distances/0/@type")
.asText());
assertEquals("koral:boundary",
@@ -295,9 +295,9 @@
assertEquals("koral:boundary",
res.at("/query/distances/0/boundary/@type").asText());
assertEquals(0, res.at("/query/distances/0/boundary/min").asInt());
- assertEquals(true, res.at("/query/distances/0/boundary/max")
+ assertTrue(res.at("/query/distances/0/boundary/max")
.isMissingNode());
- assertEquals(false, res.at("/query/inOrder").asBoolean());
+ assertFalse(res.at("/query/inOrder").asBoolean());
}
@@ -485,7 +485,7 @@
// the resulting query should be equivalent to PQ+: focus(2:dominates(focus(1:{1:<A>}<B>),{2:<C>}))<D>
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
- assertEquals(true, res.at("/query/@type").isMissingNode());
+ assertTrue(res.at("/query/@type").isMissingNode());
assertEquals(StatusCodes.UNBOUND_ANNIS_RELATION, res.at("/errors/0/0")
.asInt());
}
@@ -930,7 +930,7 @@
assertEquals("operation:focus", res.at("/query/operands/1/operation")
.asText());
assertEquals(131, res.at("/query/operands/1/classRef/0").asInt());
- assertEquals(true, res.at("/query/operands/1/operands").isMissingNode());
+ assertTrue(res.at("/query/operands/1/operands").isMissingNode());
}
@@ -975,7 +975,7 @@
assertEquals("NP", res.at("/query/wrap/key").asText());
assertEquals("match:eq", res.at("/query/wrap/match").asText());
assertEquals("koral:term", res.at("/query/attr/@type").asText());
- assertEquals(true, res.at("/query/attr/root").asBoolean());
+ assertTrue(res.at("/query/attr/root").asBoolean());
query = "cnx/cat=\"NP\" & #1:root & #1:arity=2";
qs.setQuery(query, "annis");
@@ -987,7 +987,7 @@
assertEquals("koral:termGroup", res.at("/query/attr/@type").asText());
assertEquals("koral:term", res.at("/query/attr/operands/0/@type")
.asText());
- assertEquals(true, res.at("/query/attr/operands/0/root").asBoolean());
+ assertTrue(res.at("/query/attr/operands/0/root").asBoolean());
assertEquals("koral:term", res.at("/query/attr/operands/1/@type")
.asText());
assertEquals("koral:boundary",
@@ -1044,10 +1044,8 @@
"koral:span",
res.at("/query/operands/0/operands/0/operands/0/operands/0/@type")
.asText());
- assertEquals(
- true,
- res.at("/query/operands/0/operands/0/operands/0/operands/0/key")
- .isMissingNode());
+ assertTrue(res.at("/query/operands/0/operands/0/operands/0/operands/0/key")
+ .isMissingNode());
assertEquals("koral:span",
res.at("/query/operands/0/operands/0/operands/1/@type")
.asText());
diff --git a/src/test/java/de/ids_mannheim/korap/query/test/collection/CollectionQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/test/collection/CollectionQueryProcessorTest.java
index 5829482..8f371de 100644
--- a/src/test/java/de/ids_mannheim/korap/query/test/collection/CollectionQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/test/collection/CollectionQueryProcessorTest.java
@@ -1,9 +1,5 @@
package de.ids_mannheim.korap.query.test.collection;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import org.junit.Test;
@@ -16,6 +12,8 @@
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
import de.ids_mannheim.korap.query.serialize.QueryUtils;
+import static org.junit.Assert.*;
+
public class CollectionQueryProcessorTest {
private String query = "foo";
@@ -105,7 +103,7 @@
assertEquals("koral:doc", res.at("/collection/@type").asText());
assertEquals("textClass", res.at("/collection/key").asText());
assertEquals("politik", res.at("/collection/value").asText());
- assertFalse(res.at("/collection/type").asText().equals("type:regex"));
+ assertNotEquals("type:regex", res.at("/collection/type").asText());
assertEquals("match:eq", res.at("/collection/match").asText());
collection = "textClass!=politik";
@@ -115,7 +113,7 @@
assertEquals("koral:doc", res.at("/collection/@type").asText());
assertEquals("textClass", res.at("/collection/key").asText());
assertEquals("politik", res.at("/collection/value").asText());
- assertFalse(res.at("/collection/type").asText().equals("type:regex"));
+ assertNotEquals("type:regex", res.at("/collection/type").asText());
assertEquals("match:ne", res.at("/collection/match").asText());
}
@@ -348,7 +346,7 @@
.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")
+ assertTrue(res.at("/collection/operands/1/type")
.isMissingNode());
assertEquals("match:eq", res.at("/collection/operands/1/match")
.asText());
@@ -658,7 +656,7 @@
assertEquals("koral:doc", res.at("/collection/@type").asText());
assertEquals("pubDate", res.at("/collection/key").asText());
assertEquals("2000", res.at("/collection/value").asText());
- assertEquals(true, res.at("/collection/type").isMissingNode());
+ assertTrue(res.at("/collection/type").isMissingNode());
assertEquals("match:eq", res.at("/collection/match").asText());
collection = "pubDate since 2000";
@@ -702,7 +700,7 @@
assertEquals("koral:doc", res.at("/collection/@type").asText());
assertEquals("pubDate", res.at("/collection/key").asText());
assertEquals("2000-12", res.at("/collection/value").asText());
- assertEquals(true, res.at("/collection/type").isMissingNode());
+ assertTrue(res.at("/collection/type").isMissingNode());
assertEquals("match:eq", res.at("/collection/match").asText());
collection = "pubDate since 2000-02-01";
@@ -759,11 +757,11 @@
String date_1 = "2015-05";
String date_2 = "2015-05-13";
String date_3 = "2015-23-01";
- assertEquals(false, QueryUtils.checkDateValidity(fake_date));
- assertEquals(false, QueryUtils.checkDateValidity(fake_date_2));
- assertEquals(true, QueryUtils.checkDateValidity(date));
- assertEquals(true, QueryUtils.checkDateValidity(date_1));
- assertEquals(true, QueryUtils.checkDateValidity(date_2));
- assertEquals(false, QueryUtils.checkDateValidity(date_3));
+ assertFalse(QueryUtils.checkDateValidity(fake_date));
+ assertFalse(QueryUtils.checkDateValidity(fake_date_2));
+ assertTrue(QueryUtils.checkDateValidity(date));
+ assertTrue(QueryUtils.checkDateValidity(date_1));
+ assertTrue(QueryUtils.checkDateValidity(date_2));
+ assertFalse(QueryUtils.checkDateValidity(date_3));
}
}
diff --git a/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLQueryProcessorTest.java
index 01881ee..7ca180d 100644
--- a/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLQueryProcessorTest.java
@@ -1,6 +1,7 @@
package de.ids_mannheim.korap.query.test.fcsql;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.List;
@@ -106,7 +107,7 @@
error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query));
assertEquals(306, error.get(0));
String msg = (String) error.get(1);
- assertEquals(true, msg.startsWith("Regexflags"));
+ assertTrue(msg.startsWith("Regexflags"));
query = "\"Fliegen\" /d";
error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query));
diff --git a/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/EmptyTokenTest.java b/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/EmptyTokenTest.java
index 6c215f9..a689a14 100644
--- a/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/EmptyTokenTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/EmptyTokenTest.java
@@ -39,7 +39,7 @@
qs.setQuery(query, "poliqarpplus");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:token", res.at("/query/@type").asText());
- assertEquals(true, res.at("/query/key").isMissingNode());
+ assertTrue(res.at("/query/key").isMissingNode());
}
@Test
@@ -107,7 +107,7 @@
res = mapper.readTree(qs.toJSON());
operands = Lists.newArrayList(res.at("/query/operands").elements());
assertEquals("koral:token", operands.get(0).at("/@type").asText());
- assertEquals(true, operands.get(0).at("/key").isMissingNode());
+ assertTrue(operands.get(0).at("/key").isMissingNode());
assertEquals("koral:token", operands.get(1).at("/@type").asText());
assertEquals("Mann", operands.get(1).at("/wrap/key").asText());
@@ -124,7 +124,7 @@
operands = Lists
.newArrayList(operands.get(0).at("/operands").elements());
assertEquals("koral:token", operands.get(0).at("/@type").asText());
- assertEquals(true, operands.get(0).at("/key").isMissingNode());
+ assertTrue(operands.get(0).at("/key").isMissingNode());
}
@@ -141,8 +141,7 @@
assertEquals(2, operands.get(0).at("/boundary/max").asInt());
assertEquals("koral:token",
operands.get(0).at("/operands/0/@type").asText());
- assertEquals(true,
- operands.get(0).at("/operands/0/key").isMissingNode());
+ assertTrue(operands.get(0).at("/operands/0/key").isMissingNode());
assertEquals("koral:token", operands.get(1).at("/@type").asText());
assertEquals("bose", operands.get(1).at("/wrap/key").asText());
assertEquals("koral:token", operands.get(2).at("/@type").asText());
@@ -157,7 +156,7 @@
res = mapper.readTree(qs.toJSON());
operands = Lists.newArrayList(res.at("/query/operands").elements());
assertEquals("koral:token", operands.get(1).at("/@type").asText());
- assertEquals(true, operands.get(1).at("/key").isMissingNode());
+ assertTrue(operands.get(1).at("/key").isMissingNode());
query = "[base=Mann][]{3}";
qs.setQuery(query, "poliqarpplus");
@@ -165,7 +164,7 @@
operands = Lists.newArrayList(res.at("/query/operands").elements());
res = operands.get(1);
assertEquals("koral:group", res.at("/@type").asText());
- assertEquals(true, res.at("/wrap/key").isMissingNode());
+ assertTrue(res.at("/wrap/key").isMissingNode());
assertEquals("operation:repetition", res.at("/operation").asText());
assertEquals(3, res.at("/boundary/min").asInt());
assertEquals(3, res.at("/boundary/max").asInt());
@@ -199,7 +198,7 @@
assertEquals("lemma", operands.get(0).at("/wrap/layer").asText());
assertEquals("match:eq", operands.get(0).at("/wrap/match").asText());
assertEquals("koral:token", operands.get(1).at("/@type").asText());
- assertEquals(true, operands.get(1).at("/wrap/key").isMissingNode());
+ assertTrue(operands.get(1).at("/wrap/key").isMissingNode());
assertEquals("koral:token", operands.get(2).at("/@type").asText());
assertEquals("Mann", operands.get(2).at("/wrap/key").asText());
assertEquals("lemma", operands.get(2).at("/wrap/layer").asText());
@@ -228,7 +227,7 @@
.newArrayList(operands.get(1).at("/operands").elements());
assertEquals(1, operands.size());
assertEquals("koral:token", operands.get(0).at("/@type").asText());
- assertEquals(true, operands.get(0).at("/wrap/key").isMissingNode());
+ assertTrue(operands.get(0).at("/wrap/key").isMissingNode());
}
@@ -244,7 +243,7 @@
assertEquals(3, operands.size());
assertEquals("koral:token", operands.get(1).at("/@type").asText());
- assertEquals(true, operands.get(1).at("/wrap/key").isMissingNode());
+ assertTrue(operands.get(1).at("/wrap/key").isMissingNode());
assertEquals("koral:group", operands.get(2).at("/@type").asText());
assertEquals("operation:repetition",
@@ -277,7 +276,7 @@
assertEquals(1, operands.get(0).at("/boundary/max").asInt());
assertEquals("koral:token", operands.get(1).at("/@type").asText());
- assertEquals(true, operands.get(1).at("/wrap/key").isMissingNode());
+ assertTrue(operands.get(1).at("/wrap/key").isMissingNode());
assertEquals("koral:group", operands.get(2).at("/@type").asText());
assertEquals("operation:repetition",
@@ -310,7 +309,7 @@
.newArrayList(operands.get(1).at("/operands").elements());
assertEquals(1, operands.size());
assertEquals("koral:token", operands.get(0).at("/@type").asText());
- assertEquals(true, operands.get(0).at("/wrap/key").isMissingNode());
+ assertTrue(operands.get(0).at("/wrap/key").isMissingNode());
}
@@ -330,12 +329,12 @@
assertEquals("koral:boundary",
operands.get(1).at("/boundary/@type").asText());
assertEquals(1, operands.get(1).at("/boundary/min").asInt());
- assertEquals(true, operands.get(1).at("/boundary/max").isMissingNode());
+ assertTrue(operands.get(1).at("/boundary/max").isMissingNode());
operands = Lists
.newArrayList(operands.get(1).at("/operands").elements());
assertEquals(1, operands.size());
assertEquals("koral:token", operands.get(0).at("/@type").asText());
- assertEquals(true, operands.get(0).at("/wrap/key").isMissingNode());
+ assertTrue(operands.get(0).at("/wrap/key").isMissingNode());
}
@@ -356,12 +355,12 @@
assertEquals("koral:boundary",
operands.get(1).at("/boundary/@type").asText());
assertEquals(0, operands.get(1).at("/boundary/min").asInt());
- assertEquals(true, operands.get(1).at("/boundary/max").isMissingNode());
+ assertTrue(operands.get(1).at("/boundary/max").isMissingNode());
operands = Lists
.newArrayList(operands.get(1).at("/operands").elements());
assertEquals(1, operands.size());
assertEquals("koral:token", operands.get(0).at("/@type").asText());
- assertEquals(true, operands.get(0).at("/wrap/key").isMissingNode());
+ assertTrue(operands.get(0).at("/wrap/key").isMissingNode());
}
@@ -387,8 +386,7 @@
assertEquals(5, operands.get(1).at("/boundary/max").asInt());
assertEquals("koral:token",
operands.get(1).at("/operands/0/@type").asText());
- assertEquals(true,
- operands.get(1).at("/operands/0/wrap/key").isMissingNode());
+ assertTrue(operands.get(1).at("/operands/0/wrap/key").isMissingNode());
assertEquals("koral:token", operands.get(2).at("/@type").asText());
assertEquals("Mann", operands.get(2).at("/wrap/key").asText());
@@ -402,8 +400,7 @@
assertEquals(2, operands.get(3).at("/boundary/max").asInt());
assertEquals("koral:token",
operands.get(3).at("/operands/0/@type").asText());
- assertEquals(true,
- operands.get(3).at("/operands/0/wrap/key").isMissingNode());
+ assertTrue(operands.get(3).at("/operands/0/wrap/key").isMissingNode());
assertEquals("koral:token", operands.get(4).at("/@type").asText());
assertEquals("Frau", operands.get(4).at("/wrap/key").asText());
@@ -419,8 +416,8 @@
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals(true, res.at("/query/inOrder").isMissingNode());
- assertEquals(true, res.at("/query/distances").isMissingNode());
+ assertTrue(res.at("/query/inOrder").isMissingNode());
+ assertTrue(res.at("/query/distances").isMissingNode());
operands = Lists.newArrayList(res.at("/query/operands").elements());
assertEquals(4, operands.size());
@@ -443,7 +440,7 @@
assertEquals("koral:boundary",
operands.get(2).at("/boundary/@type").asText());
assertEquals(0, operands.get(2).at("/boundary/min").asInt());
- assertEquals(true, operands.get(2).at("/boundary/max").isMissingNode());
+ assertTrue(operands.get(2).at("/boundary/max").isMissingNode());
assertEquals("koral:group", operands.get(3).at("/@type").asText());
assertEquals("operation:position",
@@ -466,11 +463,11 @@
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:position", res.at("/query/operation").asText());
assertEquals("frames:isAround", res.at("/query/frames/0").asText());
- assertEquals(true, res.at("/query/frames/1").isMissingNode());
+ assertTrue(res.at("/query/frames/1").isMissingNode());
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
assertEquals("s", res.at("/query/operands/0/wrap/key").asText());
assertEquals("koral:token", res.at("/query/operands/1/@type").asText());
- assertEquals(true, res.at("/query/operands/1/key").isMissingNode());
+ assertTrue(res.at("/query/operands/1/key").isMissingNode());
query = "contains(<s>, []{3})";
qs.setQuery(query, "poliqarpplus");
@@ -481,8 +478,7 @@
res.at("/query/operands/1/operation").asText());
assertEquals("koral:token",
res.at("/query/operands/1/operands/0/@type").asText());
- assertEquals(true,
- res.at("/query/operands/1/operands/0/key").isMissingNode());
+ assertTrue(res.at("/query/operands/1/operands/0/key").isMissingNode());
query = "contains(<s>, {1:[]{3}})";
qs.setQuery(query, "poliqarpplus");
@@ -495,7 +491,7 @@
res.at("/query/operands/1/operands/0/operation").asText());
assertEquals("koral:token", res
.at("/query/operands/1/operands/0/operands/0/@type").asText());
- assertEquals(true, res.at("/query/operands/1/operands/0/operands/0/key")
+ assertTrue(res.at("/query/operands/1/operands/0/operands/0/key")
.isMissingNode());
query = "startswith(<s>, [][base=Mann])";
@@ -507,7 +503,7 @@
operands = Lists.newArrayList(res.at("/query/operands"));
operands = Lists.newArrayList(operands.get(1).at("/operands"));
assertEquals("koral:token", operands.get(0).at("/@type").asText());
- assertEquals(true, operands.get(0).at("/key").isMissingNode());
+ assertTrue(operands.get(0).at("/key").isMissingNode());
}
@Test
@@ -517,8 +513,8 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals(true, res.at("/query/inOrder").isMissingNode());
- assertEquals(true, res.at("/query/distances").isMissingNode());
+ assertTrue(res.at("/query/inOrder").isMissingNode());
+ assertTrue(res.at("/query/distances").isMissingNode());
operands = Lists.newArrayList(res.at("/query/operands").elements());
assertEquals("der", operands.get(0).at("/wrap/key").asText());
assertEquals("Mann", operands.get(2).at("/wrap/key").asText());
@@ -529,7 +525,7 @@
operands = Lists
.newArrayList(operands.get(1).at("/operands").elements());
assertEquals("koral:token", operands.get(0).at("/@type").asText());
- assertEquals(true, operands.get(0).at("/wrap").isMissingNode());
+ assertTrue(operands.get(0).at("/wrap").isMissingNode());
assertEquals(1, res.at("/meta/highlight/0").asInt());
}
diff --git a/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/PoliqarpPlusQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/PoliqarpPlusQueryProcessorTest.java
index f8bfa1a..f1562a0 100644
--- a/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/PoliqarpPlusQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/PoliqarpPlusQueryProcessorTest.java
@@ -342,7 +342,7 @@
assertEquals("koral:token", res.at("/query/@type").asText());
assertEquals("koral:term", res.at("/query/wrap/@type").asText());
assertEquals("deutscher", res.at("/query/wrap/key").asText());
- assertEquals(true, res.at("/query/wrap/flags:caseInsensitive")
+ assertTrue(res.at("/query/wrap/flags:caseInsensitive")
.isMissingNode());
assertEquals("flags:caseInsensitive", res.at("/query/wrap/flags/0")
.asText());
@@ -366,7 +366,7 @@
assertEquals("koral:token", res.at("/query/@type").asText());
assertEquals("koral:term", res.at("/query/wrap/@type").asText());
assertEquals("deutscher", res.at("/query/wrap/key").asText());
- assertEquals(true, res.at("/query/wrap/flags/0").isMissingNode());
+ assertTrue(res.at("/query/wrap/flags/0").isMissingNode());
assertEquals("orth", res.at("/query/wrap/layer").asText());
assertEquals("match:eq", res.at("/query/wrap/match").asText());
@@ -386,7 +386,7 @@
assertEquals("Bundestag", operands.get(1).at("/wrap/key").asText());
assertEquals("orth", operands.get(1).at("/wrap/layer").asText());
assertEquals("match:eq", operands.get(1).at("/wrap/match").asText());
- assertEquals(true, operands.get(1).at("/wrap/flags/0").isMissingNode());
+ assertTrue(operands.get(1).at("/wrap/flags/0").isMissingNode());
query = "deutscher/i Bundestag";
qs.setQuery(query, "poliqarpplus");
@@ -404,7 +404,7 @@
assertEquals("Bundestag", operands.get(1).at("/wrap/key").asText());
assertEquals("orth", operands.get(1).at("/wrap/layer").asText());
assertEquals("match:eq", operands.get(1).at("/wrap/match").asText());
- assertEquals(true, operands.get(1).at("/wrap/flags:caseInsensitive")
+ assertTrue(operands.get(1).at("/wrap/flags:caseInsensitive")
.isMissingNode());
}
@@ -515,7 +515,7 @@
qs.setQuery(query, "poliqarpplus");
res = mapper.readTree(qs.toJSON());
assertEquals(3, res.at("/query/boundary/min").asInt());
- assertEquals(true, res.at("/query/boundary/max").isMissingNode());
+ assertTrue(res.at("/query/boundary/max").isMissingNode());
query = "der{3,7}";
qs.setQuery(query, "poliqarpplus");
@@ -527,13 +527,13 @@
qs.setQuery(query, "poliqarpplus");
res = mapper.readTree(qs.toJSON());
assertEquals(0, res.at("/query/boundary/min").asInt());
- assertEquals(true, res.at("/query/boundary/max").isMissingNode());
+ assertTrue(res.at("/query/boundary/max").isMissingNode());
query = "der+";
qs.setQuery(query, "poliqarpplus");
res = mapper.readTree(qs.toJSON());
assertEquals(1, res.at("/query/boundary/min").asInt());
- assertEquals(true, res.at("/query/boundary/max").isMissingNode());
+ assertTrue(res.at("/query/boundary/max").isMissingNode());
};
@@ -555,7 +555,7 @@
qs.setQuery(query, "poliqarpplus");
res = mapper.readTree(qs.toJSON());
assertEquals(3, res.at("/query/operands/1/boundary/min").asInt());
- assertEquals(true, res.at("/query/operands/1/boundary/max")
+ assertTrue(res.at("/query/operands/1/boundary/max")
.isMissingNode());
query = "contains(<s>, (der){,3})";
@@ -574,7 +574,7 @@
qs.setQuery(query, "poliqarpplus");
res = mapper.readTree(qs.toJSON());
assertEquals(0, res.at("/query/operands/1/boundary/min").asInt());
- assertEquals(true, res.at("/query/operands/1/boundary/max")
+ assertTrue(res.at("/query/operands/1/boundary/max")
.isMissingNode());
};
@@ -587,7 +587,7 @@
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:position", res.at("/query/operation").asText());
assertEquals("frames:isAround", res.at("/query/frames/0").asText());
- assertEquals(true, res.at("/query/frames/1").isMissingNode());
+ assertTrue(res.at("/query/frames/1").isMissingNode());
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
assertEquals("s", res.at("/query/operands/0/wrap/key").asText());
assertEquals("koral:token", res.at("/query/operands/1/@type").asText());
@@ -629,7 +629,7 @@
res.at("/query/operands/1/operands/1/operation").asText());
assertEquals(0, res.at("/query/operands/1/operands/1/boundary/min")
.asInt());
- assertEquals(true, res.at("/query/operands/1/operands/1/boundary/max")
+ assertTrue(res.at("/query/operands/1/operands/1/boundary/max")
.isMissingNode());
assertEquals("Mann",
res.at("/query/operands/1/operands/1/operands/0/wrap/key")
@@ -1041,7 +1041,7 @@
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:class", res.at("/query/operation").asText());
assertEquals(1, res.at("/query/classOut").asInt());
- assertEquals(true, res.at("/query/classIn").isMissingNode());
+ assertTrue(res.at("/query/classIn").isMissingNode());
assertEquals("Mann", res.at("/query/operands/0/wrap/key").asText());
query = "{[base=Mann][orth=Frau]}";
@@ -1050,7 +1050,7 @@
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:class", res.at("/query/operation").asText());
assertEquals(1, res.at("/query/classOut").asInt());
- assertEquals(true, res.at("/query/classIn").isMissingNode());
+ assertTrue(res.at("/query/classIn").isMissingNode());
assertEquals("Mann", res.at("/query/operands/0/operands/0/wrap/key")
.asText());
assertEquals("Frau", res.at("/query/operands/0/operands/1/wrap/key")
@@ -1067,7 +1067,7 @@
assertEquals("operation:class", res.at("/query/operands/1/operation")
.asText());
assertEquals(1, res.at("/query/operands/1/classOut").asInt());
- assertEquals(true, res.at("/query/classIn").isMissingNode());
+ assertTrue(res.at("/query/classIn").isMissingNode());
assertEquals("Mann", res.at("/query/operands/0/operands/0/wrap/key")
.asText());
assertEquals("Frau", res.at("/query/operands/1/operands/0/wrap/key")
@@ -1082,7 +1082,7 @@
assertEquals("operation:class", res.at("/query/operands/1/operation")
.asText());
assertEquals(1, res.at("/query/operands/1/classOut").asInt());
- assertEquals(true, res.at("/query/operands/1/classIn").isMissingNode());
+ assertTrue(res.at("/query/operands/1/classIn").isMissingNode());
assertEquals("Mann",
res.at("/query/operands/1/operands/0/operands/0/wrap/key")
.asText());
@@ -1099,7 +1099,7 @@
assertEquals("operation:class", res.at("/query/operands/0/operation")
.asText());
assertEquals(1, res.at("/query/operands/0/classOut").asInt());
- assertEquals(true, res.at("/query/operands/0/classIn").isMissingNode());
+ assertTrue(res.at("/query/operands/0/classIn").isMissingNode());
assertEquals("Mann",
res.at("/query/operands/0/operands/0/operands/0/wrap/key")
.asText());
@@ -1226,7 +1226,7 @@
qs.setQuery(query, "poliqarpplus");
res = mapper.readTree(qs.toJSON());
assertEquals(3, res.at("/query/classRef/0").asInt());
- assertEquals(true, res.at("/query/classRef/1").isMissingNode());
+ assertTrue(res.at("/query/classRef/1").isMissingNode());
assertEquals("koral:reference", res.at("/query/@type").asText());
assertEquals("operation:split", res.at("/query/operation").asText());
@@ -1260,7 +1260,7 @@
assertEquals("koral:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
assertEquals(1, res.at("/query/spanRef/0").asInt());
- assertEquals(true, res.at("/query/spanRef/1").isMissingNode());
+ assertTrue(res.at("/query/spanRef/1").isMissingNode());
assertEquals("s", res.at("/query/operands/0/wrap/key").asText());
query = "submatch(1,4:<s>)";
@@ -1354,7 +1354,7 @@
assertEquals("cnx", res.at("/query/relation/wrap/foundry").asText());
assertEquals("c", res.at("/query/relation/wrap/layer").asText());
assertEquals(0, res.at("/query/relation/boundary/min").asInt());
- assertEquals(true, res.at("/query/relation/boundary/max")
+ assertTrue(res.at("/query/relation/boundary/max")
.isMissingNode());
query = "dominates(cnx/c{1,5}:<vp>,<np>)";
@@ -1598,7 +1598,7 @@
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:position", res.at("/query/operation").asText());
assertEquals("frames:isAround", res.at("/query/frames/0").asText());
- assertEquals(true, res.at("/query/frames/1").isMissingNode());
+ assertTrue(res.at("/query/frames/1").isMissingNode());
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
assertEquals("s", res.at("/query/operands/0/wrap/key").asText());
assertEquals("koral:token", res.at("/query/operands/1/@type").asText());
@@ -1609,7 +1609,7 @@
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:position", res.at("/query/operation").asText());
assertEquals("frames:isAround", res.at("/query/frames/0").asText());
- assertEquals(true, res.at("/query/frames/1").isMissingNode());
+ assertTrue(res.at("/query/frames/1").isMissingNode());
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
assertEquals("s", res.at("/query/operands/0/wrap/key").asText());
assertEquals("koral:token", res.at("/query/operands/1/@type").asText());
diff --git a/src/test/java/de/ids_mannheim/korap/test/cosmas2/Cosmas2QueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/test/cosmas2/Cosmas2QueryProcessorTest.java
index 26aa5d7..0722c9b 100644
--- a/src/test/java/de/ids_mannheim/korap/test/cosmas2/Cosmas2QueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/test/cosmas2/Cosmas2QueryProcessorTest.java
@@ -1,8 +1,5 @@
package de.ids_mannheim.korap.test.cosmas2;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import java.util.ArrayList;
@@ -15,6 +12,8 @@
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
import de.ids_mannheim.korap.query.serialize.util.StatusCodes;
+import static org.junit.Assert.*;
+
/**
* Tests for JSON-LD serialization of Cosmas II queries.
*
@@ -205,7 +204,7 @@
assertEquals("operation:sequence", res.at("/query/operation").asText());
assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
assertEquals("Mann", res.at("/query/operands/1/wrap/key").asText());
- assertEquals(true, res.at("/query/operands/2").isMissingNode());
+ assertTrue(res.at("/query/operands/2").isMissingNode());
query = "der Mann schläft";
qs.setQuery(query, "cosmas2");
@@ -215,7 +214,7 @@
assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
assertEquals("Mann", res.at("/query/operands/1/wrap/key").asText());
assertEquals("schläft", res.at("/query/operands/2/wrap/key").asText());
- assertEquals(true, res.at("/query/operands/3").isMissingNode());
+ assertTrue(res.at("/query/operands/3").isMissingNode());
query = "der Mann schläft lang";
qs.setQuery(query, "cosmas2");
@@ -226,14 +225,14 @@
assertEquals("Mann", res.at("/query/operands/1/wrap/key").asText());
assertEquals("schläft", res.at("/query/operands/2/wrap/key").asText());
assertEquals("lang", res.at("/query/operands/3/wrap/key").asText());
- assertEquals(true, res.at("/query/operands/4").isMissingNode());
+ assertTrue(res.at("/query/operands/4").isMissingNode());
query = "#ELEM(s)";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:span", res.at("/query/@type").asText());
assertEquals("s", res.at("/query/wrap/key").asText());
- assertEquals(true, res.at("/query/key").isMissingNode());
+ assertTrue(res.at("/query/key").isMissingNode());
query = "der #ELEM(W)";
qs.setQuery(query, "cosmas2");
@@ -243,7 +242,7 @@
assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
assertEquals("w", res.at("/query/operands/1/wrap/key").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
- assertEquals(true, res.at("/query/operands/2").isMissingNode());
+ assertTrue(res.at("/query/operands/2").isMissingNode());
query = "der #ELEM(W) Mann";
qs.setQuery(query, "cosmas2");
@@ -254,7 +253,7 @@
assertEquals("w", res.at("/query/operands/1/wrap/key").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
assertEquals("Mann", res.at("/query/operands/2/wrap/key").asText());
- assertEquals(true, res.at("/query/operands/3").isMissingNode());
+ assertTrue(res.at("/query/operands/3").isMissingNode());
query = "der MORPH(p=ADJA) Mann";
qs.setQuery(query, "cosmas2");
@@ -265,7 +264,7 @@
assertEquals("ADJA", res.at("/query/operands/1/wrap/key").asText());
assertEquals("p", res.at("/query/operands/1/wrap/layer").asText());
assertEquals("Mann", res.at("/query/operands/2/wrap/key").asText());
- assertEquals(true, res.at("/query/operands/3").isMissingNode());
+ assertTrue(res.at("/query/operands/3").isMissingNode());
}
@@ -279,7 +278,7 @@
.asText());
assertEquals("Sonne", res.at("/query/operands/0/wrap/key").asText());
assertEquals("Mond", res.at("/query/operands/1/wrap/key").asText());
- assertEquals(true, res.at("/query/operands/2").isMissingNode());
+ assertTrue(res.at("/query/operands/2").isMissingNode());
query = "(Sonne scheint) oder Mond";
qs.setQuery(query, "cosmas2");
@@ -295,7 +294,7 @@
assertEquals("scheint", res.at("/query/operands/0/operands/1/wrap/key")
.asText());
assertEquals("Mond", res.at("/query/operands/1/wrap/key").asText());
- assertEquals(true, res.at("/query/operands/2").isMissingNode());
+ assertTrue(res.at("/query/operands/2").isMissingNode());
query = "(Sonne scheint) oder (Mond scheint)";
qs.setQuery(query, "cosmas2");
@@ -317,7 +316,7 @@
.asText());
assertEquals("scheint", res.at("/query/operands/1/operands/1/wrap/key")
.asText());
- assertEquals(true, res.at("/query/operands/2").isMissingNode());
+ assertTrue(res.at("/query/operands/2").isMissingNode());
}
@@ -331,8 +330,8 @@
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());
+ assertFalse(res.at("/query/inOrder").isMissingNode());
+ assertFalse(res.at("/query/inOrder").asBoolean());
assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
.asText());
@@ -343,8 +342,8 @@
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());
+ assertFalse(res.at("/query/operands/0/inOrder").isMissingNode());
+ assertFalse(res.at("/query/operands/0/inOrder").asBoolean());
assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key")
.asText());
@@ -359,8 +358,8 @@
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());
+ assertFalse(res.at("/query/inOrder").isMissingNode());
+ assertFalse(res.at("/query/inOrder").asBoolean());
assertEquals("operation:sequence", res.at("/query/operation").asText());
assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
@@ -374,8 +373,8 @@
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());
+ assertFalse(res.at("/query/operands/1/inOrder").isMissingNode());
+ assertFalse(res.at("/query/operands/1/inOrder").asBoolean());
assertEquals("Sonne", res.at("/query/operands/1/operands/0/wrap/key")
.asText());
@@ -389,8 +388,8 @@
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());
+ assertFalse(res.at("/query/inOrder").isMissingNode());
+ assertFalse(res.at("/query/inOrder").asBoolean());
assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
.asText());
@@ -404,8 +403,8 @@
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());
+ assertFalse(res.at("/query/operands/1/inOrder").isMissingNode());
+ assertFalse(res.at("/query/operands/1/inOrder").asBoolean());
assertEquals("cosmas:distance",
res.at("/query/operands/1/distances/0/@type").asText());
@@ -417,9 +416,9 @@
assertEquals("koral:group", res
.at("/query/operands/1/operands/1/@type").asText());
- assertEquals(false, res.at("/query/operands/1/operands/1/inOrder")
+ assertFalse(res.at("/query/operands/1/operands/1/inOrder")
.isMissingNode());
- assertEquals(false, res.at("/query/operands/1/operands/1/inOrder")
+ assertFalse(res.at("/query/operands/1/operands/1/inOrder")
.asBoolean());
assertEquals("operation:disjunction",
@@ -445,7 +444,7 @@
assertEquals("t", res.at("/query/distances/0/key").asText());
assertEquals(0, res.at("/query/distances/0/min").asInt());
assertEquals(0, res.at("/query/distances/0/max").asInt());
- assertEquals(true, res.at("/query/distances/0/exclude").asBoolean());
+ assertTrue(res.at("/query/distances/0/exclude").asBoolean());
assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
assertEquals("Sonne", res.at("/query/operands/0/wrap/key").asText());
assertEquals("Mond", res.at("/query/operands/1/wrap/key").asText());
@@ -460,7 +459,7 @@
assertEquals("t", res.at("/query/distances/0/key").asText());
assertEquals(0, res.at("/query/distances/0/min").asInt());
assertEquals(0, res.at("/query/distances/0/max").asInt());
- assertEquals(true, res.at("/query/distances/0/exclude").asBoolean());
+ assertTrue(res.at("/query/distances/0/exclude").asBoolean());
assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
assertEquals("Sonne", res.at("/query/operands/0/wrap/key").asText());
assertEquals("koral:group", res.at("/query/operands/1/@type").asText());
@@ -471,7 +470,7 @@
assertEquals("t", res.at("/query/operands/1/distances/0/key").asText());
assertEquals(0, res.at("/query/operands/1/distances/0/min").asInt());
assertEquals(0, res.at("/query/operands/1/distances/0/max").asInt());
- assertEquals(true, res.at("/query/operands/1/distances/0/exclude")
+ assertTrue(res.at("/query/operands/1/distances/0/exclude")
.asBoolean());
assertEquals("Mond", res.at("/query/operands/1/operands/0/wrap/key")
.asText());
@@ -488,7 +487,7 @@
assertEquals("t", res.at("/query/distances/0/key").asText());
assertEquals(0, res.at("/query/distances/0/min").asInt());
assertEquals(0, res.at("/query/distances/0/max").asInt());
- assertEquals(true, res.at("/query/distances/0/exclude").asBoolean());
+ assertTrue(res.at("/query/distances/0/exclude").asBoolean());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:sequence", res
.at("/query/operands/0/operation").asText());
@@ -497,7 +496,7 @@
assertEquals("t", res.at("/query/operands/0/distances/0/key").asText());
assertEquals(0, res.at("/query/operands/0/distances/0/min").asInt());
assertEquals(0, res.at("/query/operands/0/distances/0/max").asInt());
- assertEquals(true, res.at("/query/operands/0/distances/0/exclude")
+ assertTrue(res.at("/query/operands/0/distances/0/exclude")
.asBoolean());
assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key")
.asText());
@@ -520,7 +519,7 @@
assertEquals("w", res.at("/query/distances/0/key").asText());
assertEquals(1, res.at("/query/distances/0/boundary/min").asInt());
assertEquals(4, res.at("/query/distances/0/boundary/max").asInt());
- assertEquals(true, res.at("/query/inOrder").asBoolean());
+ assertTrue(res.at("/query/inOrder").asBoolean());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operation")
.asText());
@@ -548,7 +547,7 @@
assertEquals("p", res.at("/query/distances/2/key").asText());
assertEquals(1, res.at("/query/distances/2/boundary/min").asInt());
assertEquals(3, res.at("/query/distances/2/boundary/max").asInt());
- assertEquals(true, res.at("/query/inOrder").asBoolean());
+ assertTrue(res.at("/query/inOrder").asBoolean());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operation")
.asText());
@@ -577,7 +576,7 @@
assertEquals("p", res.at("/query/distances/2/key").asText());
assertEquals(1, res.at("/query/distances/2/boundary/min").asInt());
assertEquals(3, res.at("/query/distances/2/boundary/max").asInt());
- assertEquals(true, res.at("/query/inOrder").asBoolean());
+ assertTrue(res.at("/query/inOrder").asBoolean());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operation")
.asText());
@@ -625,7 +624,7 @@
.asText());
assertEquals("Mond", res.at("/query/operands/1/operands/0/wrap/key")
.asText());
- assertEquals(false, res.at("/query/inOrder").asBoolean());
+ assertFalse(res.at("/query/inOrder").asBoolean());
}
@@ -641,7 +640,7 @@
assertEquals("w", res.at("/query/distances/0/key").asText());
assertEquals(1, res.at("/query/distances/0/boundary/min").asInt());
assertEquals(4, res.at("/query/distances/0/boundary/max").asInt());
- assertEquals(true, res.at("/query/inOrder").asBoolean());
+ assertTrue(res.at("/query/inOrder").asBoolean());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operation")
.asText());
@@ -698,7 +697,7 @@
assertEquals("w", res.at("/query/distances/0/key").asText());
assertEquals(0, res.at("/query/distances/0/boundary/min").asInt());
assertEquals(4, res.at("/query/distances/0/boundary/max").asInt());
- assertEquals(true, res.at("/query/inOrder").asBoolean());
+ assertTrue(res.at("/query/inOrder").asBoolean());
assertEquals("koral:group", res.at("/query/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/1/operation")
.asText());
@@ -753,7 +752,7 @@
.asInt());
assertEquals(5, res.at("/query/operands/0/distances/0/boundary/max")
.asInt());
- assertEquals(false, res.at("/query/operands/0/inOrder").asBoolean());
+ assertFalse(res.at("/query/operands/0/inOrder").asBoolean());
assertEquals("koral:token", res
.at("/query/operands/0/operands/0/@type").asText());
assertEquals("der", res.at("/query/operands/0/operands/0/wrap/key")
@@ -771,7 +770,7 @@
assertEquals("w", res.at("/query/distances/0/key").asText());
assertEquals(0, res.at("/query/distances/0/boundary/min").asInt());
assertEquals(10, res.at("/query/distances/0/boundary/max").asInt());
- assertEquals(true, res.at("/query/inOrder").asBoolean());
+ assertTrue(res.at("/query/inOrder").asBoolean());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operation")
.asText());
@@ -806,9 +805,8 @@
5,
res.at("/query/operands/0/operands/0/operands/0/distances/0/boundary/max")
.asInt());
- assertEquals(false,
- res.at("/query/operands/0/operands/0/operands/0/inOrder")
- .asBoolean());
+ assertFalse(res.at("/query/operands/0/operands/0/operands/0/inOrder")
+ .asBoolean());
assertEquals(
"koral:token",
res.at("/query/operands/0/operands/0/operands/0/operands/0/@type")
@@ -839,7 +837,7 @@
assertEquals("w", res.at("/query/distances/0/key").asText());
assertEquals(0, res.at("/query/distances/0/boundary/min").asInt());
assertEquals(10, res.at("/query/distances/0/boundary/max").asInt());
- assertEquals(true, res.at("/query/inOrder").asBoolean());
+ assertTrue(res.at("/query/inOrder").asBoolean());
assertEquals("koral:group", res.at("/query/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/1/operation")
.asText());
@@ -874,9 +872,8 @@
5,
res.at("/query/operands/1/operands/0/operands/0/distances/0/boundary/max")
.asInt());
- assertEquals(false,
- res.at("/query/operands/1/operands/0/operands/0/inOrder")
- .asBoolean());
+ assertFalse(res.at("/query/operands/1/operands/0/operands/0/inOrder")
+ .asBoolean());
assertEquals(
"koral:token",
res.at("/query/operands/1/operands/0/operands/0/operands/0/@type")
@@ -914,7 +911,7 @@
.asInt());
assertEquals(5, res.at("/query/operands/0/distances/0/boundary/max")
.asInt());
- assertEquals(false, res.at("/query/operands/0/inOrder").asBoolean());
+ assertFalse(res.at("/query/operands/0/inOrder").asBoolean());
assertEquals("koral:token", res
.at("/query/operands/0/operands/0/@type").asText());
assertEquals("der", res.at("/query/operands/0/operands/0/wrap/key")
@@ -1362,7 +1359,7 @@
res.at("/query/operands/0/operands/1/operation").asText());
assertEquals("frames:startsWith",
res.at("/query/operands/0/operands/1/frames/0").asText());
- assertEquals(true, res.at("/query/operands/0/operands/1/exclude")
+ assertTrue(res.at("/query/operands/0/operands/1/exclude")
.asBoolean());
assertEquals("koral:span",
res.at("/query/operands/0/operands/1/operands/0/@type")
@@ -1467,7 +1464,7 @@
res.at("/query/operands/0/operands/1/operation").asText());
assertEquals("frames:startsWith",
res.at("/query/operands/0/operands/1/frames/0").asText());
- assertEquals(true, res.at("/query/operands/0/operands/1/exclude")
+ assertTrue(res.at("/query/operands/0/operands/1/exclude")
.asBoolean());
assertEquals("koral:span",
res.at("/query/operands/0/operands/1/operands/0/@type")
@@ -1552,10 +1549,8 @@
"frames:startsWith",
res.at("/query/operands/0/operands/1/operands/0/operands/0/frames/0")
.asText());
- assertEquals(
- true,
- res.at("/query/operands/0/operands/1/operands/0/operands/0/exclude")
- .asBoolean());
+ assertTrue(res.at("/query/operands/0/operands/1/operands/0/operands/0/exclude")
+ .asBoolean());
assertEquals(
"koral:span",
res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/@type")
@@ -1666,7 +1661,7 @@
query = "MORPH(tt/p=\"\")";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
- assertEquals(true, res.at("/query/@type").isMissingNode());
+ assertTrue(res.at("/query/@type").isMissingNode());
assertEquals(StatusCodes.INCOMPATIBLE_OPERATOR_AND_OPERAND,
res.at("/errors/0/0").asInt());
assertTrue(res
@@ -1678,7 +1673,7 @@
query = "MORPH(tt/p=\"foo)";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
- assertEquals(true, res.at("/query/@type").isMissingNode());
+ assertTrue(res.at("/query/@type").isMissingNode());
assertEquals(StatusCodes.MALFORMED_QUERY, res.at("/errors/0/0").asInt());
assertTrue(res.at("/errors/0/1").asText()
.startsWith("Early closing parenthesis"));
@@ -1686,7 +1681,7 @@
query = "MORPH(tt/p=)";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
- assertEquals(true, res.at("/query/@type").isMissingNode());
+ assertTrue(res.at("/query/@type").isMissingNode());
assertEquals(StatusCodes.MALFORMED_QUERY, res.at("/errors/0/0").asInt());
assertTrue(res.at("/errors/0/1").asText()
.startsWith("Early closing parenthesis"));
@@ -1703,7 +1698,7 @@
assertEquals(129, res.at("/query/operands/0/classOut").asInt());
assertEquals("operation:disjunction", res.at("/query/operands/1/operands/0/operation").asText());
assertEquals("cosmas:distance", res.at("/query/distances/0/@type").asText());
- assertEquals(true, res.at("/query/distances/0/exclude").asBoolean());
+ assertTrue(res.at("/query/distances/0/exclude").asBoolean());
assertEquals("s", res.at("/query/distances/0/key").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
}
diff --git a/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINTest.java b/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINTest.java
index 2b9bd68..c4636c1 100644
--- a/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINTest.java
+++ b/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINTest.java
@@ -156,11 +156,10 @@
res = mapper.readTree(qs.toJSON());
checkFocus(res);
res = res.at("/query/operands/0");
-
- assertEquals(true,
- res.at("/query/operands/0/classRefCheck").isMissingNode());
+
+ assertTrue(res.at("/query/operands/0/classRefCheck").isMissingNode());
assertEquals("frames:matches", res.at("/frames/0").asText());
- assertEquals(true, res.at("/frames/1").isMissingNode());
+ assertTrue(res.at("/frames/1").isMissingNode());
}
@Test
@@ -182,8 +181,7 @@
assertEquals("frames:matches",
res.at("/operands/0/frames/0").asText());
- assertEquals(true,
- res.at("/operands/0/frames/1").isMissingNode());
+ assertTrue(res.at("/operands/0/frames/1").isMissingNode());
assertEquals("operation:position",
res.at("/operands/0/operation").asText());
@@ -210,8 +208,7 @@
assertEquals(130, res.at("/classIn/1").asInt());
assertEquals("frames:matches",
res.at("/operands/0/frames/0").asText());
- assertEquals(true,
- res.at("/operands/0/frames/1").isMissingNode());
+ assertTrue(res.at("/operands/0/frames/1").isMissingNode());
JsonNode res1 = res.at("/operands/0/operands/0");
assertEquals("operation:class", res1.at("/operation").asText());