in computer-test/src/main/java/org/apache/hugegraph/computer/core/worker/MockMasterComputation.java [265:314]
private void assertAggregatedValueWithError(MasterComputationContext
context) {
Assert.assertThrows(IllegalArgumentException.class, () -> {
context.aggregatedValue(MockMasterComputation.AGGR_INT_SUM,
new LongValue(7L));
}, e -> {
Assert.assertContains("Can't set long value '7' to int aggregator",
e.getMessage());
});
Assert.assertThrows(IllegalArgumentException.class, () -> {
context.aggregatedValue(MockMasterComputation.AGGR_LONG_SUM,
new IntValue(7));
}, e -> {
Assert.assertContains("Can't set int value '7' to long aggregator",
e.getMessage());
});
Assert.assertThrows(IllegalArgumentException.class, () -> {
context.aggregatedValue(MockMasterComputation.AGGR_DOUBLE_SUM,
new FloatValue(7f));
}, e -> {
Assert.assertContains("Can't set float value '7.0' to double ",
e.getMessage());
});
Assert.assertThrows(IllegalArgumentException.class, () -> {
context.aggregatedValue(MockMasterComputation.AGGR_DOUBLE_MIN,
null);
}, e -> {
Assert.assertContains("Can't set value to null for aggregator " +
"'aggr_double_min'", e.getMessage());
});
Assert.assertThrows(IllegalArgumentException.class, () -> {
context.aggregatedValue(MockMasterComputation.AGGR_CUSTOM_INT,
null);
}, e -> {
Assert.assertContains("Can't set value to null for aggregator " +
"'aggr_int'", e.getMessage());
});
Assert.assertThrows(ClassCastException.class, () -> {
context.aggregatedValue(MockMasterComputation.AGGR_CUSTOM_FLOAT,
new IntValue(7));
}, e -> {
Assert.assertContains("IntValue cannot be cast to", e.getMessage());
Assert.assertContains("FloatValue", e.getMessage());
});
}