blob: 1b4260966095ec9d10cb5958a5d9616c87e9fef0 [file] [log] [blame]
margaretha92ad2ec2023-05-15 14:10:00 +02001package de.ids_mannheim.korap.web.lite;
margarethaed2ee242019-12-12 17:34:18 +01002
Marc Kupietzd43a98d2023-09-22 17:11:46 +02003import static org.junit.jupiter.api.Assertions.assertEquals;
4import static org.junit.jupiter.api.Assertions.assertTrue;
margarethaed2ee242019-12-12 17:34:18 +01005
Marc Kupietzd43a98d2023-09-22 17:11:46 +02006import org.junit.jupiter.api.Test;
margarethaed2ee242019-12-12 17:34:18 +01007
margarethaf6f6c3c2024-06-11 10:51:06 +02008import com.fasterxml.jackson.databind.JsonNode;
abcpro173fe8f22022-11-08 19:56:52 +00009
margarethaed2ee242019-12-12 17:34:18 +010010import de.ids_mannheim.korap.config.LiteJerseyTest;
11import de.ids_mannheim.korap.exceptions.KustvaktException;
margarethaed2ee242019-12-12 17:34:18 +010012import de.ids_mannheim.korap.utils.JsonUtils;
margarethaf6f6c3c2024-06-11 10:51:06 +020013import jakarta.ws.rs.ProcessingException;
14import jakarta.ws.rs.core.Response;
15import jakarta.ws.rs.core.Response.Status;
margarethaed2ee242019-12-12 17:34:18 +010016
17public class LiteMultipleCorpusQueryTest extends LiteJerseyTest {
18
19 @Test
margaretha35e1ca22023-11-16 22:00:01 +010020 public void testSearchGet () throws KustvaktException {
21 Response response = target().path(API_VERSION).path("search")
22 .queryParam("q", "das").queryParam("ql", "poliqarp")
23 .queryParam("cq", "pubPlace=München")
24 .queryParam("cq", "textSigle=\"GOE/AGA/01784\"").request()
25 .get();
Marc Kupietzd43a98d2023-09-22 17:11:46 +020026 assertEquals(Status.OK.getStatusCode(), response.getStatus());
abcpro173fe8f22022-11-08 19:56:52 +000027 String entity = response.readEntity(String.class);
margarethaed2ee242019-12-12 17:34:18 +010028 JsonNode node = JsonUtils.readTree(entity);
29 node = node.at("/collection");
margarethaf6f6c3c2024-06-11 10:51:06 +020030 assertEquals("koral:docGroup",node.at("/@type").asText());
31 assertEquals("operation:and",node.at("/operation").asText());
margarethaed2ee242019-12-12 17:34:18 +010032 assertEquals(2, node.at("/operands").size());
margarethaf6f6c3c2024-06-11 10:51:06 +020033 assertEquals("koral:doc",node.at("/operands/0/@type").asText());
34 assertEquals("match:eq",node.at("/operands/0/match").asText());
35 assertEquals("pubPlace",node.at("/operands/0/key").asText());
36 assertEquals("München",node.at("/operands/0/value").asText());
37 assertEquals("textSigle",node.at("/operands/1/key").asText());
38 assertEquals("GOE/AGA/01784",node.at("/operands/1/value").asText());
margarethaed2ee242019-12-12 17:34:18 +010039 }
40
41 @Test
margaretha35e1ca22023-11-16 22:00:01 +010042 public void testStatisticsWithMultipleCq ()
43 throws ProcessingException, KustvaktException {
44 Response response = target().path(API_VERSION).path("statistics")
45 .queryParam("cq", "textType=Abhandlung")
46 .queryParam("cq", "corpusSigle=GOE").request().method("GET");
Marc Kupietzd43a98d2023-09-22 17:11:46 +020047 assertEquals(Status.OK.getStatusCode(), response.getStatus());
abcpro173fe8f22022-11-08 19:56:52 +000048 String entity = response.readEntity(String.class);
margarethaed2ee242019-12-12 17:34:18 +010049 JsonNode node = JsonUtils.readTree(entity);
50 assertEquals(2, node.at("/documents").asInt());
51 assertEquals(138180, node.at("/tokens").asInt());
52 assertEquals(5687, node.at("/sentences").asInt());
53 assertEquals(258, node.at("/paragraphs").asInt());
margarethaed2ee242019-12-12 17:34:18 +010054 assertTrue(node.at("/warnings").isMissingNode());
55 }
56
margarethaed2ee242019-12-12 17:34:18 +010057}