PrayerTimes { public Date timeForPrayer(Prayer prayer) { switch (prayer) { case FAJR: return this.fajr; case SUNRISE: return this.sunrise; case DHUHR: return this.dhuhr; case ASR: return this.asr; case MAGHRIB: return this.maghrib; case ISHA: return this.isha; case NONE: default: return null; } } PrayerTimes(Coordinates coordinates, DateComponents date, CalculationParameters parameters); Prayer currentPrayer(); Prayer currentPrayer(Date time); Prayer nextPrayer(); Prayer nextPrayer(Date time); Date timeForPrayer(Prayer prayer); final Date fajr; final Date sunrise; final Date dhuhr; final Date asr; final Date maghrib; final Date isha; }
@Test public void testTimeForPrayer() { DateComponents components = new DateComponents(2016, 7, 1); CalculationParameters parameters = CalculationMethod.MUSLIM_WORLD_LEAGUE.getParameters(); parameters.madhab = Madhab.HANAFI; parameters.highLatitudeRule = HighLatitudeRule.TWILIGHT_ANGLE; Coordinates coordinates = new Coordinates(59.9094, 10.7349); PrayerTimes p = new PrayerTimes(coordinates, components, parameters); assertThat(p.fajr).isEqualTo(p.timeForPrayer(Prayer.FAJR)); assertThat(p.sunrise).isEqualTo(p.timeForPrayer(Prayer.SUNRISE)); assertThat(p.dhuhr).isEqualTo(p.timeForPrayer(Prayer.DHUHR)); assertThat(p.asr).isEqualTo(p.timeForPrayer(Prayer.ASR)); assertThat(p.maghrib).isEqualTo(p.timeForPrayer(Prayer.MAGHRIB)); assertThat(p.isha).isEqualTo(p.timeForPrayer(Prayer.ISHA)); assertThat(p.timeForPrayer(Prayer.NONE)).isNull(); }