private String getCreatedAttachmentContentId() throws TException {
   List<Release> importedReleases = componentClient.getReleaseSummary(user);
   sortByField(importedReleases, Release._Fields.VERSION);
   sortByField(importedReleases, Release._Fields.NAME);
   final Release release = importedReleases.get(4);
   final Set<Attachment> attachments = release.getAttachments();
   assertThat(attachments.size(), is(1));
   final Attachment theAttachment = getFirst(attachments);
   return theAttachment.getAttachmentContentId();
 }
  private void assertExpectedComponentsInDb() throws TException {
    List<Component> importedComponents = componentClient.getComponentSummary(user);
    List<Release> importedReleases = componentClient.getReleaseSummary(user);

    assertThat(importedComponents, hasSize(7)); // see the test file
    assertThat(importedReleases, hasSize(8)); // see the test file

    sortByField(importedComponents, Component._Fields.NAME);
    sortByField(importedReleases, Release._Fields.VERSION);
    sortByField(importedReleases, Release._Fields.NAME);

    Component component = importedComponents.get(0);
    assertThat(component.getName(), is("7-Zip"));

    component = componentClient.getComponentById(component.getId(), user);
    assertThat(component.getName(), is("7-Zip"));
    assertThat(component.getHomepage(), is("http://commons.apache.org/proper/commons-exec"));
    assertThat(component.getVendorNames(), is(emptyOrNullCollectionOf(String.class)));
    assertThat(component.getAttachments(), is(emptyOrNullCollectionOf(Attachment.class)));
    assertThat(component.getCreatedBy(), equalTo(user.getEmail()));
    assertThat(component.getReleases(), is(not(nullValue())));
    assertThat(
        getReleaseIds(component.getReleases()),
        containsInAnyOrder(importedReleases.get(0).getId(), importedReleases.get(1).getId()));

    final Release release = importedReleases.get(4);
    assertThat(release.getVersion(), is("1.2.11"));
    // This release has an download url so the import creates an attachmen
    final Set<Attachment> attachments = release.getAttachments();
    assertThat(attachments.size(), is(1));
    final Attachment theAttachment = getFirst(attachments);
    final String attachmentContentId = theAttachment.getAttachmentContentId();

    final AttachmentContent attachmentContent =
        attachmentClient.getAttachmentContent(attachmentContentId);

    assertThat(attachmentContent.isOnlyRemote(), is(true));

    assertThat(attachmentContent.getRemoteUrl(), is(REMOTE_URL));
  }