ElementAggregator extends TupleAdaptedBinaryOperatorComposite<String> { @Override public List<TupleAdaptedBinaryOperator<String, ?>> getComponents() { if (readOnly) { return Collections.unmodifiableList(super.getComponents()); } return super.getComponents(); }  Element apply(final Element state, final Element element); Properties apply(final Properties state, final Properties properties); @Override List<TupleAdaptedBinaryOperator<String, ?>> getComponents(); void lock(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString();  }
@Test public void shouldBuildAggregator() { final String property1 = "property 1"; final String property2a = "property 2a"; final String property2b = "property 2b"; final String property3 = "property 3"; final BinaryOperator func1 = mock(BinaryOperator.class); final BinaryOperator func2 = mock(BinaryOperator.class); final BinaryOperator func3 = mock(BinaryOperator.class); final ElementAggregator aggregator = new ElementAggregator.Builder() .select(property1) .execute(func1) .select(property2a, property2b) .execute(func2) .select(property3) .execute(func3) .build(); int i = 0; TupleAdaptedBinaryOperator<String, ?> adaptedFunction = aggregator.getComponents().get(i++); assertEquals(1, adaptedFunction.getSelection().length); assertEquals(property1, adaptedFunction.getSelection()[0]); assertSame(func1, adaptedFunction.getBinaryOperator()); adaptedFunction = aggregator.getComponents().get(i++); assertEquals(2, adaptedFunction.getSelection().length); assertEquals(property2a, adaptedFunction.getSelection()[0]); assertEquals(property2b, adaptedFunction.getSelection()[1]); assertSame(func2, adaptedFunction.getBinaryOperator()); adaptedFunction = aggregator.getComponents().get(i++); assertSame(func3, adaptedFunction.getBinaryOperator()); assertEquals(1, adaptedFunction.getSelection().length); assertEquals(property3, adaptedFunction.getSelection()[0]); assertEquals(i, aggregator.getComponents().size()); }
@Test public void shouldReturnModifiableComponentsWhenNotLocked() { final ElementAggregator aggregator = new ElementAggregator(); final List<TupleAdaptedBinaryOperator<String, ?>> components = aggregator.getComponents(); assertDoesNotThrow(() -> components.add(null)); }