Use database for statistics service
This function is limited to full version since lite doesn't support VC.
Since the statistics service accepts corpus query (cq) in general, it
only works for single VC reference.
Change-Id: I326f2de8a48dcd9387163aab8b05357233b47be4
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 41d20a4..3a9cef0 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
@@ -60,6 +60,22 @@
assertEquals(11,node.get("documents").asInt());
}
+ // EM: same results with login because availability rewrite is omitted
+ // for statistics
+ @Test
+ public void testGetStatisticsProtectedVCWithoutLogin () throws KustvaktException {
+ String corpusQuery = "availability=QAO-NC-LOC:ids";
+ Response response = target().path(API_VERSION).path("statistics")
+ .queryParam("cq", corpusQuery).request()
+ .get();
+ assert Status.OK.getStatusCode() == response.getStatus();
+
+ String ent = response.readEntity(String.class);
+ JsonNode node = JsonUtils.readTree(ent);
+ assertEquals(2,node.get("documents").asInt());
+ assertEquals(69056, node.at("/tokens").asInt());
+ }
+
@Test
public void testStatisticsWithCq () throws KustvaktException {
Response response = target().path(API_VERSION).path("statistics")
@@ -75,6 +91,19 @@
assertTrue(node.at("/warnings").isMissingNode());
}
+ @Test
+ public void testGetStatisticsWithVC ()
+ throws IOException, KustvaktException {
+ String corpusQuery = "referTo system-vc";
+ Response response = target().path(API_VERSION).path("statistics")
+ .queryParam("cq", corpusQuery).request().get();
+ assert Status.OK.getStatusCode() == response.getStatus();
+ String ent = response.readEntity(String.class);
+ JsonNode node = JsonUtils.readTree(ent);
+ assertEquals(7,node.get("documents").asInt());
+ assertEquals(279402,node.get("tokens").asInt());
+ }
+
@Test
public void testGetStatisticsWithcorpusQuery1 ()
diff --git a/src/test/resources/test-config-lite.xml b/src/test/resources/test-config-lite.xml
index 0a3451d..ec689d9 100644
--- a/src/test/resources/test-config-lite.xml
+++ b/src/test/resources/test-config-lite.xml
@@ -184,6 +184,8 @@
<!-- Services -->
<bean id="scopeService"
class="de.ids_mannheim.korap.oauth2.service.DummyOAuth2ScopeServiceImpl" />
+ <bean id="queryService"
+ class="de.ids_mannheim.korap.service.DummyQueryServiceImpl" />
<!-- DAO -->
<bean id="adminDao"
diff --git a/src/test/resources/test-config.xml b/src/test/resources/test-config.xml
index 05311db..aad2bbe 100644
--- a/src/test/resources/test-config.xml
+++ b/src/test/resources/test-config.xml
@@ -238,8 +238,7 @@
</bean>
<util:list id="statisticsRewriteTasks"
- value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
- <ref bean="foundryRewrite" />
+ value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
<ref bean="timeoutRewrite" />
<ref bean="virtualCorpusRewrite" />
<ref bean="queryReferenceRewrite" />