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