Finished serialization of virtual collections
diff --git a/src/test/java/de/ids_mannheim/korap/filter/TestKorapCollectionJSON.java b/src/test/java/de/ids_mannheim/korap/filter/TestKorapCollectionJSON.java
new file mode 100644
index 0000000..3dca921
--- /dev/null
+++ b/src/test/java/de/ids_mannheim/korap/filter/TestKorapCollectionJSON.java
@@ -0,0 +1,50 @@
+import java.util.*;
+import java.io.*;
+
+import de.ids_mannheim.korap.KorapCollection;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Ignore;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+public class TestKorapCollectionJSON {
+
+ @Test
+ public void metaQuery1 () {
+ String metaQuery = getString(getClass().getResource("/queries/metaquery.json").getFile());
+ KorapCollection kc = new KorapCollection(metaQuery);
+ assertEquals(3,kc.getCount());
+ assertEquals("filter with QueryWrapperFilter(+textClass:wissenschaft)",kc.getFilter(0).toString());
+ assertEquals("filter with QueryWrapperFilter(+pubPlace:Erfurt +author:Hesse)",kc.getFilter(1).toString());
+ assertEquals("extend with QueryWrapperFilter(+pubDate:[20110429 TO 20131231] +textClass:freizeit)",kc.getFilter(2).toString());
+ };
+
+
+ @Test
+ public void metaQuery2 () {
+ String metaQuery = getString(getClass().getResource("/queries/metaquery2.json").getFile());
+ KorapCollection kc = new KorapCollection(metaQuery);
+ assertEquals(1,kc.getCount());
+ assertEquals("filter with QueryWrapperFilter(+author:Hesse +pubDate:[0 TO 20131205])",kc.getFilter(0).toString());
+ };
+
+
+ public static String getString (String path) {
+ StringBuilder contentBuilder = new StringBuilder();
+ try {
+ BufferedReader in = new BufferedReader(new FileReader(path));
+ String str;
+ while ((str = in.readLine()) != null) {
+ contentBuilder.append(str);
+ };
+ in.close();
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ return contentBuilder.toString();
+ };
+
+};
\ No newline at end of file
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java b/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
index 763697a..3314648 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
@@ -104,14 +104,20 @@
};
ki.commit();
- String json = getString(getClass().getResource("/queries/metaquery.json").getFile());
-
+ String json = getString(getClass().getResource("/queries/metaquery3.json").getFile());
KorapResult kr = new KorapSearch(json).run(ki);
assertEquals(29, kr.getTotalResults());
assertEquals(5, kr.getItemsPerPage());
assertEquals(5, kr.getStartIndex());
assertEquals("... a: A ist [der klangreichste] der V ...", kr.getMatch(0).getSnippetBrackets());
+
+ json = getString(getClass().getResource("/queries/metaquery4.json").getFile());
+
+ kr = new KorapSearch(json).run(ki);
+ assertEquals(0, kr.getTotalResults());
+ assertEquals(5, kr.getItemsPerPage());
+ assertEquals(5, kr.getStartIndex());
};
diff --git a/src/test/resources/queries/metaquery2.json b/src/test/resources/queries/metaquery2.json
index 8dd978f..c80b044 100644
--- a/src/test/resources/queries/metaquery2.json
+++ b/src/test/resources/queries/metaquery2.json
@@ -78,7 +78,7 @@
"operands": [
{
"@type": "korap:date",
- "@value": "2013-12-5"
+ "@value": "2013-12-05"
}
]
}
diff --git a/src/test/resources/queries/metaquery3.json b/src/test/resources/queries/metaquery3.json
new file mode 100644
index 0000000..fd46052
--- /dev/null
+++ b/src/test/resources/queries/metaquery3.json
@@ -0,0 +1,62 @@
+{
+ "@context": {
+ "korap": "http://korap.ids-mannheim.de/ns/query",
+ "@language": "de",
+ "operands": {
+ "@id": "korap:operands",
+ "@container": "@list"
+ },
+ "relation": {
+ "@id": "korap:relation",
+ "@type": "korap:relation#types"
+ },
+ "class": {
+ "@id": "korap:class",
+ "@type": "xsd:integer"
+ },
+ "query": "korap:query",
+ "filter": "korap:filter",
+ "meta": "korap:meta"
+ },
+ "startPage" : 2,
+ "count" : 5,
+ "context" : {
+ "left" : [ "token", 3 ],
+ "right" : [ "char", 6 ]
+ },
+ "query":{
+ "@type":"korap:group",
+ "relation":"or",
+ "operands":[
+ {
+ "@type":"korap:token",
+ "@value":{
+ "@type":"korap:term",
+ "@value":"base:Vokal",
+ "relation":"="
+ }
+ },
+ {
+ "@type":"korap:sequence",
+ "operands":[
+ {
+ "@type":"korap:token",
+ "@value":{
+ "@type":"korap:term",
+ "@value":"base:der",
+ "relation":"="
+ }
+ },
+ {
+ "@type":"korap:token",
+ "@value":{
+ "@type":"korap:term",
+ "@value":"mate/p:ADJA",
+ "relation":"="
+ }
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/src/test/resources/queries/metaquery4.json b/src/test/resources/queries/metaquery4.json
new file mode 100644
index 0000000..6b82550
--- /dev/null
+++ b/src/test/resources/queries/metaquery4.json
@@ -0,0 +1,73 @@
+{
+ "@context": {
+ "korap": "http://korap.ids-mannheim.de/ns/query",
+ "@language": "de",
+ "operands": {
+ "@id": "korap:operands",
+ "@container": "@list"
+ },
+ "relation": {
+ "@id": "korap:relation",
+ "@type": "korap:relation#types"
+ },
+ "class": {
+ "@id": "korap:class",
+ "@type": "xsd:integer"
+ },
+ "query": "korap:query",
+ "filter": "korap:filter",
+ "meta": "korap:meta"
+ },
+ "startPage" : 2,
+ "count" : 5,
+ "context" : {
+ "left" : [ "token", 3 ],
+ "right" : [ "char", 6 ]
+ },
+ "query":{
+ "@type":"korap:group",
+ "relation":"or",
+ "operands":[
+ {
+ "@type":"korap:token",
+ "@value":{
+ "@type":"korap:term",
+ "@value":"base:Vokal",
+ "relation":"="
+ }
+ },
+ {
+ "@type":"korap:sequence",
+ "operands":[
+ {
+ "@type":"korap:token",
+ "@value":{
+ "@type":"korap:term",
+ "@value":"base:der",
+ "relation":"="
+ }
+ },
+ {
+ "@type":"korap:token",
+ "@value":{
+ "@type":"korap:term",
+ "@value":"mate/p:ADJA",
+ "relation":"="
+ }
+ }
+ ]
+ }
+ ]
+ },
+ "meta": [
+ {
+ "@type": "korap:meta-filter",
+ "@id": "korap-filter#id-1223232",
+ "@value": {
+ "@type": "korap:term",
+ "@field": "korap:field#textClass",
+ "@value": "baum"
+ }
+ }
+ ]
+}
\ No newline at end of file