@Test public void removeBookmarkOfUserRemovesBookmark() { given(userMock.getId()).willReturn(USER_ID); given(userRepository.existsByIdAndBookmarksContaining(USER_ID, projectMock)).willReturn(true); bookmarkService.removeBookmarkOfUser(userMock, projectMock); verify(userMock).removeBookmark(projectMock); verify(userRepository).save(userMock); }
@Override public void removeBookmarkOfUser(User user, Project project) { if(userHasBookmark(user, project)) { user.removeBookmark(project); userRepo.save(user); } else { throw new BookmarkNotFoundException(); } }
RepositoryBookmarkService implements BookmarkService { @Override public void removeBookmarkOfUser(User user, Project project) { if(userHasBookmark(user, project)) { user.removeBookmark(project); userRepo.save(user); } else { throw new BookmarkNotFoundException(); } } }
RepositoryBookmarkService implements BookmarkService { @Override public void removeBookmarkOfUser(User user, Project project) { if(userHasBookmark(user, project)) { user.removeBookmark(project); userRepo.save(user); } else { throw new BookmarkNotFoundException(); } } @Autowired  RepositoryBookmarkService(UserRepository userRepo); }
RepositoryBookmarkService implements BookmarkService { @Override public void removeBookmarkOfUser(User user, Project project) { if(userHasBookmark(user, project)) { user.removeBookmark(project); userRepo.save(user); } else { throw new BookmarkNotFoundException(); } } @Autowired  RepositoryBookmarkService(UserRepository userRepo); @Override Project addBookmarkToUser(User user, Project project); @Override void removeBookmarkOfUser(User user, Project project); @Override @Transactional(readOnly = true) List<Project> getBookmarksOfUser(User user); @Override @Transactional(readOnly = true) boolean userHasBookmark(User user, Project project); @Override void removeAllBookmarksOfUser(User user); }
RepositoryBookmarkService implements BookmarkService { @Override public void removeBookmarkOfUser(User user, Project project) { if(userHasBookmark(user, project)) { user.removeBookmark(project); userRepo.save(user); } else { throw new BookmarkNotFoundException(); } } @Autowired  RepositoryBookmarkService(UserRepository userRepo); @Override Project addBookmarkToUser(User user, Project project); @Override void removeBookmarkOfUser(User user, Project project); @Override @Transactional(readOnly = true) List<Project> getBookmarksOfUser(User user); @Override @Transactional(readOnly = true) boolean userHasBookmark(User user, Project project); @Override void removeAllBookmarksOfUser(User user);  }