### Question:
TimeOfDayFilter extends DurationFilter { @Override protected Date getActivationTime(ConditionContext context) { TimeOfDay activationTime = startTime; if(activationTime == null) { activationTime = MIDNIGHT; } return activationTime.next(context.getLocalTime()).getTime(); } TimeOfDayFilter(Condition delegate, TimeRange timeRange);  TimeOfDayFilter(Condition delegate, @Nullable TimeOfDay startTime, @Nullable TimeOfDay endTime); @Override String toString();  }### Answer:
@Test public void testGetNextActivationTimeNoStartTime() { TimeOfDayFilter filter = new TimeOfDayFilter(AlwaysFireCondition.getInstance(), null, new TimeOfDay(0,0,0)); Calendar expected = RuleFixtures.time(0, 0, 0); expected.add(Calendar.DAY_OF_MONTH, 1); context.setLocalTime(RuleFixtures.time(0, 0, 0)); assertDateEquals(expected.getTime(), filter.getActivationTime(context)); context.setLocalTime(RuleFixtures.time(12, 0, 0)); assertDateEquals(expected.getTime(), filter.getActivationTime(context)); context.setLocalTime(RuleFixtures.time(23, 59, 59)); assertDateEquals(expected.getTime(), filter.getActivationTime(context)); }
@Test public void testGetNextActivationWithStartTime() { TimeOfDayFilter filter = new TimeOfDayFilter(AlwaysFireCondition.getInstance(), new TimeOfDay(10, 0, 0), new TimeOfDay(23,0,0)); Calendar expected = RuleFixtures.time(10, 0, 0); context.setLocalTime(RuleFixtures.time(8, 0, 0)); assertDateEquals(expected.getTime(), filter.getActivationTime(context)); context.setLocalTime(RuleFixtures.time(10, 0, 0)); expected.add(Calendar.DAY_OF_MONTH, 1); assertDateEquals(expected.getTime(), filter.getActivationTime(context)); context.setLocalTime(RuleFixtures.time(23, 59, 59)); assertDateEquals(expected.getTime(), filter.getActivationTime(context)); }