Beispiel #1
0
  @Test
  @Category(IntegrationTest.class)
  public void addCommentSucceeds() {
    BoxAPIConnection api = new BoxAPIConnection(TestConfig.getAccessToken());
    BoxFolder rootFolder = BoxFolder.getRootFolder(api);
    String fileName = "[addCommentSucceeds] Test File.txt";
    byte[] fileBytes = "Non-empty string".getBytes(StandardCharsets.UTF_8);
    String commentMessage = "Non-empty message";

    InputStream uploadStream = new ByteArrayInputStream(fileBytes);
    BoxFile uploadedFile = rootFolder.uploadFile(uploadStream, fileName).getResource();
    BoxComment.Info addedCommentInfo = uploadedFile.addComment(commentMessage);

    assertThat(addedCommentInfo.getMessage(), is(equalTo(commentMessage)));

    uploadedFile.delete();
  }
Beispiel #2
0
  @Test
  @Category(IntegrationTest.class)
  public void addCommentWithMentionSucceeds() {
    BoxAPIConnection api = new BoxAPIConnection(TestConfig.getAccessToken());
    BoxFolder rootFolder = BoxFolder.getRootFolder(api);
    String fileName = "[addCommentSucceeds] Test File.txt";
    byte[] fileBytes = "Non-empty string".getBytes(StandardCharsets.UTF_8);
    String commentMessage =
        String.format(
            "Message mentioning @[%s:%s]",
            TestConfig.getCollaboratorID(), TestConfig.getCollaborator());
    String expectedCommentMessage = "Message mentioning " + TestConfig.getCollaborator();

    InputStream uploadStream = new ByteArrayInputStream(fileBytes);
    BoxFile uploadedFile = rootFolder.uploadFile(uploadStream, fileName).getResource();
    BoxComment.Info addedCommentInfo = uploadedFile.addComment(commentMessage);

    assertThat(addedCommentInfo.getMessage(), is(equalTo(expectedCommentMessage)));
    assertThat(
        uploadedFile.getComments(),
        hasItem(Matchers.<BoxComment.Info>hasProperty("ID", equalTo(addedCommentInfo.getID()))));

    uploadedFile.delete();
  }