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"));
}
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"));
}
Aggregations