ControllerImpl implements Controller { @Override public void stop() throws IllegalStateException { if (webServer == null) { throw new IllegalStateException("Webserver not started!"); } webServer.stopServer(); webServer = null; gui.stop(); } ControllerImpl(final ServerConfigFactory serverConfigFactory,
                          final ServerSocketFactory serverSocketFactory,
                          final ServerGui gui); @Override WebServer getWebServer(); @Override void start(); @Override void stop();  }
@Test(expected = IllegalStateException.class) public void shouldThrowExceptionOnIllegalStop() { ControllerImpl controllerImpl = new ControllerImpl(serverConfigFactory, serverSocketFactory, serverGui); controllerImpl.stop(); }