### Question:
StandardRatingVectorPDAO implements RatingVectorPDAO { @Nonnull @Override public Long2DoubleMap userRatingVector(long user) { IdBox<Long2DoubleMap> cached = cachedValue; if (cached != null && cached.getId() == user) { return cached.getValue(); } Long2DoubleMap map; try (ObjectStream<Rating> stream = dao.query(Rating.class) .withAttribute(CommonAttributes.USER_ID, user) .stream()) { map = Ratings.userRatingVector(stream); } return map; } @Inject  StandardRatingVectorPDAO(DataAccessObject dao); @Nonnull @Override Long2DoubleMap userRatingVector(long user); @Override ObjectStream<IdBox<Long2DoubleMap>> streamUsers();  }### Answer:
@Test public void testNoUser() { EntityCollectionDAO dao = EntityCollectionDAO.create(); RatingVectorPDAO source = new StandardRatingVectorPDAO(dao); assertThat(source.userRatingVector(42).entrySet(), hasSize(0)); }
@Test public void testGetRating() { EntityCollectionDAO dao = EntityCollectionDAO.create(factory.rating(42, 39, 2.5)); RatingVectorPDAO source = new StandardRatingVectorPDAO(dao); assertThat(source.userRatingVector(42), hasEntry(39L, 2.5)); }
@Test public void testGetsOnlyRating() { EntityCollectionDAO dao = EntityCollectionDAO.create(factory.rating(42, 39, 2.5), factory.rating(42, 20, 3.5), factory.rating(17, 39, 1.5)); RatingVectorPDAO source = new StandardRatingVectorPDAO(dao); Long2DoubleMap vec = source.userRatingVector(42); assertThat(vec.entrySet(), hasSize(2)); assertThat(vec, hasEntry(39L, 2.5)); assertThat(vec, hasEntry(20L, 3.5)); }