ElementFilter extends TupleAdaptedPredicateComposite<String> { @Override public List<TupleAdaptedPredicate<String, ?>> getComponents() { if (readOnly) { return Collections.unmodifiableList(super.getComponents()); } return super.getComponents(); }  boolean test(final Element element); ValidationResult testWithValidationResult(final Element element); @Override List<TupleAdaptedPredicate<String, ?>> getComponents(); void lock(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString();  }
@Test public void shouldBuildFilter() { final String property1 = "property 1"; final String property2a = "property 2a"; final String property2b = "property 2b"; final String property3 = "property 3"; final Predicate func1 = mock(Predicate.class); final Predicate func2 = mock(Predicate.class); final Predicate func3 = mock(Predicate.class); final ElementFilter filter = new ElementFilter.Builder() .select(property1) .execute(func1) .select(property2a, property2b) .execute(func2) .select(property3) .execute(func3) .build(); int i = 0; TupleAdaptedPredicate<String, ?> adaptedFunction = filter.getComponents().get(i++); assertEquals(1, adaptedFunction.getSelection().length); assertEquals(property1, adaptedFunction.getSelection()[0]); assertSame(func1, adaptedFunction.getPredicate()); adaptedFunction = filter.getComponents().get(i++); assertEquals(2, adaptedFunction.getSelection().length); assertEquals(property2a, adaptedFunction.getSelection()[0]); assertEquals(property2b, adaptedFunction.getSelection()[1]); assertSame(func2, adaptedFunction.getPredicate()); adaptedFunction = filter.getComponents().get(i++); assertSame(func3, adaptedFunction.getPredicate()); assertEquals(1, adaptedFunction.getSelection().length); assertEquals(property3, adaptedFunction.getSelection()[0]); assertEquals(i, filter.getComponents().size()); }
@Test public void shouldReturnModifiableComponentsWhenNotLocked() { final ElementFilter filter = getTestObject(); final List<TupleAdaptedPredicate<String, ?>> components = filter.getComponents(); assertDoesNotThrow(() -> components.add(null)); }