@Test
public void testComparatorsWithFinalizingAndComparatorNull()
{
String aggName = "billy";
AggregatorFactory aggFactory = EasyMock.createMock(AggregatorFactory.class);
EasyMock.expect(aggFactory.getComparator())
.andReturn(null)
.times(1);
EasyMock.replay(aggFactory);
FinalizingFieldAccessPostAggregator postAgg = buildDecorated(
"final_billy", "joe", ImmutableMap.of(aggName, aggFactory));
List<Object> computedValues = new ArrayList<>();
Map<String, Object> forNull = new HashMap<>();
forNull.put("joe", null);
computedValues.add(postAgg.compute(ImmutableMap.of("joe", "test_val1")));
computedValues.add(postAgg.compute(ImmutableMap.of("joe", "test_val2")));
computedValues.add(postAgg.compute(forNull));
computedValues.add(postAgg.compute(ImmutableMap.of("joe", "test_val4")));
Collections.sort(computedValues, postAgg.getComparator());
Assert.assertArrayEquals(
new Object[]{null, "test_val1", "test_val2", "test_val4"},
computedValues.toArray(new Object[0])
);
EasyMock.verify();
}