ElasticSearch java存根解析SUM
我有一个方法ElasticSearch java存根解析SUM,java,
elasticsearch,mockito,Java,
elasticsearch,Mockito,我有一个方法getAggregateValue,它需要一个复合聚合(ElasticSearch)和一个键。 编写单元测试;我想模拟var aggregation=aggregations.get(aggKey)以便它返回给定“aggKey”的ParsedSum类型。我该怎么做 private Summary mapCompositeAggregationToFieldSummary(CompositeAggregation.Bucket bucket) { var fi
getAggregateValue
,它需要一个复合聚合(ElasticSearch)和一个键。编写单元测试;我想模拟
var aggregation=aggregations.get(aggKey)
以便它返回给定“aggKey”的ParsedSum
类型。我该怎么做
private Summary mapCompositeAggregationToFieldSummary(CompositeAggregation.Bucket bucket) {
var field1 = getAggregateValue(bucket.getAggregations(), "field1");
}
private Long getAggregateValue(Aggregations aggregations, String aggKey) {
var aggregation = aggregations.get(aggKey);
if (aggregation == null) {
return 0L;
}
return (long)(((ParsedSum)(aggregation)).getValue());
}