@Test public void accept_ShouldReturnFalse_IfCurrentTimeIsBeforeBegin_AndStopIsBeforeBegin() throws Exception { when(config.time_begin()).thenReturn("13:00"); when(config.time_stop()).thenReturn("11:00"); subject = new TimeConstraint(config, getFixedClock(12, 30)); assertThat(subject.accept(candidate)).isFalse(); }
@Override public boolean accept(Media candidate) { LocalTime now = LocalTime.now(clock); if (begin.isBefore(stop)) { return logAndReturn(begin.isBefore(now) && now.isBefore(stop), now); } else { return logAndReturn(( now.isAfter(begin) && now.isAfter(stop)) || (now.isBefore(stop) && now.isBefore(begin)), now); } }
TimeConstraint extends AbstractConstraint { @Override public boolean accept(Media candidate) { LocalTime now = LocalTime.now(clock); if (begin.isBefore(stop)) { return logAndReturn(begin.isBefore(now) && now.isBefore(stop), now); } else { return logAndReturn(( now.isAfter(begin) && now.isAfter(stop)) || (now.isBefore(stop) && now.isBefore(begin)), now); } } }
TimeConstraint extends AbstractConstraint { @Override public boolean accept(Media candidate) { LocalTime now = LocalTime.now(clock); if (begin.isBefore(stop)) { return logAndReturn(begin.isBefore(now) && now.isBefore(stop), now); } else { return logAndReturn(( now.isAfter(begin) && now.isAfter(stop)) || (now.isBefore(stop) && now.isBefore(begin)), now); } } @Inject protected  TimeConstraint(ConstraintConfig config,
                             Clock clock); }
TimeConstraint extends AbstractConstraint { @Override public boolean accept(Media candidate) { LocalTime now = LocalTime.now(clock); if (begin.isBefore(stop)) { return logAndReturn(begin.isBefore(now) && now.isBefore(stop), now); } else { return logAndReturn(( now.isAfter(begin) && now.isAfter(stop)) || (now.isBefore(stop) && now.isBefore(begin)), now); } } @Inject protected  TimeConstraint(ConstraintConfig config,
                             Clock clock); @Override boolean accept(Media candidate); }
TimeConstraint extends AbstractConstraint { @Override public boolean accept(Media candidate) { LocalTime now = LocalTime.now(clock); if (begin.isBefore(stop)) { return logAndReturn(begin.isBefore(now) && now.isBefore(stop), now); } else { return logAndReturn(( now.isAfter(begin) && now.isAfter(stop)) || (now.isBefore(stop) && now.isBefore(begin)), now); } } @Inject protected  TimeConstraint(ConstraintConfig config,
                             Clock clock); @Override boolean accept(Media candidate);  }