### Question:
PathMappingIterator { public <T> Iterable<T> mapPaths(final Iterable<Path> paths, final PathMapper<T> pathMapper) { assert paths != null; assert pathMapper != null; IterationController.IterationMode mode = getIterationControl(pathMapper); switch (mode) { case EAGER: case EAGER_STOP_ON_NULL: List<T> result = new ArrayList<T>(); try { for (Path path : paths) { T mapped = pathMapper.mapPath(path); if (mapped == null && mode == IterationController.IterationMode.EAGER_STOP_ON_NULL) break; result.add(mapped); } } finally { close(paths); } return result; case EAGER_IGNORE_RESULTS: try { for (Path path : paths) { pathMapper.mapPath(path); } } finally { close(paths); } return null; case LAZY: return new IterableWrapper<T, Path>(paths) { @Override protected T underlyingObjectToObject(Path path) { return pathMapper.mapPath(path); } }; default: throw new IllegalStateException("Unknown IterationControl " + mode); } }  Iterable<T> mapPaths(final Iterable<Path> paths, final PathMapper<T> pathMapper);  }### Answer:
@Test public void defaultPathMapperIsLazy() { final AtomicInteger counter=new AtomicInteger(); PathMapper<Integer> pathMapper = new PathMapper<Integer>() { @Override public Integer mapPath(Path path) { return counter.incrementAndGet(); } }; Iterable<Integer> result = new PathMappingIterator().mapPaths(paths(), pathMapper); assertEquals(0, counter.get()); for (Integer integer : result) ; assertEquals(PATHS_COUNT, counter.get()); }
@Test public void defaultPathCallbackIsEagerAndIgnoresResult() { final AtomicInteger counter=new AtomicInteger(); PathMapper.WithoutResult pathMapper = new PathMapper.WithoutResult() { @Override public void eachPath(Path path) { counter.incrementAndGet(); } }; Iterable<Void> result = new PathMappingIterator().mapPaths(paths(), pathMapper); assertEquals(PATHS_COUNT, counter.get()); assertNull("no result",result); assertEquals(PATHS_COUNT, counter.get()); }