Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @PostMapping("/post", produces = ["application/xml"])
- fun post(@Valid request: RequestData): Mono<Response> {
- return Mono.just(request)
- ...
- ...
- ...
- }
- data class RequestData(
- @get:NotBlank
- @get:Email
- val email: String = "",
- )
- @ExceptionHandler
- fun bindingExceptionHandler(e: WebExchangeBindException) = "Custom Error Message"
- @Test
- fun testWhenInvalidEmail() {
- // Request body
- val email = "invalidemail"
- val request = LinkedMultiValueMap<String, String>()
- request.add("email", email)
- webTestClient.post().uri("/post")
- .body(BodyInserters.fromFormData(request))
- .exchange()
- .expectStatus().isOk
- }
Add Comment
Please, Sign In to add comment