private void waitForSpringEventToProcess(final long expected) {
        await().atMost(Duration.of(2, ChronoUnit.SECONDS)).until(() -> casEventRepository.load().count() >= expected);
    }
Pass in the number of expected events that should have been stored in the {@link CasEventRepository } after publishing a new event.
Wait for the repository to have that many events.  Waits for 2 seconds at most.

@param expected The expected number of events to have been saved into the {@link CasEventRepository }
core/cas-server-core-events/src/test/java/org/apereo/cas/support/events/CasAuthenticationEventListenerTests.java