use of org.graylog2.plugin.indexer.searches.timeranges.InvalidRangeParametersException in project graylog2-server by Graylog2.
the class DashboardWidgetCreator method fromRequest.
public DashboardWidget fromRequest(String widgetId, AddWidgetRequest awr, String userId) throws DashboardWidget.NoSuchWidgetTypeException, InvalidRangeParametersException, InvalidWidgetConfigurationException {
final String id = isNullOrEmpty(widgetId) ? UUID.randomUUID().toString() : widgetId;
// Build timerange.
final Map<String, Object> timerangeConfig = (Map<String, Object>) awr.config().get("timerange");
final TimeRange timeRange = timeRangeFactory.create(timerangeConfig);
return buildDashboardWidget(awr.type(), id, awr.description(), 0, awr.config(), timeRange, userId);
}
use of org.graylog2.plugin.indexer.searches.timeranges.InvalidRangeParametersException in project graylog2-server by Graylog2.
the class ValueReferenceTypeIdResolverTest method testSerialization.
@Test
public void testSerialization() throws IOException, InvalidRangeParametersException {
final RelativeRangeEntity relativeRange = RelativeRangeEntity.of(RelativeRange.create(300));
final String json = objectMapper.writeValueAsString(relativeRange);
assertThat(json).isNotNull();
}
use of org.graylog2.plugin.indexer.searches.timeranges.InvalidRangeParametersException in project graylog2-server by Graylog2.
the class QueryEffectiveTimeRangeTest method returnQueryTimeRangeIfNoSearchTypeTimeRangeAndNoGlobalOverride.
@Test
public void returnQueryTimeRangeIfNoSearchTypeTimeRangeAndNoGlobalOverride() throws InvalidRangeParametersException {
final SearchType searchType = mock(SearchType.class);
when(searchType.timerange()).thenReturn(Optional.empty());
final Query queryWithTimeRange = query.toBuilder().timerange(RelativeRange.create(3600)).build();
final TimeRange result = queryWithTimeRange.effectiveTimeRange(searchType);
assertThat(result).isEqualTo(RelativeRange.create(3600));
}
use of org.graylog2.plugin.indexer.searches.timeranges.InvalidRangeParametersException in project graylog2-server by Graylog2.
the class QueryEffectiveTimeRangeTest method returnGlobalOverrideTimeRangeIfPresent.
@Test
public void returnGlobalOverrideTimeRangeIfPresent() throws InvalidRangeParametersException {
final SearchType searchType = mock(SearchType.class);
when(searchType.timerange()).thenReturn(Optional.of(DerivedTimeRange.of(RelativeRange.create(7200))));
final Query queryWithTimeRange = query.toBuilder().timerange(RelativeRange.create(3600)).globalOverride(GlobalOverride.builder().timerange(RelativeRange.create(600)).build()).build();
final TimeRange result = queryWithTimeRange.effectiveTimeRange(searchType);
assertThat(result).isEqualTo(RelativeRange.create(600));
}
use of org.graylog2.plugin.indexer.searches.timeranges.InvalidRangeParametersException in project graylog2-server by Graylog2.
the class ESTimeHandlerTest method timeSpecIntervalIsCalculatedOnPivotTimerangeIfOverridden.
@Test
public void timeSpecIntervalIsCalculatedOnPivotTimerangeIfOverridden() throws InvalidRangeParametersException {
final ArgumentCaptor<TimeRange> timeRangeCaptor = ArgumentCaptor.forClass(TimeRange.class);
when(interval.toDateInterval(timeRangeCaptor.capture())).thenReturn(DateInterval.days(1));
when(pivot.timerange()).thenReturn(Optional.of(DerivedTimeRange.of(RelativeRange.create(4242))));
this.esTimeHandler.doCreateAggregation("foobar", pivot, time, esPivot, queryContext, query);
final TimeRange argumentTimeRange = timeRangeCaptor.getValue();
assertThat(argumentTimeRange).isEqualTo(RelativeRange.create(4242));
}
Aggregations