@Test public void assertExecute() { for (StatisticInterval each : StatisticInterval.values()) { taskResultStatisticJob.setStatisticInterval(each); Optional<TaskResultStatistics> latestOne = Optional.of(new TaskResultStatistics(0, 0, each, StatisticTimeUtils.getStatisticTime(each, -3))); when(repository.findLatestTaskResultStatistics(each)).thenReturn(latestOne); when(repository.add(any(TaskResultStatistics.class))).thenReturn(true); taskResultStatisticJob.execute(null); verify(repository).findLatestTaskResultStatistics(each); } verify(repository, times(StatisticInterval.values().length * 3)).add(any(TaskResultStatistics.class)); }
@Override public void execute(final JobExecutionContext context) { Optional<TaskResultStatistics> latestOne = repository.findLatestTaskResultStatistics(statisticInterval); latestOne.ifPresent(this::fillBlankIfNeeded); TaskResultStatistics taskResultStatistics = new TaskResultStatistics( sharedData.getSuccessCount(), sharedData.getFailedCount(), statisticInterval, StatisticTimeUtils.getCurrentStatisticTime(statisticInterval)); log.debug("Add taskResultStatistics, statisticInterval is:{}, successCount is:{}, failedCount is:{}", statisticInterval, sharedData.getSuccessCount(), sharedData.getFailedCount()); repository.add(taskResultStatistics); sharedData.reset(); }
TaskResultStatisticJob extends AbstractStatisticJob { @Override public void execute(final JobExecutionContext context) { Optional<TaskResultStatistics> latestOne = repository.findLatestTaskResultStatistics(statisticInterval); latestOne.ifPresent(this::fillBlankIfNeeded); TaskResultStatistics taskResultStatistics = new TaskResultStatistics( sharedData.getSuccessCount(), sharedData.getFailedCount(), statisticInterval, StatisticTimeUtils.getCurrentStatisticTime(statisticInterval)); log.debug("Add taskResultStatistics, statisticInterval is:{}, successCount is:{}, failedCount is:{}", statisticInterval, sharedData.getSuccessCount(), sharedData.getFailedCount()); repository.add(taskResultStatistics); sharedData.reset(); } }
TaskResultStatisticJob extends AbstractStatisticJob { @Override public void execute(final JobExecutionContext context) { Optional<TaskResultStatistics> latestOne = repository.findLatestTaskResultStatistics(statisticInterval); latestOne.ifPresent(this::fillBlankIfNeeded); TaskResultStatistics taskResultStatistics = new TaskResultStatistics( sharedData.getSuccessCount(), sharedData.getFailedCount(), statisticInterval, StatisticTimeUtils.getCurrentStatisticTime(statisticInterval)); log.debug("Add taskResultStatistics, statisticInterval is:{}, successCount is:{}, failedCount is:{}", statisticInterval, sharedData.getSuccessCount(), sharedData.getFailedCount()); repository.add(taskResultStatistics); sharedData.reset(); }  }
TaskResultStatisticJob extends AbstractStatisticJob { @Override public void execute(final JobExecutionContext context) { Optional<TaskResultStatistics> latestOne = repository.findLatestTaskResultStatistics(statisticInterval); latestOne.ifPresent(this::fillBlankIfNeeded); TaskResultStatistics taskResultStatistics = new TaskResultStatistics( sharedData.getSuccessCount(), sharedData.getFailedCount(), statisticInterval, StatisticTimeUtils.getCurrentStatisticTime(statisticInterval)); log.debug("Add taskResultStatistics, statisticInterval is:{}, successCount is:{}, failedCount is:{}", statisticInterval, sharedData.getSuccessCount(), sharedData.getFailedCount()); repository.add(taskResultStatistics); sharedData.reset(); }  @Override JobDetail buildJobDetail(); @Override Trigger buildTrigger(); @Override Map<String, Object> getDataMap(); @Override void execute(final JobExecutionContext context); }
TaskResultStatisticJob extends AbstractStatisticJob { @Override public void execute(final JobExecutionContext context) { Optional<TaskResultStatistics> latestOne = repository.findLatestTaskResultStatistics(statisticInterval); latestOne.ifPresent(this::fillBlankIfNeeded); TaskResultStatistics taskResultStatistics = new TaskResultStatistics( sharedData.getSuccessCount(), sharedData.getFailedCount(), statisticInterval, StatisticTimeUtils.getCurrentStatisticTime(statisticInterval)); log.debug("Add taskResultStatistics, statisticInterval is:{}, successCount is:{}, failedCount is:{}", statisticInterval, sharedData.getSuccessCount(), sharedData.getFailedCount()); repository.add(taskResultStatistics); sharedData.reset(); }  @Override JobDetail buildJobDetail(); @Override Trigger buildTrigger(); @Override Map<String, Object> getDataMap(); @Override void execute(final JobExecutionContext context);  }