@Test public void m5InstantOfNextFrameShouldReturnTheNextInstantThatsMinutesAreAMultipleOfFive() { final M5 cut = new M5(); assertThat(cut.instantOfNextFrame(LocalDate.of(2074, Month.MARCH, 30).atTime(20, 4, 0, 0).toInstant(UTC))) .isEqualTo(LocalDate.of(2074, Month.MARCH, 30).atTime(20, 5, 0, 0).toInstant(UTC)); assertThat(cut.instantOfNextFrame(LocalDate.of(1999, Month.APRIL, 23).atTime(15, 59, 0, 0).toInstant(UTC))) .isEqualTo(LocalDate.of(1999, Month.APRIL, 23).atTime(16, 0, 0, 0).toInstant(UTC)); assertThat(cut.instantOfNextFrame(LocalDate.of(2007, Month.SEPTEMBER, 6).atTime(17, 29, 0, 0).toInstant(UTC))) .isEqualTo(LocalDate.of(2007, Month.SEPTEMBER, 6).atTime(17, 30, 0, 0).toInstant(UTC)); assertThat(cut.instantOfNextFrame(LocalDate.of(2021, Month.JUNE, 8).atTime(8, 34, 0, 0).toInstant(UTC))) .isEqualTo(LocalDate.of(2021, Month.JUNE, 8).atTime(8, 35, 0, 0).toInstant(UTC)); assertThat(cut.instantOfNextFrame(LocalDate.of(1570, Month.NOVEMBER, 24).atTime(23, 7, 0, 0).toInstant(UTC))) .isEqualTo(LocalDate.of(1570, Month.NOVEMBER, 24).atTime(23, 10, 0, 0).toInstant(UTC)); assertThat(cut.instantOfNextFrame(LocalDate.of(2047, Month.JANUARY, 24).atTime(16, 15, 0, 0).toInstant(UTC))) .isEqualTo(LocalDate.of(2047, Month.JANUARY, 24).atTime(16, 20, 0, 0).toInstant(UTC)); assertThat(cut.instantOfNextFrame(LocalDate.of(1989, Month.JUNE, 10).atTime(15, 14, 37, 0).toInstant(UTC))) .isEqualTo(LocalDate.of(1989, Month.JUNE, 10).atTime(15, 15, 0, 0).toInstant(UTC)); assertThat(cut.instantOfNextFrame(LocalDate.of(2006, Month.AUGUST, 10).atTime(3, 29, 0, 7521).toInstant(UTC))) .isEqualTo(LocalDate.of(2006, Month.AUGUST, 10).atTime(3, 30, 0, 0).toInstant(UTC)); assertThat( cut.instantOfNextFrame(LocalDate.of(3057, Month.NOVEMBER, 10).atTime(8, 54, 12, 45720).toInstant(UTC))) .isEqualTo(LocalDate.of(3057, Month.NOVEMBER, 10).atTime(8, 55, 0, 0).toInstant(UTC)); }
@Override public Instant instantOfNextFrame(final Instant current) { final OffsetDateTime time = current.atOffset(UTC); final int minutes = time.get(MINUTE_OF_HOUR); return time.withSecond(0).withNano(0).plusMinutes(5 - (minutes % 5)).toInstant(); }
M5 implements TimeFrame { @Override public Instant instantOfNextFrame(final Instant current) { final OffsetDateTime time = current.atOffset(UTC); final int minutes = time.get(MINUTE_OF_HOUR); return time.withSecond(0).withNano(0).plusMinutes(5 - (minutes % 5)).toInstant(); } }
M5 implements TimeFrame { @Override public Instant instantOfNextFrame(final Instant current) { final OffsetDateTime time = current.atOffset(UTC); final int minutes = time.get(MINUTE_OF_HOUR); return time.withSecond(0).withNano(0).plusMinutes(5 - (minutes % 5)).toInstant(); }  }
M5 implements TimeFrame { @Override public Instant instantOfNextFrame(final Instant current) { final OffsetDateTime time = current.atOffset(UTC); final int minutes = time.get(MINUTE_OF_HOUR); return time.withSecond(0).withNano(0).plusMinutes(5 - (minutes % 5)).toInstant(); }  @Override Instant instantOfNextFrame(final Instant current); @Override boolean areInSameTimeFrame(final Instant instant1, final Instant instant2); }
M5 implements TimeFrame { @Override public Instant instantOfNextFrame(final Instant current) { final OffsetDateTime time = current.atOffset(UTC); final int minutes = time.get(MINUTE_OF_HOUR); return time.withSecond(0).withNano(0).plusMinutes(5 - (minutes % 5)).toInstant(); }  @Override Instant instantOfNextFrame(final Instant current); @Override boolean areInSameTimeFrame(final Instant instant1, final Instant instant2);  }