@Test void runHooksShouldThrowWhenOneHookThrows() { when(hook1.notifyDelete(any())).thenThrow(new RuntimeException()); when(hook2.notifyDelete(any())).thenReturn(Mono.empty()); assertThatThrownBy(() -> testee.runHooks(DELETE_OPERATION).block()).isInstanceOf(RuntimeException.class); }
public Mono<Void> runHooks(PreDeletionHook.DeleteOperation deleteOperation) { return Flux.fromIterable(hooks) .publishOn(Schedulers.elastic()) .flatMap(hook -> metricFactory.map(factory -> publishMetric(deleteOperation, hook, factory)) .orElse(Mono.empty()), CONCURRENCY) .then(); }
PreDeletionHooks { public Mono<Void> runHooks(PreDeletionHook.DeleteOperation deleteOperation) { return Flux.fromIterable(hooks) .publishOn(Schedulers.elastic()) .flatMap(hook -> metricFactory.map(factory -> publishMetric(deleteOperation, hook, factory)) .orElse(Mono.empty()), CONCURRENCY) .then(); } }
PreDeletionHooks { public Mono<Void> runHooks(PreDeletionHook.DeleteOperation deleteOperation) { return Flux.fromIterable(hooks) .publishOn(Schedulers.elastic()) .flatMap(hook -> metricFactory.map(factory -> publishMetric(deleteOperation, hook, factory)) .orElse(Mono.empty()), CONCURRENCY) .then(); } @Inject  PreDeletionHooks(Set<PreDeletionHook> hooks, MetricFactory metricFactory); private  PreDeletionHooks(Set<PreDeletionHook> hooks, Optional<MetricFactory> metricFactory); }
PreDeletionHooks { public Mono<Void> runHooks(PreDeletionHook.DeleteOperation deleteOperation) { return Flux.fromIterable(hooks) .publishOn(Schedulers.elastic()) .flatMap(hook -> metricFactory.map(factory -> publishMetric(deleteOperation, hook, factory)) .orElse(Mono.empty()), CONCURRENCY) .then(); } @Inject  PreDeletionHooks(Set<PreDeletionHook> hooks, MetricFactory metricFactory); private  PreDeletionHooks(Set<PreDeletionHook> hooks, Optional<MetricFactory> metricFactory); Mono<Void> runHooks(PreDeletionHook.DeleteOperation deleteOperation); }
PreDeletionHooks { public Mono<Void> runHooks(PreDeletionHook.DeleteOperation deleteOperation) { return Flux.fromIterable(hooks) .publishOn(Schedulers.elastic()) .flatMap(hook -> metricFactory.map(factory -> publishMetric(deleteOperation, hook, factory)) .orElse(Mono.empty()), CONCURRENCY) .then(); } @Inject  PreDeletionHooks(Set<PreDeletionHook> hooks, MetricFactory metricFactory); private  PreDeletionHooks(Set<PreDeletionHook> hooks, Optional<MetricFactory> metricFactory); Mono<Void> runHooks(PreDeletionHook.DeleteOperation deleteOperation); static final PreDeletionHooks NO_PRE_DELETION_HOOK; }