RepositoryBookmarkService implements BookmarkService { @Override @Transactional(readOnly = true) public List<Project> getBookmarksOfUser(User user) { return new ArrayList<>(user.getBookmarks()); } @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);  }
@Test public void getBookmarksOfUserReturnsAllBookmarks() { given(userMock.getBookmarks()).willReturn(Collections.singleton(projectMock)); List<Project> actualBookmarks = bookmarkService.getBookmarksOfUser(userMock); assertThat(actualBookmarks).containsExactly(projectMock); }