@Override
  public long getNextTimeOffset(int timesShown) {
    final Calendar calendar = mCalendarProvider.getInstance();
    final int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR);
    if (dayOfYear < mFirstNoticeStart) {
      // should start showing at May start
      return ONE_DAY * (mFirstNoticeStart - dayOfYear);
    } else if (dayOfYear < mFirstNoticeEnd) {
      // inside notice period. Notify every day
      return ONE_DAY;
    } else if (dayOfYear < mSecondNoticeStart) {
      // should start showing at November start
      return ONE_DAY * (mSecondNoticeStart - dayOfYear);
    } else if (dayOfYear < mSecondNoticeEnd) {
      // inside notice period. Notify every day
      return ONE_DAY;
    } else {
      // till next May
      return ONE_DAY * (365 + mFirstNoticeStart - dayOfYear);
    }
  }
@Test
  public void testHappyPath() {
    Calendar instance = Calendar.getInstance();
    PeriodsTimeProvider underTest = new PeriodsTimeProvider(() -> instance, 100, 115, 200, 230);

    instance.set(2020, Calendar.JANUARY, 1, 10, 10, 10);
    Assert.assertEquals(99 * ONE_DAY, underTest.getNextTimeOffset(0));
    instance.set(Calendar.DAY_OF_YEAR, 98);
    Assert.assertEquals(2 * ONE_DAY, underTest.getNextTimeOffset(1));
    instance.set(Calendar.DAY_OF_YEAR, 100);
    Assert.assertEquals(1 * ONE_DAY, underTest.getNextTimeOffset(2));
    instance.set(Calendar.DAY_OF_YEAR, 101);
    Assert.assertEquals(1 * ONE_DAY, underTest.getNextTimeOffset(3));
    instance.set(Calendar.DAY_OF_YEAR, 112);
    Assert.assertEquals(1 * ONE_DAY, underTest.getNextTimeOffset(4));
    instance.set(Calendar.DAY_OF_YEAR, 114);
    Assert.assertEquals(1 * ONE_DAY, underTest.getNextTimeOffset(5));
    instance.set(Calendar.DAY_OF_YEAR, 115);
    Assert.assertEquals(85 * ONE_DAY, underTest.getNextTimeOffset(6));
    instance.set(Calendar.DAY_OF_YEAR, 116);
    Assert.assertEquals(84 * ONE_DAY, underTest.getNextTimeOffset(1));
    instance.set(Calendar.DAY_OF_YEAR, 198);
    Assert.assertEquals(2 * ONE_DAY, underTest.getNextTimeOffset(2));
    instance.set(Calendar.DAY_OF_YEAR, 200);
    Assert.assertEquals(1 * ONE_DAY, underTest.getNextTimeOffset(3));
    instance.set(Calendar.DAY_OF_YEAR, 204);
    Assert.assertEquals(1 * ONE_DAY, underTest.getNextTimeOffset(4));
    instance.set(Calendar.DAY_OF_YEAR, 228);
    Assert.assertEquals(1 * ONE_DAY, underTest.getNextTimeOffset(5));
    instance.set(Calendar.DAY_OF_YEAR, 230);
    Assert.assertEquals((365 - 230 + 100) * ONE_DAY, underTest.getNextTimeOffset(6));
  }