You create new ObjectMapper
in test class:
MyDto dto = new ObjectMapper().readValue(json, MyDto.class);
Try to inject ObjectMapper
from Spring
context or manually register module:
mapper.registerModule(new JavaTimeModule());
See also:
More Related Contents:
- Difference between @Mock, @MockBean and Mockito.mock()
- How to customise the Jackson JSON mapper implicitly used by Spring Boot?
- Spring Boot Jackson date and timestamp Format
- Deserialize Java 8 LocalDateTime with JacksonMapper
- SpringRunner vs SpringBootTest
- java.lang.IllegalArgumentException: No converter found for return value of type
- Jackson – deserialize inner list of objects to list of one higher level
- How to test Externalized Configuration reading from yaml
- How to test ConfigurationProperties with JUnit?
- How do I mock a REST template exchange?
- How to exclude *AutoConfiguration classes in Spring Boot JUnit tests?
- How to test main class of Spring-boot application
- @TestPropertySource doesn’t work for JUnit test with AnnotationConfigContextLoader in Spring 1.2.6
- Jackson date-format for OffsetDateTime in Spring Boot
- How to customise Jackson in Spring Boot 1.4
- How to use dynamic property names for a Json object
- Spring Boot Microservices – Spring Security – ServiceTest and ControllerTest for JUnit throwing java.lang.StackOverflowError
- How to do a JUnit assert on a message in a logger
- After Spring Boot 2.0 migration: jdbcUrl is required with driverClassName
- Spring Boot 2.0.x disable security for certain profile
- Consider defining a bean of type ‘package’ in your configuration [Spring-Boot]
- How to parse a JSON string to an array using Jackson
- Configure active profile in SpringBoot via Maven
- Can Jackson be configured to trim leading/trailing whitespace from all string properties?
- Can not deserialize instance of java.util.ArrayList out of VALUE_STRING
- How to Get All Endpoints List After Startup, Spring Boot
- Using assertArrayEquals in unit tests
- How to test methods that call System.exit()?
- Spring-Boot @Autowired in main class is getting null
- Mono switchIfEmpty() is always called