@Test void getPortShouldThrowWhenDisabledConfiguration() { VersionParser versionParser = new VersionParser(SUPPORTED_VERSIONS); JMAPServer jmapServer = new JMAPServer(DISABLED_CONFIGURATION, NO_ROUTES_HANDLERS, versionParser); jmapServer.start(); assertThatThrownBy(jmapServer::getPort) .isInstanceOf(IllegalStateException.class); }
public void start() { if (configuration.isEnabled()) { server = Optional.of(HttpServer.create() .port(configuration.getPort() .map(Port::getValue) .orElse(RANDOM_PORT)) .handle((request, response) -> handleVersionRoute(request).handleRequest(request, response)) .wiretap(wireTapEnabled()) .bindNow()); } }
JMAPServer implements Startable { public void start() { if (configuration.isEnabled()) { server = Optional.of(HttpServer.create() .port(configuration.getPort() .map(Port::getValue) .orElse(RANDOM_PORT)) .handle((request, response) -> handleVersionRoute(request).handleRequest(request, response)) .wiretap(wireTapEnabled()) .bindNow()); } } }
JMAPServer implements Startable { public void start() { if (configuration.isEnabled()) { server = Optional.of(HttpServer.create() .port(configuration.getPort() .map(Port::getValue) .orElse(RANDOM_PORT)) .handle((request, response) -> handleVersionRoute(request).handleRequest(request, response)) .wiretap(wireTapEnabled()) .bindNow()); } } @Inject  JMAPServer(JMAPConfiguration configuration, Set<JMAPRoutesHandler> jmapRoutesHandlers, VersionParser versionParser); }
JMAPServer implements Startable { public void start() { if (configuration.isEnabled()) { server = Optional.of(HttpServer.create() .port(configuration.getPort() .map(Port::getValue) .orElse(RANDOM_PORT)) .handle((request, response) -> handleVersionRoute(request).handleRequest(request, response)) .wiretap(wireTapEnabled()) .bindNow()); } } @Inject  JMAPServer(JMAPConfiguration configuration, Set<JMAPRoutesHandler> jmapRoutesHandlers, VersionParser versionParser); Port getPort(); void start(); @PreDestroy void stop(); }
JMAPServer implements Startable { public void start() { if (configuration.isEnabled()) { server = Optional.of(HttpServer.create() .port(configuration.getPort() .map(Port::getValue) .orElse(RANDOM_PORT)) .handle((request, response) -> handleVersionRoute(request).handleRequest(request, response)) .wiretap(wireTapEnabled()) .bindNow()); } } @Inject  JMAPServer(JMAPConfiguration configuration, Set<JMAPRoutesHandler> jmapRoutesHandlers, VersionParser versionParser); Port getPort(); void start(); @PreDestroy void stop();  }