use of org.talend.components.google.drive.runtime.GoogleDriveUtils 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.GoogleDriveUtils in project components by Talend.
the class GoogleDriveDatasetRuntimeTest method testGetSample.
@Test
public void testGetSample() throws Exception {
rt = spy(rt);
Drive drive = mock(Drive.class, RETURNS_DEEP_STUBS);
GoogleDriveUtils utils = mock(GoogleDriveUtils.class, RETURNS_DEEP_STUBS);
GoogleDriveDataSource source = mock(GoogleDriveDataSource.class);
GoogleDriveInputReader reader = mock(GoogleDriveInputReader.class);
//
doReturn(source).when(rt).createDataSource(any(GoogleDriveInputProperties.class));
doReturn(reader).when(source).createReader(any(RuntimeContainer.class));
doReturn(drive).when(source).getDriveService();
doReturn(utils).when(source).getDriveUtils();
//
rt.initialize(container, ds);
rt.getSample(20, new Consumer<IndexedRecord>() {
@Override
public void accept(IndexedRecord indexedRecord) {
assertNotNull(indexedRecord);
}
});
}
use of org.talend.components.google.drive.runtime.GoogleDriveUtils in project components by Talend.
the class GoogleDriveInputReaderTest method testException.
@Test(expected = ComponentException.class)
public void testException() throws Exception {
dataSource = spy(dataSource);
Drive drive = mock(Drive.class, RETURNS_DEEP_STUBS);
GoogleDriveUtils utils = mock(GoogleDriveUtils.class, RETURNS_DEEP_STUBS);
doReturn(drive).when(dataSource).getDriveService();
doThrow(new IOException()).when(dataSource).getDriveUtils();
dataSource.initialize(container, inputProperties);
reader = (GoogleDriveInputReader) dataSource.createReader(container);
fail("Should not be here");
}
use of org.talend.components.google.drive.runtime.GoogleDriveUtils in project components by Talend.
the class GoogleDriveInputReaderTest method testGetLimit.
@Test
public void testGetLimit() throws Exception {
dataSource = spy(dataSource);
Drive drive = mock(Drive.class, RETURNS_DEEP_STUBS);
GoogleDriveUtils utils = mock(GoogleDriveUtils.class, RETURNS_DEEP_STUBS);
doReturn(drive).when(dataSource).getDriveService();
doReturn(utils).when(dataSource).getDriveUtils();
dataSource.initialize(container, inputProperties);
reader = (GoogleDriveInputReader) dataSource.createReader(container);
reader.setLimit(30);
assertEquals(30, reader.getLimit());
}
use of org.talend.components.google.drive.runtime.GoogleDriveUtils 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