@Test public void when_a_project_is_found_it_will_be_deleted() { Project project1 = new Project(); project1.id="project1"; when(projectRepository.findOrFailProject("project1")).thenReturn(project1); serviceToTest.deleteProject("project1"); verify(transactionService).deleteWithAssociationsInOwnTransaction(project1.getId()); }
@UseCaseAdministratorDeleteProject(@Step(number = 2, name = "Service deletes projects.", next = { 3, 4, 5, 6, 7}, description = "The service will delete the project with dependencies and triggers asynchronous events")) public void deleteProject(String projectId) { auditLogService.log("triggers delete of project {}", logSanitizer.sanitize(projectId, 30)); assertion.isValidProjectId(projectId); Project project = projectRepository.findOrFailProject(projectId); ProjectMessage message = new ProjectMessage(); message.setProjectId(project.getId()); message.setProjectActionTriggeredBy(userContext.getUserId()); User owner = project.getOwner(); if (owner == null) { LOG.warn("No owner found for project {} while deleting", project.getId()); } else { message.setProjectOwnerEmailAddress(owner.getEmailAdress()); } for (User user : project.getUsers()) { message.addUserEmailAddress(user.getEmailAdress()); } transactionService.deleteWithAssociationsInOwnTransaction(projectId); informProjectDeleted(message); if (owner != null) { sendRefreshUserAuth(owner); } }
ProjectDeleteService { @UseCaseAdministratorDeleteProject(@Step(number = 2, name = "Service deletes projects.", next = { 3, 4, 5, 6, 7}, description = "The service will delete the project with dependencies and triggers asynchronous events")) public void deleteProject(String projectId) { auditLogService.log("triggers delete of project {}", logSanitizer.sanitize(projectId, 30)); assertion.isValidProjectId(projectId); Project project = projectRepository.findOrFailProject(projectId); ProjectMessage message = new ProjectMessage(); message.setProjectId(project.getId()); message.setProjectActionTriggeredBy(userContext.getUserId()); User owner = project.getOwner(); if (owner == null) { LOG.warn("No owner found for project {} while deleting", project.getId()); } else { message.setProjectOwnerEmailAddress(owner.getEmailAdress()); } for (User user : project.getUsers()) { message.addUserEmailAddress(user.getEmailAdress()); } transactionService.deleteWithAssociationsInOwnTransaction(projectId); informProjectDeleted(message); if (owner != null) { sendRefreshUserAuth(owner); } } }
ProjectDeleteService { @UseCaseAdministratorDeleteProject(@Step(number = 2, name = "Service deletes projects.", next = { 3, 4, 5, 6, 7}, description = "The service will delete the project with dependencies and triggers asynchronous events")) public void deleteProject(String projectId) { auditLogService.log("triggers delete of project {}", logSanitizer.sanitize(projectId, 30)); assertion.isValidProjectId(projectId); Project project = projectRepository.findOrFailProject(projectId); ProjectMessage message = new ProjectMessage(); message.setProjectId(project.getId()); message.setProjectActionTriggeredBy(userContext.getUserId()); User owner = project.getOwner(); if (owner == null) { LOG.warn("No owner found for project {} while deleting", project.getId()); } else { message.setProjectOwnerEmailAddress(owner.getEmailAdress()); } for (User user : project.getUsers()) { message.addUserEmailAddress(user.getEmailAdress()); } transactionService.deleteWithAssociationsInOwnTransaction(projectId); informProjectDeleted(message); if (owner != null) { sendRefreshUserAuth(owner); } }  }
ProjectDeleteService { @UseCaseAdministratorDeleteProject(@Step(number = 2, name = "Service deletes projects.", next = { 3, 4, 5, 6, 7}, description = "The service will delete the project with dependencies and triggers asynchronous events")) public void deleteProject(String projectId) { auditLogService.log("triggers delete of project {}", logSanitizer.sanitize(projectId, 30)); assertion.isValidProjectId(projectId); Project project = projectRepository.findOrFailProject(projectId); ProjectMessage message = new ProjectMessage(); message.setProjectId(project.getId()); message.setProjectActionTriggeredBy(userContext.getUserId()); User owner = project.getOwner(); if (owner == null) { LOG.warn("No owner found for project {} while deleting", project.getId()); } else { message.setProjectOwnerEmailAddress(owner.getEmailAdress()); } for (User user : project.getUsers()) { message.addUserEmailAddress(user.getEmailAdress()); } transactionService.deleteWithAssociationsInOwnTransaction(projectId); informProjectDeleted(message); if (owner != null) { sendRefreshUserAuth(owner); } }  @UseCaseAdministratorDeleteProject(@Step(number = 2, name = "Service deletes projects.", next = { 3, 4, 5, 6, 7}, description = "The service will delete the project with dependencies and triggers asynchronous events")) void deleteProject(String projectId); }
ProjectDeleteService { @UseCaseAdministratorDeleteProject(@Step(number = 2, name = "Service deletes projects.", next = { 3, 4, 5, 6, 7}, description = "The service will delete the project with dependencies and triggers asynchronous events")) public void deleteProject(String projectId) { auditLogService.log("triggers delete of project {}", logSanitizer.sanitize(projectId, 30)); assertion.isValidProjectId(projectId); Project project = projectRepository.findOrFailProject(projectId); ProjectMessage message = new ProjectMessage(); message.setProjectId(project.getId()); message.setProjectActionTriggeredBy(userContext.getUserId()); User owner = project.getOwner(); if (owner == null) { LOG.warn("No owner found for project {} while deleting", project.getId()); } else { message.setProjectOwnerEmailAddress(owner.getEmailAdress()); } for (User user : project.getUsers()) { message.addUserEmailAddress(user.getEmailAdress()); } transactionService.deleteWithAssociationsInOwnTransaction(projectId); informProjectDeleted(message); if (owner != null) { sendRefreshUserAuth(owner); } }  @UseCaseAdministratorDeleteProject(@Step(number = 2, name = "Service deletes projects.", next = { 3, 4, 5, 6, 7}, description = "The service will delete the project with dependencies and triggers asynchronous events")) void deleteProject(String projectId);  }