ToString { public static PTransform<PCollection<? extends Iterable<?>>, PCollection<String>> iterables() { return iterables(","); } private  ToString(); static PTransform<PCollection<?>, PCollection<String>> elements(); static PTransform<PCollection<? extends KV<?, ?>>, PCollection<String>> kvs(); static PTransform<PCollection<? extends KV<?, ?>>, PCollection<String>> kvs(
      String delimiter); static PTransform<PCollection<? extends Iterable<?>>, PCollection<String>> iterables(); static PTransform<PCollection<? extends Iterable<?>>, PCollection<String>> iterables(
      String delimiter);  }
@Test @Category(NeedsRunner.class) public void testToStringIterable() { ArrayList<Iterable<String>> iterables = new ArrayList<>(); iterables.add(Arrays.asList(new String[] {"one", "two", "three"})); iterables.add(Arrays.asList(new String[] {"four", "five", "six"})); ArrayList<String> expected = new ArrayList<>(); expected.add("one,two,three"); expected.add("four,five,six"); PCollection<Iterable<String>> input = p.apply(Create.of(iterables).withCoder(IterableCoder.of(StringUtf8Coder.of()))); PCollection<String> output = input.apply(ToString.iterables()); PAssert.that(output).containsInAnyOrder(expected); p.run(); }
@Test @Category(NeedsRunner.class) public void testToStringIterableWithDelimiter() { ArrayList<Iterable<String>> iterables = new ArrayList<>(); iterables.add(Arrays.asList(new String[] {"one", "two", "three"})); iterables.add(Arrays.asList(new String[] {"four", "five", "six"})); ArrayList<String> expected = new ArrayList<>(); expected.add("one\ttwo\tthree"); expected.add("four\tfive\tsix"); PCollection<Iterable<String>> input = p.apply(Create.of(iterables).withCoder(IterableCoder.of(StringUtf8Coder.of()))); PCollection<String> output = input.apply(ToString.iterables("\t")); PAssert.that(output).containsInAnyOrder(expected); p.run(); }