Search in sources :

Example 1 with ConstructorDetector

use of com.fasterxml.jackson.databind.cfg.ConstructorDetector in project spring-boot by spring-projects.

the class JacksonAutoConfigurationTests method constructorDetectorWithNoStrategyUseDefault.

@Test
void constructorDetectorWithNoStrategyUseDefault() {
    this.contextRunner.run((context) -> {
        ObjectMapper mapper = context.getBean(ObjectMapper.class);
        ConstructorDetector cd = mapper.getDeserializationConfig().getConstructorDetector();
        assertThat(cd.singleArgMode()).isEqualTo(SingleArgConstructor.HEURISTIC);
        assertThat(cd.requireCtorAnnotation()).isFalse();
        assertThat(cd.allowJDKTypeConstructors()).isFalse();
    });
}
Also used : ConstructorDetector(com.fasterxml.jackson.databind.cfg.ConstructorDetector) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Example 2 with ConstructorDetector

use of com.fasterxml.jackson.databind.cfg.ConstructorDetector in project spring-boot by spring-projects.

the class JacksonAutoConfigurationTests method constructorDetectorWithDefaultStrategy.

@Test
void constructorDetectorWithDefaultStrategy() {
    this.contextRunner.withPropertyValues("spring.jackson.constructor-detector=default").run((context) -> {
        ObjectMapper mapper = context.getBean(ObjectMapper.class);
        ConstructorDetector cd = mapper.getDeserializationConfig().getConstructorDetector();
        assertThat(cd.singleArgMode()).isEqualTo(SingleArgConstructor.HEURISTIC);
        assertThat(cd.requireCtorAnnotation()).isFalse();
        assertThat(cd.allowJDKTypeConstructors()).isFalse();
    });
}
Also used : ConstructorDetector(com.fasterxml.jackson.databind.cfg.ConstructorDetector) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Example 3 with ConstructorDetector

use of com.fasterxml.jackson.databind.cfg.ConstructorDetector in project spring-boot by spring-projects.

the class JacksonAutoConfigurationTests method constructorDetectorWithUseDelegatingStrategy.

@Test
void constructorDetectorWithUseDelegatingStrategy() {
    this.contextRunner.withPropertyValues("spring.jackson.constructor-detector=use-delegating").run((context) -> {
        ObjectMapper mapper = context.getBean(ObjectMapper.class);
        ConstructorDetector cd = mapper.getDeserializationConfig().getConstructorDetector();
        assertThat(cd.singleArgMode()).isEqualTo(SingleArgConstructor.DELEGATING);
        assertThat(cd.requireCtorAnnotation()).isFalse();
        assertThat(cd.allowJDKTypeConstructors()).isFalse();
    });
}
Also used : ConstructorDetector(com.fasterxml.jackson.databind.cfg.ConstructorDetector) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Example 4 with ConstructorDetector

use of com.fasterxml.jackson.databind.cfg.ConstructorDetector in project spring-boot by spring-projects.

the class JacksonAutoConfigurationTests method constructorDetectorWithExplicitOnlyStrategy.

@Test
void constructorDetectorWithExplicitOnlyStrategy() {
    this.contextRunner.withPropertyValues("spring.jackson.constructor-detector=explicit-only").run((context) -> {
        ObjectMapper mapper = context.getBean(ObjectMapper.class);
        ConstructorDetector cd = mapper.getDeserializationConfig().getConstructorDetector();
        assertThat(cd.singleArgMode()).isEqualTo(SingleArgConstructor.REQUIRE_MODE);
        assertThat(cd.requireCtorAnnotation()).isFalse();
        assertThat(cd.allowJDKTypeConstructors()).isFalse();
    });
}
Also used : ConstructorDetector(com.fasterxml.jackson.databind.cfg.ConstructorDetector) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Example 5 with ConstructorDetector

use of com.fasterxml.jackson.databind.cfg.ConstructorDetector in project spring-boot by spring-projects.

the class JacksonAutoConfigurationTests method constructorDetectorWithUsePropertiesBasedStrategy.

@Test
void constructorDetectorWithUsePropertiesBasedStrategy() {
    this.contextRunner.withPropertyValues("spring.jackson.constructor-detector=use-properties-based").run((context) -> {
        ObjectMapper mapper = context.getBean(ObjectMapper.class);
        ConstructorDetector cd = mapper.getDeserializationConfig().getConstructorDetector();
        assertThat(cd.singleArgMode()).isEqualTo(SingleArgConstructor.PROPERTIES);
        assertThat(cd.requireCtorAnnotation()).isFalse();
        assertThat(cd.allowJDKTypeConstructors()).isFalse();
    });
}
Also used : ConstructorDetector(com.fasterxml.jackson.databind.cfg.ConstructorDetector) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 ConstructorDetector (com.fasterxml.jackson.databind.cfg.ConstructorDetector)5 Test (org.junit.jupiter.api.Test)5