}
@Test
public void issueCreated() {
try {
Issue issueToCreate = IssueFactory.createWithSubject("test zzx");
Calendar startCal = Calendar.getInstance();
// have to clear them because they are ignored by Redmine and
// prevent from comparison later
startCal.clear(Calendar.HOUR_OF_DAY);
startCal.clear(Calendar.MINUTE);
startCal.clear(Calendar.SECOND);
startCal.clear(Calendar.MILLISECOND);
startCal.add(Calendar.DATE, 5);
issueToCreate.setStartDate(startCal.getTime());
Calendar due = Calendar.getInstance();
due.add(Calendar.MONTH, 1);
issueToCreate.setDueDate(due.getTime());
User assignee = IntegrationTestHelper.getOurUser();
issueToCreate.setAssignee(assignee);
String description = "This is the description for the new task."
+ "\nIt has several lines." + "\nThis is the last line.";
issueToCreate.setDescription(description);
float estimatedHours = 44;
issueToCreate.setEstimatedHours(estimatedHours);
Issue newIssue = issueManager.createIssue(projectKey, issueToCreate);
assertNotNull("Checking returned result", newIssue);
assertNotNull("New issue must have some ID",
newIssue.getId());
// check startDate
Calendar returnedStartCal = Calendar.getInstance();
returnedStartCal.setTime(newIssue.getStartDate());
assertEquals(startCal.get(Calendar.YEAR),
returnedStartCal.get(Calendar.YEAR));
assertEquals(startCal.get(Calendar.MONTH),
returnedStartCal.get(Calendar.MONTH));
assertEquals(startCal.get(Calendar.DAY_OF_MONTH),
returnedStartCal.get(Calendar.DAY_OF_MONTH));
// check dueDate
Calendar returnedDueCal = Calendar.getInstance();
returnedDueCal.setTime(newIssue.getDueDate());
assertEquals(due.get(Calendar.YEAR),
returnedDueCal.get(Calendar.YEAR));
assertEquals(due.get(Calendar.MONTH),
returnedDueCal.get(Calendar.MONTH));
assertEquals(due.get(Calendar.DAY_OF_MONTH),
returnedDueCal.get(Calendar.DAY_OF_MONTH));
// check ASSIGNEE
User actualAssignee = newIssue.getAssignee();
assertNotNull("Checking assignee not null", actualAssignee);
assertEquals("Checking assignee id", assignee.getId(),
actualAssignee.getId());
// check AUTHOR
Integer EXPECTED_AUTHOR_ID = IntegrationTestHelper.getOurUser().getId();
assertEquals(EXPECTED_AUTHOR_ID, newIssue.getAuthor()
.getId());
// check ESTIMATED TIME
assertEquals((Float) estimatedHours,
newIssue.getEstimatedHours());
// check multi-line DESCRIPTION
String regexpStripExtra = "\\r|\\n|\\s";
description = description.replaceAll(regexpStripExtra, "");
String actualDescription = newIssue.getDescription();
actualDescription = actualDescription.replaceAll(regexpStripExtra,
"");
assertEquals(description, actualDescription);
// PRIORITY
assertNotNull(newIssue.getPriorityId());
assertTrue(newIssue.getPriorityId() > 0);
} catch (Exception e) {
e.printStackTrace();
fail();
}
}