deletion of deprecated classes
diff --git a/src/test/java/MetaQuerySerializationTest.java b/src/test/java/MetaQuerySerializationTest.java
index b32b8f6..4c3b355 100644
--- a/src/test/java/MetaQuerySerializationTest.java
+++ b/src/test/java/MetaQuerySerializationTest.java
@@ -1,14 +1,17 @@
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
-import de.ids_mannheim.korap.query.serialize.*;
+import de.ids_mannheim.korap.query.serialize.JsonGenerator;
+import de.ids_mannheim.korap.query.serialize.MetaQuery;
import org.joda.time.DateTime;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.io.IOException;
-import java.util.*;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
/**
* @author hanl
@@ -18,15 +21,6 @@
@RunWith(JUnit4.class)
public class MetaQuerySerializationTest {
- private MetaQuerySerializer querySerializer;
- private MetaCollectionSerializer collSerializer;
- private Serializer ser;
-
- public MetaQuerySerializationTest() {
- querySerializer = new MetaQuerySerializer();
- collSerializer = new MetaCollectionSerializer();
- ser = new Serializer();
- }
@Test
public void test() throws IOException {
@@ -34,16 +28,17 @@
j.put("author", "Goethe");
j.put("pubPlace", "Erfurt");
j.put("textClass", "wissenschaft");
- String s = querySerializer.stringify(j, MetaQuerySerializer.TYPE.FILTER);
-// System.out.println("value reference " + s);
+ MetaQuery qu = new MetaQuery().addMetaFilter(j);
+ System.out.println("value reference " + qu.stringify());
+ System.out.println();
}
@Test
public void testSingle() throws IOException {
Map<String, String> j = new HashMap();
j.put("textClass", "wissenschaft");
- String s = querySerializer.stringify(j, MetaQuerySerializer.TYPE.FILTER);
- System.out.println("------ TEXT SINGLE " + s);
+ MetaQuery query = new MetaQuery().addMetaFilter("textClass", "wissenschaft");
+ System.out.println("------ TEXT SINGLE " + query.stringify());
System.out.println();
}
@@ -53,8 +48,8 @@
queries.put("pubDate", String.valueOf(new DateTime().getMillis()) + "~"
+ String.valueOf(new DateTime().getMillis() + 2));
queries.put("author", "Goethe");
- String f = querySerializer.stringify(queries, MetaQuerySerializer.TYPE.FILTER);
- System.out.println("value until/since : " + f);
+ MetaQuery query = new MetaQuery().addMetaFilter(queries);
+ System.out.println("value until/since : " + query.stringify());
System.out.println();
}
@@ -63,8 +58,8 @@
Map<String, String> queries = new LinkedHashMap<>();
queries.put("pubDate", ">" + String.valueOf(new DateTime().getMillis()));
queries.put("author", "Hesse");
- String f = querySerializer.stringify(queries, MetaQuerySerializer.TYPE.FILTER);
- System.out.println("value until : " + f);
+ MetaQuery query = new MetaQuery().addMetaFilter(queries);
+ System.out.println("value until : " + query.stringify());
System.out.println();
}
@@ -73,8 +68,8 @@
Map<String, String> queries = new LinkedHashMap<>();
queries.put("pubDate", "<" + String.valueOf(new DateTime().getMillis()));
queries.put("author", "Kafka");
- String f = querySerializer.stringify(queries, MetaQuerySerializer.TYPE.FILTER);
- System.out.println("value since : " + f);
+ MetaQuery query = new MetaQuery().addMetaFilter(queries);
+ System.out.println("value since : " + query.stringify());
System.out.println();
}
@@ -117,14 +112,11 @@
Map<String, String> queries = new LinkedHashMap<>();
queries.put("pubDate", "<" + String.valueOf(new DateTime().getMillis()));
queries.put("author", "Kafka");
- List s = querySerializer.serializeQueries(queries, MetaQuerySerializer.TYPE.FILTER);
+ MetaQuery query = new MetaQuery().addMetaFilter(queries);
- queries.clear();
- queries.put("author", "Hesse");
+ query.addMetaExtend("author", "Hesse");
- List f = querySerializer.serializeQueries(queries, MetaQuerySerializer.TYPE.EXTEND);
- s.addAll(f);
- System.out.println("--- ALL " + s);
+ System.out.println("--- ALL " + query.stringify());
System.out.println();
}
@@ -134,94 +126,49 @@
Map<String, String> queries = new LinkedHashMap<>();
queries.put("pubDate", "<" + String.valueOf(new DateTime().getMillis()));
queries.put("author", "Kafka");
- List s = querySerializer.serializeQueries(queries, MetaQuerySerializer.TYPE.FILTER);
- System.out.println("array repres " + ser.serializeToMeta(s));
+ MetaQuery q = new MetaQuery().addMetaExtend(queries);
+ System.out.println("array repres " + q.toMeta());
System.out.println();
}
@Test
public void testCollections() throws IOException {
- Map<String, String> query = new LinkedHashMap<>();
- Serializer ser = new Serializer();
- query.put("corpusID", "A00");
- List<Map> l = ser.serializeQueries(query, MetaQuerySerializer.TYPE.FILTER);
- query.clear();
- query.put("corpusID", "A01");
- List<Map> u = ser.serializeQueries(query, MetaQuerySerializer.TYPE.EXTEND);
- l.addAll(u);
- String val = ser.stringify(l);
- System.out.println("results " + val);
+ MetaQuery q = new MetaQuery().addMetaFilter("corpusID", "A00");
+ q.addMetaExtend("corpusID", "A01");
+
+ System.out.println("results stringified " + q.stringify());
+ System.out.println("results to meta" + q.toMeta());
System.out.println();
-
-
- String meta = ser.queryToMeta(val);
-
- System.out.println("meta query " + meta);
-// List<String> list = new ArrayList<>();
-// list.add(val);
-// List s = collSerializer.serializeResource(list);
- System.out.println("printable list ");
- System.out.println();
-
}
+ /**
+ * asserts equality. input should be equal to output,
+ * since there is no other metadata added to the meta query
+ *
+ * @throws IOException
+ */
@Test
public void testResources() throws IOException {
String meta = "[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:term\",\"@field\":\"korap:field#corpusID\",\"@value\":\"WPD\"}}]";
- List s = new ArrayList();
- s.add(meta);
- List fin = ser.serializeResources(s);
-
- String string = ser.serializeToMeta(fin);
- System.out.println("meta string " + string);
-
+ MetaQuery q = new MetaQuery().addResource(meta);
+ org.junit.Assert.assertEquals("String should be empty", "", q.stringify());
+ System.out.println("meta string " + q.toMeta());
+ org.junit.Assert.assertEquals(meta, q.toMeta());
}
@Test
public void testA00() throws IOException {
- Map<String, String> query = new LinkedHashMap<>();
- Serializer ser = new Serializer();
- query.put("corpusID", "A00");
- List<Map> l = ser.serializeQueries(query, MetaQuerySerializer.TYPE.FILTER);
- query.clear();
- query.put("corpusID", "A01");
- List<Map> u = ser.serializeQueries(query, MetaQuerySerializer.TYPE.EXTEND);
- l.addAll(u);
- String val = ser.stringify(l);
- List s = new ArrayList();
- s.add(val);
-
- List fin = ser.serializeResources(s);
- System.out.println("A00 meta: " + fin);
-
+ MetaQuery q = new MetaQuery().addMetaExtend("corpusID", "A00").addMetaExtend("corpusID", "A01");
+ System.out.println("A meta: " + q.stringify());
+ System.out.println();
}
-
@Test
public void testnewMetaQuery() throws IOException {
- Map<String, String> qu = new LinkedHashMap<>();
- Serializer ser = new Serializer();
- qu.put("corpusID", "A00");
- List<Map> l = ser.serializeQueries(qu, MetaQuerySerializer.TYPE.FILTER);
- qu.clear();
- qu.put("corpusID", "A01");
- List<Map> u = ser.serializeQueries(qu, MetaQuerySerializer.TYPE.EXTEND);
- l.addAll(u);
- String val = ser.stringify(l);
- List s = new ArrayList();
- s.add(val);
-
- List fin = ser.serializeResources(s);
-
-
- System.out.println("======= METAQUERY TESTING BEGIN =======");
-
- MetaQuery query = new MetaQuery();
- query.addMetaFilter("textClass", "wissenschaft");
- query.addResources(s);
- System.out.println("query "+ query.toMeta());
- System.out.println("string "+ query.stringify());
- System.out.println("======= METAQUERY TESTING END =======");
+ String meta = "[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:term\",\"@field\":\"korap:field#corpusID\",\"@value\":\"WPD\"}}]";
+ MetaQuery q = new MetaQuery().addResource(meta);
+ q.addMetaFilter("textClass", "wissenschaft");
+ System.out.println("meta string " + q.toMeta());
}
}