Updated the statistic API with KoralQuery and added tests.

Change-Id: I974ad7cf97bb69fb8fb85c734418a27d0302f4f3
diff --git a/core/Changes b/core/Changes
index 32a842b..272c8d1 100644
--- a/core/Changes
+++ b/core/Changes
@@ -4,6 +4,8 @@
      accessRewriteDisabled (margaretha, resolved #43).
 14/11/2019
    - Added a check for OAuth2 client, VC, and group name length (margaretha)
+22/11/2019
+   - Updated the statistic API with KoralQuery (margaretha)  
 
 # version 0.62.1
 08/07/2019
@@ -18,7 +20,8 @@
 28/08/2019
    - Resolved #49. Added page param check in the search api (margaretha)
 23/09/2019   
-   - Resolved #50. Added statistics API with KoralQuery input (margaretha) 
+   - Resolved #50. Added statistics API with KoralQuery input (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 7ef29f6..43f3693 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
@@ -118,24 +118,26 @@
     
     @POST
     @Consumes(MediaType.APPLICATION_JSON + ";charset=utf-8")
-    public Response getStatisticsFromKoralQuery (@Context SecurityContext context,
-            @Context Locale locale, String koralQuery) {
-        if (koralQuery != null && !koralQuery.isEmpty()) {
-            String stats;
-            try {
+    public Response getStatisticsFromKoralQuery (
+            @Context SecurityContext context, @Context Locale locale,
+            String koralQuery) {
+        String stats;
+        try {
+            if (koralQuery != null && !koralQuery.isEmpty()) {
                 stats = searchKrill.getStatistics(koralQuery);
-                if (stats.contains("-1")){
-                    throw kustvaktResponseHandler.throwit(StatusCodes.NO_RESULT_FOUND);
-                }
-                return Response.ok(stats).build();
             }
-            catch (KustvaktException e) {
-                throw kustvaktResponseHandler.throwit(e);
+            else {
+                stats = searchKrill.getStatistics(null);
             }
+
+            if (stats.contains("-1")) {
+                throw kustvaktResponseHandler
+                        .throwit(StatusCodes.NO_RESULT_FOUND);
+            }
+            return Response.ok(stats).build();
         }
-        else {
-            throw kustvaktResponseHandler.throwit(StatusCodes.NO_QUERY, 
-                    "Koral query is missing", "koralQuery");
+        catch (KustvaktException e) {
+            throw kustvaktResponseHandler.throwit(e);
         }
     }
 }