Search in sources :

Example 26 with ExportMessagesCommand

use of org.graylog.plugins.views.search.export.ExportMessagesCommand in project graylog2-server by Graylog2.

the class ElasticsearchExportBackendIT method failsWithLeadingHighlightQueryIfDisallowed.

@Test
public void failsWithLeadingHighlightQueryIfDisallowed() {
    importFixture("messages.json");
    ExportMessagesCommand command = commandBuilderWithAllStreams().queryString(ElasticsearchQueryString.of("*a")).build();
    assertThatExceptionOfType(ExportException.class).isThrownBy(() -> sut.run(command, chunk -> {
    })).withCauseInstanceOf(ElasticsearchException.class);
}
Also used : ExportMessagesCommand(org.graylog.plugins.views.search.export.ExportMessagesCommand) ElasticsearchBaseTest(org.graylog.testing.elasticsearch.ElasticsearchBaseTest) Test(org.junit.Test)

Example 27 with ExportMessagesCommand

use of org.graylog.plugins.views.search.export.ExportMessagesCommand in project graylog2-server by Graylog2.

the class ElasticsearchExportBackendIT method usesQueryString.

@Test
public void usesQueryString() {
    importFixture("messages.json");
    ExportMessagesCommand command = commandBuilderWithAllStreams().queryString(ElasticsearchQueryString.of("Ha Ho")).build();
    runWithExpectedResultIgnoringSort(command, "timestamp,source,message", "graylog_0, 2015-01-01T04:00:00.000Z, source-2, Ho", "graylog_0, 2015-01-01T01:00:00.000Z, source-1, Ha");
}
Also used : ExportMessagesCommand(org.graylog.plugins.views.search.export.ExportMessagesCommand) ElasticsearchBaseTest(org.graylog.testing.elasticsearch.ElasticsearchBaseTest) Test(org.junit.Test)

Example 28 with ExportMessagesCommand

use of org.graylog.plugins.views.search.export.ExportMessagesCommand in project graylog2-server by Graylog2.

the class ElasticsearchExportBackendIT method usesProvidedTimeZone.

@Test
public void usesProvidedTimeZone() {
    importFixture("messages.json");
    ExportMessagesCommand command = commandBuilderWithAllStreams().timeZone(// UTC+9:30
    DateTimeZone.forID("Australia/Adelaide")).build();
    runWithExpectedResult(command, "timestamp,source,message", "graylog_0, 2015-01-01T11:30:00.000+10:30, source-1, Ha", "graylog_1, 2015-01-01T12:29:59.999+10:30, source-2, He", "graylog_0, 2015-01-01T13:30:00.000+10:30, source-1, Hi", "graylog_0, 2015-01-01T14:30:00.000+10:30, source-2, Ho");
}
Also used : ExportMessagesCommand(org.graylog.plugins.views.search.export.ExportMessagesCommand) ElasticsearchBaseTest(org.graylog.testing.elasticsearch.ElasticsearchBaseTest) Test(org.junit.Test)

Example 29 with ExportMessagesCommand

use of org.graylog.plugins.views.search.export.ExportMessagesCommand in project graylog2-server by Graylog2.

the class ElasticsearchExportBackendIT method usesCorrectIndicesAndStreams.

@Test
public void usesCorrectIndicesAndStreams() {
    importFixture("messages.json");
    ExportMessagesCommand command = commandBuilderWithAllStreams().streams(ImmutableSet.of("stream-01", "stream-02")).build();
    mockIndexLookupFor(command, "graylog_0", "graylog_1");
    runWithExpectedResultIgnoringSort(command, "timestamp,source,message", "graylog_0, 2015-01-01T01:00:00.000Z, source-1, Ha", "graylog_1, 2015-01-01T01:59:59.999Z, source-2, He", "graylog_0, 2015-01-01T04:00:00.000Z, source-2, Ho");
}
Also used : ExportMessagesCommand(org.graylog.plugins.views.search.export.ExportMessagesCommand) ElasticsearchBaseTest(org.graylog.testing.elasticsearch.ElasticsearchBaseTest) Test(org.junit.Test)

Aggregations

ExportMessagesCommand (org.graylog.plugins.views.search.export.ExportMessagesCommand)29 Test (org.junit.Test)23 ElasticsearchBaseTest (org.graylog.testing.elasticsearch.ElasticsearchBaseTest)21 SimpleMessageChunk (org.graylog.plugins.views.search.export.SimpleMessageChunk)9 ApiOperation (io.swagger.annotations.ApiOperation)3 POST (javax.ws.rs.POST)3 ElasticsearchQueryString (org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString)3 NoAuditEvent (org.graylog2.audit.jersey.NoAuditEvent)3 Test (org.junit.jupiter.api.Test)3 Search (io.searchbox.core.Search)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Search (org.graylog.plugins.views.search.Search)2 ResultFormat (org.graylog.plugins.views.search.export.ResultFormat)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Sets (com.google.common.collect.Sets)1 Arrays (java.util.Arrays)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 BadRequestException (javax.ws.rs.BadRequestException)1