use of com.dangdang.ddframe.job.statistics.type.task.TaskResultStatistics in project elastic-job by dangdangdotcom.
the class StatisticManagerTest method assertTaskResultStatisticsWhenRdbIsConfigured.
@Test
public void assertTaskResultStatisticsWhenRdbIsConfigured() throws NoSuchFieldException {
ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", rdbRepository);
when(rdbRepository.getSummedTaskResultStatistics(any(Date.class), any(StatisticInterval.class))).thenReturn(new TaskResultStatistics(10, 10, StatisticInterval.DAY, new Date()));
assertThat(statisticManager.getTaskResultStatisticsWeekly().getSuccessCount(), is(10));
assertThat(statisticManager.getTaskResultStatisticsWeekly().getFailedCount(), is(10));
assertThat(statisticManager.getTaskResultStatisticsSinceOnline().getSuccessCount(), is(10));
assertThat(statisticManager.getTaskResultStatisticsSinceOnline().getFailedCount(), is(10));
verify(rdbRepository, times(4)).getSummedTaskResultStatistics(any(Date.class), any(StatisticInterval.class));
}
use of com.dangdang.ddframe.job.statistics.type.task.TaskResultStatistics 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.type.task.TaskResultStatistics 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));
}
}
use of com.dangdang.ddframe.job.statistics.type.task.TaskResultStatistics 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.type.task.TaskResultStatistics 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));
}
}
Aggregations