Flatten { public static <T> Iterables<T> iterables() { return new Iterables<>(); }  static PCollections<T> pCollections(); static Iterables<T> iterables();  }
@Test @Category(ValidatesRunner.class) public void testFlattenIterables() { PCollection<Iterable<String>> input = p.apply( Create.<Iterable<String>>of(LINES).withCoder(IterableCoder.of(StringUtf8Coder.of()))); PCollection<String> output = input.apply(Flatten.iterables()); PAssert.that(output).containsInAnyOrder(LINES_ARRAY); p.run(); }
@Test @Category(ValidatesRunner.class) public void testFlattenIterablesLists() { PCollection<List<String>> input = p.apply(Create.<List<String>>of(LINES).withCoder(ListCoder.of(StringUtf8Coder.of()))); PCollection<String> output = input.apply(Flatten.iterables()); PAssert.that(output).containsInAnyOrder(LINES_ARRAY); p.run(); }
@Test @Category(ValidatesRunner.class) public void testFlattenIterablesSets() { Set<String> linesSet = ImmutableSet.copyOf(LINES); PCollection<Set<String>> input = p.apply(Create.<Set<String>>of(linesSet).withCoder(SetCoder.of(StringUtf8Coder.of()))); PCollection<String> output = input.apply(Flatten.iterables()); PAssert.that(output).containsInAnyOrder(LINES_ARRAY); p.run(); }
@Test @Category(ValidatesRunner.class) public void testFlattenIterablesCollections() { Set<String> linesSet = ImmutableSet.copyOf(LINES); PCollection<Collection<String>> input = p.apply( Create.<Collection<String>>of(linesSet) .withCoder(CollectionCoder.of(StringUtf8Coder.of()))); PCollection<String> output = input.apply(Flatten.iterables()); PAssert.that(output).containsInAnyOrder(LINES_ARRAY); p.run(); }
@Test @Category(ValidatesRunner.class) public void testFlattenIterablesEmpty() { PCollection<Iterable<String>> input = p.apply( Create.<Iterable<String>>of(NO_LINES) .withCoder(IterableCoder.of(StringUtf8Coder.of()))); PCollection<String> output = input.apply(Flatten.iterables()); PAssert.that(output).containsInAnyOrder(NO_LINES_ARRAY); p.run(); }