@Test void getAll() { List<UserDto> resultGetBefore = webTestClient.get().uri("/users") .exchange() .expectHeader().contentType(MediaType.APPLICATION_JSON) .expectBody(List.class).returnResult().getResponseBody(); String firstNameTest = "FirstNameTest"; String lastNameTest = "LastNameTest"; CreateUser request = CreateUser.builder() .firstName(firstNameTest) .lastName(lastNameTest) .build(); webTestClient.post().uri("/users") .contentType(MediaType.APPLICATION_JSON) .body(BodyInserters.fromValue(request)) .exchange() .expectHeader().contentType(MediaType.APPLICATION_JSON) .expectBody(UserDto.class).returnResult().getResponseBody(); webTestClient.post().uri("/users") .contentType(MediaType.APPLICATION_JSON) .body(BodyInserters.fromValue(request)) .exchange() .expectHeader().contentType(MediaType.APPLICATION_JSON) .expectBody(UserDto.class).returnResult().getResponseBody(); List<UserDto> resultGetAfter = webTestClient.get().uri("/users") .exchange() .expectHeader().contentType(MediaType.APPLICATION_JSON) .expectBody(List.class).returnResult().getResponseBody(); assertEquals(resultGetAfter.size() - resultGetBefore.size(), 2); }
Mono<ServerResponse> getAll(ServerRequest request) { log.info("getAll() -> "); return ServerResponse.ok() .contentType(MediaType.APPLICATION_JSON) .body(userQuery.getAll(), UserDto.class) .doOnError(this::logOnError); }
UserHandler implements HttpHandler { Mono<ServerResponse> getAll(ServerRequest request) { log.info("getAll() -> "); return ServerResponse.ok() .contentType(MediaType.APPLICATION_JSON) .body(userQuery.getAll(), UserDto.class) .doOnError(this::logOnError); } }
UserHandler implements HttpHandler { Mono<ServerResponse> getAll(ServerRequest request) { log.info("getAll() -> "); return ServerResponse.ok() .contentType(MediaType.APPLICATION_JSON) .body(userQuery.getAll(), UserDto.class) .doOnError(this::logOnError); } UserHandler(UserApplicationService userApplicationService, UserQuery userQuery); }
UserHandler implements HttpHandler { Mono<ServerResponse> getAll(ServerRequest request) { log.info("getAll() -> "); return ServerResponse.ok() .contentType(MediaType.APPLICATION_JSON) .body(userQuery.getAll(), UserDto.class) .doOnError(this::logOnError); } UserHandler(UserApplicationService userApplicationService, UserQuery userQuery); RouterFunction<ServerResponse> route(); }
UserHandler implements HttpHandler { Mono<ServerResponse> getAll(ServerRequest request) { log.info("getAll() -> "); return ServerResponse.ok() .contentType(MediaType.APPLICATION_JSON) .body(userQuery.getAll(), UserDto.class) .doOnError(this::logOnError); } UserHandler(UserApplicationService userApplicationService, UserQuery userQuery); RouterFunction<ServerResponse> route();  }