### Question:
StatisticRdbRepository { public TaskResultStatistics getSummedTaskResultStatistics(final Date from, final StatisticInterval statisticInterval) { TaskResultStatistics result = new TaskResultStatistics(0, 0, statisticInterval, new Date()); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String sql = String.format("SELECT sum(success_count), sum(failed_count) FROM %s WHERE statistics_time >= '%s'", TABLE_TASK_RESULT_STATISTICS + "_" + statisticInterval, formatter.format(from)); try ( Connection conn = dataSource.getConnection(); PreparedStatement preparedStatement = conn.prepareStatement(sql); ResultSet resultSet = preparedStatement.executeQuery() ) { while (resultSet.next()) { result = new TaskResultStatistics(resultSet.getInt(1), resultSet.getInt(2), statisticInterval, new Date()); } } catch (final SQLException ex) { log.error("Fetch summed taskResultStatistics from DB error:", ex); } return result; } StatisticRdbRepository(final DataSource dataSource); boolean add(final TaskResultStatistics taskResultStatistics); boolean add(final TaskRunningStatistics taskRunningStatistics); boolean add(final JobRunningStatistics jobRunningStatistics); boolean add(final JobRegisterStatistics jobRegisterStatistics); List<TaskResultStatistics> findTaskResultStatistics(final Date from, final StatisticInterval statisticInterval); TaskResultStatistics getSummedTaskResultStatistics(final Date from, final StatisticInterval statisticInterval); Optional<TaskResultStatistics> findLatestTaskResultStatistics(final StatisticInterval statisticInterval); List<TaskRunningStatistics> findTaskRunningStatistics(final Date from); List<JobRunningStatistics> findJobRunningStatistics(final Date from); Optional<TaskRunningStatistics> findLatestTaskRunningStatistics(); Optional<JobRunningStatistics> findLatestJobRunningStatistics(); List<JobRegisterStatistics> findJobRegisterStatistics(final Date from); Optional<JobRegisterStatistics> findLatestJobRegisterStatistics();  }### Answer:
@Test public void assertGetSummedTaskResultStatisticsWhenTableIsEmpty() { for (StatisticInterval each : StatisticInterval.values()) { TaskResultStatistics po = repository.getSummedTaskResultStatistics(new Date(), each); Assert.assertThat(po.getSuccessCount(), Is.is(0)); Assert.assertThat(po.getFailedCount(), Is.is(0)); } }
@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)); } }