@Test public void should_update_info_for_online_with_info_endpoint_only() { Registration registration = Registration.create("foo", wireMock.url("/health")).build(); Instance instance = Instance.create(InstanceId.of("onl")) .register(registration) .withEndpoints(Endpoints.single("info", wireMock.url("/info"))) .withStatusInfo(StatusInfo.ofUp()); StepVerifier.create(repository.save(instance)).expectNextCount(1).verifyComplete(); String body = "{ \"foo\": \"bar\" }"; wireMock.stubFor(get("/info").willReturn(okJson(body).withHeader("Content-Length", Integer.toString(body.length()) ))); Instance noInfo = Instance.create(InstanceId.of("noinfo")) .register(registration) .withEndpoints(Endpoints.single("beans", wireMock.url("/beans"))) .withStatusInfo(StatusInfo.ofUp()); StepVerifier.create(repository.save(noInfo)).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(); StepVerifier.create(eventStore) .expectSubscription() .then(() -> StepVerifier.create(updater.updateInfo(offline.getId())).verifyComplete()) .then(() -> StepVerifier.create(updater.updateInfo(unknown.getId())).verifyComplete()) .then(() -> StepVerifier.create(updater.updateInfo(noInfo.getId())).verifyComplete()) .expectNoEvent(Duration.ofMillis(100L)) .then(() -> StepVerifier.create(updater.updateInfo(instance.getId())).verifyComplete()) .assertNext(event -> assertThat(event).isInstanceOf(InstanceInfoChangedEvent.class)) .thenCancel() .verify(); StepVerifier.create(repository.find(instance.getId())) .assertNext(app -> assertThat(app.getInfo()).isEqualTo(Info.from(singletonMap("foo", "bar")))) .verifyComplete(); }
public Mono<Void> updateInfo(InstanceId id) { return repository.computeIfPresent(id, (key, instance) -> this.doUpdateInfo(instance)).then(); }
InfoUpdater { public Mono<Void> updateInfo(InstanceId id) { return repository.computeIfPresent(id, (key, instance) -> this.doUpdateInfo(instance)).then(); } }
InfoUpdater { public Mono<Void> updateInfo(InstanceId id) { return repository.computeIfPresent(id, (key, instance) -> this.doUpdateInfo(instance)).then(); } InfoUpdater(InstanceRepository repository, InstanceWebClient instanceWebClient); }
InfoUpdater { public Mono<Void> updateInfo(InstanceId id) { return repository.computeIfPresent(id, (key, instance) -> this.doUpdateInfo(instance)).then(); } InfoUpdater(InstanceRepository repository, InstanceWebClient instanceWebClient); Mono<Void> updateInfo(InstanceId id); }
InfoUpdater { public Mono<Void> updateInfo(InstanceId id) { return repository.computeIfPresent(id, (key, instance) -> this.doUpdateInfo(instance)).then(); } InfoUpdater(InstanceRepository repository, InstanceWebClient instanceWebClient); Mono<Void> updateInfo(InstanceId id);  }