@Test public void testDefaultRepositoryConfiguration() throws Exception { prepareApplicationContext(TestConfiguration.class); assertThat(this.context.getBean(CityRepository.class)).isNotNull(); Mongo mongo = this.context.getBean(Mongo.class); assertThat(mongo).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); }
@Test public void testDefaultRepositoryConfiguration() throws Exception { prepareApplicationContext(TestConfiguration.class); assertNotNull(this.context.getBean(CityRepository.class)); Mongo mongo = this.context.getBean(Mongo.class); assertThat(mongo, is(instanceOf(MongoClient.class))); MongoMappingContext mappingContext = this.context .getBean(MongoMappingContext.class); @SuppressWarnings("unchecked") Set<? extends Class<?>> entities = (Set<? extends Class<?>>) ReflectionTestUtils .getField(mappingContext, "initialEntitySet"); assertThat(entities.size(), is(equalTo(1))); }
@Test(expected = NoSuchBeanDefinitionException.class) public void autoConfigurationShouldNotKickInEvenIfManualConfigDidNotCreateAnyRepositories() { prepareApplicationContext(SortOfInvalidCustomConfiguration.class); this.context.getBean(CityRepository.class); }