@Test public void indexExecution_doNothing_whenThePlannedIndexationIsNull() { PlannedIndexation plannedIndexation = null; cut.indexExecution(plannedIndexation); verify(executionFilesProcessorService, never()).getExecution(any(PlannedIndexation.class)); verify(executionRepository, never()).save(any(Execution.class)); verify(executionRepository, never()).findByCycleDefinitionProjectIdAndJobLinkAndJobLinkNotNull(anyLong(), anyString()); verify(errorRepository, never()).autoAssignProblemsToNewErrors(anyLong(), anyList()); verify(problemDenormalizationService, never()).updateFirstAndLastSeenDateTimes(anyCollection()); verify(transactionService, never()).doAfterCommit(any(Runnable.class)); }
@Transactional public void indexExecution(PlannedIndexation plannedIndexation) { if (plannedIndexation == null) { log.info("No execution indexation found"); return; } File rawExecutionFolder = plannedIndexation.getExecutionFolder(); if (rawExecutionFolder == null) { log.info("No execution folder found"); return; } CycleDefinition cycleDefinition = plannedIndexation.getCycleDefinition(); if (cycleDefinition == null) { log.info("No cycle definition found"); return; } String branch = cycleDefinition.getBranch(); String cycle = cycleDefinition.getName(); final Long projectId = cycleDefinition.getProjectId(); String link = rawExecutionFolder.getAbsolutePath() + File.separator; log.info("Began execution indexing {}/{} for link {}", branch, cycle, link); Optional<Execution> previousExecution = executionRepository.findByCycleDefinitionProjectIdAndJobLinkAndJobLinkNotNull(projectId, link); List<Long> existingErrorIds = getErrorIds(previousExecution); Optional<Execution> processedExecution = executionFilesProcessorService.getExecution(plannedIndexation); if (!processedExecution.isPresent()) { log.info("Could not extract any execution from the directory {}", link); log.info("Some of the files may be incorrect, please check again"); return; } final Execution savedExecution = executionRepository.save(processedExecution.get()); List<Long> newErrorIds = getErrorIds(Optional.of(savedExecution)); newErrorIds.removeAll(existingErrorIds); if (!newErrorIds.isEmpty()) { final Set<Problem> updatedProblems = errorRepository.autoAssignProblemsToNewErrors(projectId, newErrorIds); problemDenormalizationService.updateFirstAndLastSeenDateTimes(updatedProblems); } if (JobStatus.DONE.equals(savedExecution.getStatus())) { transactionAppenderUtil.doAfterCommit(() -> safelySendQualityEmail(savedExecution)); } String url = processedExecution.get().getJobUrl(); log.info("Ended indexing execution {}/{} job URL {} and link {}", branch, cycle, url, link); }
ExecutionIndexerService { @Transactional public void indexExecution(PlannedIndexation plannedIndexation) { if (plannedIndexation == null) { log.info("No execution indexation found"); return; } File rawExecutionFolder = plannedIndexation.getExecutionFolder(); if (rawExecutionFolder == null) { log.info("No execution folder found"); return; } CycleDefinition cycleDefinition = plannedIndexation.getCycleDefinition(); if (cycleDefinition == null) { log.info("No cycle definition found"); return; } String branch = cycleDefinition.getBranch(); String cycle = cycleDefinition.getName(); final Long projectId = cycleDefinition.getProjectId(); String link = rawExecutionFolder.getAbsolutePath() + File.separator; log.info("Began execution indexing {}/{} for link {}", branch, cycle, link); Optional<Execution> previousExecution = executionRepository.findByCycleDefinitionProjectIdAndJobLinkAndJobLinkNotNull(projectId, link); List<Long> existingErrorIds = getErrorIds(previousExecution); Optional<Execution> processedExecution = executionFilesProcessorService.getExecution(plannedIndexation); if (!processedExecution.isPresent()) { log.info("Could not extract any execution from the directory {}", link); log.info("Some of the files may be incorrect, please check again"); return; } final Execution savedExecution = executionRepository.save(processedExecution.get()); List<Long> newErrorIds = getErrorIds(Optional.of(savedExecution)); newErrorIds.removeAll(existingErrorIds); if (!newErrorIds.isEmpty()) { final Set<Problem> updatedProblems = errorRepository.autoAssignProblemsToNewErrors(projectId, newErrorIds); problemDenormalizationService.updateFirstAndLastSeenDateTimes(updatedProblems); } if (JobStatus.DONE.equals(savedExecution.getStatus())) { transactionAppenderUtil.doAfterCommit(() -> safelySendQualityEmail(savedExecution)); } String url = processedExecution.get().getJobUrl(); log.info("Ended indexing execution {}/{} job URL {} and link {}", branch, cycle, url, link); } }
ExecutionIndexerService { @Transactional public void indexExecution(PlannedIndexation plannedIndexation) { if (plannedIndexation == null) { log.info("No execution indexation found"); return; } File rawExecutionFolder = plannedIndexation.getExecutionFolder(); if (rawExecutionFolder == null) { log.info("No execution folder found"); return; } CycleDefinition cycleDefinition = plannedIndexation.getCycleDefinition(); if (cycleDefinition == null) { log.info("No cycle definition found"); return; } String branch = cycleDefinition.getBranch(); String cycle = cycleDefinition.getName(); final Long projectId = cycleDefinition.getProjectId(); String link = rawExecutionFolder.getAbsolutePath() + File.separator; log.info("Began execution indexing {}/{} for link {}", branch, cycle, link); Optional<Execution> previousExecution = executionRepository.findByCycleDefinitionProjectIdAndJobLinkAndJobLinkNotNull(projectId, link); List<Long> existingErrorIds = getErrorIds(previousExecution); Optional<Execution> processedExecution = executionFilesProcessorService.getExecution(plannedIndexation); if (!processedExecution.isPresent()) { log.info("Could not extract any execution from the directory {}", link); log.info("Some of the files may be incorrect, please check again"); return; } final Execution savedExecution = executionRepository.save(processedExecution.get()); List<Long> newErrorIds = getErrorIds(Optional.of(savedExecution)); newErrorIds.removeAll(existingErrorIds); if (!newErrorIds.isEmpty()) { final Set<Problem> updatedProblems = errorRepository.autoAssignProblemsToNewErrors(projectId, newErrorIds); problemDenormalizationService.updateFirstAndLastSeenDateTimes(updatedProblems); } if (JobStatus.DONE.equals(savedExecution.getStatus())) { transactionAppenderUtil.doAfterCommit(() -> safelySendQualityEmail(savedExecution)); } String url = processedExecution.get().getJobUrl(); log.info("Ended indexing execution {}/{} job URL {} and link {}", branch, cycle, url, link); }  }
ExecutionIndexerService { @Transactional public void indexExecution(PlannedIndexation plannedIndexation) { if (plannedIndexation == null) { log.info("No execution indexation found"); return; } File rawExecutionFolder = plannedIndexation.getExecutionFolder(); if (rawExecutionFolder == null) { log.info("No execution folder found"); return; } CycleDefinition cycleDefinition = plannedIndexation.getCycleDefinition(); if (cycleDefinition == null) { log.info("No cycle definition found"); return; } String branch = cycleDefinition.getBranch(); String cycle = cycleDefinition.getName(); final Long projectId = cycleDefinition.getProjectId(); String link = rawExecutionFolder.getAbsolutePath() + File.separator; log.info("Began execution indexing {}/{} for link {}", branch, cycle, link); Optional<Execution> previousExecution = executionRepository.findByCycleDefinitionProjectIdAndJobLinkAndJobLinkNotNull(projectId, link); List<Long> existingErrorIds = getErrorIds(previousExecution); Optional<Execution> processedExecution = executionFilesProcessorService.getExecution(plannedIndexation); if (!processedExecution.isPresent()) { log.info("Could not extract any execution from the directory {}", link); log.info("Some of the files may be incorrect, please check again"); return; } final Execution savedExecution = executionRepository.save(processedExecution.get()); List<Long> newErrorIds = getErrorIds(Optional.of(savedExecution)); newErrorIds.removeAll(existingErrorIds); if (!newErrorIds.isEmpty()) { final Set<Problem> updatedProblems = errorRepository.autoAssignProblemsToNewErrors(projectId, newErrorIds); problemDenormalizationService.updateFirstAndLastSeenDateTimes(updatedProblems); } if (JobStatus.DONE.equals(savedExecution.getStatus())) { transactionAppenderUtil.doAfterCommit(() -> safelySendQualityEmail(savedExecution)); } String url = processedExecution.get().getJobUrl(); log.info("Ended indexing execution {}/{} job URL {} and link {}", branch, cycle, url, link); }  @Transactional void indexExecution(PlannedIndexation plannedIndexation); }
ExecutionIndexerService { @Transactional public void indexExecution(PlannedIndexation plannedIndexation) { if (plannedIndexation == null) { log.info("No execution indexation found"); return; } File rawExecutionFolder = plannedIndexation.getExecutionFolder(); if (rawExecutionFolder == null) { log.info("No execution folder found"); return; } CycleDefinition cycleDefinition = plannedIndexation.getCycleDefinition(); if (cycleDefinition == null) { log.info("No cycle definition found"); return; } String branch = cycleDefinition.getBranch(); String cycle = cycleDefinition.getName(); final Long projectId = cycleDefinition.getProjectId(); String link = rawExecutionFolder.getAbsolutePath() + File.separator; log.info("Began execution indexing {}/{} for link {}", branch, cycle, link); Optional<Execution> previousExecution = executionRepository.findByCycleDefinitionProjectIdAndJobLinkAndJobLinkNotNull(projectId, link); List<Long> existingErrorIds = getErrorIds(previousExecution); Optional<Execution> processedExecution = executionFilesProcessorService.getExecution(plannedIndexation); if (!processedExecution.isPresent()) { log.info("Could not extract any execution from the directory {}", link); log.info("Some of the files may be incorrect, please check again"); return; } final Execution savedExecution = executionRepository.save(processedExecution.get()); List<Long> newErrorIds = getErrorIds(Optional.of(savedExecution)); newErrorIds.removeAll(existingErrorIds); if (!newErrorIds.isEmpty()) { final Set<Problem> updatedProblems = errorRepository.autoAssignProblemsToNewErrors(projectId, newErrorIds); problemDenormalizationService.updateFirstAndLastSeenDateTimes(updatedProblems); } if (JobStatus.DONE.equals(savedExecution.getStatus())) { transactionAppenderUtil.doAfterCommit(() -> safelySendQualityEmail(savedExecution)); } String url = processedExecution.get().getJobUrl(); log.info("Ended indexing execution {}/{} job URL {} and link {}", branch, cycle, url, link); }  @Transactional void indexExecution(PlannedIndexation plannedIndexation);  }