Search in sources :

Example 1 with GoogleDriveDatasetRuntime

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());
    }
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) Schema(org.apache.avro.Schema) GoogleDriveDataSource(org.talend.components.google.drive.runtime.data.GoogleDriveDataSource) GoogleDriveInputReader(org.talend.components.google.drive.runtime.data.GoogleDriveInputReader) GoogleDriveDatasetRuntime(org.talend.components.google.drive.runtime.data.GoogleDriveDatasetRuntime) Test(org.junit.Test)

Example 2 with GoogleDriveDatasetRuntime

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);
            }
        }
    });
}
Also used : GoogleDriveUtils(org.talend.components.google.drive.runtime.GoogleDriveUtils) GoogleDriveDatasetRuntime(org.talend.components.google.drive.runtime.data.GoogleDriveDatasetRuntime) IOException(java.io.IOException) After(org.junit.After)

Example 3 with GoogleDriveDatasetRuntime

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));
    }
}
Also used : GoogleDriveDatasetProperties(org.talend.components.google.drive.data.GoogleDriveDatasetProperties) GoogleDriveInputProperties(org.talend.components.google.drive.data.GoogleDriveInputProperties) GoogleDriveUtils(org.talend.components.google.drive.runtime.GoogleDriveUtils) GoogleDriveDatasetRuntime(org.talend.components.google.drive.runtime.data.GoogleDriveDatasetRuntime) GoogleDriveDatastoreProperties(org.talend.components.google.drive.data.GoogleDriveDatastoreProperties) Before(org.junit.Before)

Aggregations

GoogleDriveDatasetRuntime (org.talend.components.google.drive.runtime.data.GoogleDriveDatasetRuntime)3 GoogleDriveUtils (org.talend.components.google.drive.runtime.GoogleDriveUtils)2 IOException (java.io.IOException)1 Schema (org.apache.avro.Schema)1 IndexedRecord (org.apache.avro.generic.IndexedRecord)1 After (org.junit.After)1 Before (org.junit.Before)1 Test (org.junit.Test)1 GoogleDriveDatasetProperties (org.talend.components.google.drive.data.GoogleDriveDatasetProperties)1 GoogleDriveDatastoreProperties (org.talend.components.google.drive.data.GoogleDriveDatastoreProperties)1 GoogleDriveInputProperties (org.talend.components.google.drive.data.GoogleDriveInputProperties)1 GoogleDriveDataSource (org.talend.components.google.drive.runtime.data.GoogleDriveDataSource)1 GoogleDriveInputReader (org.talend.components.google.drive.runtime.data.GoogleDriveInputReader)1