use of org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators in project graylog2-server by Graylog2.
the class ESMessageListTest method includesCustomNameInResultIfPresent.
@Test
public void includesCustomNameInResultIfPresent() {
final ESMessageList esMessageList = new ESMessageList(new QueryStringDecorators(Collections.emptySet()));
final MessageList messageList = someMessageList().toBuilder().name("customResult").build();
final SearchResult result = new MockSearchResult(Collections.emptyList(), (long) 0);
final SearchType.Result searchTypeResult = esMessageList.doExtractResult(null, someQuery(), messageList, result, null, null);
assertThat(searchTypeResult.name()).contains("customResult");
}
use of org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators in project graylog2-server by Graylog2.
the class MessagesResourceTest method setUp.
@BeforeEach
void setUp() {
GuiceInjectorHolder.createInjector(Collections.emptyList());
currentUser = mock(User.class);
when(currentUser.getName()).thenReturn("peterchen");
MessagesExporter exporter = mock(MessagesExporter.class);
commandFactory = mock(CommandFactory.class);
when(commandFactory.buildFromRequest(any())).thenReturn(ExportMessagesCommand.withDefaults());
when(commandFactory.buildWithSearchOnly(any(), any())).thenReturn(ExportMessagesCommand.withDefaults());
when(commandFactory.buildWithMessageList(any(), any(), any())).thenReturn(ExportMessagesCommand.withDefaults());
permittedStreams = mock(PermittedStreams.class);
when(permittedStreams.load(any())).thenReturn(ImmutableSet.of("a-default-stream"));
executionGuard = mock(SearchExecutionGuard.class);
SearchDomain searchDomain = mock(SearchDomain.class);
final QueryValidationServiceImpl validationService = new QueryValidationServiceImpl(new LuceneQueryParser(), (streamIds, timeRange) -> Collections.emptySet(), new QueryStringDecorators(Collections.emptySet()));
sut = new MessagesTestResource(exporter, commandFactory, searchDomain, executionGuard, permittedStreams, mock(ObjectMapper.class), eventBus, validationService);
sut.asyncRunner = c -> {
c.accept(x -> {
});
return null;
};
}
use of org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators in project graylog2-server by Graylog2.
the class ESMessageListTest method generateQueryPartWithContextFor.
private ESGeneratedQueryContext generateQueryPartWithContextFor(MessageList messageList, boolean allowHighlighting, Set<QueryStringDecorator> decorators, ESGeneratedQueryContext context) {
ESMessageList sut = new ESMessageList(new QueryStringDecorators(decorators), new LegacyDecoratorProcessor.Fake(), allowHighlighting);
sut.doGenerateQueryPart(mock(SearchJob.class), someQuery(), messageList, context);
return context;
}
use of org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators in project graylog2-server by Graylog2.
the class ElasticsearchBackendErrorHandlingTest method setUp.
@Before
public void setUp() throws Exception {
final FieldTypesLookup fieldTypesLookup = mock(FieldTypesLookup.class);
this.backend = new ElasticsearchBackend(ImmutableMap.of("dummy", () -> mock(DummyHandler.class)), client, indexLookup, new QueryStringDecorators(Collections.emptySet()), (elasticsearchBackend, ssb, job, query) -> new ESGeneratedQueryContext(elasticsearchBackend, ssb, job, query, fieldTypesLookup), false);
when(indexLookup.indexNamesForStreamsInTimeRange(any(), any())).thenReturn(Collections.emptySet());
final SearchType searchType1 = mock(SearchType.class);
when(searchType1.id()).thenReturn("deadbeef");
when(searchType1.type()).thenReturn("dummy");
final SearchType searchType2 = mock(SearchType.class);
when(searchType2.id()).thenReturn("cafeaffe");
when(searchType2.type()).thenReturn("dummy");
final Set<SearchType> searchTypes = ImmutableSet.of(searchType1, searchType2);
this.query = Query.builder().id("query1").timerange(RelativeRange.create(300)).query(ElasticsearchQueryString.of("*")).searchTypes(searchTypes).build();
final Search search = Search.builder().id("search1").queries(ImmutableSet.of(query)).build();
this.searchJob = new SearchJob("job1", search, "admin");
this.queryContext = new ESGeneratedQueryContext(this.backend, new SearchSourceBuilder(), searchJob, query, mock(FieldTypesLookup.class));
searchTypes.forEach(queryContext::searchSourceBuilder);
}
Aggregations