use of org.talend.components.google.drive.runtime.data.GoogleDriveDatasetRuntime in project components by Talend.
the class GoogleDriveDatasetTestIT method testDatasetRuntime.
@Test
public void testDatasetRuntime() throws Exception {
GoogleDriveDatasetRuntime rt = new GoogleDriveDatasetRuntime();
rt.initialize(null, dataset);
Schema schema = rt.getSchema();
LOG.debug("schema = {}.", schema);
assertNotNull(schema);
counted = 0;
rt.getSample(LIMIT, new org.talend.daikon.java8.Consumer<IndexedRecord>() {
@Override
public void accept(IndexedRecord indexedRecord) {
counted++;
}
});
assertTrue(LIMIT >= counted);
GoogleDriveDataSource source = rt.createDataSource(properties);
GoogleDriveInputReader reader = (GoogleDriveInputReader) source.createReader(null);
assertTrue(reader.start());
IndexedRecord record = reader.getCurrent();
LOG.debug("record = {}.", record);
while (reader.advance()) {
assertNotNull(reader.getCurrent());
}
}
use of org.talend.components.google.drive.runtime.data.GoogleDriveDatasetRuntime in project components by Talend.
the class GoogleDriveDatasetTestIT method tearDown.
@After
public void tearDown() throws Exception {
GoogleDriveDatasetRuntime rt = new GoogleDriveDatasetRuntime();
rt.initialize(null, dataset);
final GoogleDriveUtils utils = rt.createDataSource(properties).getDriveUtils();
createdFolders.forEach(new Consumer<String>() {
@Override
public void accept(String s) {
try {
utils.deleteResourceById(s, false);
} catch (IOException e) {
LOG.error("Error during folder id {} removing : {}.", s, e);
}
}
});
}
use of org.talend.components.google.drive.runtime.data.GoogleDriveDatasetRuntime in project components by Talend.
the class GoogleDriveDatasetTestIT method setUp.
@Before
public void setUp() throws Exception {
datastore = new GoogleDriveDatastoreProperties("test");
datastore.setupProperties();
datastore.setupLayout();
dataset = new GoogleDriveDatasetProperties("test");
dataset.setupProperties();
dataset.setupLayout();
dataset.datastore.setReference(datastore);
dataset.listMode.setValue(ListMode.Both);
dataset.folder.setValue("root");
dataset.includeSubDirectories.setValue(true);
dataset.includeTrashedFiles.setValue(false);
properties = new GoogleDriveInputProperties("test");
properties.setupProperties();
properties.setupLayout();
properties.setDatasetProperties(dataset);
//
createdFolders = new ArrayList<>();
GoogleDriveDatasetRuntime rt = new GoogleDriveDatasetRuntime();
rt.initialize(null, dataset);
GoogleDriveUtils utils = rt.createDataSource(properties).getDriveUtils();
for (int i = 0; i < LIMIT; i++) {
createdFolders.add(utils.createFolder("root", "folder" + i));
}
}
Aggregations