    @Test
    public void throwsErrorWhenCurrentPrayerNotAvailable() {

        String code = "ext-153";

        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(3);

        when(mDateHelper.getCurrentYear())
                .thenReturn(2016);

        when(mDateHelper.getNextMonth())
                .thenReturn(4);

        when(mDateHelper.isNextMonthNewYear())
                .thenReturn(false);

        when(mPrayerCache.get(anyInt(), anyInt(), eq(mLocation)))
                .thenReturn(Observable.<PrayerData>empty());

        when(mPrayerCache.get(anyInt(), anyInt(), eq(code)))
                .thenReturn(Observable.<PrayerData>empty());

        when(mPrayerClient.getPrayerTimesByCoordinates(anyDouble(), anyDouble(), anyInt(), eq(4)))
                .thenReturn(Observable.<PrayerData>error(new PrayerProviderException("JAKIM")));

        when(mPrayerClient.getPrayerTimesByCoordinates(anyDouble(), anyDouble(), anyInt(), eq(5)))
                .thenReturn(Observable.just(mPrayerData2));

        when(mPrayerClient.getPrayerTimesByCode(eq(code), anyInt(), eq(4)))
                .thenReturn(Observable.<PrayerData>error(new PrayerProviderException("JAKIM")));

        when(mPrayerClient.getPrayerTimesByCode(eq(code), anyInt(), eq(5)))
                .thenReturn(Observable.just(mPrayerData2));

        TestSubscriber<PrayerContext> testSubscriber1 = new TestSubscriber<>();
        d.getPrayerTimes(mLocation).subscribe(testSubscriber1);
        testSubscriber1.assertError(PrayerProviderException.class);

        TestSubscriber<PrayerContext> testSubscriber2 = new TestSubscriber<>();
        d.getPrayerTimes(code).subscribe(testSubscriber2);
        testSubscriber2.assertError(PrayerProviderException.class);
    }