From 40c1ff0e1acca0b84d6f3bfa985289a5a52319b4 Mon Sep 17 00:00:00 2001 From: Benjamin Gamard Date: Sun, 21 Oct 2018 01:22:31 +0200 Subject: [PATCH] #241: test highlights and suggestions --- .../docs/rest/TestDocumentResource.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs-web/src/test/java/com/sismics/docs/rest/TestDocumentResource.java b/docs-web/src/test/java/com/sismics/docs/rest/TestDocumentResource.java index b0295129..d273385f 100644 --- a/docs-web/src/test/java/com/sismics/docs/rest/TestDocumentResource.java +++ b/docs-web/src/test/java/com/sismics/docs/rest/TestDocumentResource.java @@ -162,7 +162,25 @@ public class TestDocumentResource extends BaseJerseyTest { .get(JsonObject.class); documents = json.getJsonArray("documents"); Assert.assertEquals(1, documents.size()); - + + // Check highlights + json = target().path("/document/list") + .queryParam("search", "full:uranium full:einstein") + .request() + .cookie(TokenBasedSecurityFilter.COOKIE_NAME, document1Token) + .get(JsonObject.class); + String highlight = json.getJsonArray("documents").getJsonObject(0).getString("highlight"); + Assert.assertTrue(highlight.contains("")); + + // Check suggestions + json = target().path("/document/list") + .queryParam("search", "docu") + .request() + .cookie(TokenBasedSecurityFilter.COOKIE_NAME, document1Token) + .get(JsonObject.class); + String suggestion = json.getJsonArray("suggestions").getString(0); + Assert.assertEquals("document", suggestion); + // Search documents Assert.assertEquals(1, searchDocuments("full:uranium full:einstein", document1Token)); Assert.assertEquals(2, searchDocuments("full:title", document1Token));