### Question:
ActiveWarnings implements Iterable<Warning> { @Override public Iterator<Warning> iterator() { return stream(warnings.spliterator(), false) .filter(Warning::active) .iterator(); } ActiveWarnings(Iterable<Warning> warnings); @Override Iterator<Warning> iterator();  }### Answer:
@Test public void testOne() { Warning activeWarning = new FakeWarning(true, "Active warning"); List<Warning> fakes = asList(new FakeWarning(false, "Inactive warning"), activeWarning, new FakeWarning(false, "Other inactive warning") ); Iterator<Warning> iterator = new ActiveWarnings(fakes).iterator(); assertTrue(iterator.hasNext()); assertEquals(activeWarning,iterator.next()); assertFalse(iterator.hasNext()); }
@Test public void testNone() { List<Warning> fakes = asList(new FakeWarning(false, "Inactive warning"), new FakeWarning(false, "Other inactive warning") ); Iterator<Warning> iterator = new ActiveWarnings(fakes).iterator(); assertFalse(iterator.hasNext()); }