@Test public void should_update_endpoints() { Registration registration = Registration.create("foo", "http: Instance instance = Instance.create(InstanceId.of("onl")) .register(registration) .withStatusInfo(StatusInfo.ofUp()); StepVerifier.create(repository.save(instance)).expectNextCount(1).verifyComplete(); Instance noActuator = Instance.create(InstanceId.of("noActuator")) .register(Registration.create("foo", "http: .withStatusInfo(StatusInfo.ofUp()); StepVerifier.create(repository.save(noActuator)).expectNextCount(1).verifyComplete(); Instance offline = Instance.create(InstanceId.of("off")) .register(registration) .withStatusInfo(StatusInfo.ofOffline()); StepVerifier.create(repository.save(offline)).expectNextCount(1).verifyComplete(); Instance unknown = Instance.create(InstanceId.of("unk")) .register(registration) .withStatusInfo(StatusInfo.ofUnknown()); StepVerifier.create(repository.save(unknown)).expectNextCount(1).verifyComplete(); when(strategy.detectEndpoints(any(Instance.class))).thenReturn(Mono.just(Endpoints.single("id", "url"))); StepVerifier.create(Flux.from(eventStore).log("FOO", Level.SEVERE)) .expectSubscription() .then(() -> StepVerifier.create(detector.detectEndpoints(offline.getId())).verifyComplete()) .then(() -> StepVerifier.create(detector.detectEndpoints(unknown.getId())).verifyComplete()) .then(() -> StepVerifier.create(detector.detectEndpoints(noActuator.getId())).verifyComplete()) .expectNoEvent(Duration.ofMillis(100L)) .then(() -> StepVerifier.create(detector.detectEndpoints(instance.getId())).verifyComplete()) .assertNext(event -> assertThat(event).isInstanceOf(InstanceEndpointsDetectedEvent.class)) .thenCancel() .verify(); StepVerifier.create(repository.find(instance.getId())) .assertNext(app -> assertThat(app.getEndpoints()).isEqualTo( Endpoints.single("id", "url").withEndpoint("health", "http: .verifyComplete(); }
public Mono<Void> detectEndpoints(InstanceId id) { return repository.computeIfPresent(id, (key, instance) -> this.doDetectEndpoints(instance)).then(); }
EndpointDetector { public Mono<Void> detectEndpoints(InstanceId id) { return repository.computeIfPresent(id, (key, instance) -> this.doDetectEndpoints(instance)).then(); } }
EndpointDetector { public Mono<Void> detectEndpoints(InstanceId id) { return repository.computeIfPresent(id, (key, instance) -> this.doDetectEndpoints(instance)).then(); } EndpointDetector(InstanceRepository repository, EndpointDetectionStrategy strategy); }
EndpointDetector { public Mono<Void> detectEndpoints(InstanceId id) { return repository.computeIfPresent(id, (key, instance) -> this.doDetectEndpoints(instance)).then(); } EndpointDetector(InstanceRepository repository, EndpointDetectionStrategy strategy); Mono<Void> detectEndpoints(InstanceId id); }
EndpointDetector { public Mono<Void> detectEndpoints(InstanceId id) { return repository.computeIfPresent(id, (key, instance) -> this.doDetectEndpoints(instance)).then(); } EndpointDetector(InstanceRepository repository, EndpointDetectionStrategy strategy); Mono<Void> detectEndpoints(InstanceId id);  }