@Test @SuppressWarnings("unchecked") public void hasNext() { Predicate<Line> predicate = mock(Predicate.class); LineSequence lineSequence = LineSequence.create("one"); Iterator<Line> iterator = new LinesIterable(lineSequence, predicate).iterator(); assertFalse(iterator.hasNext()); doReturn(true).when(predicate).apply(any(Line.class)); assertTrue(iterator.hasNext()); lineSequence.advance(); assertFalse(iterator.hasNext()); }
@Override public Iterator<Line> iterator() { return new LinesIterator(); }
LinesIterable implements Iterable<Line> { @Override public Iterator<Line> iterator() { return new LinesIterator(); } }
LinesIterable implements Iterable<Line> { @Override public Iterator<Line> iterator() { return new LinesIterator(); } LinesIterable(LineSequence lineSequence, Predicate<Line> predicate); }
LinesIterable implements Iterable<Line> { @Override public Iterator<Line> iterator() { return new LinesIterator(); } LinesIterable(LineSequence lineSequence, Predicate<Line> predicate); @Override Iterator<Line> iterator(); }
LinesIterable implements Iterable<Line> { @Override public Iterator<Line> iterator() { return new LinesIterator(); } LinesIterable(LineSequence lineSequence, Predicate<Line> predicate); @Override Iterator<Line> iterator();  }