ProjectService { public Project modifyProjectStatus(String projectId, ProjectStatus newStatusToApply, UserEntity requestingUser) { ProjectEntity projectEntity = loadProjectEntity(projectId); if (projectEntity.modifyStatus(newStatusToApply)) { projectEntity = projectRepository.save(projectEntity); userNotificationService.notifyCreatorOnProjectStatusUpdate(projectEntity); } return project(projectEntity, requestingUser); } @Autowired  ProjectService(ProjectRepository projectRepository,
                          PledgeRepository pledgeRepository,
                          UserRepository userRepository,
                          FinancingRoundRepository financingRoundRepository,
                          UserNotificationService userNotificationService,
                          FinancingRoundService financingRoundService,
                          LikeRepository likeRepository,
                          ProjectAttachmentRepository projectAttachmentRepository); Project getProject(String projectId, UserEntity requestingUser); List<Project> getProjects(UserEntity requestingUser); Project addProject(Project project, UserEntity creator); Project modifyProjectStatus(String projectId, ProjectStatus newStatusToApply, UserEntity requestingUser); Project modifyProjectMasterdata(String projectId, Project modifiedProject, UserEntity requestingUser); void pledge(String projectId, UserEntity userEntity, Pledge pledge); Attachment addProjectAttachment(String projectId, Attachment attachment, UserEntity savingUser); Attachment loadProjectAttachment(String projectId, Attachment attachmentRequest); void deleteProjectAttachment(String projectId, Attachment attachmentRequest, UserEntity deletingUser); void likeProject(String projectId, UserEntity user); void unlikeProject(String projectId, UserEntity user);  }
@Test public void modifyProjectStatus_updatedStateTriggersUserNotificationAndPeristence() throws Exception { final UserEntity user = user(USER_EMAIL); final ProjectEntity projectEntity = projectEntity("some_id", ProjectStatus.PROPOSED, user); projectService.modifyProjectStatus("some_id", ProjectStatus.PUBLISHED, user); verify(projectRepository).save(projectEntity); verify(userNotificationService).notifyCreatorOnProjectStatusUpdate(any(ProjectEntity.class)); }
@Test public void modifyProjectStatus_nonUpdatedStateDoesNotTriggerUserNotificationAndNoPersistence() throws Exception { UserEntity user = user(USER_EMAIL); projectEntity("some_id", ProjectStatus.PROPOSED, user); projectService.modifyProjectStatus("some_id", ProjectStatus.PROPOSED, user); verify(projectRepository, never()).save(any(ProjectEntity.class)); verify(userNotificationService, never()).notifyCreatorOnProjectStatusUpdate(any(ProjectEntity.class)); }