Guest User

Untitled

a guest
Nov 20th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. @PostMapping("/post", produces = ["application/xml"])
  2. fun post(@Valid request: RequestData): Mono<Response> {
  3. return Mono.just(request)
  4. ...
  5. ...
  6. ...
  7. }
  8.  
  9. data class RequestData(
  10.  
  11. @get:NotBlank
  12. @get:Email
  13. val email: String = "",
  14. )
  15.  
  16. @ExceptionHandler
  17. fun bindingExceptionHandler(e: WebExchangeBindException) = "Custom Error Message"
  18.  
  19. @Test
  20. fun testWhenInvalidEmail() {
  21.  
  22. // Request body
  23. val email = "invalidemail"
  24. val request = LinkedMultiValueMap<String, String>()
  25. request.add("email", email)
  26.  
  27. webTestClient.post().uri("/post")
  28. .body(BodyInserters.fromFormData(request))
  29. .exchange()
  30. .expectStatus().isOk
  31. }
Add Comment
Please, Sign In to add comment