Period implements Serializable { public Optional<Period> generateNextAvailablePeriod() { Period nextPeriod = this.next(); if (nextPeriod.isOpenToRequisitions()) { return Optional.of(nextPeriod); } return Optional.absent(); } Period(DateTime dateTime);  Period(DateTime begin, DateTime end); static Period of(Date date); static Period generateForTraining(Date date); DateTime getBegin(); DateTime getInventoryBegin(); DateTime getInventoryEnd(); DateTime getEnd(); Period previous(); static boolean isWithinSubmissionWindow(DateTime date); String toString(); Period next(); Optional<Period> generateNextAvailablePeriod(); boolean isOpenToRequisitions(); DateTime getOpeningRequisitionDate(); @Override boolean equals(Object object); @Override int hashCode(); static final int BEGIN_DAY; static final int END_DAY; static final int INVENTORY_TRAINING_BEGIN_DAY; static final int INVENTORY_TRAINING_END_DAY_NEXT; static final int INVENTORY_BEGIN_DAY; static final int INVENTORY_END_DAY_NEXT; static final int DEFAULT_INVENTORY_DAY; }
@Test public void shouldReturnAValidPeriodWhenNextPeriodIsAvailableForTheCurrentDate() { LMISTestApp.getInstance().setCurrentTimeMillis(DateTime.parse("2017-10-18").getMillis()); assertThat(period.generateNextAvailablePeriod().get(), is(new Period(DateTime.parse("2017-10-12")))); }