use of com.google.api.services.drive.model.File in project components by Talend.
the class GoogleDriveDeleteReaderTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
//
properties = new GoogleDriveDeleteProperties("test");
properties.setupProperties();
properties = (GoogleDriveDeleteProperties) setupConnectionWithInstalledApplicationWithJson(properties);
//
properties.file.setValue(FOLDER_DELETE);
when(drive.files().update(anyString(), any(File.class)).execute()).thenReturn(null);
when(drive.files().delete(anyString()).execute()).thenReturn(null);
FileList fileList = new FileList();
List<File> files = new ArrayList<>();
File f = new File();
f.setId(FOLDER_DELETE_ID);
files.add(f);
fileList.setFiles(files);
when(drive.files().list().setQ(anyString()).execute()).thenReturn(fileList);
}
use of com.google.api.services.drive.model.File in project components by Talend.
the class GoogleDriveGetReaderTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
//
properties = new GoogleDriveGetProperties("test");
properties.setupProperties();
properties = (GoogleDriveGetProperties) setupConnectionWithInstalledApplicationWithJson(properties);
//
properties.file.setValue("google-drive-get");
FileList fileList = new FileList();
List<File> files = new ArrayList<>();
File f = new File();
f.setId(FILE_GET_ID);
files.add(f);
fileList.setFiles(files);
when(drive.files().list().setQ(anyString()).execute()).thenReturn(fileList);
File file = new File();
file.setId(FILE_GET_ID);
file.setMimeType(GoogleDriveMimeTypes.MIME_TYPE_JSON);
file.setFileExtension("json");
when(drive.files().get(anyString()).setFields(anyString()).execute()).thenReturn(file);
}
use of com.google.api.services.drive.model.File in project components by Talend.
the class GoogleDriveListReaderTest method testStartOnly.
@Test
public void testStartOnly() throws Exception {
FileList fileList = new FileList();
File f = new File();
f.setName("sd");
f.setMimeType("text/text");
f.setId("id-1");
f.setModifiedTime(com.google.api.client.util.DateTime.parseRfc3339("2017-09-29T10:00:00"));
f.setSize(100L);
f.setKind("drive#fileName");
f.setTrashed(false);
f.setParents(Collections.singletonList(FOLDER_ROOT));
f.setWebViewLink("https://toto.com");
fileList.setFiles(Arrays.asList(f));
when(mockList.execute()).thenReturn(fileList);
//
source.initialize(container, properties);
GoogleDriveListReader reader = ((GoogleDriveListReader) source.createReader(container));
assertTrue(reader.start());
IndexedRecord record = (IndexedRecord) reader.getCurrent();
assertNotNull(record);
assertEquals(9, record.getSchema().getFields().size());
assertEquals("id-1", record.get(0));
assertEquals("sd", record.get(1));
assertFalse(reader.advance());
reader.close();
}
use of com.google.api.services.drive.model.File in project components by Talend.
the class GoogleDriveListReaderTest method testAdvance.
@Test
public void testAdvance() throws Exception {
FileList fileList = new FileList();
for (int i = 0; i < 5; i++) {
File f = new File();
f.setName("sd" + i);
f.setMimeType("text/text");
f.setId("id-" + i);
f.setModifiedTime(com.google.api.client.util.DateTime.parseRfc3339("2017-09-29T10:00:00"));
f.setSize(100L);
f.setKind("drive#fileName");
f.setTrashed(false);
f.setParents(Collections.singletonList(FOLDER_ROOT));
f.setWebViewLink("https://toto.com");
fileList.setFiles(Arrays.asList(f));
}
when(mockList.execute()).thenReturn(fileList);
//
properties.folder.setValue("A");
source.initialize(container, properties);
GoogleDriveListReader reader = ((GoogleDriveListReader) source.createReader(container));
assertTrue(reader.start());
while (reader.advance()) {
assertNotNull(reader.getCurrent());
}
reader.close();
}
use of com.google.api.services.drive.model.File in project components by Talend.
the class GoogleDrivePutRuntimeTest method testRunAtDriverOverwriteError.
@Test
public void testRunAtDriverOverwriteError() throws Exception {
FileList hasfilelist = new FileList();
List<File> hfiles = new ArrayList<>();
File hfile = new File();
hfile.setId(FILE_PUT_NAME);
hfiles.add(hfile);
hasfilelist.setFiles(hfiles);
when(drive.files().list().setQ(anyString()).execute()).thenReturn(hasfilelist);
properties.overwrite.setValue(false);
testRuntime.initialize(container, properties);
try {
testRuntime.runAtDriver(container);
fail("Should not be here");
} catch (Exception e) {
}
}
Aggregations