@Test public void uploadExecutionReport_should_throw_IllegalArgumentException_if_cycle_doesnt_exists() throws IOException { long projectId = 23L; String projectCode = "prj"; String branch = "master"; String cycle = "day"; MultipartFile zip = new MockMultipartFile("zip", "test.zip", "application/zip", new byte[0]); doReturn(Optional.empty()).when(cycleDefinitionRepository).findByProjectIdAndBranchAndName(projectId, branch, cycle); assertThrows(IllegalArgumentException.class, () -> cut.uploadExecutionReport(projectId, projectCode, branch, cycle, zip)); }
public void uploadExecutionReport(long projectId, String projectCode, String branch, String cycle, MultipartFile zipFile) throws IOException { CycleDefinition cycleDefinition = cycleDefinitionRepository.findByProjectIdAndBranchAndName(projectId, branch, cycle) .orElseThrow(() -> new IllegalArgumentException("The branch or cycle for this project doesn't exists.")); String path = settingService.get(projectId, Settings.EXECUTION_INDEXER_FILE_EXECUTION_BASE_PATH) .replace(Settings.PROJECT_VARIABLE, projectCode) .replace(Settings.BRANCH_VARIABLE, branch) .replace(Settings.CYCLE_VARIABLE, cycle); File destinationDirectory = new File(path, "incoming"); String buildInformationFilePath = settingService.get(projectId, Settings.EXECUTION_INDEXER_FILE_BUILD_INFORMATION_PATH); List<File> executionDirectories = this.unzipExecutions(destinationDirectory, zipFile, buildInformationFilePath); for (final File executionDirectory : executionDirectories) { try { processSpecificDirectory(cycleDefinition, executionDirectory); } catch (Exception e) { log.error("A problem occurred while indexing this execution [{}]", executionDirectory.getPath(), e); } finally { log.info("Cleaning the incoming folder: {}", executionDirectory.getAbsolutePath()); cleanExecutionFiles(projectId, executionDirectory); } } }
ExecutionService { public void uploadExecutionReport(long projectId, String projectCode, String branch, String cycle, MultipartFile zipFile) throws IOException { CycleDefinition cycleDefinition = cycleDefinitionRepository.findByProjectIdAndBranchAndName(projectId, branch, cycle) .orElseThrow(() -> new IllegalArgumentException("The branch or cycle for this project doesn't exists.")); String path = settingService.get(projectId, Settings.EXECUTION_INDEXER_FILE_EXECUTION_BASE_PATH) .replace(Settings.PROJECT_VARIABLE, projectCode) .replace(Settings.BRANCH_VARIABLE, branch) .replace(Settings.CYCLE_VARIABLE, cycle); File destinationDirectory = new File(path, "incoming"); String buildInformationFilePath = settingService.get(projectId, Settings.EXECUTION_INDEXER_FILE_BUILD_INFORMATION_PATH); List<File> executionDirectories = this.unzipExecutions(destinationDirectory, zipFile, buildInformationFilePath); for (final File executionDirectory : executionDirectories) { try { processSpecificDirectory(cycleDefinition, executionDirectory); } catch (Exception e) { log.error("A problem occurred while indexing this execution [{}]", executionDirectory.getPath(), e); } finally { log.info("Cleaning the incoming folder: {}", executionDirectory.getAbsolutePath()); cleanExecutionFiles(projectId, executionDirectory); } } } }
ExecutionService { public void uploadExecutionReport(long projectId, String projectCode, String branch, String cycle, MultipartFile zipFile) throws IOException { CycleDefinition cycleDefinition = cycleDefinitionRepository.findByProjectIdAndBranchAndName(projectId, branch, cycle) .orElseThrow(() -> new IllegalArgumentException("The branch or cycle for this project doesn't exists.")); String path = settingService.get(projectId, Settings.EXECUTION_INDEXER_FILE_EXECUTION_BASE_PATH) .replace(Settings.PROJECT_VARIABLE, projectCode) .replace(Settings.BRANCH_VARIABLE, branch) .replace(Settings.CYCLE_VARIABLE, cycle); File destinationDirectory = new File(path, "incoming"); String buildInformationFilePath = settingService.get(projectId, Settings.EXECUTION_INDEXER_FILE_BUILD_INFORMATION_PATH); List<File> executionDirectories = this.unzipExecutions(destinationDirectory, zipFile, buildInformationFilePath); for (final File executionDirectory : executionDirectories) { try { processSpecificDirectory(cycleDefinition, executionDirectory); } catch (Exception e) { log.error("A problem occurred while indexing this execution [{}]", executionDirectory.getPath(), e); } finally { log.info("Cleaning the incoming folder: {}", executionDirectory.getAbsolutePath()); cleanExecutionFiles(projectId, executionDirectory); } } }  }
ExecutionService { public void uploadExecutionReport(long projectId, String projectCode, String branch, String cycle, MultipartFile zipFile) throws IOException { CycleDefinition cycleDefinition = cycleDefinitionRepository.findByProjectIdAndBranchAndName(projectId, branch, cycle) .orElseThrow(() -> new IllegalArgumentException("The branch or cycle for this project doesn't exists.")); String path = settingService.get(projectId, Settings.EXECUTION_INDEXER_FILE_EXECUTION_BASE_PATH) .replace(Settings.PROJECT_VARIABLE, projectCode) .replace(Settings.BRANCH_VARIABLE, branch) .replace(Settings.CYCLE_VARIABLE, cycle); File destinationDirectory = new File(path, "incoming"); String buildInformationFilePath = settingService.get(projectId, Settings.EXECUTION_INDEXER_FILE_BUILD_INFORMATION_PATH); List<File> executionDirectories = this.unzipExecutions(destinationDirectory, zipFile, buildInformationFilePath); for (final File executionDirectory : executionDirectories) { try { processSpecificDirectory(cycleDefinition, executionDirectory); } catch (Exception e) { log.error("A problem occurred while indexing this execution [{}]", executionDirectory.getPath(), e); } finally { log.info("Cleaning the incoming folder: {}", executionDirectory.getAbsolutePath()); cleanExecutionFiles(projectId, executionDirectory); } } }  @Transactional(readOnly = true) Page<ExecutionWithHandlingCountsDTO> findAll(long projectId, Pageable pageable); @Transactional(readOnly = true) ExecutionWithCountryDeploymentsAndRunsAndExecutedScenariosAndTeamIdsAndErrorsAndProblemsDTO findOneWithRuns(long projectId, long id, ExecutionCriteriaDTO criteria); ExecutionDTO discard(long projectId, long id, String discardReason); ExecutionDTO unDiscard(long projectId, long id); void requestCompletion(long projectId, String jobUrl); String getQualityStatus(long projectId, String jobUrl); List<ExecutionDTO> getLatestEligibleVersions(long projectId); void uploadExecutionReport(long projectId, String projectCode, String branch, String cycle, MultipartFile zipFile); void processSpecificDirectory(CycleDefinition cycleDefinition, File executionDirectory); }
ExecutionService { public void uploadExecutionReport(long projectId, String projectCode, String branch, String cycle, MultipartFile zipFile) throws IOException { CycleDefinition cycleDefinition = cycleDefinitionRepository.findByProjectIdAndBranchAndName(projectId, branch, cycle) .orElseThrow(() -> new IllegalArgumentException("The branch or cycle for this project doesn't exists.")); String path = settingService.get(projectId, Settings.EXECUTION_INDEXER_FILE_EXECUTION_BASE_PATH) .replace(Settings.PROJECT_VARIABLE, projectCode) .replace(Settings.BRANCH_VARIABLE, branch) .replace(Settings.CYCLE_VARIABLE, cycle); File destinationDirectory = new File(path, "incoming"); String buildInformationFilePath = settingService.get(projectId, Settings.EXECUTION_INDEXER_FILE_BUILD_INFORMATION_PATH); List<File> executionDirectories = this.unzipExecutions(destinationDirectory, zipFile, buildInformationFilePath); for (final File executionDirectory : executionDirectories) { try { processSpecificDirectory(cycleDefinition, executionDirectory); } catch (Exception e) { log.error("A problem occurred while indexing this execution [{}]", executionDirectory.getPath(), e); } finally { log.info("Cleaning the incoming folder: {}", executionDirectory.getAbsolutePath()); cleanExecutionFiles(projectId, executionDirectory); } } }  @Transactional(readOnly = true) Page<ExecutionWithHandlingCountsDTO> findAll(long projectId, Pageable pageable); @Transactional(readOnly = true) ExecutionWithCountryDeploymentsAndRunsAndExecutedScenariosAndTeamIdsAndErrorsAndProblemsDTO findOneWithRuns(long projectId, long id, ExecutionCriteriaDTO criteria); ExecutionDTO discard(long projectId, long id, String discardReason); ExecutionDTO unDiscard(long projectId, long id); void requestCompletion(long projectId, String jobUrl); String getQualityStatus(long projectId, String jobUrl); List<ExecutionDTO> getLatestEligibleVersions(long projectId); void uploadExecutionReport(long projectId, String projectCode, String branch, String cycle, MultipartFile zipFile); void processSpecificDirectory(CycleDefinition cycleDefinition, File executionDirectory);  }