Added backward compatibility support for corpusQuery parameter.

Change-Id: I1fc6721c62fad1b40f0fe2f5c9a398d2d97722f6
diff --git a/core/Changes b/core/Changes
index 038b9ce..c35049b 100644
--- a/core/Changes
+++ b/core/Changes
@@ -5,7 +5,9 @@
    - Disabled some unused web-services: search post, query serialization, 
      collocation base (margaretha)
 11/07/2019
-   - Added cq parameter to VC statistics API and deprecate corpusQuery (margaretha) 
+   - Added cq parameter to VC statistics API and deprecate corpusQuery (margaretha)
+15/07/2019
+   - Added backward compatibility support for corpusQuery parameter (margaretha)    
 
 # version 0.62
 18/03/2019
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/controller/StatisticController.java b/core/src/main/java/de/ids_mannheim/korap/web/controller/StatisticController.java
index 66eb27a..84c4bb8 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/controller/StatisticController.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/controller/StatisticController.java
@@ -79,20 +79,17 @@
         String stats;
         String json = null;
         boolean isDeprecated = false;
-        boolean hasCq = false;
         try {
             if (cq != null && !cq.isEmpty()) {
                 builder.with(cq);
                 json = builder.toJSON();
-                hasCq = true;
             }
-            if (corpusQuery != null && !corpusQuery.isEmpty()) {
+            else if (corpusQuery != null && !corpusQuery.isEmpty()) {
+                builder.with(corpusQuery);
+                json = builder.toJSON();
                 isDeprecated = true;
-                if (!hasCq) {
-                    builder.with(corpusQuery);
-                    json = builder.toJSON();
-                }
             }
+            
             stats = searchKrill.getStatistics(json);
             
             if (isDeprecated){
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/StatisticsControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/StatisticsControllerTest.java
index f0d2bd1..b0d16cf 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/StatisticsControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/StatisticsControllerTest.java
@@ -1,6 +1,7 @@
 package de.ids_mannheim.korap.web.controller;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 
@@ -56,6 +57,8 @@
         assertEquals(138180, node.at("/tokens").asInt());
         assertEquals(5687, node.at("/sentences").asInt());
         assertEquals(258, node.at("/paragraphs").asInt());
+        
+        assertTrue(node.at("/warnings").isMissingNode());
     }
     
     @Test
@@ -73,6 +76,8 @@
         assertEquals(138180, node.at("/tokens").asInt());
         assertEquals(5687, node.at("/sentences").asInt());
         assertEquals(258, node.at("/paragraphs").asInt());
+        
+        assertTrue(node.at("/warnings").isMissingNode());
     }
 
     @Test
diff --git a/lite/src/test/java/de/ids_mannheim/korap/web/service/LiteStatisticControllerTest.java b/lite/src/test/java/de/ids_mannheim/korap/web/service/LiteStatisticControllerTest.java
index b03e28d..8f41b8a 100644
--- a/lite/src/test/java/de/ids_mannheim/korap/web/service/LiteStatisticControllerTest.java
+++ b/lite/src/test/java/de/ids_mannheim/korap/web/service/LiteStatisticControllerTest.java
@@ -1,6 +1,7 @@
 package de.ids_mannheim.korap.web.service;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
 
@@ -28,6 +29,8 @@
         assertEquals(138180, node.at("/tokens").asInt());
         assertEquals(5687, node.at("/sentences").asInt());
         assertEquals(258, node.at("/paragraphs").asInt());
+        
+        assertTrue(node.at("/warnings").isMissingNode());
     }
     
     @Test
@@ -46,14 +49,11 @@
         assertEquals(5687, node.at("/sentences").asInt());
         assertEquals(258, node.at("/paragraphs").asInt());
         
-        assertEquals(StatusCodes.DEPRECATED_PARAMETER,
-                node.at("/warnings/0/0").asInt());
-        assertEquals("Parameter corpusQuery is deprecated in favor of cq.",
-                node.at("/warnings/0/1").asText());
+        assertTrue(node.at("/warnings").isMissingNode());
     }
     
     @Test
-    public void testStatistics () throws KustvaktException{
+    public void testStatisticsWithCorpusQuery () throws KustvaktException{
         ClientResponse response = resource().path(API_VERSION)
                 .path("statistics")
                 .queryParam("corpusQuery", "textType=Autobiographie & corpusSigle=GOE")
@@ -66,6 +66,11 @@
         assertEquals(527662, node.at("/tokens").asInt());
         assertEquals(19387, node.at("/sentences").asInt());
         assertEquals(514, node.at("/paragraphs").asInt());
+        
+        assertEquals(StatusCodes.DEPRECATED_PARAMETER,
+                node.at("/warnings/0/0").asInt());
+        assertEquals("Parameter corpusQuery is deprecated in favor of cq.",
+                node.at("/warnings/0/1").asText());
     }
 
     @Test