DateProvider { public boolean isMorning() { final int hourOfDay = calendar.get(Calendar.HOUR_OF_DAY); return hourOfDay >= 0 && hourOfDay < 12; } @Inject  DateProvider(Calendar calendar); @VisibleForTesting  DateProvider(); long currentTimeMillis(); boolean isMorning();  }
@Test public void midnightIsMorning() { when(calendar.get(Calendar.HOUR_OF_DAY)).thenReturn(0); assertThat(dateProvider.isMorning(), is(true)); }
@Test public void lunchTimeIsNotAnyMoreMorning() { when(calendar.get(Calendar.HOUR_OF_DAY)).thenReturn(12); assertThat(dateProvider.isMorning(), is(false)); }
@Test public void dinerTimeIsNotMorning() { when(calendar.get(Calendar.HOUR_OF_DAY)).thenReturn(20); assertThat(dateProvider.isMorning(), is(false)); }