use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class GuaranteeServiceTest method assertIsNotAllCompleted.
@Test
public void assertIsNotAllCompleted() {
when(configService.load(false)).thenReturn(LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 10).build(), TestSimpleJob.class.getCanonicalName())).build());
when(jobNodeStorage.isJobNodeExisted("guarantee/completed")).thenReturn(false);
when(jobNodeStorage.getJobNodeChildrenKeys("guarantee/completed")).thenReturn(Arrays.asList("0", "1"));
assertFalse(guaranteeService.isAllCompleted());
}
use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class JobScheduleControllerTest method assertRescheduleJobFailure.
@Test(expected = JobSystemException.class)
public void assertRescheduleJobFailure() throws NoSuchFieldException, SchedulerException {
when(schedulerFacade.loadJobConfiguration()).thenReturn(LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestSimpleJob.class.getCanonicalName())).build());
when(scheduler.getTrigger(TriggerKey.triggerKey("test_job_Trigger"))).thenReturn(new CronTriggerImpl());
doThrow(SchedulerException.class).when(scheduler).rescheduleJob(eq(TriggerKey.triggerKey("test_job_Trigger")), Matchers.<Trigger>any());
ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler);
try {
jobScheduleController.rescheduleJob("0/1 * * * * ?");
} finally {
verify(scheduler).rescheduleJob(eq(TriggerKey.triggerKey("test_job_Trigger")), Matchers.<Trigger>any());
}
}
use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class JobScheduleControllerTest method assertRescheduleJobWhenTriggerIsNull.
@Test
public void assertRescheduleJobWhenTriggerIsNull() throws NoSuchFieldException, SchedulerException {
when(schedulerFacade.loadJobConfiguration()).thenReturn(LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestSimpleJob.class.getCanonicalName())).build());
ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler);
when(scheduler.isShutdown()).thenReturn(false);
jobScheduleController.rescheduleJob("0/1 * * * * ?");
verify(scheduler, times(0)).rescheduleJob(eq(TriggerKey.triggerKey("test_job_Trigger")), Matchers.<Trigger>any());
}
use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class ExecutionServiceTest method assertCleanPreviousExecutionInfoWhenNeedFixExecutionInfoForNewValuesEqual.
@Test
public void assertCleanPreviousExecutionInfoWhenNeedFixExecutionInfoForNewValuesEqual() {
when(jobNodeStorage.isJobNodeExisted("execution")).thenReturn(true);
when(leaderElectionService.isLeader()).thenReturn(true);
when(jobNodeStorage.getJobNodeChildrenKeys("execution")).thenReturn(Arrays.asList("0", "1", "2"));
when(jobNodeStorage.isJobNodeExisted("leader/execution/necessary")).thenReturn(true);
when(configService.load(false)).thenReturn(LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestSimpleJob.class.getCanonicalName())).build());
executionService.cleanPreviousExecutionInfo();
verify(jobNodeStorage).isJobNodeExisted("execution");
verify(leaderElectionService).isLeader();
verify(jobNodeStorage).fillEphemeralJobNode("leader/execution/cleaning", "");
verify(jobNodeStorage).getJobNodeChildrenKeys("execution");
verify(jobNodeStorage).removeJobNodeIfExisted("execution/0/completed");
verify(jobNodeStorage).removeJobNodeIfExisted("execution/1/completed");
verify(jobNodeStorage).removeJobNodeIfExisted("execution/2/completed");
verify(jobNodeStorage).isJobNodeExisted("leader/execution/necessary");
verify(configService).load(false);
verify(jobNodeStorage).removeJobNodeIfExisted("leader/execution/necessary");
verify(jobNodeStorage).removeJobNodeIfExisted("leader/execution/cleaning");
verify(jobNodeStorage).isJobNodeExisted("leader/execution/cleaning");
}
use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class ExecutionServiceTest method assertCleanPreviousExecutionInfoWhenNeedFixExecutionInfoForNewValuesGreater.
@Test
public void assertCleanPreviousExecutionInfoWhenNeedFixExecutionInfoForNewValuesGreater() {
when(jobNodeStorage.isJobNodeExisted("execution")).thenReturn(true);
when(leaderElectionService.isLeader()).thenReturn(true);
when(jobNodeStorage.getJobNodeChildrenKeys("execution")).thenReturn(Arrays.asList("0", "1", "2"));
when(jobNodeStorage.isJobNodeExisted("leader/execution/necessary")).thenReturn(true);
when(configService.load(false)).thenReturn(LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 4).build(), TestSimpleJob.class.getCanonicalName())).build());
executionService.cleanPreviousExecutionInfo();
verify(jobNodeStorage).isJobNodeExisted("execution");
verify(leaderElectionService).isLeader();
verify(jobNodeStorage).fillEphemeralJobNode("leader/execution/cleaning", "");
verify(jobNodeStorage).getJobNodeChildrenKeys("execution");
verify(jobNodeStorage).removeJobNodeIfExisted("execution/0/completed");
verify(jobNodeStorage).removeJobNodeIfExisted("execution/1/completed");
verify(jobNodeStorage).removeJobNodeIfExisted("execution/2/completed");
verify(jobNodeStorage).isJobNodeExisted("leader/execution/necessary");
verify(configService).load(false);
verify(jobNodeStorage).createJobNodeIfNeeded("execution/3");
verify(jobNodeStorage).removeJobNodeIfExisted("leader/execution/necessary");
verify(jobNodeStorage).removeJobNodeIfExisted("leader/execution/cleaning");
verify(jobNodeStorage).isJobNodeExisted("leader/execution/cleaning");
}
Aggregations