use of com.dangdang.ddframe.job.statistics.StatisticInterval in project elastic-job by dangdangdotcom.
the class StatisticRdbRepositoryTest method assertFindLatestTaskResultStatistics.
@Test
public void assertFindLatestTaskResultStatistics() {
for (StatisticInterval each : StatisticInterval.values()) {
repository.add(new TaskResultStatistics(100, 2, each, new Date()));
repository.add(new TaskResultStatistics(200, 5, each, new Date()));
Optional<TaskResultStatistics> po = repository.findLatestTaskResultStatistics(each);
assertThat(po.get().getSuccessCount(), is(200));
assertThat(po.get().getFailedCount(), is(5));
}
}
use of com.dangdang.ddframe.job.statistics.StatisticInterval in project elastic-job by dangdangdotcom.
the class StatisticRdbRepositoryTest method assertGetSummedTaskResultStatistics.
@Test
public void assertGetSummedTaskResultStatistics() {
for (StatisticInterval each : StatisticInterval.values()) {
Date date = new Date();
repository.add(new TaskResultStatistics(100, 2, each, date));
repository.add(new TaskResultStatistics(200, 5, each, date));
TaskResultStatistics po = repository.getSummedTaskResultStatistics(date, each);
assertThat(po.getSuccessCount(), is(300));
assertThat(po.getFailedCount(), is(7));
}
}
use of com.dangdang.ddframe.job.statistics.StatisticInterval in project elastic-job by dangdangdotcom.
the class StatisticManagerTest method assertFindLatestTaskResultStatisticsWhenRdbIsNotConfigured.
@Test
public void assertFindLatestTaskResultStatisticsWhenRdbIsNotConfigured() throws NoSuchFieldException {
ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", null);
for (StatisticInterval each : StatisticInterval.values()) {
TaskResultStatistics actual = statisticManager.findLatestTaskResultStatistics(each);
assertThat(actual.getSuccessCount(), is(0));
assertThat(actual.getFailedCount(), is(0));
}
}
use of com.dangdang.ddframe.job.statistics.StatisticInterval in project elastic-job by dangdangdotcom.
the class TaskResultStatisticJobTest method assertExecute.
@Test
public void assertExecute() throws SchedulerException {
for (StatisticInterval each : StatisticInterval.values()) {
taskResultStatisticJob.setStatisticInterval(each);
Optional<TaskResultStatistics> latestOne = Optional.of(new TaskResultStatistics(0, 0, each, StatisticTimeUtils.getStatisticTime(each, -3)));
when(repository.findLatestTaskResultStatistics(each)).thenReturn(latestOne);
when(repository.add(any(TaskResultStatistics.class))).thenReturn(true);
taskResultStatisticJob.execute(null);
verify(repository).findLatestTaskResultStatistics(each);
}
verify(repository, times(StatisticInterval.values().length * 3)).add(any(TaskResultStatistics.class));
}
Aggregations