use of org.opensearch.search.aggregations.PipelineAggregationBuilder in project OpenSearch by opensearch-project.
the class SerialDifferenceTests method testInvalidParent.
public void testInvalidParent() throws IOException {
final Set<PipelineAggregationBuilder> aggBuilders = new HashSet<>();
aggBuilders.add(createTestAggregatorFactory());
AggregationBuilder parent = mock(AggregationBuilder.class);
when(parent.getName()).thenReturn("name");
assertThat(validate(parent, new SerialDiffPipelineAggregationBuilder("name", "invalid_agg>metric")), equalTo("Validation Failed: 1: serial_diff aggregation [name] must have a histogram, " + "date_histogram or auto_date_histogram as parent;"));
}
use of org.opensearch.search.aggregations.PipelineAggregationBuilder in project OpenSearch by opensearch-project.
the class DerivativeTests method testValidateException.
/**
* The validation should throw an IllegalArgumentException, since parent
* aggregation is not a type of HistogramAggregatorFactory,
* DateHistogramAggregatorFactory or AutoDateHistogramAggregatorFactory.
*/
public void testValidateException() throws IOException {
final Set<PipelineAggregationBuilder> aggBuilders = new HashSet<>();
aggBuilders.add(new DerivativePipelineAggregationBuilder("deriv", "der"));
AggregationBuilder parent = mock(AggregationBuilder.class);
when(parent.getName()).thenReturn("name");
assertThat(validate(parent, new DerivativePipelineAggregationBuilder("name", "invalid_agg>metric")), equalTo("Validation Failed: 1: derivative aggregation [name] must have a histogram, " + "date_histogram or auto_date_histogram as parent;"));
}
use of org.opensearch.search.aggregations.PipelineAggregationBuilder in project OpenSearch by opensearch-project.
the class MovAvgTests method testDefaultParsing.
public void testDefaultParsing() throws Exception {
MovAvgPipelineAggregationBuilder expected = new MovAvgPipelineAggregationBuilder("commits_moving_avg", "commits");
String json = "{" + " \"commits_moving_avg\": {" + " \"moving_avg\": {" + " \"buckets_path\": \"commits\"" + " }" + " }" + "}";
PipelineAggregationBuilder newAgg = parse(createParser(JsonXContent.jsonXContent, json));
assertWarnings("The moving_avg aggregation has been deprecated in favor of the moving_fn aggregation.");
assertNotSame(newAgg, expected);
assertEquals(expected, newAgg);
assertEquals(expected.hashCode(), newAgg.hashCode());
}
Aggregations