Search in sources :

Example 6 with File

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

the class DrivePermissionsIntegrationTest method testList.

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

Example 7 with File

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

the class DrivePropertiesIntegrationTest method testList.

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

Example 8 with File

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

the class DriveRepliesIntegrationTest method testReplyToComment.

@Test
public void testReplyToComment() throws Exception {
    // 1. create test file
    File testFile = uploadTestFile();
    String fileId = testFile.getId();
    // 2. comment on that file
    Map<String, Object> headers = new HashMap<String, Object>();
    // parameter type is String
    headers.put("CamelGoogleDrive.fileId", fileId);
    // parameter type is com.google.api.services.drive.model.Comment
    com.google.api.services.drive.model.Comment comment = new com.google.api.services.drive.model.Comment();
    comment.setContent("Camel rocks!");
    headers.put("CamelGoogleDrive.content", comment);
    requestBodyAndHeaders("direct://INSERT_COMMENT", null, headers);
    // 3. get a list of comments on the file
    // using String message body for single parameter "fileId"
    com.google.api.services.drive.model.CommentList result1 = requestBody("direct://LIST_COMMENTS", fileId);
    assertNotNull(result1.get("items"));
    LOG.debug("list: " + result1);
    Comment comment2 = result1.getItems().get(0);
    String commentId = comment2.getCommentId();
    // 4. add reply
    headers = new HashMap<String, Object>();
    // parameter type is String
    headers.put("CamelGoogleDrive.fileId", fileId);
    // parameter type is String
    headers.put("CamelGoogleDrive.commentId", commentId);
    // parameter type is com.google.api.services.drive.model.CommentReply
    com.google.api.services.drive.model.CommentReply reply = new com.google.api.services.drive.model.CommentReply();
    reply.setContent("I know :-)");
    headers.put("CamelGoogleDrive.content", reply);
    requestBodyAndHeaders("direct://INSERT", null, headers);
    // 5. list replies on comment to file
    headers = new HashMap<String, Object>();
    // parameter type is String
    headers.put("CamelGoogleDrive.fileId", fileId);
    // parameter type is String
    headers.put("CamelGoogleDrive.commentId", commentId);
    final com.google.api.services.drive.model.CommentReplyList result = requestBodyAndHeaders("direct://LIST", null, headers);
    assertNotNull("list result", result);
    LOG.debug("list: " + result);
}
Also used : Comment(com.google.api.services.drive.model.Comment) HashMap(java.util.HashMap) Comment(com.google.api.services.drive.model.Comment) File(com.google.api.services.drive.model.File) Test(org.junit.Test)

Example 9 with File

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

the class DriveRevisionsIntegrationTest method testList.

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

Example 10 with File

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

the class FileConverterIntegrationTest method testFileConverter.

@Test
public void testFileConverter() throws Exception {
    template.sendBodyAndHeader("file://target/convertertest", "Hello!", "CamelFileName", "greeting.txt");
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    assertMockEndpointsSatisfied();
    File file = mock.getReceivedExchanges().get(0).getIn().getBody(com.google.api.services.drive.model.File.class);
    assertEquals("Hello!", context.getTypeConverter().convertTo(String.class, mock.getReceivedExchanges().get(0), file));
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) File(com.google.api.services.drive.model.File) Test(org.junit.Test)

Aggregations

File (com.google.api.services.drive.model.File)41 Test (org.junit.Test)19 IOException (java.io.IOException)17 HashMap (java.util.HashMap)9 FileList (com.google.api.services.drive.model.FileList)7 ParseException (java.text.ParseException)7 ArrayList (java.util.ArrayList)7 FileContent (com.google.api.client.http.FileContent)6 GeneralSecurityException (java.security.GeneralSecurityException)6 GenericUrl (com.google.api.client.http.GenericUrl)4 HttpResponse (com.google.api.client.http.HttpResponse)4 Permission (com.google.api.services.drive.model.Permission)4 User (com.google.api.services.drive.model.User)4 InputStream (java.io.InputStream)4 UserRecoverableAuthIOException (com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException)3 DateTime (com.google.api.client.util.DateTime)3 ParentReference (com.google.api.services.drive.model.ParentReference)3 Comment (com.google.api.services.drive.model.Comment)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2