// collect accurate information about the failure. It's not a problem if the job remains scheduled because it
// does nothing. Other tests should not rely on the number of scheduler jobs though.
getUtil().deletePage("Scheduler", "SchedulerTestJob");
// Create Job
SchedulerHomePage schedulerHomePage = SchedulerHomePage.gotoPage();
schedulerHomePage.setJobName("SchedulerTestJob");
SchedulerEditPage schedulerEdit = schedulerHomePage.clickAdd();
String jobName = "Tester problem";
schedulerEdit.setJobName(jobName);
schedulerEdit.setJobDescription(jobName);
schedulerEdit.setCron("0 15 10 ? * MON-FRI");
SchedulerPage schedulerPage = schedulerEdit.clickSaveAndView();
schedulerHomePage = schedulerPage.backToHome();
// View Job
schedulerPage = schedulerHomePage.clickJobActionView(jobName);
schedulerHomePage = schedulerPage.backToHome();
// Edit Job
schedulerEdit = schedulerHomePage.clickJobActionEdit(jobName);
schedulerEdit.setJobDescription("Tester problem2");
schedulerEdit.setCron("0 0/5 14 * * ?");
schedulerPage = schedulerEdit.clickSaveAndView();
schedulerHomePage = schedulerPage.backToHome();
// Delete and Restore Job
schedulerHomePage.clickJobActionDelete(jobName).clickYes();
schedulerHomePage = SchedulerHomePage.gotoPage();
Assert.assertFalse(getUtil().hasElement(By.linkText(jobName)));
getUtil().gotoPage("Scheduler", "SchedulerTestJob");
getDriver().findElement(By.linkText("Restore")).click();
schedulerPage = new SchedulerPage();
schedulerPage.backToHome();
// Schedule Job
schedulerHomePage.clickJobActionScheduler(jobName);
if (schedulerHomePage.hasError()) {
Assert.fail("Failed to schedule job. Error [" + schedulerHomePage.getErrorMessage() + "]");
}
// Trigger Job (a Job can only be triggered after it's been scheduled)
schedulerHomePage.clickJobActionTrigger(jobName);
if (schedulerHomePage.hasError()) {
Assert.fail("Failed to trigger job. Error [" + schedulerHomePage.getErrorMessage() + "]");
}
// Pause Job
schedulerHomePage.clickJobActionPause(jobName);
if (schedulerHomePage.hasError()) {
Assert.fail("Failed to pause job. Error [" + schedulerHomePage.getErrorMessage() + "]");
}
// Resume Job
schedulerHomePage.clickJobActionResume(jobName);
if (schedulerHomePage.hasError()) {
Assert.fail("Failed to resume job. Error [" + schedulerHomePage.getErrorMessage() + "]");
}
// Unschedule Job
schedulerHomePage.clickJobActionUnschedule(jobName);
if (schedulerHomePage.hasError()) {
Assert.fail("Failed to unschedule job. Error [" + schedulerHomePage.getErrorMessage() + "]");
}
}