use of org.graylog.plugins.views.search.searchtypes.pivot.buckets.Time in project graylog2-server by Graylog2.
the class ESPivotTest method mixedPivotsShouldBeNested.
@Test
public void mixedPivotsShouldBeNested() {
final SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
final ESPivotBucketSpecHandler<? extends BucketSpec, ? extends Aggregation> valuesBucketHandler = mock(ESValuesHandler.class);
mockBucketSpecGeneratesComparableString(valuesBucketHandler);
final ESPivotBucketSpecHandler<? extends BucketSpec, ? extends Aggregation> timeBucketHandler = mock(ESTimeHandler.class);
mockBucketSpecGeneratesComparableString(timeBucketHandler);
bucketHandlers.put(Values.NAME, valuesBucketHandler);
bucketHandlers.put(Time.NAME, timeBucketHandler);
when(queryContext.searchSourceBuilder(pivot)).thenReturn(searchSourceBuilder);
when(queryContext.nextName()).thenReturn("time-agg", "values-agg");
final Time time = Time.builder().field("timestamp").interval(AutoInterval.create()).build();
final Values values = Values.builder().field("action").limit(10).build();
when(pivot.rowGroups()).thenReturn(Collections.singletonList(time));
when(pivot.columnGroups()).thenReturn(Collections.singletonList(values));
this.esPivot.doGenerateQueryPart(job, query, pivot, queryContext);
verify(valuesBucketHandler, times(1)).createAggregation(eq("values-agg"), eq(pivot), eq(values), eq(this.esPivot), eq(queryContext), eq(query));
verify(timeBucketHandler, times(1)).createAggregation(eq("time-agg"), eq(pivot), eq(time), eq(this.esPivot), eq(queryContext), eq(query));
final DocumentContext context = JsonPath.parse(searchSourceBuilder.toString());
extractAggregation(context, "time-agg").isEqualTo("Time{type=time, field=timestamp, interval=AutoInterval{type=auto, scaling=1.0}}");
extractAggregation(context, "time-agg.values-agg").isEqualTo("Values{type=values, field=action, limit=10}");
}
use of org.graylog.plugins.views.search.searchtypes.pivot.buckets.Time in project graylog2-server by Graylog2.
the class ESPivotTest method rowPivotsShouldBeNested.
@Test
public void rowPivotsShouldBeNested() {
final SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
final ESPivotBucketSpecHandler<? extends BucketSpec, ? extends Aggregation> valuesBucketHandler = mock(ESValuesHandler.class);
mockBucketSpecGeneratesComparableString(valuesBucketHandler);
final ESPivotBucketSpecHandler<? extends BucketSpec, ? extends Aggregation> timeBucketHandler = mock(ESTimeHandler.class);
mockBucketSpecGeneratesComparableString(timeBucketHandler);
bucketHandlers.put(Values.NAME, valuesBucketHandler);
bucketHandlers.put(Time.NAME, timeBucketHandler);
when(queryContext.searchSourceBuilder(pivot)).thenReturn(searchSourceBuilder);
when(queryContext.nextName()).thenReturn("time-agg", "values-agg");
final Time time = Time.builder().field("timestamp").interval(AutoInterval.create()).build();
final Values values = Values.builder().field("action").limit(10).build();
when(pivot.rowGroups()).thenReturn(ImmutableList.of(time, values));
this.esPivot.doGenerateQueryPart(job, query, pivot, queryContext);
verify(valuesBucketHandler, times(1)).createAggregation(eq("values-agg"), eq(pivot), eq(values), eq(this.esPivot), eq(queryContext), eq(query));
verify(timeBucketHandler, times(1)).createAggregation(eq("time-agg"), eq(pivot), eq(time), eq(this.esPivot), eq(queryContext), eq(query));
final DocumentContext context = JsonPath.parse(searchSourceBuilder.toString());
extractAggregation(context, "time-agg").isEqualTo("Time{type=time, field=timestamp, interval=AutoInterval{type=auto, scaling=1.0}}");
extractAggregation(context, "time-agg.values-agg").isEqualTo("Values{type=values, field=action, limit=10}");
}
use of org.graylog.plugins.views.search.searchtypes.pivot.buckets.Time in project graylog2-server by Graylog2.
the class ESPivotTest method rowPivotsShouldBeNested.
@Test
public void rowPivotsShouldBeNested() {
final SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
final ESPivotBucketSpecHandler<? extends BucketSpec, ? extends Aggregation> valuesBucketHandler = mock(ESValuesHandler.class);
mockBucketSpecGeneratesComparableString(valuesBucketHandler);
final ESPivotBucketSpecHandler<? extends BucketSpec, ? extends Aggregation> timeBucketHandler = mock(ESTimeHandler.class);
mockBucketSpecGeneratesComparableString(timeBucketHandler);
bucketHandlers.put(Values.NAME, valuesBucketHandler);
bucketHandlers.put(Time.NAME, timeBucketHandler);
when(queryContext.searchSourceBuilder(pivot)).thenReturn(searchSourceBuilder);
when(queryContext.nextName()).thenReturn("time-agg", "values-agg");
final Time time = Time.builder().field("timestamp").interval(AutoInterval.create()).build();
final Values values = Values.builder().field("action").limit(10).build();
when(pivot.rowGroups()).thenReturn(ImmutableList.of(time, values));
this.esPivot.doGenerateQueryPart(job, query, pivot, queryContext);
verify(valuesBucketHandler, times(1)).createAggregation(eq("values-agg"), eq(pivot), eq(values), eq(this.esPivot), eq(queryContext), eq(query));
verify(timeBucketHandler, times(1)).createAggregation(eq("time-agg"), eq(pivot), eq(time), eq(this.esPivot), eq(queryContext), eq(query));
final DocumentContext context = JsonPath.parse(searchSourceBuilder.toString());
extractAggregation(context, "time-agg").isEqualTo("Time{type=time, field=timestamp, interval=AutoInterval{type=auto, scaling=1.0}}");
extractAggregation(context, "time-agg.values-agg").isEqualTo("Values{type=values, field=action, limit=10}");
}
use of org.graylog.plugins.views.search.searchtypes.pivot.buckets.Time in project graylog2-server by Graylog2.
the class ESPivotTest method mixedPivotsShouldBeNested.
@Test
public void mixedPivotsShouldBeNested() {
final SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
final ESPivotBucketSpecHandler<? extends BucketSpec, ? extends Aggregation> valuesBucketHandler = mock(ESValuesHandler.class);
mockBucketSpecGeneratesComparableString(valuesBucketHandler);
final ESPivotBucketSpecHandler<? extends BucketSpec, ? extends Aggregation> timeBucketHandler = mock(ESTimeHandler.class);
mockBucketSpecGeneratesComparableString(timeBucketHandler);
bucketHandlers.put(Values.NAME, valuesBucketHandler);
bucketHandlers.put(Time.NAME, timeBucketHandler);
when(queryContext.searchSourceBuilder(pivot)).thenReturn(searchSourceBuilder);
when(queryContext.nextName()).thenReturn("time-agg", "values-agg");
final Time time = Time.builder().field("timestamp").interval(AutoInterval.create()).build();
final Values values = Values.builder().field("action").limit(10).build();
when(pivot.rowGroups()).thenReturn(Collections.singletonList(time));
when(pivot.columnGroups()).thenReturn(Collections.singletonList(values));
this.esPivot.doGenerateQueryPart(job, query, pivot, queryContext);
verify(valuesBucketHandler, times(1)).createAggregation(eq("values-agg"), eq(pivot), eq(values), eq(this.esPivot), eq(queryContext), eq(query));
verify(timeBucketHandler, times(1)).createAggregation(eq("time-agg"), eq(pivot), eq(time), eq(this.esPivot), eq(queryContext), eq(query));
final DocumentContext context = JsonPath.parse(searchSourceBuilder.toString());
extractAggregation(context, "time-agg").isEqualTo("Time{type=time, field=timestamp, interval=AutoInterval{type=auto, scaling=1.0}}");
extractAggregation(context, "time-agg.values-agg").isEqualTo("Values{type=values, field=action, limit=10}");
}
use of org.graylog.plugins.views.search.searchtypes.pivot.buckets.Time in project graylog2-server by Graylog2.
the class ESPivotTest method columnPivotsShouldBeNested.
@Test
public void columnPivotsShouldBeNested() {
final SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
final ESPivotBucketSpecHandler<? extends BucketSpec, ? extends Aggregation> valuesBucketHandler = mock(ESValuesHandler.class);
mockBucketSpecGeneratesComparableString(valuesBucketHandler);
final ESPivotBucketSpecHandler<? extends BucketSpec, ? extends Aggregation> timeBucketHandler = mock(ESTimeHandler.class);
mockBucketSpecGeneratesComparableString(timeBucketHandler);
bucketHandlers.put(Values.NAME, valuesBucketHandler);
bucketHandlers.put(Time.NAME, timeBucketHandler);
when(queryContext.searchSourceBuilder(pivot)).thenReturn(searchSourceBuilder);
when(queryContext.nextName()).thenReturn("values-agg", "time-agg");
final Values values = Values.builder().field("action").limit(10).build();
final Time time = Time.builder().field("timestamp").interval(AutoInterval.create()).build();
when(pivot.columnGroups()).thenReturn(ImmutableList.of(values, time));
this.esPivot.doGenerateQueryPart(job, query, pivot, queryContext);
verify(valuesBucketHandler, times(1)).createAggregation(eq("values-agg"), eq(pivot), eq(values), eq(this.esPivot), eq(queryContext), eq(query));
verify(timeBucketHandler, times(1)).createAggregation(eq("time-agg"), eq(pivot), eq(time), eq(this.esPivot), eq(queryContext), eq(query));
final DocumentContext context = JsonPath.parse(searchSourceBuilder.toString());
extractAggregation(context, "values-agg").isEqualTo("Values{type=values, field=action, limit=10}");
extractAggregation(context, "values-agg.time-agg").isEqualTo("Time{type=time, field=timestamp, interval=AutoInterval{type=auto, scaling=1.0}}");
}
Aggregations