/**
* Tests {@code recommend(long, SparseVector, int, Set, Set)}.
*/
@Test
public void testUserUserRecommender4() {
ItemRecommender recommender = rec.getItemRecommender();
assert recommender != null;
LongOpenHashSet candidates = new LongOpenHashSet();
candidates.add(9);
List<ScoredId> recs = recommender.recommend(2, -1, candidates, null);
assertThat(Lists.transform(recs, ScoredIds.idFunction()),
containsInAnyOrder(9L));
recs = recommender.recommend(2, 1, candidates, null);
assertThat(Lists.transform(recs, ScoredIds.idFunction()),
containsInAnyOrder(9L));
recs = recommender.recommend(2, 0, candidates, null);
assertTrue(recs.isEmpty());
LongOpenHashSet exclude = new LongOpenHashSet();
exclude.add(9);
recs = recommender.recommend(2, -1, candidates, exclude);
assertTrue(recs.isEmpty());
// FIXME Add tests for default exclude set
recs = recommender.recommend(5, -1, null, LongSets.EMPTY_SET);
assertThat(Lists.transform(recs, ScoredIds.idFunction()),
contains(9L, 7L, 6L, 8L));
recs = recommender.recommend(5, 5, null, LongSets.EMPTY_SET);
assertThat(Lists.transform(recs, ScoredIds.idFunction()),
contains(9L, 7L, 6L, 8L));
recs = recommender.recommend(5, 4, null, LongSets.EMPTY_SET);
assertThat(Lists.transform(recs, ScoredIds.idFunction()),
contains(9L, 7L, 6L, 8L));
recs = recommender.recommend(5, 3, null, LongSets.EMPTY_SET);
assertThat(Lists.transform(recs, ScoredIds.idFunction()),
contains(9L, 7L, 6L));
recs = recommender.recommend(5, 2, null, LongSets.EMPTY_SET);
assertThat(Lists.transform(recs, ScoredIds.idFunction()),
contains(9L, 7L));
recs = recommender.recommend(5, 1, null, LongSets.EMPTY_SET);
assertThat(Lists.transform(recs, ScoredIds.idFunction()),
contains(9L));
recs = recommender.recommend(5, 0, null, LongSets.EMPTY_SET);
assertTrue(recs.isEmpty());
candidates.clear();
candidates.add(6);
candidates.add(7);
recs = recommender.recommend(6, -1, candidates, LongSets.EMPTY_SET);
assertThat(Lists.transform(recs, ScoredIds.idFunction()),
containsInAnyOrder(6L, 7L));
candidates.remove(6);
recs = recommender.recommend(6, -1, candidates, LongSets.EMPTY_SET);
assertThat(Lists.transform(recs, ScoredIds.idFunction()),
contains(7L));
candidates.remove(7);
recs = recommender.recommend(6, -1, candidates, LongSets.EMPTY_SET);
assertTrue(recs.isEmpty());
candidates.add(6);
candidates.add(7);
exclude.add(6);
recs = recommender.recommend(6, -1, candidates, exclude);
assertThat(Lists.transform(recs, ScoredIds.idFunction()),
contains(7L));
exclude.add(7);
recs = recommender.recommend(6, -1, candidates, exclude);
assertTrue(recs.isEmpty());
exclude.remove(6);
recs = recommender.recommend(6, -1, candidates, exclude);
assertThat(Lists.transform(recs, ScoredIds.idFunction()),
contains(6L));
}