### Question:
Options { public static <T> Iterable<T> flatten(Iterable<Option<T>> options) { return Lazily.map(somes(options), Options.<T>toValue()); }  static Iterable<Option<T>> somes(Iterable<Option<T>> options); static Iterable<Option<T>> nones(Iterable<Option<T>> options); static Predicate<Option<T>> isSome(); static Predicate<Option<T>> isNone(); static Predicate<Option<T>> hasValue(); static Predicate<Option<T>> hasNoValue(); static Mapper<Option<T>, T> toValue(); static Mapper<Option<T>, T> toValue(
            @SuppressWarnings("unused") Class<T> valueClass); static Iterable<T> flatten(Iterable<Option<T>> options);  }### Answer:
@Test public void flattensIterableOfOptionsToValues() { Iterable<Option<Integer>> options = iterableWith( option(1), option(2), option(3)); Iterable<Integer> expectedValues = iterableWith(1, 2, 3); Iterable<Integer> actualValues = Options.flatten(options); assertThat(actualValues, hasOnlyItemsInOrder(expectedValues)); }
@Test public void filtersNonesWhenFlatteningIterableOfOptions() { Iterable<Option<Integer>> options = iterableWith( option(1), none(Integer.class), option(2), none(Integer.class), option(3)); Iterable<Integer> expectedValues = iterableWith(1, 2, 3); Iterable<Integer> actualValues = Options.flatten(options); assertThat(actualValues, hasOnlyItemsInOrder(expectedValues)); }
@Test(expected = NullPointerException.class) public void throwsNullPointerExceptionWhenFlattenPassedNullIterable() { Iterable<Option<String>> options = null; Options.flatten(options); }