### Question:
RegistrationApplicationListener implements InitializingBean, DisposableBean { @EventListener @Order(Ordered.LOWEST_PRECEDENCE) public void onApplicationReady(ApplicationReadyEvent event) { if (autoRegister) { startRegisterTask(); } } RegistrationApplicationListener(ApplicationRegistrator registrator);   RegistrationApplicationListener(ApplicationRegistrator registrator, ThreadPoolTaskScheduler taskScheduler); @EventListener @Order(Ordered.LOWEST_PRECEDENCE) void onApplicationReady(ApplicationReadyEvent event); @EventListener @Order(Ordered.LOWEST_PRECEDENCE) void onClosedContext(ContextClosedEvent event); void startRegisterTask(); void stopRegisterTask(); void setAutoDeregister(boolean autoDeregister); void setAutoRegister(boolean autoRegister); void setRegisterPeriod(Duration registerPeriod); @Override void afterPropertiesSet(); @Override void destroy();  }### Answer:
@Test public void should_schedule_register_task() { ApplicationRegistrator registrator = mock(ApplicationRegistrator.class); ThreadPoolTaskScheduler scheduler = mock(ThreadPoolTaskScheduler.class); RegistrationApplicationListener listener = new RegistrationApplicationListener(registrator, scheduler); listener.onApplicationReady(new ApplicationReadyEvent(mock(SpringApplication.class), null, mock(ConfigurableWebApplicationContext.class))); verify(scheduler).scheduleAtFixedRate(isA(Runnable.class), eq(Duration.ofSeconds(10))); }