| margaretha | 541b8cc | 2018-01-10 13:02:46 +0100 | [diff] [blame] | 1 | package de.ids_mannheim.korap.web.controller; |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [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.assertFalse; |
| 5 | import static org.junit.jupiter.api.Assertions.assertNotEquals; |
| 6 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 7 | import static org.junit.jupiter.api.Assertions.assertTrue; |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 8 | |
| margaretha | 96c309d | 2023-08-16 12:24:12 +0200 | [diff] [blame] | 9 | import jakarta.ws.rs.client.Entity; |
| 10 | import jakarta.ws.rs.core.MediaType; |
| 11 | import jakarta.ws.rs.core.Response.Status; |
| margaretha | 3d55b00 | 2019-03-19 12:00:44 +0100 | [diff] [blame] | 12 | |
| Marc Kupietz | 805afde | 2020-03-24 09:08:50 +0100 | [diff] [blame] | 13 | import de.ids_mannheim.korap.config.KustvaktConfiguration; |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 14 | import org.junit.jupiter.api.Disabled; |
| 15 | import org.junit.jupiter.api.Test; |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 16 | import com.fasterxml.jackson.databind.JsonNode; |
| margaretha | 58e1863 | 2018-02-15 13:04:42 +0100 | [diff] [blame] | 17 | import com.google.common.net.HttpHeaders; |
| margaretha | 96c309d | 2023-08-16 12:24:12 +0200 | [diff] [blame] | 18 | import jakarta.ws.rs.core.Response; |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 19 | |
| margaretha | 56e8e55 | 2017-12-05 16:31:21 +0100 | [diff] [blame] | 20 | import de.ids_mannheim.korap.authentication.http.HttpAuthorizationHandler; |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 21 | import de.ids_mannheim.korap.config.Attributes; |
| margaretha | 82c75c2 | 2024-12-11 09:36:50 +0100 | [diff] [blame] | 22 | import de.ids_mannheim.korap.config.FullConfiguration; |
| margaretha | 7a25f01 | 2018-03-22 19:49:01 +0100 | [diff] [blame] | 23 | import de.ids_mannheim.korap.config.SpringJerseyTest; |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 24 | import de.ids_mannheim.korap.exceptions.KustvaktException; |
| margaretha | c1db913 | 2019-08-28 11:32:04 +0200 | [diff] [blame] | 25 | import de.ids_mannheim.korap.exceptions.StatusCodes; |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 26 | import de.ids_mannheim.korap.query.serialize.QuerySerializer; |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 27 | import de.ids_mannheim.korap.utils.JsonUtils; |
| Marc Kupietz | 805afde | 2020-03-24 09:08:50 +0100 | [diff] [blame] | 28 | import org.springframework.beans.factory.annotation.Autowired; |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 29 | |
| 30 | /** |
| margaretha | 852a0f6 | 2019-02-19 12:14:30 +0100 | [diff] [blame] | 31 | * @author hanl, margaretha |
| margaretha | 3d55b00 | 2019-03-19 12:00:44 +0100 | [diff] [blame] | 32 | * @lastUpdate 18/03/2019 |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 33 | */ |
| margaretha | 7a25f01 | 2018-03-22 19:49:01 +0100 | [diff] [blame] | 34 | public class SearchControllerTest extends SpringJerseyTest { |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 35 | |
| Marc Kupietz | 805afde | 2020-03-24 09:08:50 +0100 | [diff] [blame] | 36 | @Autowired |
| margaretha | 82c75c2 | 2024-12-11 09:36:50 +0100 | [diff] [blame] | 37 | private FullConfiguration config; |
| Marc Kupietz | 805afde | 2020-03-24 09:08:50 +0100 | [diff] [blame] | 38 | |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 39 | private JsonNode requestSearchWithFields (String fields) |
| 40 | throws KustvaktException { |
| 41 | Response response = target().path(API_VERSION).path("search") |
| 42 | .queryParam("q", "[orth=das]").queryParam("ql", "poliqarp") |
| 43 | .queryParam("fields", fields).queryParam("context", "sentence") |
| 44 | .queryParam("count", "13").request().get(); |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 45 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| abcpro1 | 73fe8f2 | 2022-11-08 19:56:52 +0000 | [diff] [blame] | 46 | String query = response.readEntity(String.class); |
| margaretha | 852a0f6 | 2019-02-19 12:14:30 +0100 | [diff] [blame] | 47 | JsonNode node = JsonUtils.readTree(query); |
| 48 | return node; |
| 49 | } |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 50 | |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 51 | private String createJsonQuery () { |
| margaretha | 2544cdf | 2019-07-08 11:39:43 +0200 | [diff] [blame] | 52 | QuerySerializer s = new QuerySerializer(); |
| 53 | s.setQuery("[orth=der]", "poliqarp"); |
| 54 | s.setCollection("corpusSigle=GOE"); |
| 55 | s.setQuery("Wasser", "poliqarp"); |
| 56 | return s.toJSON(); |
| 57 | } |
| Marc Kupietz | 805afde | 2020-03-24 09:08:50 +0100 | [diff] [blame] | 58 | |
| 59 | @Test |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 60 | public void testApiWelcomeMessage () { |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 61 | Response response = target().path(API_VERSION).path("").request().get(); |
| 62 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 63 | assertEquals(response.getHeaders().getFirst("X-Index-Revision"), |
| 64 | "Wes8Bd4h1OypPqbWF5njeQ=="); |
| abcpro1 | 73fe8f2 | 2022-11-08 19:56:52 +0000 | [diff] [blame] | 65 | String message = response.readEntity(String.class); |
| Marc Kupietz | 805afde | 2020-03-24 09:08:50 +0100 | [diff] [blame] | 66 | assertEquals(message, config.getApiWelcomeMessage()); |
| 67 | } |
| 68 | |
| margaretha | 852a0f6 | 2019-02-19 12:14:30 +0100 | [diff] [blame] | 69 | @Test |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 70 | public void testSearchShowTokens () throws KustvaktException { |
| 71 | Response response = target().path(API_VERSION).path("search") |
| 72 | .queryParam("q", "[orth=die]").queryParam("ql", "poliqarp") |
| 73 | .queryParam("show-tokens", true).request().get(); |
| margaretha | ac85ae1 | 2023-05-08 11:09:13 +0200 | [diff] [blame] | 74 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| 75 | String entity = response.readEntity(String.class); |
| 76 | JsonNode node = JsonUtils.readTree(entity); |
| 77 | assertEquals(3, node.at("/matches/0/tokens").size()); |
| 78 | assertFalse(node.at("/matches/0/snippet").isMissingNode()); |
| 79 | } |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 80 | |
| margaretha | ac85ae1 | 2023-05-08 11:09:13 +0200 | [diff] [blame] | 81 | @Test |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 82 | public void testSearchDisableSnippet () throws KustvaktException { |
| 83 | Response response = target().path(API_VERSION).path("search") |
| 84 | .queryParam("q", "[orth=die]").queryParam("ql", "poliqarp") |
| 85 | .queryParam("show-snippet", false) |
| 86 | .queryParam("show-tokens", true).request().get(); |
| margaretha | ac85ae1 | 2023-05-08 11:09:13 +0200 | [diff] [blame] | 87 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| 88 | String entity = response.readEntity(String.class); |
| 89 | JsonNode node = JsonUtils.readTree(entity); |
| 90 | assertTrue(node.at("/matches/0/snippet").isMissingNode()); |
| 91 | assertEquals(3, node.at("/matches/0/tokens").size()); |
| 92 | } |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 93 | |
| margaretha | ac85ae1 | 2023-05-08 11:09:13 +0200 | [diff] [blame] | 94 | @Test |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 95 | public void testSearchWithField () throws KustvaktException { |
| margaretha | 852a0f6 | 2019-02-19 12:14:30 +0100 | [diff] [blame] | 96 | JsonNode node = requestSearchWithFields("author"); |
| 97 | assertNotEquals(0, node.at("/matches").size()); |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 98 | assertEquals("[\"author\"]", node.at("/meta/fields").toString()); |
| margaretha | ac85ae1 | 2023-05-08 11:09:13 +0200 | [diff] [blame] | 99 | assertTrue(node.at("/matches/0/tokens").isMissingNode()); |
| margaretha | 852a0f6 | 2019-02-19 12:14:30 +0100 | [diff] [blame] | 100 | } |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 101 | |
| margaretha | 852a0f6 | 2019-02-19 12:14:30 +0100 | [diff] [blame] | 102 | @Test |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 103 | public void testSearchWithMultipleFields () throws KustvaktException { |
| margaretha | 852a0f6 | 2019-02-19 12:14:30 +0100 | [diff] [blame] | 104 | JsonNode node = requestSearchWithFields("author, title"); |
| 105 | assertNotEquals(0, node.at("/matches").size()); |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 106 | assertEquals("[\"author\",\"title\"]", |
| 107 | node.at("/meta/fields").toString()); |
| margaretha | 852a0f6 | 2019-02-19 12:14:30 +0100 | [diff] [blame] | 108 | } |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 109 | |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 110 | @Test |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 111 | public void testSearchQueryPublicCorpora () throws KustvaktException { |
| 112 | Response response = target().path(API_VERSION).path("search") |
| 113 | .queryParam("q", "[orth=der]").queryParam("ql", "poliqarp") |
| 114 | .request().accept(MediaType.APPLICATION_JSON).get(); |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 115 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| abcpro1 | 73fe8f2 | 2022-11-08 19:56:52 +0000 | [diff] [blame] | 116 | String ent = response.readEntity(String.class); |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 117 | JsonNode node = JsonUtils.readTree(ent); |
| 118 | assertNotNull(node); |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 119 | assertEquals("koral:doc", node.at("/collection/@type").asText()); |
| 120 | assertEquals("availability", node.at("/collection/key").asText()); |
| 121 | assertEquals("CC.*", node.at("/collection/value").asText()); |
| margaretha | 8489f86 | 2025-02-05 11:32:16 +0100 | [diff] [blame] | 122 | assertEquals(freeCorpusAccess, |
| 123 | node.at("/collection/rewrites/0/_comment").asText()); |
| margaretha | 9d82046 | 2024-11-25 16:11:57 +0100 | [diff] [blame] | 124 | assertEquals("operation:injection", |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 125 | node.at("/collection/rewrites/0/operation").asText()); |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 126 | } |
| 127 | |
| Akron | d505816 | 2018-07-05 11:17:15 +0200 | [diff] [blame] | 128 | @Test |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 129 | public void testSearchQueryFailure () throws KustvaktException { |
| 130 | Response response = target().path(API_VERSION).path("search") |
| 131 | .queryParam("q", "[orth=der").queryParam("ql", "poliqarp") |
| 132 | .queryParam("cq", "corpusSigle=WPD | corpusSigle=GOE") |
| 133 | .queryParam("count", "13").request() |
| 134 | .accept(MediaType.APPLICATION_JSON).get(); |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 135 | assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus()); |
| abcpro1 | 73fe8f2 | 2022-11-08 19:56:52 +0000 | [diff] [blame] | 136 | String ent = response.readEntity(String.class); |
| margaretha | 064eb6f | 2018-07-10 18:33:01 +0200 | [diff] [blame] | 137 | JsonNode node = JsonUtils.readTree(ent); |
| Akron | d505816 | 2018-07-05 11:17:15 +0200 | [diff] [blame] | 138 | assertNotNull(node); |
| 139 | assertEquals(302, node.at("/errors/0/0").asInt()); |
| 140 | assertEquals(302, node.at("/errors/1/0").asInt()); |
| margaretha | 064eb6f | 2018-07-10 18:33:01 +0200 | [diff] [blame] | 141 | assertTrue(node.at("/errors/2").isMissingNode()); |
| 142 | assertFalse(node.at("/collection").isMissingNode()); |
| Akron | d505816 | 2018-07-05 11:17:15 +0200 | [diff] [blame] | 143 | assertEquals(13, node.at("/meta/count").asInt()); |
| 144 | } |
| 145 | |
| margaretha | 3fc0fd4 | 2017-05-02 18:08:31 +0200 | [diff] [blame] | 146 | @Test |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 147 | public void testSearchQueryWithMeta () throws KustvaktException { |
| 148 | Response response = target().path(API_VERSION).path("search") |
| 149 | .queryParam("q", "[orth=Bachelor]").queryParam("ql", "poliqarp") |
| 150 | .queryParam("cutoff", "true").queryParam("count", "5") |
| 151 | .queryParam("page", "1").queryParam("context", "40-t,30-t") |
| 152 | .request().get(); |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 153 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| abcpro1 | 73fe8f2 | 2022-11-08 19:56:52 +0000 | [diff] [blame] | 154 | String ent = response.readEntity(String.class); |
| margaretha | 3fc0fd4 | 2017-05-02 18:08:31 +0200 | [diff] [blame] | 155 | JsonNode node = JsonUtils.readTree(ent); |
| 156 | assertNotNull(node); |
| 157 | assertTrue(node.at("/meta/cutOff").asBoolean()); |
| 158 | assertEquals(5, node.at("/meta/count").asInt()); |
| 159 | assertEquals(0, node.at("/meta/startIndex").asInt()); |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 160 | assertEquals("token", node.at("/meta/context/left/0").asText()); |
| margaretha | 3fc0fd4 | 2017-05-02 18:08:31 +0200 | [diff] [blame] | 161 | assertEquals(40, node.at("/meta/context/left/1").asInt()); |
| 162 | assertEquals(30, node.at("/meta/context/right/1").asInt()); |
| margaretha | a89c3f9 | 2017-05-30 19:02:08 +0200 | [diff] [blame] | 163 | assertEquals(-1, node.at("/meta/totalResults").asInt()); |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 164 | for (String path : new String[] { "/meta/count", "/meta/startIndex", |
| 165 | "/meta/context/left/1", "/meta/context/right/1", |
| 166 | "/meta/totalResults", "/meta/itemsPerPage" }) { |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 167 | assertTrue(node.at(path).isNumber(), path + " should be a number"); |
| Marc Kupietz | 824f204 | 2023-09-18 14:50:21 +0200 | [diff] [blame] | 168 | } |
| margaretha | 3fc0fd4 | 2017-05-02 18:08:31 +0200 | [diff] [blame] | 169 | } |
| 170 | |
| margaretha | ebe869a | 2017-06-01 19:07:41 +0200 | [diff] [blame] | 171 | @Test |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 172 | public void testSearchQueryFreeExtern () throws KustvaktException { |
| 173 | Response response = target().path(API_VERSION).path("search") |
| 174 | .queryParam("q", "[orth=die]").queryParam("ql", "poliqarp") |
| 175 | .request().header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32") |
| 176 | .get(); |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 177 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| abcpro1 | 73fe8f2 | 2022-11-08 19:56:52 +0000 | [diff] [blame] | 178 | String entity = response.readEntity(String.class); |
| margaretha | ebe869a | 2017-06-01 19:07:41 +0200 | [diff] [blame] | 179 | JsonNode node = JsonUtils.readTree(entity); |
| 180 | assertNotNull(node); |
| 181 | assertNotEquals(0, node.path("matches").size()); |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 182 | assertEquals("koral:doc", node.at("/collection/@type").asText()); |
| 183 | assertEquals("availability", node.at("/collection/key").asText()); |
| 184 | assertEquals("CC.*", node.at("/collection/value").asText()); |
| margaretha | 8489f86 | 2025-02-05 11:32:16 +0100 | [diff] [blame] | 185 | assertEquals(freeCorpusAccess, |
| 186 | node.at("/collection/rewrites/0/_comment").asText()); |
| margaretha | 9d82046 | 2024-11-25 16:11:57 +0100 | [diff] [blame] | 187 | assertEquals("operation:injection", |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 188 | node.at("/collection/rewrites/0/operation").asText()); |
| margaretha | ebe869a | 2017-06-01 19:07:41 +0200 | [diff] [blame] | 189 | } |
| margaretha | 064eb6f | 2018-07-10 18:33:01 +0200 | [diff] [blame] | 190 | |
| margaretha | ebe869a | 2017-06-01 19:07:41 +0200 | [diff] [blame] | 191 | @Test |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 192 | public void testSearchQueryFreeIntern () throws KustvaktException { |
| 193 | Response response = target().path(API_VERSION).path("search") |
| 194 | .queryParam("q", "[orth=die]").queryParam("ql", "poliqarp") |
| 195 | .request().header(HttpHeaders.X_FORWARDED_FOR, "172.27.0.32") |
| 196 | .get(); |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 197 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| abcpro1 | 73fe8f2 | 2022-11-08 19:56:52 +0000 | [diff] [blame] | 198 | String entity = response.readEntity(String.class); |
| margaretha | ebe869a | 2017-06-01 19:07:41 +0200 | [diff] [blame] | 199 | JsonNode node = JsonUtils.readTree(entity); |
| 200 | assertNotNull(node); |
| 201 | assertNotEquals(0, node.path("matches").size()); |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 202 | assertEquals("koral:doc", node.at("/collection/@type").asText()); |
| 203 | assertEquals("availability", node.at("/collection/key").asText()); |
| 204 | assertEquals("CC.*", node.at("/collection/value").asText()); |
| margaretha | 8489f86 | 2025-02-05 11:32:16 +0100 | [diff] [blame] | 205 | assertEquals(freeCorpusAccess, |
| 206 | node.at("/collection/rewrites/0/_comment").asText()); |
| margaretha | 9d82046 | 2024-11-25 16:11:57 +0100 | [diff] [blame] | 207 | assertEquals("operation:injection", |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 208 | node.at("/collection/rewrites/0/operation").asText()); |
| margaretha | ebe869a | 2017-06-01 19:07:41 +0200 | [diff] [blame] | 209 | } |
| margaretha | 064eb6f | 2018-07-10 18:33:01 +0200 | [diff] [blame] | 210 | |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 211 | @Test |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 212 | public void testSearchQueryExternAuthorized () throws KustvaktException { |
| 213 | Response response = target().path(API_VERSION).path("search") |
| 214 | .queryParam("q", "[orth=die]").queryParam("ql", "poliqarp") |
| 215 | .request() |
| 216 | .header(Attributes.AUTHORIZATION, |
| 217 | HttpAuthorizationHandler |
| 218 | .createBasicAuthorizationHeaderValue("kustvakt", |
| 219 | "kustvakt2015")) |
| 220 | .header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32").get(); |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 221 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| abcpro1 | 73fe8f2 | 2022-11-08 19:56:52 +0000 | [diff] [blame] | 222 | String entity = response.readEntity(String.class); |
| margaretha | 61471cc | 2017-04-20 18:42:23 +0200 | [diff] [blame] | 223 | JsonNode node = JsonUtils.readTree(entity); |
| margaretha | 064eb6f | 2018-07-10 18:33:01 +0200 | [diff] [blame] | 224 | // System.out.println(entity); |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 225 | assertNotNull(node); |
| margaretha | 65b6714 | 2017-05-29 16:23:16 +0200 | [diff] [blame] | 226 | assertNotEquals(0, node.path("matches").size()); |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 227 | assertEquals("koral:docGroup", node.at("/collection/@type").asText()); |
| 228 | assertEquals("CC.*", node.at("/collection/operands/0/value").asText()); |
| 229 | assertEquals("ACA.*", |
| 230 | node.at("/collection/operands/1/operands/0/value").asText()); |
| 231 | assertEquals("QAO-NC", |
| 232 | node.at("/collection/operands/1/operands/1/value").asText()); |
| 233 | assertEquals("operation:or", node.at("/collection/operation").asText()); |
| margaretha | 8489f86 | 2025-02-05 11:32:16 +0100 | [diff] [blame] | 234 | assertEquals(publicCorpusAccess, |
| 235 | node.at("/collection/rewrites/0/_comment").asText()); |
| margaretha | 9d82046 | 2024-11-25 16:11:57 +0100 | [diff] [blame] | 236 | assertEquals("operation:injection", |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 237 | node.at("/collection/rewrites/0/operation").asText()); |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 238 | } |
| 239 | |
| margaretha | 65b6714 | 2017-05-29 16:23:16 +0200 | [diff] [blame] | 240 | @Test |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 241 | public void testSearchQueryInternAuthorized () throws KustvaktException { |
| 242 | Response response = target().path(API_VERSION).path("search") |
| 243 | .queryParam("q", "[orth=die]").queryParam("ql", "poliqarp") |
| 244 | .request() |
| 245 | .header(Attributes.AUTHORIZATION, |
| 246 | HttpAuthorizationHandler |
| 247 | .createBasicAuthorizationHeaderValue("kustvakt", |
| 248 | "kustvakt2015")) |
| 249 | .header(HttpHeaders.X_FORWARDED_FOR, "172.27.0.32").get(); |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 250 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| abcpro1 | 73fe8f2 | 2022-11-08 19:56:52 +0000 | [diff] [blame] | 251 | String entity = response.readEntity(String.class); |
| margaretha | 65b6714 | 2017-05-29 16:23:16 +0200 | [diff] [blame] | 252 | JsonNode node = JsonUtils.readTree(entity); |
| 253 | assertNotNull(node); |
| 254 | assertNotEquals(0, node.path("matches").size()); |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 255 | assertEquals("koral:docGroup", node.at("/collection/@type").asText()); |
| margaretha | 82c75c2 | 2024-12-11 09:36:50 +0100 | [diff] [blame] | 256 | assertEquals(config.getFreeOnlyRegex(), |
| 257 | node.at("/collection/operands/0/value").asText()); |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 258 | assertEquals("ACA.*", |
| 259 | node.at("/collection/operands/1/operands/0/value").asText()); |
| 260 | assertEquals("QAO-NC", |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 261 | node.at("/collection/operands/1/operands/1/operands/0/value") |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 262 | .asText()); |
| margaretha | 82c75c2 | 2024-12-11 09:36:50 +0100 | [diff] [blame] | 263 | assertEquals(config.getAllOnlyRegex(), |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 264 | node.at("/collection/operands/1/operands/1/operands/1/value") |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 265 | .asText()); |
| 266 | assertEquals("operation:or", node.at("/collection/operation").asText()); |
| margaretha | 8489f86 | 2025-02-05 11:32:16 +0100 | [diff] [blame] | 267 | assertEquals(allCorpusAccess, |
| 268 | node.at("/collection/rewrites/0/_comment").asText()); |
| margaretha | 9d82046 | 2024-11-25 16:11:57 +0100 | [diff] [blame] | 269 | assertEquals("operation:injection", |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 270 | node.at("/collection/rewrites/0/operation").asText()); |
| margaretha | 65b6714 | 2017-05-29 16:23:16 +0200 | [diff] [blame] | 271 | } |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 272 | |
| margaretha | ac85ae1 | 2023-05-08 11:09:13 +0200 | [diff] [blame] | 273 | @Test |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 274 | public void testSearchWithCorpusQuery () throws KustvaktException { |
| 275 | Response response = target().path(API_VERSION).path("search") |
| 276 | .queryParam("q", "[orth=der]").queryParam("ql", "poliqarp") |
| 277 | .queryParam("cq", "corpusTitle=gingko").request() |
| 278 | .accept(MediaType.APPLICATION_JSON).get(); |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 279 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| margaretha | ac85ae1 | 2023-05-08 11:09:13 +0200 | [diff] [blame] | 280 | String ent = response.readEntity(String.class); |
| 281 | JsonNode node = JsonUtils.readTree(ent); |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 282 | assertEquals("koral:docGroup", node.at("/collection/@type").asText()); |
| 283 | assertEquals("operation:and", |
| 284 | node.at("/collection/operation").asText()); |
| margaretha | ac85ae1 | 2023-05-08 11:09:13 +0200 | [diff] [blame] | 285 | assertEquals(2, node.at("/collection/operands").size()); |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 286 | assertEquals("CC.*", node.at("/collection/operands/0/value").asText()); |
| 287 | assertEquals("gingko", |
| 288 | node.at("/collection/operands/1/value").asText()); |
| 289 | assertEquals("match:eq", |
| 290 | node.at("/collection/operands/1/match").asText()); |
| margaretha | ac85ae1 | 2023-05-08 11:09:13 +0200 | [diff] [blame] | 291 | assertTrue(node.at("/collection/operands/1/type").isMissingNode()); |
| 292 | } |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 293 | |
| 294 | @Test |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 295 | public void testSearchWithCorpusQueryNoQuery () throws KustvaktException { |
| 296 | Response response = target().path(API_VERSION).path("search") |
| 297 | .queryParam("q", "NOQUERY").queryParam("ql", "poliqarp") |
| 298 | .queryParam("count", 0).queryParam("cutoff", "true") |
| 299 | .queryParam("cq", "corpusSigle=WPD17").request() |
| 300 | .accept(MediaType.APPLICATION_JSON).get(); |
| 301 | |
| 302 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| 303 | |
| 304 | String ent = response.readEntity(String.class); |
| 305 | JsonNode node = JsonUtils.readTree(ent); |
| 306 | |
| 307 | assertEquals(0, node.at("/meta/count").asInt()); |
| 308 | assertEquals(-1, node.at("/meta/totalResults").asInt()); |
| 309 | assertEquals("CC.*", node.at("/collection/operands/0/value").asText()); |
| 310 | assertEquals("corpusSigle", |
| 311 | node.at("/collection/operands/1/key").asText()); |
| 312 | assertEquals("WPD17", node.at("/collection/operands/1/value").asText()); |
| 313 | assertEquals("match:eq", |
| 314 | node.at("/collection/operands/1/match").asText()); |
| 315 | } |
| 316 | |
| 317 | @Test |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 318 | public void testSearchQueryWithCollectionQueryAuthorizedWithoutIP () |
| 319 | throws KustvaktException { |
| 320 | Response response = target().path(API_VERSION).path("search") |
| 321 | .queryParam("q", "[orth=das]").queryParam("ql", "poliqarp") |
| 322 | .queryParam("cq", "textClass=politik & corpusSigle=BRZ10") |
| 323 | .request() |
| 324 | .header(Attributes.AUTHORIZATION, |
| 325 | HttpAuthorizationHandler |
| 326 | .createBasicAuthorizationHeaderValue("kustvakt", |
| 327 | "kustvakt2015")) |
| 328 | .get(); |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 329 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| abcpro1 | 73fe8f2 | 2022-11-08 19:56:52 +0000 | [diff] [blame] | 330 | JsonNode node = JsonUtils.readTree(response.readEntity(String.class)); |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 331 | assertNotNull(node); |
| margaretha | d9e43ec | 2024-12-20 12:11:43 +0100 | [diff] [blame] | 332 | assertEquals("operation:override", |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 333 | node.at("/collection/rewrites/0/operation").asText()); |
| margaretha | d9e43ec | 2024-12-20 12:11:43 +0100 | [diff] [blame] | 334 | // assertEquals("availability(FREE)", |
| 335 | // node.at("/collection/rewrites/0/scope").asText()); |
| margaretha | a89c3f9 | 2017-05-30 19:02:08 +0200 | [diff] [blame] | 336 | // EM: double AND operations |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 337 | assertEquals("availability", |
| 338 | node.at("/collection/operands/0/key").asText()); |
| 339 | assertEquals("CC.*", node.at("/collection/operands/0/value").asText()); |
| 340 | assertEquals("textClass", |
| 341 | node.at("/collection/operands/1/operands/0/key").asText()); |
| 342 | assertEquals("corpusSigle", |
| 343 | node.at("/collection/operands/1/operands/1/key").asText()); |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 344 | } |
| margaretha | 064eb6f | 2018-07-10 18:33:01 +0200 | [diff] [blame] | 345 | |
| margaretha | a89c3f9 | 2017-05-30 19:02:08 +0200 | [diff] [blame] | 346 | @Test |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 347 | @Disabled |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 348 | public void testSearchQueryAuthorizedWithoutIP () throws KustvaktException { |
| 349 | Response response = target().path(API_VERSION).path("search") |
| 350 | .queryParam("q", "[orth=die]").queryParam("ql", "poliqarp") |
| 351 | .request() |
| 352 | .header(Attributes.AUTHORIZATION, |
| 353 | HttpAuthorizationHandler |
| 354 | .createBasicAuthorizationHeaderValue("kustvakt", |
| 355 | "kustvakt2015")) |
| 356 | .get(); |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 357 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| abcpro1 | 73fe8f2 | 2022-11-08 19:56:52 +0000 | [diff] [blame] | 358 | String entity = response.readEntity(String.class); |
| margaretha | ebe869a | 2017-06-01 19:07:41 +0200 | [diff] [blame] | 359 | JsonNode node = JsonUtils.readTree(entity); |
| margaretha | a89c3f9 | 2017-05-30 19:02:08 +0200 | [diff] [blame] | 360 | assertNotNull(node); |
| margaretha | ebe869a | 2017-06-01 19:07:41 +0200 | [diff] [blame] | 361 | assertNotEquals(0, node.path("matches").size()); |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 362 | assertEquals("koral:docGroup", node.at("/collection/@type").asText()); |
| 363 | assertEquals("CC.*", node.at("/collection/operands/0/value").asText()); |
| 364 | assertEquals("ACA.*", node.at("/collection/operands/1/value").asText()); |
| 365 | assertEquals("operation:or", node.at("/collection/operation").asText()); |
| margaretha | 8489f86 | 2025-02-05 11:32:16 +0100 | [diff] [blame] | 366 | assertEquals(publicCorpusAccess, |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 367 | node.at("/collection/rewrites/0/scope").asText()); |
| margaretha | a89c3f9 | 2017-05-30 19:02:08 +0200 | [diff] [blame] | 368 | } |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 369 | |
| margaretha | c1db913 | 2019-08-28 11:32:04 +0200 | [diff] [blame] | 370 | @Test |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 371 | public void testSearchWithInvalidPage () throws KustvaktException { |
| 372 | Response response = target().path(API_VERSION).path("search") |
| 373 | .queryParam("q", "[orth=die]").queryParam("ql", "poliqarp") |
| 374 | .queryParam("page", "0").request().get(); |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 375 | assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus()); |
| abcpro1 | 73fe8f2 | 2022-11-08 19:56:52 +0000 | [diff] [blame] | 376 | String entity = response.readEntity(String.class); |
| margaretha | c1db913 | 2019-08-28 11:32:04 +0200 | [diff] [blame] | 377 | JsonNode node = JsonUtils.readTree(entity); |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 378 | assertEquals(StatusCodes.INVALID_ARGUMENT, |
| 379 | node.at("/errors/0/0").asInt()); |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 380 | assertEquals("page must start from 1", node.at("/errors/0/1").asText()); |
| margaretha | c1db913 | 2019-08-28 11:32:04 +0200 | [diff] [blame] | 381 | } |
| margaretha | 064eb6f | 2018-07-10 18:33:01 +0200 | [diff] [blame] | 382 | |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 383 | @Test |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 384 | public void testSearchSentenceMeta () throws KustvaktException { |
| 385 | Response response = target().path(API_VERSION).path("search") |
| 386 | .queryParam("q", "[orth=der]").queryParam("ql", "poliqarp") |
| 387 | .queryParam("context", "sentence").request().get(); |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 388 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| abcpro1 | 73fe8f2 | 2022-11-08 19:56:52 +0000 | [diff] [blame] | 389 | String ent = response.readEntity(String.class); |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 390 | JsonNode node = JsonUtils.readTree(ent); |
| 391 | assertNotNull(node); |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 392 | assertEquals("base/s:s", node.at("/meta/context").asText()); |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 393 | assertNotEquals("/meta/version", "${project.version}"); |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 394 | } |
| 395 | |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 396 | // EM: The API is disabled |
| 397 | @Disabled |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 398 | @Test |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 399 | public void testSearchSimpleCQL () throws KustvaktException { |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 400 | QuerySerializer s = new QuerySerializer(); |
| 401 | s.setQuery("(der) or (das)", "CQL"); |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 402 | Response response = target().path(API_VERSION).path("search").request() |
| 403 | .post(Entity.json(s.toJSON())); |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 404 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| abcpro1 | 73fe8f2 | 2022-11-08 19:56:52 +0000 | [diff] [blame] | 405 | String ent = response.readEntity(String.class); |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 406 | JsonNode node = JsonUtils.readTree(ent); |
| 407 | assertNotNull(node); |
| 408 | assertNotEquals(0, node.path("matches").size()); |
| margaretha | 064eb6f | 2018-07-10 18:33:01 +0200 | [diff] [blame] | 409 | // assertEquals(17027, node.at("/meta/totalResults").asInt()); |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 410 | } |
| 411 | |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 412 | // EM: The API is disabled |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 413 | @Test |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 414 | @Disabled |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 415 | public void testSearchRawQuery () throws KustvaktException { |
| 416 | Response response = target().path(API_VERSION).path("search").request() |
| 417 | .post(Entity.json(createJsonQuery())); |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 418 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| abcpro1 | 73fe8f2 | 2022-11-08 19:56:52 +0000 | [diff] [blame] | 419 | String ent = response.readEntity(String.class); |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 420 | JsonNode node = JsonUtils.readTree(ent); |
| 421 | assertNotNull(node); |
| 422 | assertNotEquals(0, node.path("matches").size()); |
| margaretha | 8489f86 | 2025-02-05 11:32:16 +0100 | [diff] [blame] | 423 | assertEquals(freeCorpusAccess, |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 424 | node.at("/collection/rewrites/0/scope").asText()); |
| margaretha | 2544cdf | 2019-07-08 11:39:43 +0200 | [diff] [blame] | 425 | } |
| margaretha | 2544cdf | 2019-07-08 11:39:43 +0200 | [diff] [blame] | 426 | |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 427 | // EM: The API is disabled |
| 428 | @Test |
| 429 | @Disabled |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 430 | public void testSearchPostAll () throws KustvaktException { |
| 431 | Response response = target().path(API_VERSION).path("search").request() |
| 432 | .header(HttpHeaders.X_FORWARDED_FOR, "10.27.0.32") |
| 433 | .header(Attributes.AUTHORIZATION, |
| 434 | HttpAuthorizationHandler |
| 435 | .createBasicAuthorizationHeaderValue("kustvakt", |
| 436 | "kustvakt2015")) |
| 437 | .post(Entity.json(createJsonQuery())); |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 438 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| 439 | String ent = response.readEntity(String.class); |
| margaretha | 2544cdf | 2019-07-08 11:39:43 +0200 | [diff] [blame] | 440 | JsonNode node = JsonUtils.readTree(ent); |
| 441 | assertNotNull(node); |
| 442 | assertNotEquals(0, node.path("matches").size()); |
| margaretha | 8489f86 | 2025-02-05 11:32:16 +0100 | [diff] [blame] | 443 | assertEquals(allCorpusAccess, |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 444 | node.at("/collection/rewrites/0/scope").asText()); |
| margaretha | 2544cdf | 2019-07-08 11:39:43 +0200 | [diff] [blame] | 445 | } |
| margaretha | 2544cdf | 2019-07-08 11:39:43 +0200 | [diff] [blame] | 446 | |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 447 | // EM: The API is disabled |
| 448 | @Test |
| 449 | @Disabled |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 450 | public void testSearchPostPublic () throws KustvaktException { |
| 451 | Response response = target().path(API_VERSION).path("search").request() |
| 452 | .header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32") |
| 453 | .header(Attributes.AUTHORIZATION, |
| 454 | HttpAuthorizationHandler |
| 455 | .createBasicAuthorizationHeaderValue("kustvakt", |
| 456 | "kustvakt2015")) |
| 457 | .post(Entity.json(createJsonQuery())); |
| Marc Kupietz | d43a98d | 2023-09-22 17:11:46 +0200 | [diff] [blame] | 458 | assertEquals(Status.OK.getStatusCode(), response.getStatus()); |
| 459 | String ent = response.readEntity(String.class); |
| margaretha | 2544cdf | 2019-07-08 11:39:43 +0200 | [diff] [blame] | 460 | JsonNode node = JsonUtils.readTree(ent); |
| 461 | assertNotNull(node); |
| 462 | assertNotEquals(0, node.path("matches").size()); |
| margaretha | 8489f86 | 2025-02-05 11:32:16 +0100 | [diff] [blame] | 463 | assertEquals(publicCorpusAccess, |
| margaretha | 1c0a41d | 2024-11-13 15:44:25 +0100 | [diff] [blame] | 464 | node.at("/collection/rewrites/0/scope").asText()); |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 465 | } |
| margaretha | 0c47c65 | 2017-04-19 18:44:40 +0200 | [diff] [blame] | 466 | } |