use of org.motechproject.scheduler.contract.CronSchedulableJob in project motech by motech.
the class SchedulableJobValidatorTest method shouldThrowIllegalArgumentExceptionIfCronExpressionIsNull.
@Test(expected = IllegalArgumentException.class)
public void shouldThrowIllegalArgumentExceptionIfCronExpressionIsNull() {
CronSchedulableJob job = new CronSchedulableJob(motechEvent, null, DateTime.now().plusHours(1), null, false, true);
SchedulableJobValidator.validateCronSchedulableJob(job);
}
use of org.motechproject.scheduler.contract.CronSchedulableJob in project motech by motech.
the class SchedulableJobValidatorTest method shouldThrowIllegalArgumentExceptionIfCronExpressionIsEmpty.
@Test(expected = IllegalArgumentException.class)
public void shouldThrowIllegalArgumentExceptionIfCronExpressionIsEmpty() {
CronSchedulableJob job = new CronSchedulableJob(motechEvent, "", DateTime.now().plusHours(1), null, false, true);
SchedulableJobValidator.validateCronSchedulableJob(job);
}
use of org.motechproject.scheduler.contract.CronSchedulableJob in project motech by motech.
the class SchedulableJobValidatorTest method shouldThrowIllegalArgumentExceptionIfMotechEventIsNullInCronSchedulableJob.
@Test(expected = IllegalArgumentException.class)
public void shouldThrowIllegalArgumentExceptionIfMotechEventIsNullInCronSchedulableJob() {
CronSchedulableJob job = new CronSchedulableJob(null, "0 0 0 * * ? *", DateTime.now().plusHours(1), null, false, true);
SchedulableJobValidator.validateCronSchedulableJob(job);
}
use of org.motechproject.scheduler.contract.CronSchedulableJob in project motech by motech.
the class TestCronSchedulabeJob method equalsTest.
@Test
public void equalsTest() throws Exception {
String cron1 = "0/5 0 * * * ?";
String cron2 = "5 0 * * * ?";
CronSchedulableJob job1 = new CronSchedulableJob(motechEvent1, cron1);
CronSchedulableJob job1Same = new CronSchedulableJob(motechEvent1, cron1);
CronSchedulableJob job2 = new CronSchedulableJob(motechEvent2, cron1);
CronSchedulableJob job3 = new CronSchedulableJob(motechEvent1, cron2);
assertTrue(job1.equals(job1));
assertTrue(job1.equals(job1Same));
assertFalse(job1.equals(null));
assertFalse(job1.equals(motechEvent1));
// Same date, different event
assertFalse(job1.equals(job2));
// Same event different date
assertFalse(job1.equals(job3));
}
use of org.motechproject.scheduler.contract.CronSchedulableJob in project motech by motech.
the class MotechScheduler method scheduleTestEvent.
private static void scheduleTestEvent() {
Map<String, Object> params = new HashMap<>();
params.put(MotechSchedulerService.JOB_ID_KEY, TEST_EVENT_NAME);
MotechEvent motechEvent = new MotechEvent(TEST_SUBJECT, params);
CronSchedulableJob cronSchedulableJob = new CronSchedulableJob(motechEvent, TEST_CRON_EXPRESSION);
try {
LOGGER.info("Scheduling test job: " + cronSchedulableJob);
schedulerService.scheduleJob(cronSchedulableJob);
} catch (RuntimeException e) {
LOGGER.warn("Can not schedule test job.", e);
}
}
Aggregations