Period implements Serializable { public boolean isOpenToRequisitions() { return isOpenForCurrentDate() || isBeforeCurrent(); } 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 shouldReturnTrueWhenPeriodIsBeforeCurrent() { Period periodBefore = new Period(DateTime.parse("2017-08-12")); LMISTestApp.getInstance().setCurrentTimeMillis(DateTime.parse("2017-09-12").getMillis()); assertThat(periodBefore.isOpenToRequisitions(), is(true)); }
@Test public void shouldReturnFalseWhenPeriodIsCurrentAndTodayIsBeforeRequisitionDate() { LMISTestApp.getInstance().setCurrentTimeMillis(DateTime.parse("2017-09-17").getMillis()); assertThat(period.isOpenToRequisitions(), is(false)); }
@Test public void shouldReturnTrueWhenCurrentDateIsBetweenOpeningRequisitionIntervalOnCurrentPeriod() { DateTime testedDate = DateTime.parse("2017-09-18"); Interval validInterval = new Interval(testedDate, DateTime.parse("2017-09-26")); while (validInterval.contains(testedDate)) { LMISTestApp.getInstance().setCurrentTimeMillis(testedDate.getMillis()); assertThat(period.isOpenToRequisitions(), is(true)); testedDate = testedDate.plusDays(ONE_DAY); } }
@Test public void shouldReturnFalseWhenPeriodIsAfterCurrentOne() { Period period = new Period(DateTime.parse("2017-09-26")); LMISTestApp.getInstance().setCurrentTimeMillis(DateTime.parse("2017-09-17").getMillis()); assertThat(period.isOpenToRequisitions(), is(false)); }
@Test public void shouldReturnFalseWhenPeriodIsGreaterThanCurrentOne() { Period period = new Period(DateTime.parse("2017-09-21")); LMISTestApp.getInstance().setCurrentTimeMillis(DateTime.parse("2017-09-12").getMillis()); assertThat(period.isOpenToRequisitions(), is(false)); }