### Question:
FilteringDecorator implements AccessVisitor { @Override public void apply(final AccessPoint source, final AccessPoint dest, final AccessType type) { if (this.filter.test(dest.getElementName()) && this.filter.test(source.getElementName())) { this.child.apply(source, dest, type); } } FilteringDecorator(final AccessVisitor child, final Predicate<ElementName> filter); @Override void apply(final AccessPoint source, final AccessPoint dest, final AccessType type); @Override void newNode(final ElementName clazz); @Override void newEntryPoint(ElementName clazz); @Override void newAccessPoint(AccessPoint ap);  }### Answer:
@Test public void shouldNotForwardCallWhenFilterDoesNotMatchSource() { when(this.filter.test(this.fooElement)).thenReturn(false); when(this.filter.test(this.barElement)).thenReturn(true); this.testee.apply(this.foo, this.bar, AccessType.COMPOSED); verify(this.child, never()).apply(this.foo, this.bar, AccessType.COMPOSED); }
@Test public void shouldNotForwardCallWhenFilterDoesNotMatchDest() { when(this.filter.test(this.fooElement)).thenReturn(true); when(this.filter.test(this.barElement)).thenReturn(false); this.testee.apply(this.foo, this.bar, AccessType.COMPOSED); verify(this.child, never()).apply(this.foo, this.bar, AccessType.COMPOSED); }
@Test public void shouldForwardCallWhenFilterMatchesSourceAndDest() { when(this.filter.test(this.fooElement)).thenReturn(true); when(this.filter.test(this.barElement)).thenReturn(true); this.testee.apply(this.foo, this.bar, AccessType.COMPOSED); verify(this.child).apply(this.foo, this.bar, AccessType.COMPOSED); }