@Test public void prayerContextCoordinateCache() { PrayerDownloader d = new PrayerDownloader( mDateHelper, mPrayerClient, mPrayerCache, mInterfacePreferences ); when(mLocation.getLatitude()) .thenReturn(3.28011); when(mLocation.getLongitude()) .thenReturn(101.556); when(mLocation.distanceTo(any(Location.class))) .thenReturn(0f); when(mDateHelper.getCurrentMonth()) .thenReturn(11); when(mDateHelper.getCurrentYear()) .thenReturn(2016); when(mDateHelper.getNextYear()) .thenReturn(2017); when(mDateHelper.getNextMonth()) .thenReturn(0); when(mDateHelper.isNextMonthNewYear()) .thenReturn(true); when(mPrayerCache.get(eq(2016), eq(12), eq(mLocation))) .thenReturn(Observable.just(mPrayerData1)); when(mPrayerCache.get(eq(2017), eq(1), eq(mLocation))) .thenReturn(Observable.just(mPrayerData2)); when(mPrayerClient.getPrayerTimesByCoordinates(anyDouble(), anyDouble(), anyInt(), eq(12))) .thenReturn(Observable.just(mPrayerData3)); when(mPrayerClient.getPrayerTimesByCoordinates(anyDouble(), anyDouble(), anyInt(), eq(1))) .thenReturn(Observable.just(mPrayerData4)); TestSubscriber<PrayerContext> testSubscriber = new TestSubscriber<>(); d.getPrayerTimes(mLocation).subscribe(testSubscriber); testSubscriber.assertNoErrors(); List<PrayerContext> prayers = testSubscriber.getOnNextEvents(); assertThat(prayers).hasSize(1); PrayerContextImpl pc = (PrayerContextImpl) prayers.get(0); assertThat(pc.getCurrentPrayerData()).isEqualTo(mPrayerData1); assertThat(pc.getNextPrayerData()).isEqualTo(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);   }