@Before public void setup() { mappingContext = new DocumentDbMappingContext(); try { mappingContext.setInitialEntitySet(new EntityScanner(this.applicationContext) .scan(Persistent.class)); } catch (ClassNotFoundException e) { throw new RuntimeException(e.getMessage()); } dbConverter = new MappingDocumentDbConverter(mappingContext); documentClient = new DocumentClient(documentDbUri, documentDbKey, ConnectionPolicy.GetDefault(), ConsistencyLevel.Session); dbTemplate = new DocumentDbTemplate(documentClient, dbConverter, TEST_DB_NAME); dbTemplate.createCollectionIfNotExists(Person.class.getSimpleName(), null, null); dbTemplate.insert(Person.class.getSimpleName(), TEST_PERSON, null); }
@Bean @ConditionalOnMissingBean public MongoMappingContext mongoMappingContext(BeanFactory beanFactory, ApplicationContext applicationContext) throws ClassNotFoundException { MongoMappingContext context = new MongoMappingContext(); context.setInitialEntitySet(new EntityScanner(applicationContext).scan(Document.class, Persistent.class)); return context; }
@Bean @ConditionalOnMissingBean public MongoMappingContext mongoMappingContext(BeanFactory beanFactory) throws ClassNotFoundException { MongoMappingContext context = new MongoMappingContext(); context.setInitialEntitySet(new EntityScanner(this.applicationContext) .scan(Document.class, Persistent.class)); Class<?> strategyClass = this.properties.getFieldNamingStrategy(); if (strategyClass != null) { context.setFieldNamingStrategy( (FieldNamingStrategy) BeanUtils.instantiate(strategyClass)); } return context; }
@Override protected Set<Class<?>> getInitialEntitySet() throws ClassNotFoundException { return new EntityScanner(this.applicationContext).scan(Document.class, Persistent.class); }