### Question:
ClassPathParser implements ClassParser { public void parse(final ClasspathRoot classes, final AccessVisitor v) throws IOException { for (final ElementName each : classes.classNames()) { if (this.filter.test(each)) { parseClass(classes, v, each); } } } ClassPathParser(final Predicate<ElementName> filter);  ClassPathParser(final Predicate<ElementName> filter, final NameTransformer nameTransformer); void parse(final ClasspathRoot classes, final AccessVisitor v);  }### Answer:
@Test public void shouldNotParseClassesThatDoNotMatchFilter() throws IOException { final ElementName foo = ElementName.fromString("foo"); when(this.cp.classNames()).thenReturn(Collections.singleton(foo)); when(this.filter.test(foo)).thenReturn(false); testee.parse(cp, v); verify(cp, never()).getData(foo); }
@Test public void shouldCloseClassInputStreams() throws IOException { final ElementName foo = ElementName.fromString("foo"); when(this.cp.classNames()).thenReturn(Collections.singleton(foo)); when(this.filter.test(foo)).thenReturn(true); final InputStream is = Mockito.mock(InputStream.class); when(this.cp.getData(foo)).thenReturn(is); doThrow(new IOException()).when(is).read(); doThrow(new IOException()).when(is).read(any(), anyInt(), anyInt()); try { this.testee.parse(cp, this.v); } catch (final IOException ex) { } verify(is).close(); }