@Test public void assertFindLatestTaskResultStatisticsWhenRdbIsConfigured() { 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)); }
public TaskResultStatistics findLatestTaskResultStatistics(final StatisticInterval statisticInterval) { if (isRdbConfigured()) { Optional<TaskResultStatistics> result = rdbRepository.findLatestTaskResultStatistics(statisticInterval); if (result.isPresent()) { return result.get(); } } return new TaskResultStatistics(0, 0, statisticInterval, new Date()); }
StatisticManager { public TaskResultStatistics findLatestTaskResultStatistics(final StatisticInterval statisticInterval) { if (isRdbConfigured()) { Optional<TaskResultStatistics> result = rdbRepository.findLatestTaskResultStatistics(statisticInterval); if (result.isPresent()) { return result.get(); } } return new TaskResultStatistics(0, 0, statisticInterval, new Date()); } }
StatisticManager { public TaskResultStatistics findLatestTaskResultStatistics(final StatisticInterval statisticInterval) { if (isRdbConfigured()) { Optional<TaskResultStatistics> result = rdbRepository.findLatestTaskResultStatistics(statisticInterval); if (result.isPresent()) { return result.get(); } } return new TaskResultStatistics(0, 0, statisticInterval, new Date()); } private  StatisticManager(final CoordinatorRegistryCenter registryCenter, final TracingConfiguration tracingConfiguration,
                             final StatisticsScheduler scheduler, final Map<StatisticInterval, TaskResultMetaData> statisticData); }
StatisticManager { public TaskResultStatistics findLatestTaskResultStatistics(final StatisticInterval statisticInterval) { if (isRdbConfigured()) { Optional<TaskResultStatistics> result = rdbRepository.findLatestTaskResultStatistics(statisticInterval); if (result.isPresent()) { return result.get(); } } return new TaskResultStatistics(0, 0, statisticInterval, new Date()); } private  StatisticManager(final CoordinatorRegistryCenter registryCenter, final TracingConfiguration tracingConfiguration,
                             final StatisticsScheduler scheduler, final Map<StatisticInterval, TaskResultMetaData> statisticData); static StatisticManager getInstance(final CoordinatorRegistryCenter regCenter, final TracingConfiguration tracingConfiguration); void startup(); void shutdown(); void taskRunSuccessfully(); void taskRunFailed(); TaskResultStatistics getTaskResultStatisticsWeekly(); TaskResultStatistics getTaskResultStatisticsSinceOnline(); TaskResultStatistics findLatestTaskResultStatistics(final StatisticInterval statisticInterval); List<TaskResultStatistics> findTaskResultStatisticsDaily(); JobExecutionTypeStatistics getJobExecutionTypeStatistics(); List<TaskRunningStatistics> findTaskRunningStatisticsWeekly(); List<JobRunningStatistics> findJobRunningStatisticsWeekly(); List<JobRegisterStatistics> findJobRegisterStatisticsSinceOnline(); }
StatisticManager { public TaskResultStatistics findLatestTaskResultStatistics(final StatisticInterval statisticInterval) { if (isRdbConfigured()) { Optional<TaskResultStatistics> result = rdbRepository.findLatestTaskResultStatistics(statisticInterval); if (result.isPresent()) { return result.get(); } } return new TaskResultStatistics(0, 0, statisticInterval, new Date()); } private  StatisticManager(final CoordinatorRegistryCenter registryCenter, final TracingConfiguration tracingConfiguration,
                             final StatisticsScheduler scheduler, final Map<StatisticInterval, TaskResultMetaData> statisticData); static StatisticManager getInstance(final CoordinatorRegistryCenter regCenter, final TracingConfiguration tracingConfiguration); void startup(); void shutdown(); void taskRunSuccessfully(); void taskRunFailed(); TaskResultStatistics getTaskResultStatisticsWeekly(); TaskResultStatistics getTaskResultStatisticsSinceOnline(); TaskResultStatistics findLatestTaskResultStatistics(final StatisticInterval statisticInterval); List<TaskResultStatistics> findTaskResultStatisticsDaily(); JobExecutionTypeStatistics getJobExecutionTypeStatistics(); List<TaskRunningStatistics> findTaskRunningStatisticsWeekly(); List<JobRunningStatistics> findJobRunningStatisticsWeekly(); List<JobRegisterStatistics> findJobRegisterStatisticsSinceOnline();  }