use of com.dangdang.ddframe.job.statistics.type.job.JobRunningStatistics in project elastic-job by dangdangdotcom.
the class StatisticRdbRepositoryTest method assertFindJobRunningStatisticsWithDifferentFromDate.
@Test
public void assertFindJobRunningStatisticsWithDifferentFromDate() {
Date now = new Date();
Date yesterday = getYesterday();
assertTrue(repository.add(new JobRunningStatistics(100, yesterday)));
assertTrue(repository.add(new JobRunningStatistics(100, now)));
assertThat(repository.findJobRunningStatistics(yesterday).size(), is(2));
assertThat(repository.findJobRunningStatistics(now).size(), is(1));
}
use of com.dangdang.ddframe.job.statistics.type.job.JobRunningStatistics in project elastic-job by dangdangdotcom.
the class JobRunningStatisticJobTest method assertExecute.
@Test
public void assertExecute() throws SchedulerException {
Optional<JobRunningStatistics> latestJobRunningStatistics = Optional.of(new JobRunningStatistics(0, StatisticTimeUtils.getStatisticTime(StatisticInterval.MINUTE, -3)));
Optional<TaskRunningStatistics> latestTaskRunningStatistics = Optional.of(new TaskRunningStatistics(0, StatisticTimeUtils.getStatisticTime(StatisticInterval.MINUTE, -3)));
when(repository.findLatestJobRunningStatistics()).thenReturn(latestJobRunningStatistics);
when(repository.findLatestTaskRunningStatistics()).thenReturn(latestTaskRunningStatistics);
when(repository.add(any(JobRunningStatistics.class))).thenReturn(true);
when(repository.add(any(TaskRunningStatistics.class))).thenReturn(true);
Map<String, Set<TaskContext>> jobMap = new HashMap<>(1);
Set<TaskContext> jobSet = new HashSet<>(1);
jobSet.add(TaskContext.from(TaskNode.builder().jobName("test_job").build().getTaskNodeValue()));
jobMap.put("test_job", jobSet);
when(runningService.getAllRunningTasks()).thenReturn(jobMap);
jobRunningStatisticJob.execute(null);
verify(repository).findLatestJobRunningStatistics();
verify(repository).findLatestTaskRunningStatistics();
verify(repository, times(3)).add(any(JobRunningStatistics.class));
verify(repository, times(3)).add(any(TaskRunningStatistics.class));
verify(runningService).getAllRunningTasks();
}
Aggregations