Last active
May 28, 2018 11:08
-
-
Save bclozel/4e2d873e7c3999c175af9535824f818f to your computer and use it in GitHub Desktop.
repro sample for Spring Boot issue #13248
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.demo; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; | |
import org.springframework.boot.test.context.SpringBootTest; | |
import org.springframework.http.MediaType; | |
import org.springframework.test.context.junit4.SpringRunner; | |
import org.springframework.test.web.reactive.server.WebTestClient; | |
import static org.assertj.core.api.Assertions.assertThat; | |
@RunWith(SpringRunner.class) | |
@SpringBootTest | |
@AutoConfigureWebTestClient | |
public class DemoApplicationTests { | |
@Autowired | |
private WebTestClient webTestClient; | |
@Test | |
public void testUserJsonDeserialization() { | |
User user = this.webTestClient.get().uri("/") | |
.accept(MediaType.APPLICATION_JSON).exchange() | |
.expectBody(User.class).returnResult().getResponseBody(); | |
assertThat(user.getName()).isEqualTo("spring"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.demo; | |
import javax.validation.constraints.NotBlank; | |
import lombok.Builder; | |
import lombok.Data; | |
import org.hibernate.validator.constraints.Range; | |
@Data | |
@Builder | |
public class User { | |
private String id; | |
@NotBlank | |
private String name; | |
@Range(min = 10,max = 100) | |
private Integer age; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.demo; | |
import reactor.core.publisher.Mono; | |
import org.springframework.stereotype.Controller; | |
import org.springframework.web.bind.annotation.GetMapping; | |
import org.springframework.web.bind.annotation.ResponseBody; | |
@Controller | |
public class UserController { | |
@GetMapping("/") | |
@ResponseBody | |
public Mono<User> fetchUser() { | |
return Mono.just(User.builder().age(15).name("spring").build()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment