### Question:
JpaPersonRepository implements PersonRepository { @Override public boolean addFriend(String friendUsername, String username) { JpaPersonAssociation senderItem = new JpaPersonAssociation(); senderItem.setFollower(personConverter.convert(findByUsername(username))); senderItem.setFollowedby(personConverter.convert(findByUsername(friendUsername))); senderItem.setStatus(FriendRequestStatus.SENT); senderItem = saveOrUpdate(senderItem.getEntityId(), manager, senderItem); JpaPersonAssociation receiverItem = new JpaPersonAssociation(); receiverItem.setFollower(personConverter.convert(findByUsername(friendUsername))); receiverItem.setFollowedby(personConverter.convert(findByUsername(username))); receiverItem.setStatus(FriendRequestStatus.RECEIVED); receiverItem = saveOrUpdate(receiverItem.getEntityId(), manager, receiverItem); return senderItem.getEntityId() != null && receiverItem.getEntityId() != null; }  @Override Person findByUsername(String username); @Override List<Person> findAllConnectedPeople(String username); @Override List<Person> findAllConnectedPeople(String username, String appId); @Override List<Person> findAllConnectedPeopleWithFriend(String username, String friendUsername); @Override List<Person> findFriends(String username); @Override List<Person> findFriends(String username, String appId); @Override List<Person> findFriendsWithFriend(String username, String friendUsername); @Override List<Person> findByGroup(String groupId); @Override List<Person> findByGroup(String groupId, String appId); @Override List<Person> findByGroupWithFriend(String groupId, String friendUsername); @Override Class<? extends Person> getType(); @Override Person get(String id); @Override Person save(Person item); @Override void delete(Person item); @Override boolean addFriend(String friendUsername, String username); @Override void removeFriend(String friendUsername, String username); @Override HashMap<String, List<Person>> findFriendsAndRequests(String username); @Override List<Person> findFriendRequestsSent(String username); @Override List<Person> findFriendRequestsReceived(String username); @Override boolean acceptFriendRequest(String friendUsername, String username); @Override int removeAllFriendsAndRequests(String userid); @Override List<Person> getAll(); @Override List<Person> getLimitedList(int offset, int limit); @Override int getCountAll();  }### Answer:
@Test @Transactional(readOnly=false) @Rollback(true) public void addFriend() { repository.addFriend(VALID_USER5, VALID_USER); List<Person> friendRequestsSent = repository.findFriendRequestsSent(VALID_USER); assertThat(friendRequestsSent.size(), is(equalTo(1))); assertThat(friendRequestsSent.get(0).getUsername(), is(equalTo(VALID_USER5))); List<Person> friendRequestsReceived = repository.findFriendRequestsReceived(VALID_USER5); assertThat(friendRequestsReceived.size(), is(equalTo(1))); assertThat(friendRequestsReceived.get(0).getUsername(), is(equalTo(VALID_USER))); List<Person> friends = repository.findFriends(VALID_USER5); assertThat(friends.size(), is(equalTo(1))); assertThat(friends.get(0).getUsername(), is(equalTo(VALID_USER2))); }