use of org.apache.crunch.io.avro.AvroFileReaderFactoryTest.PojoPerson in project crunch by cloudera.
the class AvroFileSourceTargetTest method testReflect.
@Test
public void testReflect() throws IOException {
Schema pojoPersonSchema = ReflectData.get().getSchema(PojoPerson.class);
GenericRecord savedRecord = new GenericData.Record(pojoPersonSchema);
savedRecord.put("name", "John Doe");
populateGenericFile(Lists.newArrayList(savedRecord), pojoPersonSchema);
Pipeline pipeline = new MRPipeline(AvroFileSourceTargetTest.class);
PCollection<PojoPerson> personCollection = pipeline.read(At.avroFile(avroFile.getAbsolutePath(), Avros.reflects(PojoPerson.class)));
List<PojoPerson> recordList = Lists.newArrayList(personCollection.materialize());
assertEquals(1, recordList.size());
PojoPerson person = recordList.get(0);
assertEquals("John Doe", person.getName());
}
Aggregations