@Test
public void testFixedUnhealthyTriggerShouldSendEmailWhenBuildSucceedsAfterAbortedBuild()
throws Exception {
// fail
project.getBuildersList().add(new FailureBuilder());
FreeStyleBuild build1 = project.scheduleBuild2(0).get();
j.assertBuildStatus(Result.FAILURE, build1);
// abort
project.getBuildersList().clear();
project.getBuildersList().add(new MockBuilder(Result.ABORTED));
FreeStyleBuild build2 = project.scheduleBuild2(0).get();
j.assertBuildStatus(Result.ABORTED, build2);
FixedUnhealthyTrigger trigger = new FixedUnhealthyTrigger(recProviders, "$DEFAULT_RECIPIENTS",
"$DEFAULT_REPLYTO", "$DEFAULT_SUBJECT", "$DEFAULT_CONTENT", "", 0, "project");
addEmailType(trigger);
publisher.getConfiguredTriggers().add(trigger);
// succeed
project.getBuildersList().clear();
FreeStyleBuild build3 = project.scheduleBuild2(0).get();
j.assertBuildStatusSuccess(build3);
assertThat("Email should have been triggered, so we should see it in the logs.", build3.getLog(100),
hasItems("Email was triggered for: " + FixedUnhealthyTrigger.TRIGGER_NAME));
assertEquals(1, Mailbox.get("ashlux@gmail.com").size());
}