@Test void startShouldCallHealthCheckMultipleTimes() { testee.start(); scheduler.advanceTimeBy(PERIOD.multipliedBy(EXPECTED_INVOKED_TIME)); verify(mockHealthCheck1, times(EXPECTED_INVOKED_TIME)).check(); }
public void start() { disposable = Flux.interval(configuration.getPeriod(), scheduler) .flatMapIterable(any -> healthChecks) .flatMap(healthCheck -> Mono.from(healthCheck.check())) .doOnNext(this::logResult) .onErrorContinue(this::logError) .subscribeOn(Schedulers.elastic()) .subscribe(); }
PeriodicalHealthChecks implements Startable { public void start() { disposable = Flux.interval(configuration.getPeriod(), scheduler) .flatMapIterable(any -> healthChecks) .flatMap(healthCheck -> Mono.from(healthCheck.check())) .doOnNext(this::logResult) .onErrorContinue(this::logError) .subscribeOn(Schedulers.elastic()) .subscribe(); } }
PeriodicalHealthChecks implements Startable { public void start() { disposable = Flux.interval(configuration.getPeriod(), scheduler) .flatMapIterable(any -> healthChecks) .flatMap(healthCheck -> Mono.from(healthCheck.check())) .doOnNext(this::logResult) .onErrorContinue(this::logError) .subscribeOn(Schedulers.elastic()) .subscribe(); } @Inject  PeriodicalHealthChecks(Set<HealthCheck> healthChecks, PeriodicalHealthChecksConfiguration configuration);   PeriodicalHealthChecks(Set<HealthCheck> healthChecks, Scheduler scheduler, PeriodicalHealthChecksConfiguration configuration); }
PeriodicalHealthChecks implements Startable { public void start() { disposable = Flux.interval(configuration.getPeriod(), scheduler) .flatMapIterable(any -> healthChecks) .flatMap(healthCheck -> Mono.from(healthCheck.check())) .doOnNext(this::logResult) .onErrorContinue(this::logError) .subscribeOn(Schedulers.elastic()) .subscribe(); } @Inject  PeriodicalHealthChecks(Set<HealthCheck> healthChecks, PeriodicalHealthChecksConfiguration configuration);   PeriodicalHealthChecks(Set<HealthCheck> healthChecks, Scheduler scheduler, PeriodicalHealthChecksConfiguration configuration); void start(); @PreDestroy void stop(); }
PeriodicalHealthChecks implements Startable { public void start() { disposable = Flux.interval(configuration.getPeriod(), scheduler) .flatMapIterable(any -> healthChecks) .flatMap(healthCheck -> Mono.from(healthCheck.check())) .doOnNext(this::logResult) .onErrorContinue(this::logError) .subscribeOn(Schedulers.elastic()) .subscribe(); } @Inject  PeriodicalHealthChecks(Set<HealthCheck> healthChecks, PeriodicalHealthChecksConfiguration configuration);   PeriodicalHealthChecks(Set<HealthCheck> healthChecks, Scheduler scheduler, PeriodicalHealthChecksConfiguration configuration); void start(); @PreDestroy void stop();  }