use of org.graylog.plugins.views.search.searchtypes.MessageList in project graylog2-server by Graylog2.
the class CommandFactoryTest method takesDefaultFieldsIfNotSpecifiedInResultFormat.
@Test
void takesDefaultFieldsIfNotSpecifiedInResultFormat() {
MessageList ml = MessageList.builder().id("ml-id").build();
Query q = validQueryBuilderWith(ml).build();
Search s = searchWithQueries(q);
ExportMessagesCommand command = buildFrom(s, ml.id(), ResultFormat.builder().build());
assertThat(command.fieldsInOrder()).isEqualTo(DEFAULT_FIELDS);
}
use of org.graylog.plugins.views.search.searchtypes.MessageList in project graylog2-server by Graylog2.
the class CommandFactoryTest method takesQueryStringFromQueryIfOnlySpecifiedThere.
@Test
void takesQueryStringFromQueryIfOnlySpecifiedThere() {
MessageList ml = MessageList.builder().id("ml-id").build();
Query q = validQueryBuilderWith(ml).query(ElasticsearchQueryString.of("nacken")).build();
Search s = searchWithQueries(q);
ExportMessagesCommand command = buildFrom(s, ml.id());
assertThat(command.queryString()).isEqualTo(q.query());
}
use of org.graylog.plugins.views.search.searchtypes.MessageList in project graylog2-server by Graylog2.
the class CommandFactory method buildWithMessageList.
public ExportMessagesCommand buildWithMessageList(Search search, String messageListId, ResultFormat resultFormat) {
Query query = search.queryForSearchType(messageListId);
SearchType searchType = searchTypeFrom(query, messageListId);
final List<Decorator> decorators = searchType instanceof MessageList ? ((MessageList) searchType).decorators() : Collections.emptyList();
ExportMessagesCommand.Builder commandBuilder = builderFrom(resultFormat).timeRange(resultFormat.timerange().orElse(toAbsolute(timeRangeFrom(query, searchType)))).queryString(queryStringFrom(search, query, searchType)).streams(streamsFrom(query, searchType)).decorators(decorators);
return commandBuilder.build();
}
use of org.graylog.plugins.views.search.searchtypes.MessageList in project graylog2-server by Graylog2.
the class QueryTest method mergeWithExecutionState.
@Test
public void mergeWithExecutionState() throws Exception {
final String messageListId = UUID.randomUUID().toString();
Query query = Query.builder().id("abc123").timerange(RelativeRange.create(600)).query(ElasticsearchQueryString.of("*")).searchTypes(ImmutableSet.of(MessageList.builder().id(messageListId).build())).build();
ExecutionStateGlobalOverride.Builder executionState = ExecutionStateGlobalOverride.builder();
executionState.timerange(RelativeRange.create(60));
executionState.searchTypesBuilder().put(messageListId, SearchTypeExecutionState.builder().offset(150).limit(300).build());
final Query mergedQuery = query.applyExecutionState(executionState.build());
assertThat(mergedQuery).isNotEqualTo(query).extracting(Query::timerange).extracting("range").containsExactly(60);
final Optional<SearchType> messageList = mergedQuery.searchTypes().stream().filter(searchType -> messageListId.equals(searchType.id())).findFirst();
assertThat(messageList).isPresent();
final MessageList msgList = (MessageList) messageList.get();
assertThat(msgList).extracting(MessageList::offset).containsExactly(150);
assertThat(msgList).extracting(MessageList::limit).containsExactly(300);
}
use of org.graylog.plugins.views.search.searchtypes.MessageList in project graylog2-server by Graylog2.
the class CommandFactoryTest method takesDecoratorsFromMessageList.
@Test
void takesDecoratorsFromMessageList() {
Decorator decorator = mock(Decorator.class);
MessageList ml = MessageList.builder().id("ml-id").decorators(newArrayList(decorator)).build();
Query q = validQueryBuilderWith(ml).build();
Search s = searchWithQueries(q);
ExportMessagesCommand command = buildFrom(s, ml.id());
assertThat(command.decorators()).containsExactly(decorator);
}
Aggregations