Search in sources :

Example 1 with File

use of com.google.api.services.drive.model.File in project camel by apache.

the class AbstractGoogleDriveTestSupport method uploadTestFolder.

protected File uploadTestFolder() {
    File fileMetadata = new File();
    fileMetadata.setTitle("testfolder");
    fileMetadata.setMimeType("application/vnd.google-apps.folder");
    File result = requestBody("google-drive://drive-files/insert?inBody=content", fileMetadata);
    return result;
}
Also used : File(com.google.api.services.drive.model.File)

Example 2 with File

use of com.google.api.services.drive.model.File in project camel by apache.

the class DriveFilesIntegrationTest method testPatch.

@Test
public void testPatch() throws Exception {
    File file = uploadTestFile();
    // lets update the filename
    file.setTitle(UPLOAD_FILE.getName() + "PATCHED");
    final Map<String, Object> headers = new HashMap<String, Object>();
    // parameter type is String
    headers.put("CamelGoogleDrive.fileId", file.getId());
    // parameter type is String
    headers.put("CamelGoogleDrive.fields", "title");
    // parameter type is com.google.api.services.drive.model.File
    headers.put("CamelGoogleDrive.content", file);
    File result = requestBodyAndHeaders("direct://PATCH", null, headers);
    assertNotNull("patch result", result);
    assertEquals(UPLOAD_FILE.getName() + "PATCHED", result.getTitle());
    LOG.debug("patch: " + result);
}
Also used : HashMap(java.util.HashMap) File(com.google.api.services.drive.model.File) Test(org.junit.Test)

Example 3 with File

use of com.google.api.services.drive.model.File in project camel by apache.

the class DriveFilesIntegrationTest method testGet.

@Test
public void testGet() throws Exception {
    File testFile = uploadTestFile();
    String fileId = testFile.getId();
    // using String message body for single parameter "fileId"
    final File result = requestBody("direct://GET", fileId);
    assertNotNull("get result", result);
    LOG.debug("get: " + result);
}
Also used : File(com.google.api.services.drive.model.File) Test(org.junit.Test)

Example 4 with File

use of com.google.api.services.drive.model.File in project camel by apache.

the class DriveFilesIntegrationTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    File theTestFile = uploadTestFile();
    final Map<String, Object> headers = new HashMap<String, Object>();
    // parameter type is String
    headers.put("CamelGoogleDrive.fileId", theTestFile.getId());
    // parameter type is com.google.api.services.drive.model.File
    headers.put("CamelGoogleDrive.content", theTestFile);
    File result = requestBodyAndHeaders("direct://UPDATE", null, headers);
    assertNotNull("update result", result);
    LOG.debug("update: " + result);
}
Also used : HashMap(java.util.HashMap) File(com.google.api.services.drive.model.File) Test(org.junit.Test)

Example 5 with File

use of com.google.api.services.drive.model.File in project camel by apache.

the class DriveFilesIntegrationTest method testInsert1.

@Test
public void testInsert1() throws Exception {
    File result = uploadTestFile();
    assertNotNull("insert result", result);
    LOG.debug("insert: " + result);
}
Also used : File(com.google.api.services.drive.model.File) Test(org.junit.Test)

Aggregations

File (com.google.api.services.drive.model.File)94 FileList (com.google.api.services.drive.model.FileList)35 Test (org.junit.Test)33 IOException (java.io.IOException)27 ArrayList (java.util.ArrayList)24 Before (org.junit.Before)12 FileContent (com.google.api.client.http.FileContent)10 HashMap (java.util.HashMap)10 UserRecoverableAuthIOException (com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException)9 FileNotFoundException (java.io.FileNotFoundException)7 ParseException (java.text.ParseException)7 GoogleJsonResponseException (com.google.api.client.googleapis.json.GoogleJsonResponseException)6 DateTime (com.google.api.client.util.DateTime)6 Drive (com.google.api.services.drive.Drive)6 InputStream (java.io.InputStream)6 GeneralSecurityException (java.security.GeneralSecurityException)6 Matchers.anyString (org.mockito.Matchers.anyString)6 ParentReference (com.google.api.services.drive.model.ParentReference)5 Permission (com.google.api.services.drive.model.Permission)5 User (com.google.api.services.drive.model.User)5