use of org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator in project spring-data-mongodb by spring-projects.
the class MongoTemplateUnitTests method registersDefaultEntityIndexCreatorIfApplicationContextHasOneForDifferentMappingContext.
// DATAMONGO-533
@Test
void registersDefaultEntityIndexCreatorIfApplicationContextHasOneForDifferentMappingContext() {
GenericApplicationContext applicationContext = new GenericApplicationContext();
applicationContext.getBeanFactory().registerSingleton("foo", new MongoPersistentEntityIndexCreator(new MongoMappingContext(), template));
applicationContext.refresh();
GenericApplicationContext spy = spy(applicationContext);
MongoTemplate mongoTemplate = new MongoTemplate(factory, converter);
mongoTemplate.setApplicationContext(spy);
verify(spy, times(1)).addApplicationListener(argThat(new ArgumentMatcher<MongoPersistentEntityIndexCreator>() {
@Override
public boolean matches(MongoPersistentEntityIndexCreator argument) {
return argument.isIndexCreatorFor(mappingContext);
}
}));
}
Aggregations