use of org.graylog.storage.elasticsearch7.views.searchtypes.pivot.ESPivot in project graylog2-server by Graylog2.
the class ESPivotTest method setUp.
@Before
public void setUp() throws Exception {
bucketHandlers = new HashMap<>();
seriesHandlers = new HashMap<>();
this.esPivot = new ESPivot(bucketHandlers, seriesHandlers);
when(pivot.id()).thenReturn("dummypivot");
}
use of org.graylog.storage.elasticsearch7.views.searchtypes.pivot.ESPivot in project graylog2-server by Graylog2.
the class ESPivotTest method includesCustomNameinResultIfPresent.
@Test
public void includesCustomNameinResultIfPresent() throws InvalidRangeParametersException {
final ESPivot esPivot = new ESPivot(Collections.emptyMap(), Collections.emptyMap());
final Pivot pivot = Pivot.builder().id("somePivotId").name("customPivot").series(Collections.emptyList()).rollup(false).build();
final long documentCount = 424242;
when(queryResult.getTotal()).thenReturn(documentCount);
final MetricAggregation mockMetricAggregation = createTimestampRangeAggregations((double) new Date().getTime(), (double) new Date().getTime());
when(queryResult.getAggregations()).thenReturn(mockMetricAggregation);
when(query.effectiveTimeRange(pivot)).thenReturn(RelativeRange.create(300));
final SearchType.Result result = esPivot.doExtractResult(null, query, pivot, queryResult, null, null);
assertThat(result.name()).contains("customPivot");
}
use of org.graylog.storage.elasticsearch7.views.searchtypes.pivot.ESPivot in project graylog2-server by Graylog2.
the class ElasticsearchBackendGeneratedRequestTestBase method setUpSUT.
@Before
public void setUpSUT() {
this.elasticSearchTypeHandlers = new HashMap<>();
final Map<String, ESPivotBucketSpecHandler<? extends BucketSpec, ? extends Aggregation>> bucketHandlers = Collections.emptyMap();
final Map<String, ESPivotSeriesSpecHandler<? extends SeriesSpec, ? extends Aggregation>> seriesHandlers = new HashMap<>();
seriesHandlers.put(Average.NAME, new ESAverageHandler());
seriesHandlers.put(Max.NAME, new ESMaxHandler());
elasticSearchTypeHandlers.put(Pivot.NAME, () -> new ESPivot(bucketHandlers, seriesHandlers));
this.elasticsearchBackend = new ElasticsearchBackend(elasticSearchTypeHandlers, jestClient, indexLookup, new QueryStringDecorators.Fake(), (elasticsearchBackend, ssb, job, query) -> new ESGeneratedQueryContext(elasticsearchBackend, ssb, job, query, fieldTypesLookup), false, objectMapper);
}
use of org.graylog.storage.elasticsearch7.views.searchtypes.pivot.ESPivot in project graylog2-server by Graylog2.
the class ElasticsearchBackendGeneratedRequestTestBase method setUpSUT.
@Before
public void setUpSUT() {
this.elasticSearchTypeHandlers = new HashMap<>();
final Map<String, ESPivotBucketSpecHandler<? extends BucketSpec, ? extends Aggregation>> bucketHandlers = Collections.emptyMap();
final Map<String, ESPivotSeriesSpecHandler<? extends SeriesSpec, ? extends Aggregation>> seriesHandlers = new HashMap<>();
seriesHandlers.put(Average.NAME, new ESAverageHandler());
seriesHandlers.put(Max.NAME, new ESMaxHandler());
elasticSearchTypeHandlers.put(Pivot.NAME, () -> new ESPivot(bucketHandlers, seriesHandlers));
this.elasticsearchBackend = new ElasticsearchBackend(elasticSearchTypeHandlers, client, indexLookup, new QueryStringDecorators.Fake(), (elasticsearchBackend, ssb, job, query) -> new ESGeneratedQueryContext(elasticsearchBackend, ssb, job, query, fieldTypesLookup), false);
}
use of org.graylog.storage.elasticsearch7.views.searchtypes.pivot.ESPivot in project graylog2-server by Graylog2.
the class ESPivotTest method includesCustomNameinResultIfPresent.
@Test
public void includesCustomNameinResultIfPresent() throws InvalidRangeParametersException {
final ESPivot esPivot = new ESPivot(Collections.emptyMap(), Collections.emptyMap());
final Pivot pivot = Pivot.builder().id("somePivotId").name("customPivot").series(Collections.emptyList()).rollup(false).build();
final long documentCount = 424242;
returnDocumentCount(queryResult, documentCount);
final Aggregations mockMetricAggregation = createTimestampRangeAggregations((double) new Date().getTime(), (double) new Date().getTime());
when(queryResult.getAggregations()).thenReturn(mockMetricAggregation);
when(query.effectiveTimeRange(pivot)).thenReturn(RelativeRange.create(300));
final SearchType.Result result = esPivot.doExtractResult(null, query, pivot, queryResult, null, null);
assertThat(result.name()).contains("customPivot");
}
Aggregations