@Test public void testBecomingIdle() { setupToRun(); sut.register(action1, 0); TimerHandler hdlr = timerHandlerInt.getObject(); final States state = context.states("time").startsAs("notLast"); context.checking(new Expectations() { { exactly(IDLE_TIMEOUT - 1).of(action1).run(); when(state.is("notLast")); oneOf(timer).cancel(); when(state.is("last")); allowing(actionProcessor).setQueueRequests(true); allowing(actionProcessor).fireQueuedRequests(); allowing(actionProcessor).setQueueRequests(false); } }); for (int i = 1; i <= IDLE_TIMEOUT; i++) { if (i == IDLE_TIMEOUT) { state.become("last"); } hdlr.run(); incrementTime(); } 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();  }