### Question:
PredicateFilter implements SearchFilter { @Override public Collection<FluentWebElement> applyFilter(Collection<FluentWebElement> elements) { return elements.stream().filter(predicate).collect(Collectors.toList()); } PredicateFilter(Predicate<FluentWebElement> predicate); @Override String getCssFilter(); @Override boolean isCssFilterSupported(); @Override Collection<FluentWebElement> applyFilter(Collection<FluentWebElement> elements);  }### Answer:
@Test public void shouldApplyFilter() { when(webElement1.isSelected()).thenReturn(true); when(webElement3.isSelected()).thenReturn(true); FluentWebElement fluentWebElem1 = new FluentWebElement(webElement1, control, instantiator); FluentWebElement fluentWebElem2 = new FluentWebElement(mock(WebElement.class), control, instantiator); FluentWebElement fluentWebElem3 = new FluentWebElement(webElement3, control, instantiator); FluentWebElement fluentWebElem4 = new FluentWebElement(mock(WebElement.class), control, instantiator); List<FluentWebElement> elementsToFilter = Lists.newArrayList(fluentWebElem1, fluentWebElem2, fluentWebElem3, fluentWebElem4); List<FluentWebElement> filteredElements = Lists.newArrayList(fluentWebElem1, fluentWebElem3); PredicateFilter predicateFilter = new PredicateFilter(FluentWebElement::selected); assertThat(predicateFilter.applyFilter(elementsToFilter)).containsExactlyInAnyOrderElementsOf(filteredElements); }