Added support for multiple cq parameters.
Change-Id: Ica7effe455cc9320ca0a5cc1c8f730167e78e1d8
diff --git a/full/Changes b/full/Changes
index 8697d35..4ec9218 100644
--- a/full/Changes
+++ b/full/Changes
@@ -3,7 +3,10 @@
- Implemented pipe extension in the search API (margaretha)
11/12/2019
- Added errors when requesting VC in caching process (margaretha,
- resolved #47)
+ resolved #47)
+12/12/2019
+ - Added support for multiple cq parameters (margaretha, resolved #46)
+
# version 0.62.2
17/10/2019
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/MultipleCorpusQueryTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/MultipleCorpusQueryTest.java
new file mode 100644
index 0000000..1692fdc
--- /dev/null
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/MultipleCorpusQueryTest.java
@@ -0,0 +1,86 @@
+package de.ids_mannheim.korap.web.controller;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.sun.jersey.api.client.ClientHandlerException;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.UniformInterfaceException;
+
+import de.ids_mannheim.korap.config.SpringJerseyTest;
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.exceptions.StatusCodes;
+import de.ids_mannheim.korap.utils.JsonUtils;
+
+public class MultipleCorpusQueryTest extends SpringJerseyTest {
+
+ @Test
+ public void testSearchGet () throws KustvaktException {
+ ClientResponse response = resource().path(API_VERSION).path("search")
+ .queryParam("q", "das").queryParam("ql", "poliqarp")
+ .queryParam("cq", "pubPlace=München")
+ .queryParam("cq", "textSigle=\"GOE/AGA/01784\"")
+ .get(ClientResponse.class);
+ assertEquals(ClientResponse.Status.OK.getStatusCode(),
+ response.getStatus());
+ String entity = response.getEntity(String.class);
+ JsonNode node = JsonUtils.readTree(entity);
+ node = node.at("/collection/operands/1");
+ assertEquals("koral:docGroup", node.at("/@type").asText());
+ assertEquals("operation:and", node.at("/operation").asText());
+ assertEquals(2, node.at("/operands").size());
+ 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
+ public void testStatisticsWithMultipleCq ()
+ throws UniformInterfaceException, ClientHandlerException,
+ KustvaktException {
+ ClientResponse response = resource().path(API_VERSION)
+ .path("statistics").queryParam("cq", "textType=Abhandlung")
+ .queryParam("cq", "corpusSigle=GOE")
+ .method("GET", ClientResponse.class);
+ assertEquals(ClientResponse.Status.OK.getStatusCode(),
+ response.getStatus());
+ String entity = response.getEntity(String.class);
+ JsonNode node = JsonUtils.readTree(entity);
+ 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 testStatisticsWithMultipleCorpusQuery ()
+ throws UniformInterfaceException, ClientHandlerException,
+ KustvaktException {
+ ClientResponse response =
+ resource().path(API_VERSION).path("statistics")
+ .queryParam("corpusQuery", "textType=Autobiographie")
+ .queryParam("corpusQuery", "corpusSigle=GOE")
+ .method("GET", ClientResponse.class);
+ assertEquals(ClientResponse.Status.OK.getStatusCode(),
+ response.getStatus());
+ String entity = response.getEntity(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_PARAMETER,
+ node.at("/warnings/0/0").asInt());
+ assertEquals("Parameter corpusQuery is deprecated in favor of cq.",
+ node.at("/warnings/0/1").asText());
+ }
+}
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/StatisticsControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/StatisticsControllerTest.java
index dc5d3c7..8ac68fa 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/StatisticsControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/StatisticsControllerTest.java
@@ -228,10 +228,10 @@
response.getStatus());
String ent = response.getEntity(String.class);
JsonNode node = JsonUtils.readTree(ent);
- assertEquals(node.at("/errors/0/0").asInt(),
- de.ids_mannheim.korap.util.StatusCodes.UNABLE_TO_PARSE_JSON);
- assertEquals(node.at("/errors/0/1").asText(),
- "Unable to parse JSON");
+ assertEquals(StatusCodes.DESERIALIZATION_FAILED,
+ node.at("/errors/0/0").asInt());
+ assertEquals("Failed deserializing json object: { \"collection\" : }",
+ node.at("/errors/0/1").asText());
}
@Test