public final void expectEvent(EventExpectation expect) {
expectEventCount++;
EventPredicate p = expect.getPredicate();
Event e = enterEventHandling(expect.getTimeout());
try {
if (!p.apply(e)) throw UnexpectedEventException.of(e, p, expectEventCount);
if (e instanceof ExceptionEvent) {
ExceptionEvent xe = (ExceptionEvent)e;
throw new SchedulerException("Error while polling event: " + xe.getException(), xe.getException() );
}