NovaService { public void start() { if (!serviceDescriptor.lifecycleEnabled) { logger.warn("Service lifecycle disabled, the invocation of start() has no effect"); return; } doInit(); if (started) { throw new IllegalStateException("service " + serviceDescriptor + " already started"); } lifecycleEventHandlers.invokeStartupHandlers(); lifeline.start(); started = true; logger.info("Service {} up and running.", serviceDescriptor); } protected  NovaService(Nova nova); protected  NovaService(Nova nova, ServiceDescriptor serviceDescriptor); void registerInitHandler(Runnable initHandler); void registerStartupHandler(Runnable startupHandler); void registerShutdownHandler(Runnable shutdownHandler); void start(); void shutdown(); boolean isStarted(); Flowable<MetricsDump> dumpMetricsContinuously(Duration interval); final Nova nova; }
@Test void exceptionInOnInitPreventsServiceCreation() { assertThrows(RuntimeException.class, () -> new MyBrokenInitService().start()); }