use of com.dangdang.ddframe.job.statistics.StatisticInterval in project elastic-job by dangdangdotcom.
the class TaskResultStatisticJobTest method assertExecuteWhenRepositoryIsEmpty.
@Test
public void assertExecuteWhenRepositoryIsEmpty() throws SchedulerException {
Optional<TaskResultStatistics> latestOne = Optional.absent();
for (StatisticInterval each : StatisticInterval.values()) {
taskResultStatisticJob.setStatisticInterval(each);
when(repository.findLatestTaskResultStatistics(each)).thenReturn(latestOne);
when(repository.add(any(TaskResultStatistics.class))).thenReturn(true);
taskResultStatisticJob.execute(null);
verify(repository).findLatestTaskResultStatistics(each);
}
verify(repository, times(3)).add(any(TaskResultStatistics.class));
}
use of com.dangdang.ddframe.job.statistics.StatisticInterval in project elastic-job by dangdangdotcom.
the class TaskResultStatisticJobTest method assertBuildTrigger.
@Test
public void assertBuildTrigger() throws SchedulerException {
for (StatisticInterval each : StatisticInterval.values()) {
taskResultStatisticJob.setStatisticInterval(each);
Trigger trigger = taskResultStatisticJob.buildTrigger();
assertThat(trigger.getKey().getName(), is(TaskResultStatisticJob.class.getSimpleName() + "Trigger" + "_" + each));
}
}
use of com.dangdang.ddframe.job.statistics.StatisticInterval in project elastic-job by dangdangdotcom.
the class StatisticRdbRepositoryTest method assertFindTaskResultStatisticsWithDifferentFromDate.
@Test
public void assertFindTaskResultStatisticsWithDifferentFromDate() {
Date now = new Date();
Date yesterday = getYesterday();
for (StatisticInterval each : StatisticInterval.values()) {
assertTrue(repository.add(new TaskResultStatistics(100, 0, each, yesterday)));
assertTrue(repository.add(new TaskResultStatistics(100, 0, each, now)));
assertThat(repository.findTaskResultStatistics(yesterday, each).size(), is(2));
assertThat(repository.findTaskResultStatistics(now, each).size(), is(1));
}
}
use of com.dangdang.ddframe.job.statistics.StatisticInterval in project elastic-job by dangdangdotcom.
the class StatisticManagerTest method assertFindLatestTaskResultStatisticsWhenRdbIsConfigured.
@Test
public void assertFindLatestTaskResultStatisticsWhenRdbIsConfigured() throws NoSuchFieldException {
ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", rdbRepository);
for (StatisticInterval each : StatisticInterval.values()) {
when(rdbRepository.findLatestTaskResultStatistics(each)).thenReturn(Optional.of(new TaskResultStatistics(10, 5, each, new Date())));
TaskResultStatistics actual = statisticManager.findLatestTaskResultStatistics(each);
assertThat(actual.getSuccessCount(), is(10));
assertThat(actual.getFailedCount(), is(5));
}
verify(rdbRepository, times(StatisticInterval.values().length)).findLatestTaskResultStatistics(any(StatisticInterval.class));
}
use of com.dangdang.ddframe.job.statistics.StatisticInterval in project elastic-job by dangdangdotcom.
the class StatisticRdbRepositoryTest method assertGetSummedTaskResultStatisticsWhenTableIsEmpty.
@Test
public void assertGetSummedTaskResultStatisticsWhenTableIsEmpty() {
for (StatisticInterval each : StatisticInterval.values()) {
TaskResultStatistics po = repository.getSummedTaskResultStatistics(new Date(), each);
assertThat(po.getSuccessCount(), is(0));
assertThat(po.getFailedCount(), is(0));
}
}
Aggregations