@Test
public void testAggregateAndRecommendReducer() throws Exception {
Reducer<VarLongWritable,PrefAndSimilarityColumnWritable,VarLongWritable,RecommendedItemsWritable>.Context context =
EasyMock.createMock(Reducer.Context.class);
context.write(EasyMock.eq(new VarLongWritable(123L)), recommendationsMatch(new GenericRecommendedItem(1L, 2.8f),
new GenericRecommendedItem(2L, 2.0f)));
EasyMock.replay(context);
RandomAccessSparseVector similarityColumnOne = new RandomAccessSparseVector(Integer.MAX_VALUE, 100);
similarityColumnOne.set(1, 0.1);
similarityColumnOne.set(2, 0.5);
RandomAccessSparseVector similarityColumnTwo = new RandomAccessSparseVector(Integer.MAX_VALUE, 100);
similarityColumnTwo.set(1, 0.9);
similarityColumnTwo.set(2, 0.5);
List<PrefAndSimilarityColumnWritable> values = Arrays.asList(
new PrefAndSimilarityColumnWritable(1.0f, similarityColumnOne),
new PrefAndSimilarityColumnWritable(3.0f, similarityColumnTwo));
OpenIntLongHashMap indexItemIDMap = new OpenIntLongHashMap();
indexItemIDMap.put(1, 1L);
indexItemIDMap.put(2, 2L);
AggregateAndRecommendReducer reducer = new AggregateAndRecommendReducer();
setField(reducer, "indexItemIDMap", indexItemIDMap);
setField(reducer, "recommendationsPerUser", 3);
reducer.reduce(new VarLongWritable(123L), values, context);
EasyMock.verify(context);
}