@Test
public void testIssueJournals() {
try {
// create at least 1 issue
Issue issueToCreate = new Issue();
issueToCreate.setSubject("testGetIssues: " + new Date());
Issue newIssue = issueManager.createIssue(projectKey, issueToCreate);
Issue loadedIssueWithJournals = issueManager.getIssueById(newIssue.getId(),
Include.journals);
assertTrue(loadedIssueWithJournals.getJournals().isEmpty());
String commentDescribingTheUpdate = "some comment describing the issue update";
loadedIssueWithJournals.setSubject("new subject");
loadedIssueWithJournals.setNotes(commentDescribingTheUpdate);
issueManager.update(loadedIssueWithJournals);
Issue loadedIssueWithJournals2 = issueManager.getIssueById(newIssue.getId(),
Include.journals);
assertEquals(1, loadedIssueWithJournals2.getJournals()
.size());
Journal journalItem = loadedIssueWithJournals2.getJournals().iterator().next();
assertEquals(commentDescribingTheUpdate, journalItem.getNotes());
User ourUser = IntegrationTestHelper.getOurUser();
// can't compare User objects because either of them is not
// completely filled
assertEquals(ourUser.getId(), journalItem.getUser().getId());
assertEquals(ourUser.getFirstName(), journalItem.getUser()
.getFirstName());
assertEquals(ourUser.getLastName(), journalItem.getUser()
.getLastName());
assertEquals(1, journalItem.getDetails().size());
final JournalDetail journalDetail = journalItem.getDetails().get(0);
assertEquals("new subject", journalDetail.getNewValue());
assertEquals("subject", journalDetail.getName());
assertEquals("attr", journalDetail.getProperty());
Issue loadedIssueWithoutJournals = issueManager.getIssueById(newIssue.getId());
assertTrue(loadedIssueWithoutJournals.getJournals().isEmpty());
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}