use of com.rbmhtechnology.vind.monitoring.model.session.SimpleSession in project vind by RBMHTechnology.
the class MonitoringSearchServerTest method testSuggestionQueryMonitoringWithSessionAndLogger.
@Test
public void testSuggestionQueryMonitoringWithSessionAndLogger() throws IOException {
TestMonitoringWriter logger = new TestMonitoringWriter();
MonitoringSearchServer server = new MonitoringSearchServer(testSearchServer.getSearchServer(), new SimpleApplication("app"), new SimpleSession("123"), logger);
final SingleValueFieldDescriptor.TextFieldDescriptor<String> textField = new FieldDescriptorBuilder<String>().setFacet(true).buildTextField("textField");
final DocumentFactory factory = new DocumentFactoryBuilder("asset").addField(textField).build();
server.execute(Search.fulltext(), factory);
server.setSession(new SimpleSession("456"));
server.execute(Search.fulltext("Hello World").filter(or(eq(textField, "testFilter"), not(prefix("textField", "pref")))).facet(textField).sort(Sort.desc(textField)), factory);
// logger.logs.get(1).toJson();
assertEquals(2, logger.logs.size());
assertEquals("app", ((SimpleApplication) logger.logs.get(0).getApplication()).getId());
assertEquals("123", logger.logs.get(0).getSession().getSessionId());
assertEquals("*", ((FullTextEntry) logger.logs.get(0)).getRequest().getQuery());
assertEquals("456", logger.logs.get(1).getSession().getSessionId());
assertEquals("*", ((FullTextEntry) logger.logs.get(0)).getRequest().getQuery());
}
use of com.rbmhtechnology.vind.monitoring.model.session.SimpleSession in project vind by RBMHTechnology.
the class MonitoringSearchServerTest method testQueryMonitoringWithSessionAndLogger.
@Test
public void testQueryMonitoringWithSessionAndLogger() throws IOException {
TestMonitoringWriter logger = new TestMonitoringWriter();
MonitoringSearchServer server = new MonitoringSearchServer(testSearchServer.getSearchServer(), new SimpleApplication("app"), new SimpleSession("123"), logger);
// index 2 news items
NewsItem i1 = new NewsItem("1", "New Vind instance needed", ZonedDateTime.now().minusMonths(3), "article", "coding");
NewsItem i2 = new NewsItem("2", "Vind instance available", ZonedDateTime.now(), "blog", "coding", "release");
server.indexBean(i1);
server.indexBean(i2);
server.commit();
// this search should retrieve news items that should match the search term best
FulltextSearch search = Search.fulltext("vind release");
search.facet("category", "kind");
BeanSearchResult<NewsItem> result = server.execute(search, NewsItem.class);
assertEquals(1, logger.logs.size());
}
Aggregations