Search in sources :

Example 1 with DecoratorProcessor

use of org.graylog2.decorators.DecoratorProcessor in project graylog2-server by Graylog2.

the class SearchResourceTest method restrictTimeRangeReturnsGivenTimeRangeIfNoLimitHasBeenSet.

@Test
public void restrictTimeRangeReturnsGivenTimeRangeIfNoLimitHasBeenSet() {
    when(clusterConfigService.get(SearchesClusterConfig.class)).thenReturn(SearchesClusterConfig.createDefault().toBuilder().queryTimeRangeLimit(Period.ZERO).build());
    final SearchResource resource = new SearchResource(searches, clusterConfigService, decoratorProcessor, searchExecutor) {
    };
    final DateTime from = new DateTime(2015, 1, 15, 12, 0, DateTimeZone.UTC);
    final DateTime to = from.plusYears(1);
    final TimeRange timeRange = AbsoluteRange.create(from, to);
    final TimeRange restrictedTimeRange = resource.restrictTimeRange(timeRange);
    assertThat(restrictedTimeRange).isNotNull();
    assertThat(restrictedTimeRange.getFrom()).isEqualTo(from);
    assertThat(restrictedTimeRange.getTo()).isEqualTo(to);
}
Also used : TimeRange(org.graylog2.plugin.indexer.searches.timeranges.TimeRange) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

TimeRange (org.graylog2.plugin.indexer.searches.timeranges.TimeRange)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1