@Test
public void uploadAttachment() throws RedmineException, IOException {
final byte[] content = new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
final Attachment attach1 = attachmentManager.uploadAttachment("test.bin",
"application/ternary", content);
final Issue testIssue = IssueFactory.createWithSubject("This is upload ticket!");
testIssue.addAttachment(attach1);
final Issue createdIssue = issueManager.createIssue(projectKey, testIssue);
try {
final Collection<Attachment> attachments = createdIssue.getAttachments();
assertThat(attachments.size()).isEqualTo(1);
final Attachment added = attachments.iterator().next();
assertThat(added.getFileName()).isEqualTo("test.bin");
assertThat(added.getContentType()).isEqualTo("application/ternary");
final byte[] receivedContent = attachmentManager.downloadAttachmentContent(added);
assertArrayEquals(content, receivedContent);
Issue issueById = issueManager.getIssueById(createdIssue.getId(), Include.attachments);
assertThat(issueById.getAttachments().size()).isEqualTo(1);
} finally {
issueManager.deleteIssue(createdIssue.getId());
}
}