@Test public void deleteApplicationDeletesApplicationWhenApplicationNotFound() { var applicationId = 1L; given(applicationRepoMock.findByUserAndId(userMock, applicationId)).willReturn(Optional.empty()); assertThatThrownBy(() -> applicationService.deleteApplication(userMock, applicationId)) .isInstanceOf(ApplicationNotFoundException.class); }
@Transactional @Override public ProjectApplication deleteApplication(User user, long applicationId) throws ApplicationNotFoundException { var application = applicationRepo.findByUserAndId(user, applicationId).orElseThrow(ApplicationNotFoundException::new); applicationRepo.delete(application); log.debug(String.format("Application with id '%d' of user '%s' was deleted", applicationId, user.getId())); return application; }
RepositoryApplicationService implements ApplicationService { @Transactional @Override public ProjectApplication deleteApplication(User user, long applicationId) throws ApplicationNotFoundException { var application = applicationRepo.findByUserAndId(user, applicationId).orElseThrow(ApplicationNotFoundException::new); applicationRepo.delete(application); log.debug(String.format("Application with id '%d' of user '%s' was deleted", applicationId, user.getId())); return application; } }
RepositoryApplicationService implements ApplicationService { @Transactional @Override public ProjectApplication deleteApplication(User user, long applicationId) throws ApplicationNotFoundException { var application = applicationRepo.findByUserAndId(user, applicationId).orElseThrow(ApplicationNotFoundException::new); applicationRepo.delete(application); log.debug(String.format("Application with id '%d' of user '%s' was deleted", applicationId, user.getId())); return application; } @Autowired  RepositoryApplicationService(ProjectService projectService,
                                        ProjectApplicationRepository applicationRepo,
                                        ProjectApplicationEventHandler applicationEventHandler,
                                        Clock clock,
                                        ProjectBoardConfigurationProperties properties); }
RepositoryApplicationService implements ApplicationService { @Transactional @Override public ProjectApplication deleteApplication(User user, long applicationId) throws ApplicationNotFoundException { var application = applicationRepo.findByUserAndId(user, applicationId).orElseThrow(ApplicationNotFoundException::new); applicationRepo.delete(application); log.debug(String.format("Application with id '%d' of user '%s' was deleted", applicationId, user.getId())); return application; } @Autowired  RepositoryApplicationService(ProjectService projectService,
                                        ProjectApplicationRepository applicationRepo,
                                        ProjectApplicationEventHandler applicationEventHandler,
                                        Clock clock,
                                        ProjectBoardConfigurationProperties properties); @Override boolean userHasAppliedForProject(User user, Project project); @Override @Transactional ProjectApplication createApplicationForUser(User user, String projectId, String comment); @Override List<ProjectApplication> getApplicationsOfUser(User user, Sort sort); @Override List<ProjectApplication> getApplicationsOfUsers(Collection<User> users, Sort sort); @Transactional @Override ProjectApplication deleteApplication(User user, long applicationId); }
RepositoryApplicationService implements ApplicationService { @Transactional @Override public ProjectApplication deleteApplication(User user, long applicationId) throws ApplicationNotFoundException { var application = applicationRepo.findByUserAndId(user, applicationId).orElseThrow(ApplicationNotFoundException::new); applicationRepo.delete(application); log.debug(String.format("Application with id '%d' of user '%s' was deleted", applicationId, user.getId())); return application; } @Autowired  RepositoryApplicationService(ProjectService projectService,
                                        ProjectApplicationRepository applicationRepo,
                                        ProjectApplicationEventHandler applicationEventHandler,
                                        Clock clock,
                                        ProjectBoardConfigurationProperties properties); @Override boolean userHasAppliedForProject(User user, Project project); @Override @Transactional ProjectApplication createApplicationForUser(User user, String projectId, String comment); @Override List<ProjectApplication> getApplicationsOfUser(User user, Sort sort); @Override List<ProjectApplication> getApplicationsOfUsers(Collection<User> users, Sort sort); @Transactional @Override ProjectApplication deleteApplication(User user, long applicationId);  }