| margaretha | 92ad2ec | 2023-05-15 14:10:00 +0200 | [diff] [blame] | 1 | package de.ids_mannheim.korap.web.lite; |
| margaretha | ed2ee24 | 2019-12-12 17:34:18 +0100 | [diff] [blame] | 2 | |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 4 | import static org.junit.jupiter.api.Assertions.assertTrue; |
| margaretha | ed2ee24 | 2019-12-12 17:34:18 +0100 | [diff] [blame] | 5 | |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 6 | import org.junit.jupiter.api.Test; |
| margaretha | ed2ee24 | 2019-12-12 17:34:18 +0100 | [diff] [blame] | 7 | |
| margaretha | f6f6c3c | 2024-06-11 10:51:06 +0200 | [diff] [blame] | 8 | import com.fasterxml.jackson.databind.JsonNode; |
| abcpro1 | 73fe8f2 | 2022-11-08 19:56:52 +0000 | [diff] [blame] | 9 | |
| margaretha | ed2ee24 | 2019-12-12 17:34:18 +0100 | [diff] [blame] | 10 | import de.ids_mannheim.korap.config.LiteJerseyTest; |
| 11 | import de.ids_mannheim.korap.exceptions.KustvaktException; |
| margaretha | ed2ee24 | 2019-12-12 17:34:18 +0100 | [diff] [blame] | 12 | import de.ids_mannheim.korap.utils.JsonUtils; |
| margaretha | f6f6c3c | 2024-06-11 10:51:06 +0200 | [diff] [blame] | 13 | import jakarta.ws.rs.ProcessingException; |
| 14 | import jakarta.ws.rs.core.Response; |
| 15 | import jakarta.ws.rs.core.Response.Status; |
| margaretha | ed2ee24 | 2019-12-12 17:34:18 +0100 | [diff] [blame] | 16 | |
| 17 | public class LiteMultipleCorpusQueryTest extends LiteJerseyTest { |
| 18 | |
| 19 | @Test |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 20 | 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 Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 26 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| abcpro1 | 73fe8f2 | 2022-11-08 19:56:52 +0000 | [diff] [blame] | 27 | String entity = response.readEntity(String.class); |
| margaretha | ed2ee24 | 2019-12-12 17:34:18 +0100 | [diff] [blame] | 28 | JsonNode node = JsonUtils.readTree(entity); |
| 29 | node = node.at("/collection"); |
| margaretha | f6f6c3c | 2024-06-11 10:51:06 +0200 | [diff] [blame] | 30 | assertEquals("koral:docGroup",node.at("/@type").asText()); |
| 31 | assertEquals("operation:and",node.at("/operation").asText()); |
| margaretha | ed2ee24 | 2019-12-12 17:34:18 +0100 | [diff] [blame] | 32 | assertEquals(2, node.at("/operands").size()); |
| margaretha | f6f6c3c | 2024-06-11 10:51:06 +0200 | [diff] [blame] | 33 | 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()); |
| margaretha | ed2ee24 | 2019-12-12 17:34:18 +0100 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | @Test |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 42 | 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 Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 47 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| abcpro1 | 73fe8f2 | 2022-11-08 19:56:52 +0000 | [diff] [blame] | 48 | String entity = response.readEntity(String.class); |
| margaretha | ed2ee24 | 2019-12-12 17:34:18 +0100 | [diff] [blame] | 49 | 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()); |
| margaretha | ed2ee24 | 2019-12-12 17:34:18 +0100 | [diff] [blame] | 54 | assertTrue(node.at("/warnings").isMissingNode()); |
| 55 | } |
| 56 | |
| margaretha | ed2ee24 | 2019-12-12 17:34:18 +0100 | [diff] [blame] | 57 | } |