Search in sources :

Example 1 with FieldNamingStrategy

use of org.springframework.data.mapping.model.FieldNamingStrategy in project spring-boot by spring-projects.

the class MongoDataAutoConfigurationTests method testFieldNamingStrategy.

public void testFieldNamingStrategy(String strategy, Class<? extends FieldNamingStrategy> expectedType) {
    this.context = new AnnotationConfigApplicationContext();
    if (strategy != null) {
        EnvironmentTestUtils.addEnvironment(this.context, "spring.data.mongodb.field-naming-strategy:" + strategy);
    }
    this.context.register(PropertyPlaceholderAutoConfiguration.class, MongoAutoConfiguration.class, MongoDataAutoConfiguration.class);
    this.context.refresh();
    MongoMappingContext mappingContext = this.context.getBean(MongoMappingContext.class);
    FieldNamingStrategy fieldNamingStrategy = (FieldNamingStrategy) ReflectionTestUtils.getField(mappingContext, "fieldNamingStrategy");
    assertThat(fieldNamingStrategy.getClass()).isEqualTo(expectedType);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MongoMappingContext(org.springframework.data.mongodb.core.mapping.MongoMappingContext) FieldNamingStrategy(org.springframework.data.mapping.model.FieldNamingStrategy) CamelCaseAbbreviatingFieldNamingStrategy(org.springframework.data.mapping.model.CamelCaseAbbreviatingFieldNamingStrategy) PropertyNameFieldNamingStrategy(org.springframework.data.mapping.model.PropertyNameFieldNamingStrategy)

Aggregations

AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 CamelCaseAbbreviatingFieldNamingStrategy (org.springframework.data.mapping.model.CamelCaseAbbreviatingFieldNamingStrategy)1 FieldNamingStrategy (org.springframework.data.mapping.model.FieldNamingStrategy)1 PropertyNameFieldNamingStrategy (org.springframework.data.mapping.model.PropertyNameFieldNamingStrategy)1 MongoMappingContext (org.springframework.data.mongodb.core.mapping.MongoMappingContext)1