@Test public void delete_ShouldFail_WhenDemoProjectDoesNotExist() throws NotFoundException { when(projectRepository.findOneByCode(PROJECT_CODE_DEMO)).thenReturn(null); assertThrows(NotFoundException.class, () -> cut.delete()); }
public void delete() throws NotFoundException { final Project project = projectRepository.findOneByCode(PROJECT_CODE_DEMO); if (project == null) { throw new NotFoundException(Messages.NOT_FOUND_PROJECT, Entities.PROJECT); } final String executionBasePath = settingService.get(project.getId().longValue(), Settings.EXECUTION_INDEXER_FILE_EXECUTION_BASE_PATH); projectRepository.delete(project); if (executionBasePath.contains(Settings.PROJECT_VARIABLE)) { final String projectExecutionsFolder = executionBasePath .replace(Settings.PROJECT_VARIABLE, PROJECT_CODE_DEMO) .replace(Settings.BRANCH_VARIABLE, "") .replace(Settings.CYCLE_VARIABLE, ""); try { FileUtils.deleteDirectory(new File(projectExecutionsFolder)); } catch (IOException e) { log.error("Cannot delete the temporary directory for the demo project's executions: " + projectExecutionsFolder, e); } } }
DemoService { public void delete() throws NotFoundException { final Project project = projectRepository.findOneByCode(PROJECT_CODE_DEMO); if (project == null) { throw new NotFoundException(Messages.NOT_FOUND_PROJECT, Entities.PROJECT); } final String executionBasePath = settingService.get(project.getId().longValue(), Settings.EXECUTION_INDEXER_FILE_EXECUTION_BASE_PATH); projectRepository.delete(project); if (executionBasePath.contains(Settings.PROJECT_VARIABLE)) { final String projectExecutionsFolder = executionBasePath .replace(Settings.PROJECT_VARIABLE, PROJECT_CODE_DEMO) .replace(Settings.BRANCH_VARIABLE, "") .replace(Settings.CYCLE_VARIABLE, ""); try { FileUtils.deleteDirectory(new File(projectExecutionsFolder)); } catch (IOException e) { log.error("Cannot delete the temporary directory for the demo project's executions: " + projectExecutionsFolder, e); } } } }
DemoService { public void delete() throws NotFoundException { final Project project = projectRepository.findOneByCode(PROJECT_CODE_DEMO); if (project == null) { throw new NotFoundException(Messages.NOT_FOUND_PROJECT, Entities.PROJECT); } final String executionBasePath = settingService.get(project.getId().longValue(), Settings.EXECUTION_INDEXER_FILE_EXECUTION_BASE_PATH); projectRepository.delete(project); if (executionBasePath.contains(Settings.PROJECT_VARIABLE)) { final String projectExecutionsFolder = executionBasePath .replace(Settings.PROJECT_VARIABLE, PROJECT_CODE_DEMO) .replace(Settings.BRANCH_VARIABLE, "") .replace(Settings.CYCLE_VARIABLE, ""); try { FileUtils.deleteDirectory(new File(projectExecutionsFolder)); } catch (IOException e) { log.error("Cannot delete the temporary directory for the demo project's executions: " + projectExecutionsFolder, e); } } }  }
DemoService { public void delete() throws NotFoundException { final Project project = projectRepository.findOneByCode(PROJECT_CODE_DEMO); if (project == null) { throw new NotFoundException(Messages.NOT_FOUND_PROJECT, Entities.PROJECT); } final String executionBasePath = settingService.get(project.getId().longValue(), Settings.EXECUTION_INDEXER_FILE_EXECUTION_BASE_PATH); projectRepository.delete(project); if (executionBasePath.contains(Settings.PROJECT_VARIABLE)) { final String projectExecutionsFolder = executionBasePath .replace(Settings.PROJECT_VARIABLE, PROJECT_CODE_DEMO) .replace(Settings.BRANCH_VARIABLE, "") .replace(Settings.CYCLE_VARIABLE, ""); try { FileUtils.deleteDirectory(new File(projectExecutionsFolder)); } catch (IOException e) { log.error("Cannot delete the temporary directory for the demo project's executions: " + projectExecutionsFolder, e); } } }  @Transactional ProjectDTO create(); void delete(); }
DemoService { public void delete() throws NotFoundException { final Project project = projectRepository.findOneByCode(PROJECT_CODE_DEMO); if (project == null) { throw new NotFoundException(Messages.NOT_FOUND_PROJECT, Entities.PROJECT); } final String executionBasePath = settingService.get(project.getId().longValue(), Settings.EXECUTION_INDEXER_FILE_EXECUTION_BASE_PATH); projectRepository.delete(project); if (executionBasePath.contains(Settings.PROJECT_VARIABLE)) { final String projectExecutionsFolder = executionBasePath .replace(Settings.PROJECT_VARIABLE, PROJECT_CODE_DEMO) .replace(Settings.BRANCH_VARIABLE, "") .replace(Settings.CYCLE_VARIABLE, ""); try { FileUtils.deleteDirectory(new File(projectExecutionsFolder)); } catch (IOException e) { log.error("Cannot delete the temporary directory for the demo project's executions: " + projectExecutionsFolder, e); } } }  @Transactional ProjectDTO create(); void delete();  }