CommentService { public void addComment(Comment comment, String projectId, String commentingUserEmail) { final ProjectEntity project = projectService.loadProjectEntity(projectId); final UserEntity commentingUser = userService.getUserByEmail(commentingUserEmail); CommentEntity commentEntity = new CommentEntity(project, commentingUser, comment.getComment()); commentRepository.save(commentEntity); userNotificationService.notifyCreatorOnComment(commentEntity); } @Autowired  CommentService(CommentRepository commentRepository, ProjectService projectService, UserService userService, UserNotificationService userNotificationService); void addComment(Comment comment, String projectId, String commentingUserEmail); List<Comment> loadCommentsByProject(String projectId);  }
@Test public void addComment_ShouldPersistCommentAndNotifyCreator() throws Exception { Comment comment = new Comment(null, null, "Awesome project, dude!"); prepareProjectServiceMock(); prepareUserServiceMock(); commentService.addComment(comment, EXISTING_PROJECT_ID, EXISTING_USER_MAIL); final CommentEntity expectedComment2BPersisted = new CommentEntity(projectEntity, userEntity, comment.getComment()); verify(commentRepository).save(expectedComment2BPersisted); verify(userNotificationService).notifyCreatorOnComment(expectedComment2BPersisted); }