### Question:
DistrictRenderer implements ModelRenderer<District, DistrictRenderer.RenderArgs> { @WorkerThread @Override public @Nullable DistrictListElement renderFromKey(String key, ModelType type, RenderArgs args) { District district = mDatafeed.fetchDistrict(key).toBlocking().first(); if (district == null) { return null; } List<Event> events = mDatafeed.fetchDistrictEvents(key).toBlocking().first(); RenderArgs newArgs = new RenderArgs(events != null ? events.size() : 0, args != null && args.showMyTba); return renderFromModel(district, newArgs); } @Inject  DistrictRenderer(APICache datafeed); @WorkerThread @Override @Nullable DistrictListElement renderFromKey(String key, ModelType type, RenderArgs args); @WorkerThread @Override @Nullable DistrictListElement renderFromModel(District district, RenderArgs args);  }### Answer:
@Test public void testRenderFromKey() { when(mDatafeed.fetchDistrict(DISTRICT_KEY)).thenReturn(Observable.just(mDistrict)); when(mDatafeed.fetchDistrictEvents("2015ne")).thenReturn(Observable.just(new ArrayList<>())); DistrictListElement element = mRenderer.renderFromKey(DISTRICT_KEY, ModelType.DISTRICT, null); assertDistrictItem(element, 0, 2015, false); }
@Test public void testNullRenderFromKey(){ when(mDatafeed.fetchDistrict(DISTRICT_KEY)).thenReturn(Observable.just(null)); when(mDatafeed.fetchDistrictEvents("2015ne")).thenReturn(Observable.just(new ArrayList<>())); DistrictListElement element = mRenderer.renderFromKey(DISTRICT_KEY, ModelType.DISTRICT, null); assertNull(element); }
@Test public void testRenderFromKeyNullEvents() { when(mDatafeed.fetchDistrict(DISTRICT_KEY)).thenReturn(Observable.just(mDistrict)); when(mDatafeed.fetchDistrictEvents("2015ne")).thenReturn(Observable.just(null)); DistrictListElement element = mRenderer.renderFromKey(DISTRICT_KEY, ModelType.DISTRICT, null); assertDistrictItem(element, 0, 2015, false); }