@Test public void create_ShouldFail_WhenDemoProjectAlreadyExists() throws BadRequestException { when(projectService.findOne(PROJECT_CODE_DEMO)).thenReturn(Optional.of(new ProjectDTO())); assertThrows(BadRequestException.class, () -> cut.create()); }
@Transactional public ProjectDTO create() throws BadRequestException { if (projectService.findOne(PROJECT_CODE_DEMO).isPresent()) { throw new BadRequestException(Messages.RULE_DEMO_PROJECT_ALREADY_EXISTS, Entities.PROJECT, "demo-exists"); } final ProjectDTO project = demoSettingsLoader.createProjectWithCommunicationsAndRootCauses(); long projectId = project.getId().longValue(); demoSettingsLoader.setCommunications(projectId); demoSettingsLoader.createSources(projectId); demoSettingsLoader.createTypes(projectId); demoSettingsLoader.createCountries(projectId); demoSettingsLoader.createSeverities(projectId); List<TeamDTO> teams = demoSettingsLoader.createTeams(projectId); demoProblemLoader.createProblems(projectId, teams); final Map<String, Long> functionalityIds = demoFunctionalityLoader.createFunctionalityTree(projectId, teams); demoScenarioLoader.createScenarios(projectId, functionalityIds); final List<CycleDefinitionDTO> cycleDefinitions = demoSettingsLoader.createCycleDefinitions(projectId); demoExecutionLoader.importExecution(projectId, functionalityIds, cycleDefinitions); return project; }
DemoService { @Transactional public ProjectDTO create() throws BadRequestException { if (projectService.findOne(PROJECT_CODE_DEMO).isPresent()) { throw new BadRequestException(Messages.RULE_DEMO_PROJECT_ALREADY_EXISTS, Entities.PROJECT, "demo-exists"); } final ProjectDTO project = demoSettingsLoader.createProjectWithCommunicationsAndRootCauses(); long projectId = project.getId().longValue(); demoSettingsLoader.setCommunications(projectId); demoSettingsLoader.createSources(projectId); demoSettingsLoader.createTypes(projectId); demoSettingsLoader.createCountries(projectId); demoSettingsLoader.createSeverities(projectId); List<TeamDTO> teams = demoSettingsLoader.createTeams(projectId); demoProblemLoader.createProblems(projectId, teams); final Map<String, Long> functionalityIds = demoFunctionalityLoader.createFunctionalityTree(projectId, teams); demoScenarioLoader.createScenarios(projectId, functionalityIds); final List<CycleDefinitionDTO> cycleDefinitions = demoSettingsLoader.createCycleDefinitions(projectId); demoExecutionLoader.importExecution(projectId, functionalityIds, cycleDefinitions); return project; } }
DemoService { @Transactional public ProjectDTO create() throws BadRequestException { if (projectService.findOne(PROJECT_CODE_DEMO).isPresent()) { throw new BadRequestException(Messages.RULE_DEMO_PROJECT_ALREADY_EXISTS, Entities.PROJECT, "demo-exists"); } final ProjectDTO project = demoSettingsLoader.createProjectWithCommunicationsAndRootCauses(); long projectId = project.getId().longValue(); demoSettingsLoader.setCommunications(projectId); demoSettingsLoader.createSources(projectId); demoSettingsLoader.createTypes(projectId); demoSettingsLoader.createCountries(projectId); demoSettingsLoader.createSeverities(projectId); List<TeamDTO> teams = demoSettingsLoader.createTeams(projectId); demoProblemLoader.createProblems(projectId, teams); final Map<String, Long> functionalityIds = demoFunctionalityLoader.createFunctionalityTree(projectId, teams); demoScenarioLoader.createScenarios(projectId, functionalityIds); final List<CycleDefinitionDTO> cycleDefinitions = demoSettingsLoader.createCycleDefinitions(projectId); demoExecutionLoader.importExecution(projectId, functionalityIds, cycleDefinitions); return project; }  }
DemoService { @Transactional public ProjectDTO create() throws BadRequestException { if (projectService.findOne(PROJECT_CODE_DEMO).isPresent()) { throw new BadRequestException(Messages.RULE_DEMO_PROJECT_ALREADY_EXISTS, Entities.PROJECT, "demo-exists"); } final ProjectDTO project = demoSettingsLoader.createProjectWithCommunicationsAndRootCauses(); long projectId = project.getId().longValue(); demoSettingsLoader.setCommunications(projectId); demoSettingsLoader.createSources(projectId); demoSettingsLoader.createTypes(projectId); demoSettingsLoader.createCountries(projectId); demoSettingsLoader.createSeverities(projectId); List<TeamDTO> teams = demoSettingsLoader.createTeams(projectId); demoProblemLoader.createProblems(projectId, teams); final Map<String, Long> functionalityIds = demoFunctionalityLoader.createFunctionalityTree(projectId, teams); demoScenarioLoader.createScenarios(projectId, functionalityIds); final List<CycleDefinitionDTO> cycleDefinitions = demoSettingsLoader.createCycleDefinitions(projectId); demoExecutionLoader.importExecution(projectId, functionalityIds, cycleDefinitions); return project; }  @Transactional ProjectDTO create(); void delete(); }
DemoService { @Transactional public ProjectDTO create() throws BadRequestException { if (projectService.findOne(PROJECT_CODE_DEMO).isPresent()) { throw new BadRequestException(Messages.RULE_DEMO_PROJECT_ALREADY_EXISTS, Entities.PROJECT, "demo-exists"); } final ProjectDTO project = demoSettingsLoader.createProjectWithCommunicationsAndRootCauses(); long projectId = project.getId().longValue(); demoSettingsLoader.setCommunications(projectId); demoSettingsLoader.createSources(projectId); demoSettingsLoader.createTypes(projectId); demoSettingsLoader.createCountries(projectId); demoSettingsLoader.createSeverities(projectId); List<TeamDTO> teams = demoSettingsLoader.createTeams(projectId); demoProblemLoader.createProblems(projectId, teams); final Map<String, Long> functionalityIds = demoFunctionalityLoader.createFunctionalityTree(projectId, teams); demoScenarioLoader.createScenarios(projectId, functionalityIds); final List<CycleDefinitionDTO> cycleDefinitions = demoSettingsLoader.createCycleDefinitions(projectId); demoExecutionLoader.importExecution(projectId, functionalityIds, cycleDefinitions); return project; }  @Transactional ProjectDTO create(); void delete();  }