WorkerManager implements WorkerManagerService { @Override public void registerApplicationStopper(SpaceEnrollerConfig config, String applicationId, String appBindingId) { Duration interval = spaceEnrollerConfigRepository.findOne(config.getId()).getIdleDuration(); log.debug("Initializing a watch on app {}, for an idleDuration of {} ", applicationId, interval.toString()); ApplicationStopper checker = ApplicationStopper.builder() .applicationLocker(applicationLocker) .applicationRepository(applicationRepository) .appUid(applicationId) .bindingId(appBindingId) .clock(clock) .cloudFoundryApi(cloudFoundryApi) .ignoreRouteBindingError(config.isIgnoreRouteServiceError()) .period(interval) .spaceEnrollerConfigId(config.getId()) .proxyMap(proxyMapEntryRepository) .build(); checker.startNow(); }  @PostConstruct void init(); @Override void registerApplicationStopper(SpaceEnrollerConfig config, String applicationId, String appBindingId); @Override void registerSpaceEnroller(SpaceEnrollerConfig service);  }
@Test public void test_task_of_stop_is_scheduled() { SpaceEnrollerConfig config = BeanGenerator.createServiceInstance(); spyWatcher.registerApplicationStopper(config, APPLICATION_ID, "bindingid"); verify(clock).scheduleTask(anyString(), eq(Duration.ofSeconds(0)), any(ApplicationStopper.class)); }