Search in sources :

Example 6 with MongoMappingContext

use of org.springframework.data.mongodb.core.mapping.MongoMappingContext in project spring-boot by spring-projects.

the class ReactiveMongoRepositoriesAutoConfigurationTests method testDefaultRepositoryConfiguration.

@Test
public void testDefaultRepositoryConfiguration() throws Exception {
    prepareApplicationContext(TestConfiguration.class);
    assertThat(this.context.getBean(ReactiveCityRepository.class)).isNotNull();
    MongoClient client = this.context.getBean(MongoClient.class);
    assertThat(client).isInstanceOf(MongoClient.class);
    MongoMappingContext mappingContext = this.context.getBean(MongoMappingContext.class);
    @SuppressWarnings("unchecked") Set<? extends Class<?>> entities = (Set<? extends Class<?>>) ReflectionTestUtils.getField(mappingContext, "initialEntitySet");
    assertThat(entities).hasSize(1);
}
Also used : MongoClient(com.mongodb.reactivestreams.client.MongoClient) Set(java.util.Set) MongoMappingContext(org.springframework.data.mongodb.core.mapping.MongoMappingContext) Test(org.junit.Test)

Aggregations

MongoMappingContext (org.springframework.data.mongodb.core.mapping.MongoMappingContext)6 Test (org.junit.Test)4 Set (java.util.Set)3 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)3 Mongo (com.mongodb.Mongo)1 MongoClient (com.mongodb.reactivestreams.client.MongoClient)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 EntityScanner (org.springframework.boot.autoconfigure.domain.EntityScanner)1 Bean (org.springframework.context.annotation.Bean)1 Persistent (org.springframework.data.annotation.Persistent)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 Document (org.springframework.data.mongodb.core.mapping.Document)1