### Question:
SimpleRatingPredictor implements RatingPredictor { @Override public RescoredResult predict(long user, long item) { Result r = scorer.score(user, item); if(r == null) { return null; } double val = r.getScore(); if (preferenceDomain != null) { val = preferenceDomain.clampValue(val); } return Results.rescore(r, val); } @Inject  SimpleRatingPredictor(@Nonnull @PredictionScorer ItemScorer s,
                                 @Nullable PreferenceDomain dom); @Nonnull ItemScorer getItemScorer(); @Nullable PreferenceDomain getPreferenceDomain(); @Override RescoredResult predict(long user, long item); @Nonnull @Override Map<Long, Double> predict(long user, @Nonnull Collection<Long> items); @Nonnull @Override ResultMap predictWithDetails(long user, @Nonnull Collection<Long> items);  }### Answer:
@Test public void testBasicPredict() { assertThat(pred.predict(40, 1).getScore(), closeTo(4.0, EPSILON)); assertThat(pred.predict(40, 1).getOriginalResult(), equalTo((Result) Results.create(1, 4.0))); }
@Test public void testBasicPredictHigh() { assertThat(pred.predict(40, 2).getScore(), closeTo(5.0, EPSILON)); }
@Test public void testBasicPredictLow() { assertThat(pred.predict(40, 3).getScore(), closeTo(1.0, EPSILON)); }
@Test public void testUnclampedPredict() { assertThat(unclamped.predict(40, 1).getScore(), closeTo(4.0, EPSILON)); }
@Test public void testUnclampedPredictHigh() { assertThat(unclamped.predict(40, 2).getScore(), closeTo(5.5, EPSILON)); }
@Test public void testUnclampedPredictLow() { assertThat(unclamped.predict(40, 3).getScore(), closeTo(-1, EPSILON)); }
@Test public void testBulkPredict() { Map<Long,Double> scores = pred.predict(40, LongUtils.packedSet(1, 2, 3, 4)); assertThat(scores.size(), equalTo(3)); assertThat(scores, hasEntry(1L, 4.0)); assertThat(scores, hasEntry(2L, 5.0)); assertThat(scores, hasEntry(3L, 1.0)); }
@Test public void testBulkUnclampedPredict() { Map<Long,Double> scores = unclamped.predict(40, LongUtils.packedSet(1, 2, 3, 4)); assertThat(scores.size(), equalTo(3)); assertThat(scores, hasEntry(1L, 4.0)); assertThat(scores, hasEntry(2L, 5.5)); assertThat(scores, hasEntry(3L, -1.0)); }