@Test
public void testRescorer() throws Exception {

  DataModel dataModel = getDataModel(
          new long[] {1, 2, 3},
          new Double[][] {
                  {0.1, 0.2},
                  {0.2, 0.3, 0.3, 0.6},
                  {0.4, 0.4, 0.5, 0.9},
          });
  Collection<GenericItemSimilarity.ItemItemSimilarity> similarities = Lists.newArrayList();
  similarities.add(new GenericItemSimilarity.ItemItemSimilarity(0, 1, 1.0));
  similarities.add(new GenericItemSimilarity.ItemItemSimilarity(0, 2, 0.5));
  similarities.add(new GenericItemSimilarity.ItemItemSimilarity(0, 3, 0.2));
  similarities.add(new GenericItemSimilarity.ItemItemSimilarity(1, 2, 0.7));
  similarities.add(new GenericItemSimilarity.ItemItemSimilarity(1, 3, 0.5));
  similarities.add(new GenericItemSimilarity.ItemItemSimilarity(2, 3, 0.9));
  ItemSimilarity similarity = new GenericItemSimilarity(similarities);
  Recommender recommender = new GenericItemBasedRecommender(dataModel, similarity);
  List<RecommendedItem> originalRecommended = recommender.recommend(1, 2);
  List<RecommendedItem> rescoredRecommended =
      recommender.recommend(1, 2, new ReversingRescorer<Long>());
  assertNotNull(originalRecommended);
  assertNotNull(rescoredRecommended);
  assertEquals(2, originalRecommended.size());
  assertEquals(2, rescoredRecommended.size());
  assertEquals(originalRecommended.get(0).getItemID(), rescoredRecommended.get(1).getItemID());
  assertEquals(originalRecommended.get(1).getItemID(), rescoredRecommended.get(0).getItemID());
}