@Test void testLifecycleHandlerWithoutReturnTypeCompletableFutureIsRegistered(@Mock Configuration config) { AtomicBoolean started = new AtomicBoolean(false); ComponentWithLifecycleHandlers testComponent = new ComponentWithLifecycleHandlers(started); ArgumentCaptor<LifecycleHandler> lifecycleHandlerCaptor = ArgumentCaptor.forClass(LifecycleHandler.class); LifecycleHandlerInspector.registerLifecycleHandlers(config, testComponent); verify(config).onStart(eq(TEST_PHASE), lifecycleHandlerCaptor.capture()); lifecycleHandlerCaptor.getValue().run(); assertTrue(started.get()); }
public static void registerLifecycleHandlers(Configuration configuration, Object component) { if (component == null) { logger.debug("Ignoring [null] component for inspection as it wont participate in the lifecycle"); return; } registerLifecycleHandlers(configuration, component, StartHandler.class, Configuration::onStart); registerLifecycleHandlers(configuration, component, ShutdownHandler.class, Configuration::onShutdown); }
LifecycleHandlerInspector { public static void registerLifecycleHandlers(Configuration configuration, Object component) { if (component == null) { logger.debug("Ignoring [null] component for inspection as it wont participate in the lifecycle"); return; } registerLifecycleHandlers(configuration, component, StartHandler.class, Configuration::onStart); registerLifecycleHandlers(configuration, component, ShutdownHandler.class, Configuration::onShutdown); } }
LifecycleHandlerInspector { public static void registerLifecycleHandlers(Configuration configuration, Object component) { if (component == null) { logger.debug("Ignoring [null] component for inspection as it wont participate in the lifecycle"); return; } registerLifecycleHandlers(configuration, component, StartHandler.class, Configuration::onStart); registerLifecycleHandlers(configuration, component, ShutdownHandler.class, Configuration::onShutdown); } private  LifecycleHandlerInspector(); }
LifecycleHandlerInspector { public static void registerLifecycleHandlers(Configuration configuration, Object component) { if (component == null) { logger.debug("Ignoring [null] component for inspection as it wont participate in the lifecycle"); return; } registerLifecycleHandlers(configuration, component, StartHandler.class, Configuration::onStart); registerLifecycleHandlers(configuration, component, ShutdownHandler.class, Configuration::onShutdown); } private  LifecycleHandlerInspector(); static void registerLifecycleHandlers(Configuration configuration, Object component); }
LifecycleHandlerInspector { public static void registerLifecycleHandlers(Configuration configuration, Object component) { if (component == null) { logger.debug("Ignoring [null] component for inspection as it wont participate in the lifecycle"); return; } registerLifecycleHandlers(configuration, component, StartHandler.class, Configuration::onStart); registerLifecycleHandlers(configuration, component, ShutdownHandler.class, Configuration::onShutdown); } private  LifecycleHandlerInspector(); static void registerLifecycleHandlers(Configuration configuration, Object component);  }