.functions(new SetResolution(Issue.RESOLUTION_FIXED), new SetCloseDate(true))
.automatic()
.build())
+ .transition(Transition.builder("automaticclose")
+ .from(Issue.STATUS_CONFIRMED).to(Issue.STATUS_CLOSED)
+ .conditions(new IsAlive(false))
+ .functions(new SetResolution(Issue.RESOLUTION_FIXED), new SetCloseDate(true))
+ .automatic()
+ .build())
// Close the issues marked as resolved and that do not exist anymore.
// Note that false-positives are kept resolved and are not closed.
.transition(Transition.builder("automaticclose")
assertThat(issue.updateDate()).isEqualTo(now);
}
+ @Test
+ public void should_close_open_dead_issue() throws Exception {
+ workflow.start();
+
+ DefaultIssue issue = new DefaultIssue()
+ .setKey("ABCDE")
+ .setResolution(null)
+ .setStatus(Issue.STATUS_OPEN)
+ .setNew(false)
+ .setAlive(false);
+ Date now = new Date();
+ workflow.doAutomaticTransition(issue, IssueChangeContext.createScan(now));
+ assertThat(issue.resolution()).isEqualTo(Issue.RESOLUTION_FIXED);
+ assertThat(issue.status()).isEqualTo(Issue.STATUS_CLOSED);
+ assertThat(issue.closeDate()).isNotNull();
+ assertThat(issue.updateDate()).isEqualTo(now);
+ }
+
+ @Test
+ public void should_close_reopened_dead_issue() throws Exception {
+ workflow.start();
+
+ DefaultIssue issue = new DefaultIssue()
+ .setKey("ABCDE")
+ .setResolution(null)
+ .setStatus(Issue.STATUS_REOPENED)
+ .setNew(false)
+ .setAlive(false);
+ Date now = new Date();
+ workflow.doAutomaticTransition(issue, IssueChangeContext.createScan(now));
+ assertThat(issue.resolution()).isEqualTo(Issue.RESOLUTION_FIXED);
+ assertThat(issue.status()).isEqualTo(Issue.STATUS_CLOSED);
+ assertThat(issue.closeDate()).isNotNull();
+ assertThat(issue.updateDate()).isEqualTo(now);
+ }
+
+ @Test
+ public void should_close_confirmed_dead_issue() throws Exception {
+ workflow.start();
+
+ DefaultIssue issue = new DefaultIssue()
+ .setKey("ABCDE")
+ .setResolution(null)
+ .setStatus(Issue.STATUS_CONFIRMED)
+ .setNew(false)
+ .setAlive(false);
+ Date now = new Date();
+ workflow.doAutomaticTransition(issue, IssueChangeContext.createScan(now));
+ assertThat(issue.resolution()).isEqualTo(Issue.RESOLUTION_FIXED);
+ assertThat(issue.status()).isEqualTo(Issue.STATUS_CLOSED);
+ assertThat(issue.closeDate()).isNotNull();
+ assertThat(issue.updateDate()).isEqualTo(now);
+ }
+
+
@Test
public void should_fail_if_unknown_status() throws Exception {
workflow.start();