@Test public void should_chain_on_empty() { Instance instance = Instance.create(InstanceId.of("id")); ChainingStrategy strategy = new ChainingStrategy((a) -> Mono.empty(), (a) -> Mono.empty(), (a) -> Mono.just(Endpoints.single("id", "path"))); StepVerifier.create(strategy.detectEndpoints(instance)) .expectNext(Endpoints.single("id", "path")) .verifyComplete(); }
@Override public Mono<Endpoints> detectEndpoints(Instance instance) { Mono<Endpoints> result = Mono.empty(); for (EndpointDetectionStrategy delegate : delegates) { result = result.switchIfEmpty(delegate.detectEndpoints(instance)); } return result.switchIfEmpty(Mono.just(Endpoints.empty())); }
ChainingStrategy implements EndpointDetectionStrategy { @Override public Mono<Endpoints> detectEndpoints(Instance instance) { Mono<Endpoints> result = Mono.empty(); for (EndpointDetectionStrategy delegate : delegates) { result = result.switchIfEmpty(delegate.detectEndpoints(instance)); } return result.switchIfEmpty(Mono.just(Endpoints.empty())); } }
ChainingStrategy implements EndpointDetectionStrategy { @Override public Mono<Endpoints> detectEndpoints(Instance instance) { Mono<Endpoints> result = Mono.empty(); for (EndpointDetectionStrategy delegate : delegates) { result = result.switchIfEmpty(delegate.detectEndpoints(instance)); } return result.switchIfEmpty(Mono.just(Endpoints.empty())); } ChainingStrategy(EndpointDetectionStrategy... delegates); }
ChainingStrategy implements EndpointDetectionStrategy { @Override public Mono<Endpoints> detectEndpoints(Instance instance) { Mono<Endpoints> result = Mono.empty(); for (EndpointDetectionStrategy delegate : delegates) { result = result.switchIfEmpty(delegate.detectEndpoints(instance)); } return result.switchIfEmpty(Mono.just(Endpoints.empty())); } ChainingStrategy(EndpointDetectionStrategy... delegates); @Override Mono<Endpoints> detectEndpoints(Instance instance); }
ChainingStrategy implements EndpointDetectionStrategy { @Override public Mono<Endpoints> detectEndpoints(Instance instance) { Mono<Endpoints> result = Mono.empty(); for (EndpointDetectionStrategy delegate : delegates) { result = result.switchIfEmpty(delegate.detectEndpoints(instance)); } return result.switchIfEmpty(Mono.just(Endpoints.empty())); } ChainingStrategy(EndpointDetectionStrategy... delegates); @Override Mono<Endpoints> detectEndpoints(Instance instance);  }