Fix test failure after Spring Boot upgraded from Jackson 2.11.2 to 2.11.3, which introduced an API (contractual) breaking change.

Seems Jackson introduced an API breaking change that now requires a PolymorphicTypeValidator when configuring and activating the default typing as a propery on the ObjectMapper.
This commit is contained in:
John Blum
2020-10-13 12:22:46 -07:00
parent a9fce4577d
commit 77ab747c2c

View File

@@ -40,6 +40,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.InvalidDefinitionException;
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import com.fasterxml.jackson.databind.jsontype.DefaultBaseTypeLimitingValidator;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.junit.Before;
@@ -623,7 +624,8 @@ public class JsonCacheDataImporterExporterIntegrationTests extends SpringApplica
.identifiedAs(1L);
ObjectMapper objectMapper = newObjectMapper()
.activateDefaultTypingAsProperty(null, ObjectMapper.DefaultTyping.EVERYTHING, "@type");
.activateDefaultTypingAsProperty(new DefaultBaseTypeLimitingValidator(),
ObjectMapper.DefaultTyping.EVERYTHING, "@type");
String json = objectMapper.writeValueAsString(purchaseOrder);