FriendshipService { public boolean unfollowUser(String usernameToUnfollow) { log.debug("Removing followed user : {}", usernameToUnfollow); User currentUser = authenticationService.getCurrentUser(); String loginToUnfollow = this.getLoginFromUsername(usernameToUnfollow); User userToUnfollow = userRepository.findUserByLogin(loginToUnfollow); return unfollowUser(currentUser, userToUnfollow); }  boolean followUser(String usernameToFollow); boolean unfollowUser(String usernameToUnfollow); boolean unfollowUser(User currentUser, User userToUnfollow); List<String> getFriendIdsForUser(String login); Collection<String> getFollowerIdsForUser(String login); Collection<User> getFriendsForUser(String username); Collection<User> getFollowersForUser(String username); boolean isFollowed(String userLogin); boolean isFollowing(String userLogin);  }
@Test public void shouldForgetUser() { mockAuthentication("userWhoWantToForget@ippon.fr"); User userWhoWantToForget = userService.getUserByUsername("userWhoWantToForget"); assertThat(userWhoWantToForget.getFriendsCount(), is(1L)); User userToForget = new User(); userToForget.setLogin("userToForget@ippon.fr"); userService.createUser(userToForget); userToForget.setDailyDigestSubscription(false); userToForget.setWeeklyDigestSubscription(false); userService.updateUser(userToForget); assertTrue(friendshipService.unfollowUser("userToForget")); userWhoWantToForget = userService.getUserByUsername("userWhoWantToForget"); assertThat(userWhoWantToForget.getFriendsCount(), is(0L)); User userWhoIsForgotten = userService.getUserByUsername("userToForget"); assertThat(userWhoIsForgotten.getFollowersCount(), is(0L)); }
@Test public void shouldNotForgetUserBecauseUserDoesNotExist() { mockAuthentication("userWhoWantToForget@ippon.fr"); assertFalse(friendshipService.unfollowUser("unknownUser")); User userWhoWantToForget = userService.getUserByUsername("userWhoWantToForget"); assertThat(userWhoWantToForget.getFriendsCount(), is(0L)); }