Remove corpusQuery param in the statistics web-service (close #758).

Change-Id: Id0948be3f2f358d1cf747ecde4cebadb6d9b57b3
diff --git a/Changes b/Changes
index f9e67dc..5c6eb17 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,7 @@
+# version 0.73.3-SNAPSHOT
+
+- Remove corpusQuery param in the statistics web-service (close #758).
+
 # version 0.73.2
 
 - Added tests for the DNB scenario with custom max match 
diff --git a/pom.xml b/pom.xml
index cb14187..069413d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>de.ids-mannheim.korap.kustvakt</groupId>
 	<artifactId>Kustvakt</artifactId>
-	<version>0.73.2</version>
+	<version>0.73.3-SNAPSHOT</version>
 	<properties>
 		<java.version>17</java.version>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
diff --git a/src/main/java/de/ids_mannheim/korap/core/service/StatisticService.java b/src/main/java/de/ids_mannheim/korap/core/service/StatisticService.java
index 6f0a3f0..e4451b8 100644
--- a/src/main/java/de/ids_mannheim/korap/core/service/StatisticService.java
+++ b/src/main/java/de/ids_mannheim/korap/core/service/StatisticService.java
@@ -6,12 +6,10 @@
 import org.springframework.stereotype.Service;
 
 import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
 
 import de.ids_mannheim.korap.config.KustvaktConfiguration;
 import de.ids_mannheim.korap.exceptions.KustvaktException;
 import de.ids_mannheim.korap.exceptions.StatusCodes;
-import de.ids_mannheim.korap.response.Notifications;
 import de.ids_mannheim.korap.utils.JsonUtils;
 import de.ids_mannheim.korap.utils.KoralCollectionQueryBuilder;
 import de.ids_mannheim.korap.web.SearchKrill;
@@ -24,8 +22,7 @@
     @Autowired
     private KustvaktConfiguration config;
 
-    public String retrieveStatisticsForCorpusQuery (List<String> cqList,
-            boolean isDeprecated) throws KustvaktException {
+    public String retrieveStatisticsForCorpusQuery (List<String> cqList) throws KustvaktException {
 
         KoralCollectionQueryBuilder builder = new KoralCollectionQueryBuilder();
         String cq = combineMultipleCorpusQuery(cqList);
@@ -40,16 +37,6 @@
         }
         String stats = searchKrill.getStatistics(json);
 
-        if (isDeprecated) {
-            Notifications n = new Notifications();
-            n.addWarning(StatusCodes.DEPRECATED,
-                    "Parameter corpusQuery is deprecated in favor of cq.");
-            ObjectNode warning = (ObjectNode) n.toJsonNode();
-            ObjectNode node = (ObjectNode) JsonUtils.readTree(stats);
-            node.setAll(warning);
-            stats = node.toString();
-        }
-
         if (stats.contains("-1")) {
             throw new KustvaktException(StatusCodes.NO_RESULT_FOUND);
         }
diff --git a/src/main/java/de/ids_mannheim/korap/core/web/controller/StatisticController.java b/src/main/java/de/ids_mannheim/korap/core/web/controller/StatisticController.java
index 0c90f2f..965f99e 100644
--- a/src/main/java/de/ids_mannheim/korap/core/web/controller/StatisticController.java
+++ b/src/main/java/de/ids_mannheim/korap/core/web/controller/StatisticController.java
@@ -65,17 +65,11 @@
      */
     @GET
     public Response getStatistics (@Context SecurityContext context,
-            @Context Locale locale, @QueryParam("cq") List<String> cq,
-            @QueryParam("corpusQuery") List<String> corpusQuery) {
+            @Context Locale locale, @QueryParam("cq") List<String> cq) {
 
         String stats;
-        boolean isDeprecated = false;
         try {
-            if (cq.isEmpty() && corpusQuery != null && !corpusQuery.isEmpty()) {
-                isDeprecated = true;
-                cq = corpusQuery;
-            }
-            stats = service.retrieveStatisticsForCorpusQuery(cq, isDeprecated);
+            stats = service.retrieveStatisticsForCorpusQuery(cq);
             if (DEBUG) {
                 jlog.debug("Stats: " + stats);
             }
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/MultipleCorpusQueryTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/MultipleCorpusQueryTest.java
index 775afd8..fba3947 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/MultipleCorpusQueryTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/MultipleCorpusQueryTest.java
@@ -53,23 +53,4 @@
         assertEquals(258, node.at("/paragraphs").asInt());
         assertTrue(node.at("/warnings").isMissingNode());
     }
-
-    @Test
-    public void testStatisticsWithMultipleCorpusQuery ()
-            throws ProcessingException, KustvaktException {
-        Response response = target().path(API_VERSION).path("statistics")
-                .queryParam("corpusQuery", "textType=Autobiographie")
-                .queryParam("corpusQuery", "corpusSigle=GOE").request()
-                .method("GET");
-        assertEquals(Status.OK.getStatusCode(), response.getStatus());
-        String entity = response.readEntity(String.class);
-        JsonNode node = JsonUtils.readTree(entity);
-        assertEquals(9, node.at("/documents").asInt());
-        assertEquals(527662, node.at("/tokens").asInt());
-        assertEquals(19387, node.at("/sentences").asInt());
-        assertEquals(514, node.at("/paragraphs").asInt());
-        assertEquals(StatusCodes.DEPRECATED, node.at("/warnings/0/0").asInt());
-        assertEquals(node.at("/warnings/0/1").asText(),
-                "Parameter corpusQuery is deprecated in favor of cq.");
-    }
 }
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/StatisticsControllerTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/StatisticsControllerTest.java
index ea5008f..8b2ec7c 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/StatisticsControllerTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/StatisticsControllerTest.java
@@ -29,14 +29,14 @@
             throws IOException, KustvaktException {
         String corpusQuery = "corpusSigle=WPD15";
         Response response = target().path(API_VERSION).path("statistics")
-                .queryParam("corpusQuery", corpusQuery).request().get();
+                .queryParam("cq", corpusQuery).request().get();
         assert Status.OK.getStatusCode() == response.getStatus();
         assertEquals(response.getHeaders().getFirst("X-Index-Revision"),
                 "Wes8Bd4h1OypPqbWF5njeQ==");
         String ent = response.readEntity(String.class);
         JsonNode node = JsonUtils.readTree(ent);
-        assertEquals(node.get("documents").asInt(), 0);
-        assertEquals(node.get("tokens").asInt(), 0);
+        assertEquals(0,node.get("documents").asInt());
+        assertEquals(0,node.get("tokens").asInt());
     }
 
     @Test
@@ -54,83 +54,62 @@
         assertTrue(node.at("/warnings").isMissingNode());
     }
 
-    @Test
-    public void testStatisticsWithCqAndCorpusQuery () throws KustvaktException {
-        Response response = target().path(API_VERSION).path("statistics")
-                .queryParam("cq", "textType=Abhandlung & corpusSigle=GOE")
-                .queryParam("corpusQuery",
-                        "textType=Autobiographie & corpusSigle=GOE")
-                .request().method("GET");
-        assertEquals(Status.OK.getStatusCode(), response.getStatus());
-        String query = response.readEntity(String.class);
-        JsonNode node = JsonUtils.readTree(query);
-        assertEquals(2, node.at("/documents").asInt());
-        assertEquals(138180, node.at("/tokens").asInt());
-        assertEquals(5687, node.at("/sentences").asInt());
-        assertEquals(258, node.at("/paragraphs").asInt());
-        assertTrue(node.at("/warnings").isMissingNode());
-    }
 
     @Test
     public void testGetStatisticsWithcorpusQuery1 ()
             throws IOException, KustvaktException {
         String corpusQuery = "corpusSigle=GOE";
         Response response = target().path(API_VERSION).path("statistics")
-                .queryParam("corpusQuery", corpusQuery).request().get();
+                .queryParam("cq", corpusQuery).request().get();
         assert Status.OK.getStatusCode() == response.getStatus();
         String ent = response.readEntity(String.class);
         JsonNode node = JsonUtils.readTree(ent);
-        assertEquals(node.get("documents").asInt(), 11);
-        assertEquals(node.get("tokens").asInt(), 665842);
-        assertEquals(StatusCodes.DEPRECATED, node.at("/warnings/0/0").asInt());
-        assertEquals(node.at("/warnings/0/1").asText(),
-                "Parameter corpusQuery is deprecated in favor of cq.");
+        assertEquals(11,node.get("documents").asInt());
+        assertEquals(665842,node.get("tokens").asInt());
     }
 
     @Test
     public void testGetStatisticsWithcorpusQuery2 ()
             throws IOException, KustvaktException {
         Response response = target().path(API_VERSION).path("statistics")
-                .queryParam("corpusQuery", "creationDate since 1810").request()
+                .queryParam("cq", "creationDate since 1810").request()
                 .get();
         String ent = response.readEntity(String.class);
         JsonNode node = JsonUtils.readTree(ent);
         assert Status.OK.getStatusCode() == response.getStatus();
-        assertEquals(node.get("documents").asInt(), 7);
-        assertEquals(node.get("tokens").asInt(), 279402);
-        assertEquals(node.get("sentences").asInt(), 11047);
-        assertEquals(node.get("paragraphs").asInt(), 489);
+        assertEquals(7,node.get("documents").asInt());
+        assertEquals(279402,node.get("tokens").asInt());
+        assertEquals(11047,node.get("sentences").asInt());
+        assertEquals(489,node.get("paragraphs").asInt());
     }
 
     @Test
     public void testGetStatisticsWithWrongcorpusQuery ()
             throws IOException, KustvaktException {
         Response response = target().path(API_VERSION).path("statistics")
-                .queryParam("corpusQuery", "creationDate geq 1810").request()
-                .get();
+                .queryParam("cq", "creationDate geq 1810").request().get();
         assert Status.BAD_REQUEST.getStatusCode() == response.getStatus();
         String ent = response.readEntity(String.class);
         JsonNode node = JsonUtils.readTree(ent);
-        assertEquals(node.at("/errors/0/0").asInt(), 302);
-        assertEquals(node.at("/errors/0/1").asText(),
-                "Could not parse query >>> (creationDate geq 1810) <<<.");
-        assertEquals(node.at("/errors/0/2").asText(),
-                "(creationDate geq 1810)");
+        assertEquals(302, node.at("/errors/0/0").asInt());
+        assertEquals("Could not parse query >>> (creationDate geq 1810) <<<.",
+                node.at("/errors/0/1").asText());
+        assertEquals("(creationDate geq 1810)",
+                node.at("/errors/0/2").asText());
     }
 
     @Test
     public void testGetStatisticsWithWrongcorpusQuery2 ()
             throws IOException, KustvaktException {
         Response response = target().path(API_VERSION).path("statistics")
-                .queryParam("corpusQuery", "creationDate >= 1810").request()
-                .get();
+                .queryParam("cq", "creationDate >= 1810").request().get();
         String ent = response.readEntity(String.class);
         assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
         JsonNode node = JsonUtils.readTree(ent);
-        assertEquals(node.at("/errors/0/0").asInt(), 305);
-        assertEquals(node.at("/errors/0/1").asText(),
-                "Operator >= is not acceptable.");
-        assertEquals(node.at("/errors/0/2").asText(), ">=");
+        assertEquals(305, node.at("/errors/0/0").asInt());
+        assertEquals("Operator >= is not acceptable.",
+                node.at("/errors/0/1").asText());
+        assertEquals(">=", node.at("/errors/0/2").asText());
     }
 
     @Test
@@ -178,10 +157,10 @@
         assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
         String ent = response.readEntity(String.class);
         JsonNode node = JsonUtils.readTree(ent);
-        assertEquals(node.at("/errors/0/0").asInt(),
-                de.ids_mannheim.korap.util.StatusCodes.MISSING_COLLECTION);
-        assertEquals(node.at("/errors/0/1").asText(),
-                "Collection is not found");
+        assertEquals(de.ids_mannheim.korap.util.StatusCodes.MISSING_COLLECTION,
+                node.at("/errors/0/0").asInt());
+        assertEquals("Collection is not found",
+                node.at("/errors/0/1").asText());
     }
 
     @Test
@@ -196,8 +175,8 @@
         JsonNode node = JsonUtils.readTree(ent);
         assertEquals(StatusCodes.DESERIALIZATION_FAILED,
                 node.at("/errors/0/0").asInt());
-        assertEquals(node.at("/errors/0/1").asText(),
-                "Failed deserializing json object: { \"collection\" : }");
+        assertEquals("Failed deserializing json object: { \"collection\" : }",
+                node.at("/errors/0/1").asText());
     }
 
     @Test
diff --git a/src/test/java/de/ids_mannheim/korap/web/lite/LiteMultipleCorpusQueryTest.java b/src/test/java/de/ids_mannheim/korap/web/lite/LiteMultipleCorpusQueryTest.java
index 5d93355..1b42609 100644
--- a/src/test/java/de/ids_mannheim/korap/web/lite/LiteMultipleCorpusQueryTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/lite/LiteMultipleCorpusQueryTest.java
@@ -4,16 +4,15 @@
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import org.junit.jupiter.api.Test;
-import com.fasterxml.jackson.databind.JsonNode;
 
-import jakarta.ws.rs.ProcessingException;
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.core.Response.Status;
+import com.fasterxml.jackson.databind.JsonNode;
 
 import de.ids_mannheim.korap.config.LiteJerseyTest;
 import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.exceptions.StatusCodes;
 import de.ids_mannheim.korap.utils.JsonUtils;
+import jakarta.ws.rs.ProcessingException;
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response.Status;
 
 public class LiteMultipleCorpusQueryTest extends LiteJerseyTest {
 
@@ -28,15 +27,15 @@
         String entity = response.readEntity(String.class);
         JsonNode node = JsonUtils.readTree(entity);
         node = node.at("/collection");
-        assertEquals(node.at("/@type").asText(), "koral:docGroup");
-        assertEquals(node.at("/operation").asText(), "operation:and");
+        assertEquals("koral:docGroup",node.at("/@type").asText());
+        assertEquals("operation:and",node.at("/operation").asText());
         assertEquals(2, node.at("/operands").size());
-        assertEquals(node.at("/operands/0/@type").asText(), "koral:doc");
-        assertEquals(node.at("/operands/0/match").asText(), "match:eq");
-        assertEquals(node.at("/operands/0/key").asText(), "pubPlace");
-        assertEquals(node.at("/operands/0/value").asText(), "München");
-        assertEquals(node.at("/operands/1/key").asText(), "textSigle");
-        assertEquals(node.at("/operands/1/value").asText(), "GOE/AGA/01784");
+        assertEquals("koral:doc",node.at("/operands/0/@type").asText());
+        assertEquals("match:eq",node.at("/operands/0/match").asText());
+        assertEquals("pubPlace",node.at("/operands/0/key").asText());
+        assertEquals("München",node.at("/operands/0/value").asText());
+        assertEquals("textSigle",node.at("/operands/1/key").asText());
+        assertEquals("GOE/AGA/01784",node.at("/operands/1/value").asText());
     }
 
     @Test
@@ -55,22 +54,4 @@
         assertTrue(node.at("/warnings").isMissingNode());
     }
 
-    @Test
-    public void testStatisticsWithMultipleCorpusQuery ()
-            throws ProcessingException, KustvaktException {
-        Response response = target().path(API_VERSION).path("statistics")
-                .queryParam("corpusQuery", "textType=Autobiographie")
-                .queryParam("corpusQuery", "corpusSigle=GOE").request()
-                .method("GET");
-        assertEquals(Status.OK.getStatusCode(), response.getStatus());
-        String entity = response.readEntity(String.class);
-        JsonNode node = JsonUtils.readTree(entity);
-        assertEquals(9, node.at("/documents").asInt());
-        assertEquals(527662, node.at("/tokens").asInt());
-        assertEquals(19387, node.at("/sentences").asInt());
-        assertEquals(514, node.at("/paragraphs").asInt());
-        assertEquals(StatusCodes.DEPRECATED, node.at("/warnings/0/0").asInt());
-        assertEquals(node.at("/warnings/0/1").asText(),
-                "Parameter corpusQuery is deprecated in favor of cq.");
-    }
 }
diff --git a/src/test/java/de/ids_mannheim/korap/web/lite/LiteStatisticControllerTest.java b/src/test/java/de/ids_mannheim/korap/web/lite/LiteStatisticControllerTest.java
index 5fe5b1a..141aafa 100644
--- a/src/test/java/de/ids_mannheim/korap/web/lite/LiteStatisticControllerTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/lite/LiteStatisticControllerTest.java
@@ -38,44 +38,9 @@
     }
 
     @Test
-    public void testStatisticsWithCqAndCorpusQuery () throws KustvaktException {
+    public void testStatisticsEmptyCq () throws KustvaktException {
         Response response = target().path(API_VERSION).path("statistics")
-                .queryParam("cq", "textType=Abhandlung & corpusSigle=GOE")
-                .queryParam("corpusQuery",
-                        "textType=Autobiographie & corpusSigle=GOE")
-                .request().method("GET");
-        assertEquals(Status.OK.getStatusCode(), response.getStatus());
-        String query = response.readEntity(String.class);
-        JsonNode node = JsonUtils.readTree(query);
-        assertEquals(2, node.at("/documents").asInt());
-        assertEquals(138180, node.at("/tokens").asInt());
-        assertEquals(5687, node.at("/sentences").asInt());
-        assertEquals(258, node.at("/paragraphs").asInt());
-        assertTrue(node.at("/warnings").isMissingNode());
-    }
-
-    @Test
-    public void testStatisticsWithCorpusQuery () throws KustvaktException {
-        Response response = target().path(API_VERSION).path("statistics")
-                .queryParam("corpusQuery",
-                        "textType=Autobiographie & corpusSigle=GOE")
-                .request().method("GET");
-        assertEquals(Status.OK.getStatusCode(), response.getStatus());
-        String query = response.readEntity(String.class);
-        JsonNode node = JsonUtils.readTree(query);
-        assertEquals(9, node.at("/documents").asInt());
-        assertEquals(527662, node.at("/tokens").asInt());
-        assertEquals(19387, node.at("/sentences").asInt());
-        assertEquals(514, node.at("/paragraphs").asInt());
-        assertEquals(StatusCodes.DEPRECATED, node.at("/warnings/0/0").asInt());
-        assertEquals(node.at("/warnings/0/1").asText(),
-                "Parameter corpusQuery is deprecated in favor of cq.");
-    }
-
-    @Test
-    public void testEmptyStatistics () throws KustvaktException {
-        Response response = target().path(API_VERSION).path("statistics")
-                .queryParam("corpusQuery", "").request().method("GET");
+                .queryParam("cq", "").request().method("GET");
         assertEquals(Status.OK.getStatusCode(), response.getStatus());
         String query = response.readEntity(String.class);
         JsonNode node = JsonUtils.readTree(query);
diff --git a/src/test/resources/test-config.xml b/src/test/resources/test-config.xml
index cae0248..058eb31 100644
--- a/src/test/resources/test-config.xml
+++ b/src/test/resources/test-config.xml
@@ -48,6 +48,13 @@
 			</array>
 		</property>
 	</bean>
+	
+	<!-- props are injected from default-config.xml -->
+	<bean id="kustvakt_config"
+		class="de.ids_mannheim.korap.config.FullConfiguration">
+		<constructor-arg name="properties" ref="props" />
+	</bean>
+	
 
 	<!-- <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager' 
 		p:cacheManager-ref='ehcache' /> <bean id='ehcache' class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean' 
@@ -66,25 +73,13 @@
 		<!--<property name="poolPreparedStatements" value="true"/> -->
 	</bean>
 
-<!-- <bean id="sqliteDataSource"
-		class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
-		lazy-init="true">
-		<property name="driverClassName" value="${jdbc.driverClassName}" />
-		<property name="url" value="${jdbc.url}" />
-		<property name="username" value="${jdbc.username}" />
-		<property name="password" value="${jdbc.password}" />
-		<property name="connectionProperties">
-			<props>
-				<prop key="date_string_format">yyyy-MM-dd HH:mm:ss</prop>
-			</props>
-		</property>
-
-		Sqlite can only have a single connection
-		<property name="suppressClose">
-			<value>true</value>
-		</property>
-	</bean>
- -->
+	<!-- <bean id="sqliteDataSource" class="org.springframework.jdbc.datasource.SingleConnectionDataSource" 
+		lazy-init="true"> <property name="driverClassName" value="${jdbc.driverClassName}" 
+		/> <property name="url" value="${jdbc.url}" /> <property name="username" 
+		value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" 
+		/> <property name="connectionProperties"> <props> <prop key="date_string_format">yyyy-MM-dd 
+		HH:mm:ss</prop> </props> </property> Sqlite can only have a single connection 
+		<property name="suppressClose"> <value>true</value> </property> </bean> -->
 	<bean id="c3p0DataSource"
 		class="com.mchange.v2.c3p0.ComboPooledDataSource"
 		destroy-method="close">
@@ -178,12 +173,6 @@
 	<bean id="scopeService"
 		class="de.ids_mannheim.korap.oauth2.service.OAuth2ScopeServiceImpl" />
 
-	<!-- props are injected from default-config.xml -->
-	<bean id="kustvakt_config"
-		class="de.ids_mannheim.korap.config.FullConfiguration">
-		<constructor-arg name="properties" ref="props" />
-	</bean>
-
 	<bean id="initializator"
 		class="de.ids_mannheim.korap.init.Initializator"
 		init-method="initTest">