@Test public void usesAutoConfigurationPackageToPickUpDocumentTypes() { this.context = new AnnotationConfigApplicationContext(); String cityPackage = City.class.getPackage().getName(); AutoConfigurationPackages.register(this.context, cityPackage); this.context.register(MongoAutoConfiguration.class, MongoDataAutoConfiguration.class); this.context.refresh(); assertDomainTypesDiscovered(this.context.getBean(MongoMappingContext.class), City.class); }
@Test @SuppressWarnings("unchecked") public void entityScanShouldSetInitialEntitySet() throws Exception { this.context = new AnnotationConfigApplicationContext(); this.context.register(EntityScanConfig.class, PropertyPlaceholderAutoConfiguration.class, MongoAutoConfiguration.class, MongoDataAutoConfiguration.class); this.context.refresh(); MongoMappingContext mappingContext = this.context .getBean(MongoMappingContext.class); Set<Class<?>> initialEntitySet = (Set<Class<?>>) ReflectionTestUtils .getField(mappingContext, "initialEntitySet"); assertThat(initialEntitySet).containsOnly(City.class, Country.class); }