@Test
public void testToVectorAndPrefReducer() throws Exception {
Reducer<VarIntWritable,VectorOrPrefWritable,VarIntWritable,VectorAndPrefsWritable>.Context context =
EasyMock.createMock(Reducer.Context.class);
context.write(EasyMock.eq(new VarIntWritable(1)), vectorAndPrefsWritableMatches(Arrays.asList(123L, 456L),
Arrays.asList(1.0f, 2.0f), MathHelper.elem(3, 0.5), MathHelper.elem(7, 0.8)));
EasyMock.replay(context);
Vector similarityColumn = new RandomAccessSparseVector(Integer.MAX_VALUE, 100);
similarityColumn.set(3, 0.5);
similarityColumn.set(7, 0.8);
VectorOrPrefWritable itemPref1 = new VectorOrPrefWritable(123L, 1.0f);
VectorOrPrefWritable itemPref2 = new VectorOrPrefWritable(456L, 2.0f);
VectorOrPrefWritable similarities = new VectorOrPrefWritable(similarityColumn);
new ToVectorAndPrefReducer().reduce(new VarIntWritable(1), Arrays.asList(itemPref1, itemPref2, similarities),
context);
EasyMock.verify(context);
}