Added statistics test
Change-Id: Ia2c6178683688aeb4b8ed4166488dfa95860f260
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/full/ResourceService.java b/src/main/java/de/ids_mannheim/korap/web/service/full/ResourceService.java
index 8d35f95..74cb2a9 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/full/ResourceService.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/full/ResourceService.java
@@ -3,7 +3,6 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/StatisticsServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/StatisticsServiceTest.java
index b3b2357..3252ed8 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/StatisticsServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/StatisticsServiceTest.java
@@ -36,6 +36,23 @@
"de.ids_mannheim.korap.web.utils");
}
+ @Test
+ public void testGetStatisticsNoResource ()
+ throws JsonProcessingException, IOException {
+ String collectionQuery = "corpusSigle=WPD15";
+ ClientResponse response = resource().path(getAPIVersion())
+ .path("statistics")
+ .queryParam("collectionQuery", collectionQuery)
+ .get(ClientResponse.class);
+
+ assert ClientResponse.Status.OK.getStatusCode() == response.getStatus();
+
+ String ent = response.getEntity(String.class);
+ JsonNode node = mapper.readTree(ent);
+ assertEquals(node.get("documents").asInt(),0);
+ assertEquals(node.get("tokens").asInt(),0);
+ }
+
@Test
public void testGetStatisticsWithCollectionQuery1 ()
@@ -50,8 +67,8 @@
String ent = response.getEntity(String.class);
JsonNode node = mapper.readTree(ent);
- assert node.get("documents").asInt() == 11;
- assert node.get("tokens").asInt() == 665842;
+ assertEquals(node.get("documents").asInt(),11);
+ assertEquals(node.get("tokens").asInt(),665842);
}
@@ -65,8 +82,8 @@
String ent = response.getEntity(String.class);
JsonNode node = mapper.readTree(ent);
assert ClientResponse.Status.OK.getStatusCode() == response.getStatus();
- assert node.get("documents").asInt() == 7;
- assert node.get("tokens").asInt() == 279402;
+ assertEquals(node.get("documents").asInt(),7);
+ assertEquals(node.get("tokens").asInt(),279402);
// EM: why zero?
assertEquals(node.get("sentences").asInt(), 11047);
assertEquals(node.get("paragraphs").asInt(), 489);