### Question:
ApplicationLifecycleController { public synchronized void shutdownApplication() { if (!shutdownRequested) { shutdownRequested = true; logger.info("Shutting down application"); shutdownDeadline = DateTimeUtils.currentTimeMillis() + SHUTDOWN_TIMEOUT_MILLIS; messageListeners.stream().forEach(MessageListener::prepareForShutdown); restServer.shutdownAndAwait(millisToShutdownDeadline()); logger.info("Shutting down message listeners (except system message listener)"); shutdownAndAwait(messageListenersExcept(systemEventMessageListener)); logger.info("Shutting down system event message listener"); shutdownAndAwait(Collections.singleton(systemEventMessageListener)); logger.info("Application shutdown completed"); } else { logger.debug("Application already shut down"); } } ApplicationLifecycleController(final RestServer restServer, final MessageListener systemEventMessageListener,
            final Collection<MessageListener> messageListeners); void startApplication(final int servicePort, final String bindAddress, final int workerThreads); synchronized void shutdownApplication();  }### Answer:
@Test public void shouldShutdownApplication() { applicationLifecycleController.shutdownApplication(); verifyShutdownRestServerBeforeMessageListener(mockSystemEventMessageListener); verifyShutdownRestServerBeforeMessageListener(mockOtherMessageListener); verifyShutdownSystemMessageListenerLast(); }