### Question:
MongoDbPersonRepository implements PersonRepository { @Override public boolean acceptFriendRequest(String friendUsername, String username) { MongoDbUser follower = (MongoDbUser) template.findOne(getUsernameQuery(username)); MongoDbUser followed = (MongoDbUser) template.findOne(getUsernameQuery(friendUsername)); setAccepted(follower, followed); setAccepted(followed, follower); template.save(follower); template.save(followed); return true; }  @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 boolean addFriend(String friendUsername, String username); @Override void removeFriend(String friendUsername, String username); @Override HashMap<String, List<Person>> findFriendsAndRequests(String username); @Override boolean acceptFriendRequest(String friendUsername, String username); @Override List<Person> findFriendRequestsReceived(String username); @Override List<Person> findFriendRequestsSent(String username); @Override int removeAllFriendsAndRequests(String userid); @Override Class<? extends Person> getType(); @Override Person get(String id); @Override Person save(Person item); @Override void delete(Person item); void setTemplate(MongoUserOperations template); void setPageTemplate(MongoPageOperations pageTemplate); void setWidgetOperations(MongoWidgetOperations widgetOperations); @Override List<Person> getAll(); @Override List<Person> getLimitedList(int offset, int limit); @Override int getCountAll();  }### Answer:
@Test public void acceptFriendRequest() { String username = "username"; String friendUsername = "friendUsername"; MongoDbUser carol = new MongoDbUser("1111L"); MongoDbUser amy = new MongoDbUser("2222L"); List<MongoDbPersonAssociation> carols_friends = Lists.newArrayList(); MongoDbPersonAssociation friendA = new MongoDbPersonAssociation("1111L", FriendRequestStatus.SENT, MongoDbPersonAssociation.Direction.OUTGOING); carols_friends.add(friendA); List<MongoDbPersonAssociation> amys_friends = Lists.newArrayList(); MongoDbPersonAssociation friendC = new MongoDbPersonAssociation("2222L", FriendRequestStatus.RECEIVED, MongoDbPersonAssociation.Direction.INCOMING); amys_friends.add(friendC); carol.setFriends(carols_friends); amy.setFriends(amys_friends); expect(template.findOne(isA(Query.class))).andReturn(carol); expect(template.findOne(isA(Query.class))).andReturn(amy); expect(template.save(isA(MongoDbUser.class))).andReturn(carol); expect(template.save(isA(MongoDbUser.class))).andReturn(amy); replay(template); boolean result = repo.acceptFriendRequest(friendUsername, username); assertTrue(result); }