本文整理匯總了Java中com.google.api.services.drive.model.FileList.setFiles方法的典型用法代碼示例。如果您正苦於以下問題:Java FileList.setFiles方法的具體用法?Java FileList.setFiles怎麽用?Java FileList.setFiles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.api.services.drive.model.FileList
的用法示例。
在下文中一共展示了FileList.setFiles方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testRunAtDriverTooManyFiles
import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
@Test
public void testRunAtDriverTooManyFiles() throws Exception {
FileList hasfilelist = new FileList();
List<File> hfiles = new ArrayList<>();
File hfile = new File();
hfile.setId(FILE_PUT_NAME);
hfiles.add(hfile);
hfiles.add(new File());
hasfilelist.setFiles(hfiles);
when(drive.files().list().setQ(anyString()).execute()).thenReturn(hasfilelist);
properties.overwrite.setValue(true);
testRuntime.initialize(container, properties);
try {
testRuntime.runAtDriver(container);
fail("Should not be here");
} catch (Exception e) {
}
}
示例2: testRunAtDriverOverwrite
import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
@Test
public void testRunAtDriverOverwrite() 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(true);
testRuntime.initialize(container, properties);
testRuntime.runAtDriver(container);
assertNull(container.getComponentData(TEST_CONTAINER, getStudioName(GoogleDrivePutDefinition.RETURN_CONTENT)));
assertEquals(PUT_FILE_ID,
container.getComponentData(TEST_CONTAINER, getStudioName(GoogleDrivePutDefinition.RETURN_FILE_ID)));
assertEquals(PUT_FILE_PARENT_ID,
container.getComponentData(TEST_CONTAINER, getStudioName(GoogleDrivePutDefinition.RETURN_PARENT_FOLDER_ID)));
}
示例3: testRunAtDriverOverwriteError
import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
@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) {
}
}
示例4: setUp
import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
container = new DefaultComponentRuntimeContainerImpl() {
@Override
public String getCurrentComponentId() {
return TEST_CONTAINER;
}
};
//
DATA_STORE_DIR = new File(getClass().getClassLoader().getResource("./").toURI().getPath());
HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
//
drive = mock(Drive.class, RETURNS_DEEP_STUBS);
sourceOrSink = spy(GoogleDriveSourceOrSink.class);
source = spy(GoogleDriveSource.class);
sink = spy(GoogleDriveSink.class);
doReturn(drive).when(sourceOrSink).getDriveService();
doReturn(drive).when(source).getDriveService();
doReturn(drive).when(sink).getDriveService();
//
emptyFileList = new FileList();
emptyFileList.setFiles(new ArrayList<com.google.api.services.drive.model.File>());
}
示例5: createFolderFileList
import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
protected FileList createFolderFileList(String folderId, boolean createDuplicate) {
FileList fileList = new FileList();
java.util.List<com.google.api.services.drive.model.File> files = new ArrayList<>();
com.google.api.services.drive.model.File file = new com.google.api.services.drive.model.File();
file.setId(folderId);
files.add(file);
//
if (createDuplicate) {
com.google.api.services.drive.model.File fileDup = new com.google.api.services.drive.model.File();
fileDup.setId(folderId);
files.add(fileDup);
}
fileList.setFiles(files);
return fileList;
}
示例6: testManyResourcesMatching
import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
@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");
}
示例7: testManyFiles
import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
@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");
}
示例8: testStartOnly
import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
@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();
}
示例9: testAdvance
import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
@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();
}
示例10: setUp
import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
super.setUp();
properties = new GoogleDriveCreateProperties("test");
properties.setupProperties();
properties = (GoogleDriveCreateProperties) setupConnectionWithInstalledApplicationWithIdAndSecret(properties);
//
properties.parentFolder.setValue(FOLDER_ROOT);
properties.newFolder.setValue(FOLDER_CREATE);
testRuntime = spy(GoogleDriveCreateRuntime.class);
doReturn(drive).when(testRuntime).getDriveService();
File fc = new File();
fc.setId(FOLDER_CREATE_ID);
when(drive.files().create(any(File.class)).setFields(eq("id")).execute()).thenReturn(fc);
//
FileList flA = new FileList();
List<File> fs = new ArrayList<>();
File fA = new File();
fA.setId("A");
fs.add(fA);
flA.setFiles(fs);
when(drive.files().list().setQ(eq(qA)).execute()).thenReturn(flA);
FileList flB = new FileList();
List<File> fsA = new ArrayList<>();
File fB = new File();
fB.setId("B");
fsA.add(fB);
flB.setFiles(fsA);
when(drive.files().list().setQ(eq(qB)).execute()).thenReturn(flB);
FileList flC = new FileList();
List<File> fsC = new ArrayList<>();
File fC = new File();
fC.setId("C");
fsC.add(fC);
flC.setFiles(fsC);
when(drive.files().list().setQ(eq(qC)).execute()).thenReturn(flC);
}
示例11: setUp
import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
super.setUp();
properties = new GoogleDriveCopyProperties("test");
properties.setupProperties();
properties = (GoogleDriveCopyProperties) setupConnectionWithInstalledApplicationWithIdAndSecret(properties);
//
properties.copyMode.setValue(CopyMode.File);
properties.source.setValue(FILE_COPY_NAME);
properties.destinationFolder.setValue("/A");
properties.newName.setValue("newName");
// source fileName/folder
File dest = new File();
dest.setId(SOURCE_ID);
FileList list = new FileList();
List<File> files = new ArrayList<>();
files.add(dest);
list.setFiles(files);
final String q1 = "name='A' and 'root' in parents and mimeType='application/vnd.google-apps.folder'";
final String q2 = "name='" + FILE_COPY_NAME + "' and mimeType!='application/vnd.google-apps.folder'";
when(drive.files().list().setQ(eq(q1)).execute()).thenReturn(list);
when(drive.files().list().setQ(eq(q2)).execute()).thenReturn(list);
// destination/copied
File copiedFile = new File();
copiedFile.setId(DESTINATION_ID);
copiedFile.setParents(Collections.singletonList(SOURCE_ID));
when(drive.files().copy(anyString(), any(File.class)).setFields(anyString()).execute()).thenReturn(copiedFile);
File destFolder = new File();
destFolder.setId(DESTINATION_ID);
destFolder.setParents(Collections.singletonList(SOURCE_ID));
when(drive.files().create(any(File.class)).setFields(anyString()).execute()).thenReturn(destFolder);
}
示例12: testAdvance
import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
@Test
public void testAdvance() 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();
List mockList = mock(List.class, RETURNS_DEEP_STUBS);
when(drive.files().list()).thenReturn(mockList);
//
// String qA = "name='A' and 'root' in parents and mimeType='application/vnd.google-apps.folder' and trashed=false";
//
// when(drive.files().list().setQ(eq(qA)).execute()).thenReturn(createFolderFileList("A", false));
//
// GoogleDriveAbstractListReader alr = mock(GoogleDriveAbstractListReader.class);
// doReturn(true).when(alr).start();
inputProperties.getDatasetProperties().folder.setValue("A");
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, f, f, f, f));
when(mockList.execute()).thenReturn(fileList);
dataSource.initialize(container, inputProperties);
reader = (GoogleDriveInputReader) dataSource.createReader(container);
reader.setLimit(2);
assertTrue(reader.start());
reader.getCurrent();
assertTrue(reader.advance());
reader.getCurrent();
assertFalse(reader.advance());
}
示例13: setUp
import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
super.setUp();
testRuntime = spy(GoogleDriveCopyRuntime.class);
doReturn(drive).when(testRuntime).getDriveService();
properties = new GoogleDriveCopyProperties("test");
properties.setupProperties();
properties = (GoogleDriveCopyProperties) setupConnectionWithInstalledApplicationWithIdAndSecret(properties);
//
properties.copyMode.setValue(CopyMode.File);
properties.source.setValue(FILE_COPY_NAME);
properties.destinationFolder.setValue("/A");
properties.newName.setValue("newName");
// source fileName/folder
File dest = new File();
dest.setId(SOURCE_ID);
FileList list = new FileList();
List<File> files = new ArrayList<>();
files.add(dest);
list.setFiles(files);
final String q1 = "name='A' and 'root' in parents and mimeType='application/vnd.google-apps.folder'";
final String q2 = "name='fileName-copy-name' and mimeType!='application/vnd.google-apps.folder'";
final String q3 = "name='A' and mimeType='application/vnd.google-apps.folder'";
when(drive.files().list().setQ(eq(q1)).execute()).thenReturn(list);
when(drive.files().list().setQ(eq(q2)).execute()).thenReturn(list);
when(drive.files().list().setQ(eq(q3)).execute()).thenReturn(list);
// destination/copied
File copiedFile = new File();
copiedFile.setId(DESTINATION_ID);
copiedFile.setParents(Collections.singletonList(SOURCE_ID));
when(drive.files().copy(anyString(), any(File.class)).setFields(anyString()).execute()).thenReturn(copiedFile);
File destFolder = new File();
destFolder.setId(DESTINATION_ID);
destFolder.setParents(Collections.singletonList(SOURCE_ID));
when(drive.files().create(any(File.class)).setFields(anyString()).execute()).thenReturn(destFolder);
}
示例14: testRunAtDriverCopyFolder
import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
@Test
public void testRunAtDriverCopyFolder() throws Exception {
final String q1 = "name='folder' and 'root' in parents and mimeType='application/vnd.google-apps.folder'";
final String q2 = "'source-id' in parents and trashed=false";
final String q3 = "'folder-id2' in parents and trashed=false";
//
FileList fsource = new FileList();
List<File> fsfiles = new ArrayList<>();
File fsfolder = new File();
fsfolder.setMimeType(GoogleDriveMimeTypes.MIME_TYPE_FOLDER);
fsfolder.setName("folder");
fsfolder.setId(SOURCE_ID);
fsfiles.add(fsfolder);
fsource.setFiles(fsfiles);
when(drive.files().list().setQ(eq(q1)).execute()).thenReturn(fsource);
FileList flist = new FileList();
List<File> ffiles = new ArrayList<>();
File ffile = new File();
ffile.setMimeType(GoogleDriveMimeTypes.MIME_TYPE_CSV);
ffile.setName("fileName");
ffile.setId("fileName-id");
ffiles.add(ffile);
File ffolder = new File();
ffolder.setMimeType(GoogleDriveMimeTypes.MIME_TYPE_FOLDER);
ffolder.setName("folder");
ffolder.setId("folder-id2");
ffiles.add(ffolder);
flist.setFiles(ffiles);
when(drive.files().list().setQ(eq(q2)).execute()).thenReturn(flist);
when(drive.files().list().setQ(eq(q3)).execute()).thenReturn(emptyFileList);
properties.copyMode.setValue(CopyMode.Folder);
properties.source.setValue("/folder");
properties.newName.setValue("");
testRuntime.initialize(container, properties);
testRuntime.runAtDriver(container);
assertEquals(SOURCE_ID,
container.getComponentData(TEST_CONTAINER, getStudioName(GoogleDriveCopyDefinition.RETURN_SOURCE_ID)));
assertEquals(DESTINATION_ID,
container.getComponentData(TEST_CONTAINER, getStudioName(GoogleDriveCopyDefinition.RETURN_DESTINATION_ID)));
}
示例15: testStartCopyFolder
import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
@Test
public void testStartCopyFolder() throws Exception {
final String q1 = "name='folder' and 'root' in parents and mimeType='application/vnd.google-apps.folder'";
final String q2 = "'" + SOURCE_ID + "' in parents and trashed=false";
final String q3 = "'folder-id2' in parents and trashed=false";
//
FileList fsource = new FileList();
List<File> fsfiles = new ArrayList<>();
File fsfolder = new File();
fsfolder.setMimeType(GoogleDriveMimeTypes.MIME_TYPE_FOLDER);
fsfolder.setName("folder");
fsfolder.setId(SOURCE_ID);
fsfiles.add(fsfolder);
fsource.setFiles(fsfiles);
when(drive.files().list().setQ(eq(q1)).execute()).thenReturn(fsource);
FileList flist = new FileList();
List<File> ffiles = new ArrayList<>();
File ffile = new File();
ffile.setMimeType(GoogleDriveMimeTypes.MIME_TYPE_CSV);
ffile.setName("fileName");
ffile.setId("fileName-id");
ffiles.add(ffile);
File ffolder = new File();
ffolder.setMimeType(GoogleDriveMimeTypes.MIME_TYPE_FOLDER);
ffolder.setName("folder");
ffolder.setId("folder-id2");
ffiles.add(ffolder);
flist.setFiles(ffiles);
when(drive.files().list().setQ(eq(q2)).execute()).thenReturn(flist);
when(drive.files().list().setQ(eq(q3)).execute()).thenReturn(emptyFileList);
properties.copyMode.setValue(CopyMode.Folder);
properties.source.setValue("/folder");
source.initialize(container, properties);
BoundedReader reader = source.createReader(container);
assertTrue(reader.start());
IndexedRecord record = (IndexedRecord) reader.getCurrent();
assertNotNull(record);
assertEquals(2, record.getSchema().getFields().size());
assertEquals(SOURCE_ID, record.get(0));
assertEquals(DESTINATION_ID, record.get(1));
reader.close();
Map<String, Object> returnValues = reader.getReturnValues();
assertNotNull(returnValues);
assertEquals(SOURCE_ID, returnValues.get(GoogleDriveCopyDefinition.RETURN_SOURCE_ID));
assertEquals(DESTINATION_ID, returnValues.get(GoogleDriveCopyDefinition.RETURN_DESTINATION_ID));
}