@Test public void testTiming() { setupToRun(); sut.register(action1, 2); sut.register(action2, 3); TimerHandler hdlr = timerHandlerInt.getObject(); final States state = context.states("time").startsAs("1"); context.checking(new Expectations() { { oneOf(action1).run(); when(state.is("3")); oneOf(action1).run(); when(state.is("5")); oneOf(action1).run(); when(state.is("7")); oneOf(action1).run(); when(state.is("9")); oneOf(action1).run(); when(state.is("11")); oneOf(action2).run(); when(state.is("4")); oneOf(action2).run(); when(state.is("7")); oneOf(action2).run(); when(state.is("10")); allowing(actionProcessor).setQueueRequests(true); allowing(actionProcessor).fireQueuedRequests(); allowing(actionProcessor).setQueueRequests(false); } }); for (int i = 2; i <= 9 + 3; i++) { incrementTime(); state.become(Integer.toString(i)); hdlr.run(); } context.assertIsSatisfied(); }
public void register(final TimerHandler handler, final int period) { Registration reg = new Registration(handler, period); reg.computeNextTime(timeNow()); registrations.add(reg); }
PeriodicEventManager { public void register(final TimerHandler handler, final int period) { Registration reg = new Registration(handler, period); reg.computeNextTime(timeNow()); registrations.add(reg); } }
PeriodicEventManager { public void register(final TimerHandler handler, final int period) { Registration reg = new Registration(handler, period); reg.computeNextTime(timeNow()); registrations.add(reg); } PeriodicEventManager(final long inIdleTimeout, final TimerFactory inTimerFactory,
            final ActionProcessor inActionProcessor); }
PeriodicEventManager { public void register(final TimerHandler handler, final int period) { Registration reg = new Registration(handler, period); reg.computeNextTime(timeNow()); registrations.add(reg); } PeriodicEventManager(final long inIdleTimeout, final TimerFactory inTimerFactory,
            final ActionProcessor inActionProcessor); void register(final TimerHandler handler, final int period); void deregister(final TimerHandler handler); void start(); void userActivityDetected(); }
PeriodicEventManager { public void register(final TimerHandler handler, final int period) { Registration reg = new Registration(handler, period); reg.computeNextTime(timeNow()); registrations.add(reg); } PeriodicEventManager(final long inIdleTimeout, final TimerFactory inTimerFactory,
            final ActionProcessor inActionProcessor); void register(final TimerHandler handler, final int period); void deregister(final TimerHandler handler); void start(); void userActivityDetected();  }