Convert { public static <InputT, OutputT> PTransform<PCollection<InputT>, PCollection<OutputT>> to( Class<OutputT> clazz) { return to(TypeDescriptor.of(clazz)); }  static PTransform<PCollection<InputT>, PCollection<Row>> toRows(); static PTransform<PCollection<Row>, PCollection<OutputT>> fromRows(
      Class<OutputT> clazz); static PTransform<PCollection<Row>, PCollection<OutputT>> fromRows(
      TypeDescriptor<OutputT> typeDescriptor); static PTransform<PCollection<InputT>, PCollection<OutputT>> to(
      Class<OutputT> clazz); static PTransform<PCollection<InputT>, PCollection<OutputT>> to(
      TypeDescriptor<OutputT> typeDescriptor);  }
@Test @Category(NeedsRunner.class) public void testGeneralConvert() { PCollection<POJO2> pojos = pipeline.apply(Create.of(new POJO1())).apply(Convert.to(POJO2.class)); PAssert.that(pojos).containsInAnyOrder(new POJO2()); pipeline.run(); }
@Test @Category(NeedsRunner.class) public void testFromRowsUnboxingRow() { PCollection<POJO1Nested> pojos = pipeline .apply(Create.of(new POJO1())) .apply(Select.fieldNames("field3")) .apply(Convert.to(TypeDescriptor.of(POJO1Nested.class))); PAssert.that(pojos).containsInAnyOrder(new POJO1Nested()); pipeline.run(); }
@Test @Category(NeedsRunner.class) public void testFromRowsUnboxingPrimitive() { PCollection<Long> longs = pipeline .apply(Create.of(new POJO1())) .apply(Select.fieldNames("field2")) .apply(Convert.to(TypeDescriptors.longs())); PAssert.that(longs).containsInAnyOrder((Long) EXPECTED_ROW1.getValue("field2")); pipeline.run(); }