### Question:
MongoDbPersonRepository implements PersonRepository { @Override public List<Person> findFriendsWithFriend(String username, String friendUsername) { MongoDbUser follower = (MongoDbUser) template.findOne(getUsernameQuery(username)); MongoDbUser followed = (MongoDbUser) template.findOne(getUsernameQuery(friendUsername)); List<String> commonFriends = getCommonFriends(follower, followed); return Lists.transform(commonFriends, new Function<String, Person>() { @Override public Person apply(@Nullable String id) { return id == null ? null : template.get(id).toPerson(); } }); }  @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 findFriendsWithFriend() { String username = "follower"; String friendUsername = "followed"; MongoDbUser follower = new MongoDbUser("1111L"); MongoDbUser followed = new MongoDbUser("2222L"); MongoDbPersonAssociation friend = new MongoDbPersonAssociation("3333L", FriendRequestStatus.ACCEPTED, MongoDbPersonAssociation.Direction.INCOMING); MongoDbPersonAssociation friend2 = new MongoDbPersonAssociation("4444L", FriendRequestStatus.ACCEPTED, MongoDbPersonAssociation.Direction.INCOMING); List<MongoDbPersonAssociation> friends_follower = Lists.newLinkedList(); List<MongoDbPersonAssociation> friends_followed = Lists.newLinkedList(); friends_follower.add(friend); friends_followed.add(friend); friends_followed.add(friend2); follower.setFriends(friends_follower); followed.setFriends(friends_followed); expect(template.findOne(isA(Query.class))).andReturn(follower); expect(template.findOne(isA(Query.class))).andReturn(followed); expect(template.get("3333L")).andReturn(follower); replay(template); List<Person> results = repo.findFriendsWithFriend(username, friendUsername); assertThat(results.size(), is(equalTo(1))); }