### Question:
MatchRenderer implements ModelRenderer<Match, Integer> { @WorkerThread @Override public @Nullable MatchListElement renderFromKey(String key, ModelType type, Integer args) { Match match = mDatafeed.fetchMatch(key).toBlocking().first(); if (match == null) { return null; } return renderFromModel(match, RENDER_DEFAULT); } MatchRenderer(APICache datafeed, Resources resources); @WorkerThread @Override @Nullable MatchListElement renderFromKey(String key, ModelType type, Integer args); @WorkerThread @Override @Nullable MatchListElement renderFromModel(Match match, Integer renderMode); @VisibleForTesting static RenderArgs argsFromMode(@RenderType Integer type); static final int RENDER_DEFAULT; static final int RENDER_MATCH_INFO; static final int RENDER_NOTIFICATION; }### Answer:
@Test public void testRenderFromKey() { when(mDatafeed.fetchMatch(mMatchKey)).thenReturn(Observable.just(mMatch)); MatchListElement element = mRenderer.renderFromKey(mMatchKey, ModelType.MATCH, null); RenderArgs expectedArgs = MatchRenderer.argsFromMode(RENDER_DEFAULT); assertMatch(element, mMatch, expectedArgs); }
@Test public void testNullRenderFromKey() { when(mDatafeed.fetchMatch(mMatchKey)).thenReturn(Observable.just(null)); MatchListElement element = mRenderer.renderFromKey(mMatchKey, ModelType.MATCH, null); assertNull(element); }