use of org.springframework.data.spel.ExtensionAwareEvaluationContextProvider in project spring-data-mongodb by spring-projects.
the class BasicMongoPersistentEntityUnitTests method collectionAllowsReferencingSpringBean.
// DATAMONGO-65, DATAMONGO-1108
@Test
void collectionAllowsReferencingSpringBean() {
CollectionProvider provider = new CollectionProvider();
provider.collectionName = "reference";
when(context.getBean("myBean")).thenReturn(provider);
BasicMongoPersistentEntity<DynamicallyMapped> entity = new BasicMongoPersistentEntity<>(ClassTypeInformation.from(DynamicallyMapped.class));
entity.setEvaluationContextProvider(new ExtensionAwareEvaluationContextProvider(context));
assertThat(entity.getCollection()).isEqualTo("reference");
provider.collectionName = "otherReference";
assertThat(entity.getCollection()).isEqualTo("otherReference");
}
use of org.springframework.data.spel.ExtensionAwareEvaluationContextProvider in project spring-data-mongodb by spring-projects.
the class BasicMongoPersistentEntityUnitTests method usesEvaluationContextExtensionInDynamicDocumentName.
// DATAMONGO-1874
@Test
void usesEvaluationContextExtensionInDynamicDocumentName() {
BasicMongoPersistentEntity<MappedWithExtension> entity = new BasicMongoPersistentEntity<>(ClassTypeInformation.from(MappedWithExtension.class));
entity.setEvaluationContextProvider(new ExtensionAwareEvaluationContextProvider(Collections.singletonList(new SampleExtension())));
assertThat(entity.getCollection()).isEqualTo("collectionName");
}
use of org.springframework.data.spel.ExtensionAwareEvaluationContextProvider in project spring-data-mongodb by spring-projects.
the class BasicMongoPersistentEntityUnitTests method usesCorrectExpressionsForCollectionAndCollation.
// DATAMONGO-2565
@Test
void usesCorrectExpressionsForCollectionAndCollation() {
BasicMongoPersistentEntity<WithCollectionAndCollationFromSpEL> entity = new BasicMongoPersistentEntity<>(ClassTypeInformation.from(WithCollectionAndCollationFromSpEL.class));
entity.setEvaluationContextProvider(new ExtensionAwareEvaluationContextProvider(Collections.singletonList(new SampleExtension())));
assertThat(entity.getCollection()).isEqualTo("collectionName");
assertThat(entity.getCollation()).isEqualTo(Collation.of("en_US"));
}
Aggregations