### Question:
FallbackItemScorer extends AbstractItemScorer { @Override public FallbackResult score(long user, long item) { Result r = primaryScorer.score(user, item); if (r != null) { return new FallbackResult(r, true); } r = baselineScorer.score(user, item); if (r != null) { return new FallbackResult(r, false); } else { return null; } } @Inject  FallbackItemScorer(@PrimaryScorer ItemScorer primary,
                              @BaselineScorer ItemScorer baseline); @Override FallbackResult score(long user, long item); @Nonnull @Override ResultMap scoreWithDetails(long user, @Nonnull Collection<Long> items); @Nonnull ItemScorer getPrimaryScorer(); @Nonnull ItemScorer getBaselineScorer();  }### Answer:
@Test public void testScoreItemPrimary() { FallbackResult r = scorer.score(42, 39); assertThat(r, notNullValue()); assertThat(r.getScore(), equalTo(3.5)); assertThat(r.isFromPrimary(), equalTo(true)); }
@Test public void testFallbackItem() { FallbackResult r = scorer.score(42, 30); assertThat(r, notNullValue()); assertThat(r.getScore(), equalTo(4.0)); assertThat(r.isFromPrimary(), equalTo(false)); }
@Test public void testFallbackUser() { FallbackResult r = scorer.score(15, 30); assertThat(r, notNullValue()); assertThat(r.getScore(), equalTo(5.0)); assertThat(r.isFromPrimary(), equalTo(false)); }
@Test public void testNoRec() { FallbackResult r = scorer.score(15, 39); assertThat(r, nullValue()); }