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