@Test public void should_convert_legacy_endpont() { Instance instance = Instance.create(InstanceId.of("id")) .register(Registration.create("test", wireMock.url("/status")).build()); String responseBody = "{ \"status\" : \"UP\", \"foo\" : \"bar\" }"; wireMock.stubFor(get("/status").willReturn(okForContentType(ActuatorMediaType.V1_JSON, responseBody).withHeader(CONTENT_LENGTH, Integer.toString(responseBody.length()) ).withHeader("X-Custom", "1234"))); Mono<ClientResponse> exchange = instanceWebClient.instance(instance).get().uri("health").exchange(); StepVerifier.create(exchange).assertNext(response -> { assertThat(response.headers().contentLength()).isEmpty(); assertThat(response.headers().contentType()).contains(MediaType.parseMediaType(ActuatorMediaType.V2_JSON)); assertThat(response.headers().header("X-Custom")).containsExactly("1234"); assertThat(response.headers().header(CONTENT_TYPE)).containsExactly(ActuatorMediaType.V2_JSON); assertThat(response.headers().header(CONTENT_LENGTH)).isEmpty(); assertThat(response.headers().asHttpHeaders().get("X-Custom")).containsExactly("1234"); assertThat(response.headers().asHttpHeaders().get(CONTENT_TYPE)).containsExactly(ActuatorMediaType.V2_JSON); assertThat(response.headers().asHttpHeaders().get(CONTENT_LENGTH)).isNull(); assertThat(response.statusCode()).isEqualTo(HttpStatus.OK); }).verifyComplete(); String expectedBody = "{\"status\":\"UP\",\"details\":{\"foo\":\"bar\"}}"; StepVerifier.create(exchange.flatMap(r -> r.bodyToMono(String.class))) .assertNext(actualBody -> assertThat(actualBody).isEqualTo(expectedBody)) .verifyComplete(); wireMock.verify(2, getRequestedFor(urlEqualTo("/status"))); }
public WebClient instance(Mono<Instance> instance) { return webClient.mutate() .filters(filters -> filters.add(0, InstanceExchangeFilterFunctions.setInstance(instance))) .build(); }
InstanceWebClient { public WebClient instance(Mono<Instance> instance) { return webClient.mutate() .filters(filters -> filters.add(0, InstanceExchangeFilterFunctions.setInstance(instance))) .build(); } }
InstanceWebClient { public WebClient instance(Mono<Instance> instance) { return webClient.mutate() .filters(filters -> filters.add(0, InstanceExchangeFilterFunctions.setInstance(instance))) .build(); } protected  InstanceWebClient(WebClient webClient); }
InstanceWebClient { public WebClient instance(Mono<Instance> instance) { return webClient.mutate() .filters(filters -> filters.add(0, InstanceExchangeFilterFunctions.setInstance(instance))) .build(); } protected  InstanceWebClient(WebClient webClient); WebClient instance(Mono<Instance> instance); WebClient instance(Instance instance); static InstanceWebClient.Builder builder(); }
InstanceWebClient { public WebClient instance(Mono<Instance> instance) { return webClient.mutate() .filters(filters -> filters.add(0, InstanceExchangeFilterFunctions.setInstance(instance))) .build(); } protected  InstanceWebClient(WebClient webClient); WebClient instance(Mono<Instance> instance); WebClient instance(Instance instance); static InstanceWebClient.Builder builder();  }