use of com.google.api.services.drive.model.File in project components by Talend.
the class GoogleDriveCreateRuntimeTest method testManyResourcesMatching.
@Test(expected = ComponentException.class)
public void testManyResourcesMatching() throws Exception {
FileList flA = new FileList();
List<File> fs = new ArrayList<>();
File fA = new File();
fA.setId("A");
fs.add(fA);
File fAp = new File();
fAp.setId("A");
fs.add(fAp);
flA.setFiles(fs);
when(drive.files().list().setQ(eq(qA)).execute()).thenReturn(flA);
properties.parentFolder.setValue("/A");
testRuntime.initialize(container, properties);
testRuntime.runAtDriver(container);
fail("Should not be here");
}
use of com.google.api.services.drive.model.File in project components by Talend.
the class GoogleDriveDeleteRuntimeTest 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);
testRuntime = spy(GoogleDriveDeleteRuntime.class);
doReturn(drive).when(testRuntime).getDriveService();
when(drive.files().update(anyString(), any(File.class)).execute()).thenReturn(null);
when(drive.files().delete(anyString()).execute()).thenReturn(null);
deleteFileList = new FileList();
List<File> files = new ArrayList<>();
File f = new File();
f.setId(FOLDER_DELETE_ID);
files.add(f);
deleteFileList.setFiles(files);
}
use of com.google.api.services.drive.model.File in project components by Talend.
the class GoogleDriveGetRuntimeTest method testRunAtDriverWithPath.
@Test
public void testRunAtDriverWithPath() throws Exception {
String qA = "name='A' and 'root' in parents and mimeType='application/vnd.google-apps.folder'";
String qB = "name='B' and 'A' in parents and mimeType='application/vnd.google-apps.folder'";
String qC = "name='C' and 'B' in parents and mimeType='application/vnd.google-apps.folder'";
File file = new File();
file.setId("fileName-id");
file.setMimeType(GoogleDriveMimeTypes.MIME_TYPE_GOOGLE_DOCUMENT);
when(drive.files().list().setQ(eq(qA)).execute()).thenReturn(createFolderFileList("A", false));
when(drive.files().list().setQ(eq(qB)).execute()).thenReturn(createFolderFileList("B", false));
when(drive.files().list().setQ(eq(qC)).execute()).thenReturn(createFolderFileList("C", false));
when(drive.files().get(anyString()).setFields(anyString()).execute()).thenReturn(file);
//
properties.file.setValue("/A/B/C");
testRuntime.initialize(container, properties);
testRuntime.runAtDriver(container);
assertEquals("C", container.getComponentData(TEST_CONTAINER, getStudioName(GoogleDriveGetDefinition.RETURN_FILE_ID)));
assertNull(container.getComponentData(TEST_CONTAINER, getStudioName(GoogleDriveGetDefinition.RETURN_CONTENT)));
}
use of com.google.api.services.drive.model.File in project components by Talend.
the class GoogleDriveGetRuntimeTest method testManyFiles.
@Test(expected = ComponentException.class)
public void testManyFiles() throws Exception {
FileList files = new FileList();
List<File> fl = new ArrayList<>();
File f1 = new File();
fl.add(f1);
File f2 = new File();
fl.add(f2);
files.setFiles(fl);
String q1 = "name='A' and 'root' in parents and mimeType='application/vnd.google-apps.folder'";
when(drive.files().list().setQ(q1).execute()).thenReturn(files);
when(drive.files().list().setQ(anyString()).execute()).thenReturn(files);
//
properties.file.setValue("/A");
testRuntime.initialize(container, properties);
testRuntime.runAtDriver(container);
fail("Should not be here");
}
use of com.google.api.services.drive.model.File in project components by Talend.
the class GoogleDriveGetRuntimeTest method testRunAtDriverForGoogleDoc.
@Test
public void testRunAtDriverForGoogleDoc() throws Exception {
File file = new File();
file.setId("fileName-id");
file.setMimeType(GoogleDriveMimeTypes.MIME_TYPE_GOOGLE_DOCUMENT);
when(drive.files().get(anyString()).setFields(anyString()).execute()).thenReturn(file);
//
testRuntime.initialize(container, properties);
testRuntime.runAtDriver(container);
assertEquals(FILE_GET_ID, container.getComponentData(TEST_CONTAINER, getStudioName(GoogleDriveGetDefinition.RETURN_FILE_ID)));
assertNull(container.getComponentData(TEST_CONTAINER, getStudioName(GoogleDriveGetDefinition.RETURN_CONTENT)));
}
Aggregations