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