### Question:
PackedRatingMatrix implements RatingMatrix { @Override public Collection<RatingMatrixEntry> getUserRatings(long userId) { int uidx = userIndex().tryGetIndex(userId); List<Collection<RatingMatrixEntry>> userLists = userIndexLists.get(); if (uidx < 0 || uidx >= userLists.size()) { return Collections.emptyList(); } else { return userLists.get(uidx); } } PackedRatingMatrix(PackedRatingData data); @Override LongCollection getUserIds(); @Override LongCollection getItemIds(); @Override KeyIndex userIndex(); @Override KeyIndex itemIndex(); @Override List<RatingMatrixEntry> getRatings(); @Override Collection<RatingMatrixEntry> getUserRatings(long userId); @Override synchronized Long2DoubleMap getUserRatingVector(long userId); @PreDestroy void dispose();  }### Answer:
@Test public void testGetUserRatings() { Collection<RatingMatrixEntry> ratings = snap.getUserRatings(1); Equivalence<Preference> eq = Ratings.preferenceEquivalence(); assertThat(ratings, hasSize(4)); assertThat(Iterables.transform(ratings, eq::wrap), containsInAnyOrder(eq.wrap(entry(1, 7, 4)), eq.wrap(entry(1, 8, 5)), eq.wrap(entry(1, 9, 3)), eq.wrap(entry(1, 11, 5)))); ratings = snap.getUserRatings(2); assertThat(ratings, hasSize(0)); ratings = snap.getUserRatings(3); assertEquals(4, ratings.size()); assertThat(Iterables.transform(ratings, eq::wrap), containsInAnyOrder(eq.wrap(entry(3, 7, 3)), eq.wrap(entry(3, 8, 3)), eq.wrap(entry(3, 9, 4)), eq.wrap(entry(3, 11, 5)))); ratings = snap.getUserRatings(4); assertEquals(5, ratings.size()); assertThat(Iterables.transform(ratings, eq::wrap), containsInAnyOrder(eq.wrap(entry(4, 7, 4)), eq.wrap(entry(4, 8, 2)), eq.wrap(entry(4, 9, 5)), eq.wrap(entry(4, 10, 4)), eq.wrap(entry(4, 11, 5)))); ratings = snap.getUserRatings(5); assertEquals(2, ratings.size()); assertThat(Iterables.transform(ratings, eq::wrap), containsInAnyOrder(eq.wrap(entry(5, 7, 3)), eq.wrap(entry(5, 8, 5)))); ratings = snap.getUserRatings(6); assertEquals(2, ratings.size()); assertThat(Iterables.transform(ratings, eq::wrap), containsInAnyOrder(eq.wrap(entry(6, 7, 5)), eq.wrap(entry(6, 8, 5)))); ratings = snap.getUserRatings(7); assertEquals(3, ratings.size()); assertThat(Iterables.transform(ratings, eq::wrap), containsInAnyOrder(eq.wrap(entry(7, 8, 2)), eq.wrap(entry(7, 9, 3)), eq.wrap(entry(7, 10, 4)))); }