Make sure totalResults and other numeric results are numbers

Resolves #668

Change-Id: If4bead2e9f4a5552ea417469557c23af6ffb5a80
diff --git a/full/src/main/java/de/ids_mannheim/korap/core/service/SearchService.java b/full/src/main/java/de/ids_mannheim/korap/core/service/SearchService.java
index 7cfdcac..ce383e8 100644
--- a/full/src/main/java/de/ids_mannheim/korap/core/service/SearchService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/core/service/SearchService.java
@@ -255,10 +255,10 @@
             ObjectNode queryNode = (ObjectNode) JsonUtils.readTree(result);
             ObjectNode meta = (ObjectNode) queryNode.at("/meta");
             if (meta.isMissingNode()) {
-                queryNode.put("totalResults", totalResults);
+                queryNode.put("totalResults", Integer.valueOf(totalResults));
             }
             else {
-                meta.put("totalResults", totalResults);
+                meta.put("totalResults", Integer.valueOf(totalResults));
             }
             result = queryNode.toString();
         }
diff --git a/full/src/test/java/de/ids_mannheim/korap/cache/TotalResultTest.java b/full/src/test/java/de/ids_mannheim/korap/cache/TotalResultTest.java
index b958245..cd91692 100644
--- a/full/src/test/java/de/ids_mannheim/korap/cache/TotalResultTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/cache/TotalResultTest.java
@@ -33,6 +33,7 @@
         assertEquals(Status.OK.getStatusCode(), response.getStatus());
         String entity = response.readEntity(String.class);
         JsonNode node = JsonUtils.readTree(entity);
+        assertTrue("totalResults should be a number", node.at("/meta/totalResults").isNumber());
         int totalResults = node.at("/meta/totalResults").asInt();
 
         assertEquals(1, searchService.getTotalResultCache()
@@ -45,8 +46,9 @@
         assertEquals(Status.OK.getStatusCode(), response.getStatus());
         entity = response.readEntity(String.class);
         node = JsonUtils.readTree(entity);
+        assertTrue("totalResults should be a number", node.at("/meta/totalResults").isNumber());
         assertEquals(totalResults, node.at("/meta/totalResults").asInt());
-        
+
         assertEquals(1, searchService.getTotalResultCache()
                 .getAllCacheElements().size());
         
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java
index 8bdee32..d592ccf 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java
@@ -183,6 +183,11 @@
         assertEquals(40, node.at("/meta/context/left/1").asInt());
         assertEquals(30, node.at("/meta/context/right/1").asInt());
         assertEquals(-1, node.at("/meta/totalResults").asInt());
+        for (String path : new String[] { "/meta/count", "/meta/startIndex",
+                "/meta/context/left/1", "/meta/context/right/1",
+                "/meta/totalResults", "/meta/itemsPerPage" }) {
+            assertTrue(path + " should be a number", node.at(path).isNumber());
+        }
     }
 
     @Test