CompositeAggregation extends BucketAggregation { public JsonObject getAfterKey() { return afterKey; } CompositeAggregation(String name, JsonObject agg); @Override List<Entry> getBuckets(); JsonObject getAfterKey();  }
@Test public void testParseAfterKey() { for (String input : Arrays.asList("{" + afterKey + ", " + bucketsArr + "}", "{" + afterKey + "}")) { JsonObject compositeAggregationJson = gson.fromJson( input.replace('\'', '\"'), JsonObject.class); CompositeAggregation compositeAggregation = new CompositeAggregation("composite", compositeAggregationJson); assertEquals("valB", compositeAggregation.getAfterKey().get("field").getAsString()); } }
@Test public void testNoAfterKey() { for (String input : Arrays.asList("{" + bucketsArr + "}", "{" + "}")) { JsonObject compositeAggregationJson = gson.fromJson( input.replace('\'', '\"'), JsonObject.class); CompositeAggregation compositeAggregation = new CompositeAggregation("composite", compositeAggregationJson); assertNull(compositeAggregation.getAfterKey()); } }