### Question:
OriginsReloadCommandHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { return new Eventual<>(Flux.create(this::reload) .subscribeOn(Schedulers.fromExecutor(executor))); } OriginsReloadCommandHandler(Registry<BackendService> backendServicesRegistry); @Override Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context);  }### Answer:
@Test public void returnsWithConfirmationWhenChangesArePerformed() { mockRegistryReload(completedFuture(reloaded("ok"))); HttpResponse response = Mono.from(handler.handle(get("/").build(), mock(HttpInterceptor.Context.class))).block(); assertThat(response.status(), is(OK)); assertThat(response.bodyAs(UTF_8), is("Origins reloaded successfully.\n")); }
@Test public void returnsWithInformationWhenChangesAreUnnecessary() { mockRegistryReload(completedFuture(unchanged("this test returns 'no meaningful changes'"))); HttpResponse response = Mono.from(handler.handle(get("/").build(), mock(HttpInterceptor.Context.class))).block(); assertThat(response.status(), is(OK)); assertThat(response.bodyAs(UTF_8), is("Origins were not reloaded because this test returns 'no meaningful changes'.\n")); }
@Test public void returnsWithInformationWhenJsonErrorOccursDuringReload() { mockRegistryReload(failedFuture(new RuntimeException(new JsonMappingException("simulated error")))); HttpResponse response = Mono.from(handler.handle(get("/").build(), mock(HttpInterceptor.Context.class))).block(); assertThat(response.status(), is(BAD_REQUEST)); assertThat(response.bodyAs(UTF_8), is(matchesRegex("There was an error processing your request. It has been logged \\(ID [0-9a-f-]+\\)\\.\n"))); }
@Test public void returnsWithInformationWhenErrorDuringReload() { mockRegistryReload(failedFuture(new RuntimeException(new RuntimeException("simulated error")))); HttpResponse response = Mono.from(handler.handle(get("/").build(), mock(HttpInterceptor.Context.class))).block(); assertThat(response.status(), is(INTERNAL_SERVER_ERROR)); assertThat(response.bodyAs(UTF_8), is(matchesRegex("There was an error processing your request. It has been logged \\(ID [0-9a-f-]+\\)\\.\n"))); }