@Test public void testGetRatings() throws Exception { RandomDataSplitStrategyProvider splitData = new RandomDataSplitStrategyProvider(snapshot, new Random(), 0, 0.2); DataSplitStrategy splitStrategy = splitData.get(); KeyIndex userIndex = splitStrategy.getUserIndex(); KeyIndex itemIndex = splitStrategy.getItemIndex(); List<RatingMatrixEntry> validations = splitStrategy.getValidationRatings(); List<RatingMatrixEntry> trainingRatings = splitStrategy.getTrainRatings(); for (RatingMatrixEntry re : trainingRatings) { int user = re.getUserIndex(); int item = re.getItemIndex(); long userId = userIndex.getKey(user); long itemId = itemIndex.getKey(item); double rating = re.getValue(); assertThat(rating, equalTo(snapshot.getUserRatingVector(userId).get(itemId))); assertThat(rating, equalTo(data.get(itemId).get(userId))); } for (RatingMatrixEntry re : validations) { long userId = re.getUserId(); long itemId = re.getItemId(); double rating = re.getValue(); assertThat(rating, equalTo(snapshot.getUserRatingVector(userId).get(itemId))); assertThat(rating, equalTo(data.get(itemId).get(userId))); } }