@Test
  @Category(IntegrationTest.class)
  public void shouldReturnTrashedAtForADeleteVersion() {
    BoxAPIConnection api = new BoxAPIConnection(TestConfig.getAccessToken());
    BoxFolder rootFolder = BoxFolder.getRootFolder(api);
    String fileName = "[deleteVersionSucceeds] Multi-version File.txt";
    byte[] version1Bytes = "Version 1".getBytes(StandardCharsets.UTF_8);
    byte[] version2Bytes = "Version 2".getBytes(StandardCharsets.UTF_8);

    InputStream uploadStream = new ByteArrayInputStream(version1Bytes);
    BoxFile uploadedFile = rootFolder.uploadFile(uploadStream, fileName).getResource();
    uploadStream = new ByteArrayInputStream(version2Bytes);
    uploadedFile.uploadVersion(uploadStream);

    Collection<BoxFileVersion> versions = uploadedFile.getVersions();
    BoxFileVersion previousVersion = versions.iterator().next();

    assertThat(previousVersion.getTrashedAt(), is(nullValue()));

    previousVersion.delete();
    versions = uploadedFile.getVersions();
    previousVersion = versions.iterator().next();

    assertThat(previousVersion.getTrashedAt(), is(notNullValue()));

    uploadedFile.delete();
  }
  @Test
  @Category(IntegrationTest.class)
  public void promoteVersionsSucceeds() throws UnsupportedEncodingException {
    BoxAPIConnection api = new BoxAPIConnection(TestConfig.getAccessToken());
    BoxFolder rootFolder = BoxFolder.getRootFolder(api);
    String fileName = "[promoteVersionsSucceeds] Multi-version File.txt";
    String version1Content = "Version 1";
    byte[] version1Bytes = version1Content.getBytes(StandardCharsets.UTF_8);
    byte[] version2Bytes = "Version 2".getBytes(StandardCharsets.UTF_8);

    InputStream uploadStream = new ByteArrayInputStream(version1Bytes);
    BoxFile uploadedFile = rootFolder.uploadFile(uploadStream, fileName).getResource();
    uploadStream = new ByteArrayInputStream(version2Bytes);
    uploadedFile.uploadVersion(uploadStream);

    Collection<BoxFileVersion> versions = uploadedFile.getVersions();
    BoxFileVersion previousVersion = versions.iterator().next();
    previousVersion.promote();

    ByteArrayOutputStream downloadStream = new ByteArrayOutputStream();
    uploadedFile.download(downloadStream);
    String downloadedContent = downloadStream.toString(StandardCharsets.UTF_8.name());
    assertThat(downloadedContent, equalTo(version1Content));

    uploadedFile.delete();
  }
  @Test
  @Category(IntegrationTest.class)
  public void uploadAndDownloadMultipleVersionsSucceeds() throws UnsupportedEncodingException {
    BoxAPIConnection api = new BoxAPIConnection(TestConfig.getAccessToken());
    BoxFolder rootFolder = BoxFolder.getRootFolder(api);
    String fileName = "[uploadAndDownloadMultipleVersionsSucceeds] Multi-version File.txt";
    String version1Content = "Version 1";
    String version1Sha = "db3cbc01da600701b9fe4a497fe328e71fa7022f";
    byte[] version1Bytes = version1Content.getBytes(StandardCharsets.UTF_8);
    long version1Size = version1Bytes.length;
    String version2Content = "Version 2";
    byte[] version2Bytes = version2Content.getBytes(StandardCharsets.UTF_8);
    long version2Size = version1Bytes.length;

    InputStream uploadStream = new ByteArrayInputStream(version1Bytes);
    BoxFile uploadedFile = rootFolder.uploadFile(uploadStream, fileName).getResource();

    uploadStream = new ByteArrayInputStream(version2Bytes);
    ProgressListener mockUploadListener = mock(ProgressListener.class);
    uploadedFile.uploadVersion(uploadStream, null, version2Size, mockUploadListener);

    Collection<BoxFileVersion> versions = uploadedFile.getVersions();
    BoxFileVersion previousVersion = versions.iterator().next();

    ByteArrayOutputStream downloadStream = new ByteArrayOutputStream();
    ProgressListener mockDownloadListener = mock(ProgressListener.class);
    previousVersion.download(downloadStream, mockDownloadListener);
    String downloadedContent = downloadStream.toString(StandardCharsets.UTF_8.name());

    assertThat(versions, hasSize(1));
    assertThat(previousVersion.getSha1(), is(equalTo(version1Sha)));
    assertThat(downloadedContent, equalTo(version1Content));
    verify(mockDownloadListener, atLeastOnce()).onProgressChanged(anyLong(), anyLong());
    verify(mockUploadListener, atLeastOnce())
        .onProgressChanged(anyLong(), longThat(is(equalTo(version1Size))));

    uploadedFile.delete();
  }