@Test public void singleFriendRecommendation() throws Exception { deleteSocialGraph(); Person a = personRepository.createPerson("a"); Person b = personRepository.createPerson("b"); Person c = personRepository.createPerson("c"); Person d = personRepository.createPerson("d"); Person e = personRepository.createPerson("e"); // A is friends with B,C and D a.addFriend(b); a.addFriend(c); a.addFriend(d); // E is also friend with B, C and D e.addFriend(b); e.addFriend(c); e.addFriend(d); Person recommendation = IteratorUtil.single(a.getFriendRecommendation(1).iterator()); assertThat(recommendation, equalTo(e)); }
public Iterable<Node> getFriends(String name) { ResourceIterable<Node> users = db.findNodesByLabelAndProperty(USER, "name", name); Node startNode = IteratorUtil.single(users); return traversalDescription.traverse(startNode).nodes(); }