Search in sources :

Example 1 with MappingContextEvent

use of org.springframework.data.mapping.context.MappingContextEvent in project spring-data-mongodb by spring-projects.

the class MongoPersistentEntityIndexCreatorUnitTests method doesNotCreateIndexForEntityComingFromDifferentMappingContext.

@Test
void doesNotCreateIndexForEntityComingFromDifferentMappingContext() {
    MongoMappingContext mappingContext = new MongoMappingContext();
    MongoMappingContext personMappingContext = prepareMappingContext(Person.class);
    MongoPersistentEntityIndexCreator creator = new MongoPersistentEntityIndexCreator(mappingContext, mongoTemplate);
    MongoPersistentEntity<?> entity = personMappingContext.getRequiredPersistentEntity(Person.class);
    MappingContextEvent<MongoPersistentEntity<?>, MongoPersistentProperty> event = new MappingContextEvent<MongoPersistentEntity<?>, MongoPersistentProperty>(personMappingContext, entity);
    creator.onApplicationEvent(event);
    verifyNoInteractions(collection);
}
Also used : MappingContextEvent(org.springframework.data.mapping.context.MappingContextEvent) MongoPersistentEntity(org.springframework.data.mongodb.core.mapping.MongoPersistentEntity) MongoPersistentProperty(org.springframework.data.mongodb.core.mapping.MongoPersistentProperty) MongoMappingContext(org.springframework.data.mongodb.core.mapping.MongoMappingContext) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 MappingContextEvent (org.springframework.data.mapping.context.MappingContextEvent)1 MongoMappingContext (org.springframework.data.mongodb.core.mapping.MongoMappingContext)1 MongoPersistentEntity (org.springframework.data.mongodb.core.mapping.MongoPersistentEntity)1 MongoPersistentProperty (org.springframework.data.mongodb.core.mapping.MongoPersistentProperty)1