Search in sources :

Example 6 with OffsetRange

use of org.graylog.plugins.views.search.timeranges.OffsetRange in project graylog2-server by Graylog2.

the class OffsetRangeTest method returnsCorrectRangeForTimeRangeOfSearchType.

@Test
public void returnsCorrectRangeForTimeRangeOfSearchType() throws Exception {
    final OffsetRange offsetRange = constructRange("300", "search_type", "searchTypeId");
    final TimeRange sourceRange = mock(TimeRange.class);
    when(sourceRange.getFrom()).thenReturn(DateTime.parse("2019-11-18T10:00:00.000Z"));
    when(sourceRange.getTo()).thenReturn(DateTime.parse("2019-11-21T12:00:00.000Z"));
    final Query query = queryWithSearchTypeTimeRange(sourceRange, "searchTypeId");
    final TimeRange result = offsetRange.deriveTimeRange(query, null);
    assertThat(result).isEqualTo(AbsoluteRange.create("2019-11-18T09:55:00.000Z", "2019-11-21T11:55:00.000Z"));
}
Also used : OffsetRange(org.graylog.plugins.views.search.timeranges.OffsetRange) DerivedTimeRange(org.graylog.plugins.views.search.timeranges.DerivedTimeRange) TimeRange(org.graylog2.plugin.indexer.searches.timeranges.TimeRange) Query(org.graylog.plugins.views.search.Query) Test(org.junit.Test)

Example 7 with OffsetRange

use of org.graylog.plugins.views.search.timeranges.OffsetRange in project graylog2-server by Graylog2.

the class OffsetRangeTest method returnsCorrectRangeForTimeRangeOfSearchTypeWithOffsetInUnits.

@Test
public void returnsCorrectRangeForTimeRangeOfSearchTypeWithOffsetInUnits() throws Exception {
    final OffsetRange offsetRange = constructRange("2i", "search_type", "searchTypeId");
    final TimeRange sourceRange = mock(TimeRange.class);
    when(sourceRange.getFrom()).thenReturn(DateTime.parse("2019-11-18T10:00:00.000Z"));
    when(sourceRange.getTo()).thenReturn(DateTime.parse("2019-11-21T12:00:00.000Z"));
    final Query query = queryWithSearchTypeTimeRange(sourceRange, "searchTypeId");
    final TimeRange result = offsetRange.deriveTimeRange(query, null);
    assertThat(result).isEqualTo(AbsoluteRange.create("2019-11-12T06:00:00.000Z", "2019-11-15T08:00:00.000Z"));
}
Also used : OffsetRange(org.graylog.plugins.views.search.timeranges.OffsetRange) DerivedTimeRange(org.graylog.plugins.views.search.timeranges.DerivedTimeRange) TimeRange(org.graylog2.plugin.indexer.searches.timeranges.TimeRange) Query(org.graylog.plugins.views.search.Query) Test(org.junit.Test)

Aggregations

Query (org.graylog.plugins.views.search.Query)7 DerivedTimeRange (org.graylog.plugins.views.search.timeranges.DerivedTimeRange)7 OffsetRange (org.graylog.plugins.views.search.timeranges.OffsetRange)7 TimeRange (org.graylog2.plugin.indexer.searches.timeranges.TimeRange)7 Test (org.junit.Test)7 SearchType (org.graylog.plugins.views.search.SearchType)2