Search in sources :

Example 1 with Comment

use of com.google.api.services.drive.model.Comment 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 2 with Comment

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

the class DriveCommentsIntegrationTest method testComment.

@Test
public void testComment() 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", 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", fileId);
    assertNotNull(result1.get("items"));
    LOG.debug("list: " + result1);
    Comment comment2 = result1.getItems().get(0);
    // 4. now try and get that comment 
    headers = new HashMap<String, Object>();
    // parameter type is String
    headers.put("CamelGoogleDrive.fileId", fileId);
    // parameter type is String
    headers.put("CamelGoogleDrive.commentId", comment2.getCommentId());
    final com.google.api.services.drive.model.Comment result3 = requestBodyAndHeaders("direct://GET", null, headers);
    assertNotNull("get result", result3);
    // 5. delete the comment
    headers = new HashMap<String, Object>();
    // parameter type is String
    headers.put("CamelGoogleDrive.fileId", fileId);
    // parameter type is String
    headers.put("CamelGoogleDrive.commentId", comment2.getCommentId());
    requestBodyAndHeaders("direct://DELETE", null, headers);
    // 6. ensure the comment is gone
    headers = new HashMap<String, Object>();
    // parameter type is String
    headers.put("CamelGoogleDrive.fileId", fileId);
    // parameter type is String
    headers.put("CamelGoogleDrive.commentId", comment2.getCommentId());
    try {
        final com.google.api.services.drive.model.Comment result4 = requestBodyAndHeaders("direct://GET", null, headers);
        assertTrue("Should have thrown an exception.", false);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
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)

Aggregations

Comment (com.google.api.services.drive.model.Comment)2 File (com.google.api.services.drive.model.File)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2