@Test public void should_change_status_to_down() { String body = "{ \"status\" : \"UP\", \"details\" : { \"foo\" : \"bar\" } }"; wireMock.stubFor(get("/health").willReturn(okForContentType(ActuatorMediaType.V2_JSON, body).withHeader("Content-Length", Integer.toString(body.length()) ))); StepVerifier.create(eventStore) .expectSubscription() .then(() -> StepVerifier.create(updater.updateStatus(instance.getId())).verifyComplete()) .assertNext(event -> { assertThat(event).isInstanceOf(InstanceStatusChangedEvent.class); assertThat(event.getInstance()).isEqualTo(instance.getId()); InstanceStatusChangedEvent statusChangedEvent = (InstanceStatusChangedEvent) event; assertThat(statusChangedEvent.getStatusInfo().getStatus()).isEqualTo("UP"); assertThat(statusChangedEvent.getStatusInfo().getDetails()).isEqualTo(singletonMap("foo", "bar" )); }) .thenCancel() .verify(); StepVerifier.create(repository.find(instance.getId())) .assertNext(app -> assertThat(app.getStatusInfo().getStatus()).isEqualTo("UP")) .verifyComplete(); StepVerifier.create(repository.computeIfPresent(instance.getId(), (key, instance) -> Mono.just(instance.deregister()) )) .then(() -> StepVerifier.create(updater.updateStatus(instance.getId())).verifyComplete()) .thenCancel() .verify(); StepVerifier.create(repository.find(instance.getId())) .assertNext(app -> assertThat(app.getStatusInfo().getStatus()).isEqualTo("UNKNOWN")) .verifyComplete(); }
public Mono<Void> updateStatus(InstanceId id) { return repository.computeIfPresent(id, (key, instance) -> this.doUpdateStatus(instance)).then(); }
StatusUpdater { public Mono<Void> updateStatus(InstanceId id) { return repository.computeIfPresent(id, (key, instance) -> this.doUpdateStatus(instance)).then(); } }
StatusUpdater { public Mono<Void> updateStatus(InstanceId id) { return repository.computeIfPresent(id, (key, instance) -> this.doUpdateStatus(instance)).then(); } StatusUpdater(InstanceRepository repository, InstanceWebClient instanceWebClient); }
StatusUpdater { public Mono<Void> updateStatus(InstanceId id) { return repository.computeIfPresent(id, (key, instance) -> this.doUpdateStatus(instance)).then(); } StatusUpdater(InstanceRepository repository, InstanceWebClient instanceWebClient); Mono<Void> updateStatus(InstanceId id); }
StatusUpdater { public Mono<Void> updateStatus(InstanceId id) { return repository.computeIfPresent(id, (key, instance) -> this.doUpdateStatus(instance)).then(); } StatusUpdater(InstanceRepository repository, InstanceWebClient instanceWebClient); Mono<Void> updateStatus(InstanceId id);  }