Added test statistics with referTo and pubDate.

Change-Id: Ic3089000abd47e2d5d9615842e6609956b3e06d1
diff --git a/Changes b/Changes
index 6f9132d..557d0e6 100644
--- a/Changes
+++ b/Changes
@@ -1,7 +1,8 @@
-0.59.3 2020-11-11
+0.59.3 2021-02-18
     - [feature] Added "missing query reference" status code (diewald)
     - [cleanup] Added test coverage checking with
       $ mvn cobertura:cobertura (diewald, kupietz)
+    - [cleanup] Added test statistics with referTo and pubDate (margaretha)
 
 0.59.2 2020-07-24
     - [feature] Add fingerprint method to index (diewald)
diff --git a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionIndex.java b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionIndex.java
index 2457c1e..69e8d9f 100644
--- a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionIndex.java
@@ -1,35 +1,32 @@
 package de.ids_mannheim.korap.collection;
 
-import java.io.IOException;
+import static de.ids_mannheim.korap.TestSimple.getJsonString;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
+import java.io.IOException;
 import java.util.Properties;
 
-import de.ids_mannheim.korap.KrillIndex;
-import de.ids_mannheim.korap.KrillCollection;
-import de.ids_mannheim.korap.collection.CollectionBuilder;
-import de.ids_mannheim.korap.index.FieldDocument;
-import de.ids_mannheim.korap.response.Result;
-import de.ids_mannheim.korap.response.SearchContext;
-import de.ids_mannheim.korap.util.StatusCodes;
-import de.ids_mannheim.korap.util.QueryException;
-import de.ids_mannheim.korap.util.KrillProperties;
-import de.ids_mannheim.korap.Krill;
-import de.ids_mannheim.korap.query.QueryBuilder;
-
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.spans.SpanQuery;
 import org.apache.lucene.search.spans.SpanTermQuery;
-import static de.ids_mannheim.korap.TestSimple.*;
-
-import static org.junit.Assert.*;
-import org.junit.Test;
 import org.junit.Ignore;
+import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
 
+import de.ids_mannheim.korap.Krill;
+import de.ids_mannheim.korap.KrillCollection;
+import de.ids_mannheim.korap.KrillIndex;
+import de.ids_mannheim.korap.index.FieldDocument;
+import de.ids_mannheim.korap.query.QueryBuilder;
+import de.ids_mannheim.korap.response.Result;
+import de.ids_mannheim.korap.response.SearchContext;
+import de.ids_mannheim.korap.util.KrillProperties;
+import de.ids_mannheim.korap.util.QueryException;
+import de.ids_mannheim.korap.util.StatusCodes;
 import net.sf.ehcache.Element;
 
 
@@ -747,6 +744,8 @@
 	@Test
 	@Ignore
     public void testNestedNamedVCs () throws IOException {
+	    KrillCollection.initializeCache();
+	    
         Properties prop = KrillProperties.loadDefaultProperties();
 
         String vcPath = getClass().getResource(path + "named-vcs").getFile();
@@ -858,6 +857,7 @@
 	@Test
 	@Ignore
     public void testNamedVCsAfterQueryWithMissingDocs () throws IOException {
+	    KrillCollection.initializeCache();
         Properties prop = KrillProperties.loadDefaultProperties();
 
         String vcPath = getClass().getResource(path + "named-vcs").getFile();
@@ -1032,6 +1032,35 @@
         prop.setProperty("krill.namedVC", tempVC);
     };
     
+    @Test
+    public void testCollectionWithVCRefAndPubDate () throws IOException {
+
+        KrillCollection.initializeCache();
+
+        ki = new KrillIndex();
+        ki.addDoc(createDoc2());
+        ki.addDoc(createDoc3());
+        ki.addDoc(createDoc5000());
+        ki.commit();
+
+        testManualAddToCache(ki, "named-vcs/named-vc3.jsonld", "named-vc3");
+
+        Element element = KrillCollection.cache.get("named-vc3");
+        CachedVCData cc = (CachedVCData) element.getObjectValue();
+        assertTrue(cc.getDocIdMap().size() > 0);
+            
+        String json = _getJSONString("collection-with-vc-ref-and-pubDate.jsonld");
+
+        KrillCollection kc = new KrillCollection(json);
+        kc.setIndex(ki);
+        assertEquals(2, kc.numberOf("documents"));
+        
+        // testAddDocToIndex();
+        ki.addDoc(createDoc1());
+        ki.commit();
+        // Cache is removed after index change
+
+    }
     
 
     @Test
diff --git a/src/test/resources/queries/collections/collection-with-vc-ref-and-pubDate.jsonld b/src/test/resources/queries/collections/collection-with-vc-ref-and-pubDate.jsonld
new file mode 100644
index 0000000..f837c94
--- /dev/null
+++ b/src/test/resources/queries/collections/collection-with-vc-ref-and-pubDate.jsonld
@@ -0,0 +1,26 @@
+{
+    "meta": {},
+    "warnings": [],
+    "query": {},
+    "messages": [],
+    "collection": {
+        "operands": [
+            {
+                "@type": "koral:doc",
+                "match": "match:eq",
+                "type": "type:date",
+                "value": "2005",
+                "key": "pubDate"
+            },
+            {
+                "ref": "named-vc3",
+                "@type": "koral:docGroupRef"
+            }
+        ],
+        "@type": "koral:docGroup",
+        "operation": "operation:and"
+    },
+    "@context": "http://korap.ids-mannheim.de/ns/koral/0.3/context.jsonld",
+    "errors": []
+}
+
diff --git a/src/test/resources/queries/collections/named-vcs/named-vc3.jsonld b/src/test/resources/queries/collections/named-vcs/named-vc3.jsonld
new file mode 100644
index 0000000..4f71629
--- /dev/null
+++ b/src/test/resources/queries/collections/named-vcs/named-vc3.jsonld
@@ -0,0 +1,10 @@
+{"collection": {
+    "@type": "koral:doc",
+    "key": "UID",
+    "type" : "type:string",
+    "value": [
+        2,
+        3,
+	5000
+    ]
+}}