use of org.talend.components.test.RecordSet in project components by Talend.
the class SimpleFileIODatasetRuntimeTest method testGetSampleAvro.
@Test
public void testGetSampleAvro() throws Exception {
RecordSet rs = getSimpleTestData(0);
writeRandomAvroFile(mini.getFs(), "/user/test/input.avro", rs);
String fileSpec = mini.getFs().getUri().resolve("/user/test/input.avro").toString();
// Configure the component.
SimpleFileIODatasetProperties props = createDatasetProperties();
props.format.setValue(SimpleFileIOFormat.AVRO);
props.path.setValue(fileSpec);
// Create the runtime.
SimpleFileIODatasetRuntime runtime = new SimpleFileIODatasetRuntime();
runtime.initialize(null, props);
// Attempt to get a sample using the runtime methods.
final List<IndexedRecord> actual = new ArrayList<>();
runtime.getSample(100, new Consumer<IndexedRecord>() {
@Override
public void accept(IndexedRecord ir) {
actual.add(ir);
}
});
// Check the expected values.
assertThat(actual, (Matcher) equalTo(rs.getAllData()));
}
Aggregations