use of uk.gov.gchq.koryphe.binaryoperator.KorypheBinaryOperator in project Gaffer by gchq.
the class ElementAggregatorTest method shouldAggregateElementUsingKorypheBinaryOperator.
@Test
public void shouldAggregateElementUsingKorypheBinaryOperator() {
// Given
final String reference = "reference1";
final BinaryOperator<Integer> function = new KorypheBinaryOperator<Integer>() {
@Override
public Integer _apply(final Integer a, final Integer b) {
return a + b;
}
};
final ElementAggregator aggregator = new ElementAggregator.Builder().select(reference).execute(function).build();
final Edge edge1 = new Edge.Builder().property(reference, 1).build();
final Edge edge2 = new Edge.Builder().property(reference, 2).build();
// When
final Element result = aggregator.apply(edge1, edge2);
// Then
assertEquals(3, result.getProperty(reference));
}
Aggregations