BoxSDKService { public void addCommentToFile(String fileId, String comment) throws BoxSDKServiceException { try { BoxFile boxFile = new BoxFile(getBoxAPIConnection(), fileId); boxFile.addComment(comment); } catch (BoxAPIException e) { if (isSimilarCommentException(e)) { logger.debug("Trying to add the same comment, do nothing"); } else { String msg = "Error trying to add a comment to file " + fileId; logger.error(msg, e); throw new BoxSDKServiceException(msg, e); } } }  BoxSDKServiceConfig getBoxSDKServiceConfig(); BoxAPIConnection getBoxAPIConnection(); BoxFolder getRootFolder(); BoxFolder createSharedFolder(String folderName); BoxFolder createSharedFolder(String folderName, String parentId); BoxFolder createFolderUnderRoot(String folderName); BoxFolder createFolder(String folderName, String parentId); BoxFile uploadFile(String folderId, String filename, String filecontent); List<BoxFile> listFiles(String folderId); BoxFileWithContent getFileContent(BoxFile file); String getFileContent(String fileId); String getBoxEmbedWidgetIFrame(BoxFolder boxFolder); BoxFolder getFolderWithName(String folderName); BoxFolder getFolderWithNameAndParentFolderId(String folderName, String parentFolderId); void deleteFolderAndItsContent(String folderId); void deleteFolderContentOlderThan(String folderId, DateTime olderThan); void addCommentToFile(String fileId, String comment);  }
@Test @Category(BoxSDKTest.class) public void testAddCommentToFile() throws BoxSDKServiceException { String testFolderId = testFolder.getID(); BoxFolder rootFolder = boxSDKService.createFolder("testAddCommentOnFile-" + new Date().getTime(), testFolderId); BoxFile uploadFile = boxSDKService.uploadFile(rootFolder.getID(), "fileWithComment.txt", "for test"); boxSDKService.addCommentToFile(uploadFile.getID(), "test comment"); boxSDKService.addCommentToFile(uploadFile.getID(), "test comment2"); List<BoxComment.Info> comments = uploadFile.getComments(); Assert.assertEquals(2, comments.size()); Assert.assertEquals("test comment", comments.get(0).getMessage()); Assert.assertEquals("test comment2", comments.get(1).getMessage()); }