@Test public void getError() { ErrorMessage errorResult = webTestClient.get().uri("/shorteners/errors") .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus() .is4xxClientError() .expectBody(ErrorMessage.class).returnResult().getResponseBody(); System.out.println("Error Zemo: -> " + errorResult.error()); }
Mono<ServerResponse> getError(ServerRequest request) { log.info("getError() -> "); return Mono.error(new RuntimeException("Error")).flatMap(r -> ServerResponse.ok() .contentType(MediaType .APPLICATION_JSON).body(fromValue(r))); }
ShortenerHandler implements HttpHandler { Mono<ServerResponse> getError(ServerRequest request) { log.info("getError() -> "); return Mono.error(new RuntimeException("Error")).flatMap(r -> ServerResponse.ok() .contentType(MediaType .APPLICATION_JSON).body(fromValue(r))); } }
ShortenerHandler implements HttpHandler { Mono<ServerResponse> getError(ServerRequest request) { log.info("getError() -> "); return Mono.error(new RuntimeException("Error")).flatMap(r -> ServerResponse.ok() .contentType(MediaType .APPLICATION_JSON).body(fromValue(r))); } ShortenerHandler(ShortenerService shortenerService, ShortenerQuery shortenerQuery); }
ShortenerHandler implements HttpHandler { Mono<ServerResponse> getError(ServerRequest request) { log.info("getError() -> "); return Mono.error(new RuntimeException("Error")).flatMap(r -> ServerResponse.ok() .contentType(MediaType .APPLICATION_JSON).body(fromValue(r))); } ShortenerHandler(ShortenerService shortenerService, ShortenerQuery shortenerQuery); @Override RouterFunction<ServerResponse> route(); }
ShortenerHandler implements HttpHandler { Mono<ServerResponse> getError(ServerRequest request) { log.info("getError() -> "); return Mono.error(new RuntimeException("Error")).flatMap(r -> ServerResponse.ok() .contentType(MediaType .APPLICATION_JSON).body(fromValue(r))); } ShortenerHandler(ShortenerService shortenerService, ShortenerQuery shortenerQuery); @Override RouterFunction<ServerResponse> route();  }