@Test public void getPrayerContextCodeSameYear() { String code = "ext-157"; PrayerDownloader d = new PrayerDownloader( mDateHelper, mPrayerClient, mPrayerCache, mInterfacePreferences ); when(mDateHelper.getCurrentMonth()) .thenReturn(3); when(mDateHelper.getCurrentYear()) .thenReturn(2016); when(mDateHelper.getNextMonth()) .thenReturn(4); when(mDateHelper.isNextMonthNewYear()) .thenReturn(false); when(mPrayerCache.get(anyInt(), anyInt(), eq(code))) .thenReturn(Observable.<PrayerData>empty()); when(mPrayerClient.getPrayerTimesByCode(eq(code), anyInt(), eq(4))) .thenReturn(Observable.just(mPrayerData1)); when(mPrayerClient.getPrayerTimesByCode(eq(code), anyInt(), eq(5))) .thenReturn(Observable.just(mPrayerData2)); TestSubscriber<PrayerContext> testSubscriber = new TestSubscriber<>(); d.getPrayerTimes(code).subscribe(testSubscriber); testSubscriber.assertNoErrors(); List<PrayerContext> prayers = testSubscriber.getOnNextEvents(); assertThat(prayers).hasSize(1); verify(mPrayerCache, times(1)).get(eq(2016), eq(4), eq(code)); verify(mPrayerCache, times(1)).get(eq(2016), eq(5), eq(code)); verify(mPrayerClient, times(1)).getPrayerTimesByCode(eq(code), eq(2016), eq(4)); verify(mPrayerClient, times(1)).getPrayerTimesByCode(eq(code), eq(2016), eq(5)); verify(mPrayerCache, times(1)).save(eq(mPrayerData1)); verify(mPrayerCache, times(1)).save(eq(mPrayerData2)); }
Observable<PrayerContext> getPrayerTimes(String code) { return getCurrentPrayerTimesByCode(code) .zipWith(getNextPrayerTimesByCode(code), mPrayerContextCreator); }
PrayerDownloader { Observable<PrayerContext> getPrayerTimes(String code) { return getCurrentPrayerTimesByCode(code) .zipWith(getNextPrayerTimesByCode(code), mPrayerContextCreator); } }
PrayerDownloader { Observable<PrayerContext> getPrayerTimes(String code) { return getCurrentPrayerTimesByCode(code) .zipWith(getNextPrayerTimesByCode(code), mPrayerContextCreator); } @Inject  PrayerDownloader(DateTimeHelper helper,
                     PrayerClient client,
                     PrayerCacheManager cache,
                     InterfacePreferences iprefs); }
PrayerDownloader { Observable<PrayerContext> getPrayerTimes(String code) { return getCurrentPrayerTimesByCode(code) .zipWith(getNextPrayerTimesByCode(code), mPrayerContextCreator); } @Inject  PrayerDownloader(DateTimeHelper helper,
                     PrayerClient client,
                     PrayerCacheManager cache,
                     InterfacePreferences iprefs);  }
PrayerDownloader { Observable<PrayerContext> getPrayerTimes(String code) { return getCurrentPrayerTimesByCode(code) .zipWith(getNextPrayerTimesByCode(code), mPrayerContextCreator); } @Inject  PrayerDownloader(DateTimeHelper helper,
                     PrayerClient client,
                     PrayerCacheManager cache,
                     InterfacePreferences iprefs);   }