### Question:
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 Optional<JobEventRdbConfiguration> jobEventRdbConfiguration,
                             final StatisticsScheduler scheduler, final Map<StatisticInterval, TaskResultMetaData> statisticData); static StatisticManager getInstance(final CoordinatorRegistryCenter regCenter, final Optional<JobEventRdbConfiguration> jobEventRdbConfiguration); void startup(); void shutdown(); void taskRunSuccessfully(); void taskRunFailed(); TaskResultStatistics getTaskResultStatisticsWeekly(); TaskResultStatistics getTaskResultStatisticsSinceOnline(); TaskResultStatistics findLatestTaskResultStatistics(final StatisticInterval statisticInterval); List<TaskResultStatistics> findTaskResultStatisticsDaily(); JobTypeStatistics getJobTypeStatistics(); JobExecutionTypeStatistics getJobExecutionTypeStatistics(); List<TaskRunningStatistics> findTaskRunningStatisticsWeekly(); List<JobRunningStatistics> findJobRunningStatisticsWeekly(); List<JobRegisterStatistics> findJobRegisterStatisticsSinceOnline();  }### Answer:
@Test public void assertFindLatestTaskResultStatisticsWhenRdbIsNotConfigured() throws NoSuchFieldException { ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", null); for (StatisticInterval each : StatisticInterval.values()) { TaskResultStatistics actual = statisticManager.findLatestTaskResultStatistics(each); Assert.assertThat(actual.getSuccessCount(), Is.is(0)); Assert.assertThat(actual.getFailedCount(), Is.is(0)); } }
@Test public void assertFindLatestTaskResultStatisticsWhenRdbIsConfigured() throws NoSuchFieldException { ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", rdbRepository); for (StatisticInterval each : StatisticInterval.values()) { Mockito.when(rdbRepository.findLatestTaskResultStatistics(each)) .thenReturn(Optional.of(new TaskResultStatistics(10, 5, each, new Date()))); TaskResultStatistics actual = statisticManager.findLatestTaskResultStatistics(each); Assert.assertThat(actual.getSuccessCount(), Is.is(10)); Assert.assertThat(actual.getFailedCount(), Is.is(5)); } Mockito.verify(rdbRepository, Mockito.times(StatisticInterval.values().length)).findLatestTaskResultStatistics(Mockito.any(StatisticInterval.class)); }