mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 14:07:55 +01:00
#241: test highlights and suggestions
This commit is contained in:
parent
6ceb1f6c02
commit
40c1ff0e1a
@ -163,6 +163,24 @@ public class TestDocumentResource extends BaseJerseyTest {
|
|||||||
documents = json.getJsonArray("documents");
|
documents = json.getJsonArray("documents");
|
||||||
Assert.assertEquals(1, documents.size());
|
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("<strong>"));
|
||||||
|
|
||||||
|
// 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
|
// Search documents
|
||||||
Assert.assertEquals(1, searchDocuments("full:uranium full:einstein", document1Token));
|
Assert.assertEquals(1, searchDocuments("full:uranium full:einstein", document1Token));
|
||||||
Assert.assertEquals(2, searchDocuments("full:title", document1Token));
|
Assert.assertEquals(2, searchDocuments("full:title", document1Token));
|
||||||
|
Loading…
Reference in New Issue
Block a user