blob: c44d0368d84b48245164a44ceed7641ece958b2b [file] [log] [blame]
Michael Hanl55191d92013-12-05 11:53:10 +00001import de.ids_mannheim.korap.query.serialize.MetaCollectionSerializer;
2import de.ids_mannheim.korap.query.serialize.MetaQuerySerializer;
Michael Hanl296a0312013-12-05 17:27:51 +00003import org.joda.time.DateTime;
Michael Hanl55191d92013-12-05 11:53:10 +00004import org.junit.Test;
5import org.junit.runner.RunWith;
6import org.junit.runners.JUnit4;
7
8import java.io.IOException;
9import java.util.HashMap;
Michael Hanl296a0312013-12-05 17:27:51 +000010import java.util.LinkedHashMap;
Michael Hanl55191d92013-12-05 11:53:10 +000011import java.util.Map;
12
13/**
14 * @author hanl
15 * @date 04/12/2013
16 */
17
18@RunWith(JUnit4.class)
19public class MetaQuerySerializationTest {
20
Michael Hanl296a0312013-12-05 17:27:51 +000021 private MetaQuerySerializer querySerializer;
22 private MetaCollectionSerializer collSerializer;
Michael Hanl55191d92013-12-05 11:53:10 +000023
24 public MetaQuerySerializationTest() {
Michael Hanl296a0312013-12-05 17:27:51 +000025 querySerializer = new MetaQuerySerializer();
26 collSerializer = new MetaCollectionSerializer();
Michael Hanl55191d92013-12-05 11:53:10 +000027 }
28
29 @Test
30 public void test() throws IOException {
31 Map<String, String> j = new HashMap();
32 j.put("author", "Goethe");
Michael Hanl296a0312013-12-05 17:27:51 +000033 j.put("pubPlace", "Erfurt");
Michael Hanl55191d92013-12-05 11:53:10 +000034 j.put("textClass", "wissenschaft");
Michael Hanl296a0312013-12-05 17:27:51 +000035 String s = querySerializer.stringify(j, MetaQuerySerializer.TYPE.FILTER);
Michael Hanl55191d92013-12-05 11:53:10 +000036// System.out.println("value reference " + s);
37 }
38
39 @Test
40 public void testSingle() throws IOException {
41 Map<String, String> j = new HashMap();
42 j.put("textClass", "wissenschaft");
Michael Hanl296a0312013-12-05 17:27:51 +000043 String s = querySerializer.stringify(j, MetaQuerySerializer.TYPE.FILTER);
Michael Hanl55191d92013-12-05 11:53:10 +000044// System.out.println("value reference test single " + s);
45 }
46
47 @Test
48 public void testResourceMeta() throws IOException {
Michael Hanl296a0312013-12-05 17:27:51 +000049 String s = collSerializer.serialize("25");
50// System.out.println(" --- RESULT JSON " + s);
51 }
Michael Hanl55191d92013-12-05 11:53:10 +000052
Michael Hanl296a0312013-12-05 17:27:51 +000053 @Test
54 public void testDates() throws IOException {
55 Map<String, String> queries = new LinkedHashMap<>();
56 queries.put("<pubDate", String.valueOf(new DateTime().getMillis()));
57 queries.put(">pubDate", String.valueOf(new DateTime().getMillis()+2));
58 queries.put("author", "Goethe");
59 String f = querySerializer.stringify(queries, MetaQuerySerializer.TYPE.FILTER);
60 System.out.println("value : "+ f);
Michael Hanl55191d92013-12-05 11:53:10 +000061 }
62}