use of org.springframework.data.mongodb.core.schema.MongoJsonSchema in project spring-data-mongodb by spring-projects.
the class MappingMongoJsonSchemaCreatorUnitTests method csfleWithKeyFromMethod.
// GH-3800
@Test
public void csfleWithKeyFromMethod() {
GenericApplicationContext applicationContext = new GenericApplicationContext();
applicationContext.registerBean("encryptionExtension", EncryptionExtension.class, () -> new EncryptionExtension());
applicationContext.refresh();
MongoMappingContext mappingContext = new MongoMappingContext();
mappingContext.setApplicationContext(applicationContext);
mappingContext.afterPropertiesSet();
MongoJsonSchema schema = //
MongoJsonSchemaCreator.create(mappingContext).filter(//
MongoJsonSchemaCreator.encryptedOnly()).createSchemaFor(EncryptionMetadataFromMethod.class);
assertThat(schema.schemaDocument().toBsonDocument()).isEqualTo(BsonDocument.parse(ENC_FROM_METHOD_SCHEMA));
}
use of org.springframework.data.mongodb.core.schema.MongoJsonSchema in project spring-data-mongodb by spring-projects.
the class JsonSchemaQueryTests method mapsNestedFieldName.
// DATAMONGO-1835
@Test
public void mapsNestedFieldName() {
MongoJsonSchema schema = //
MongoJsonSchema.builder().required(//
"address").property(object("address").properties(string("street").matching("^Apple.*"))).build();
assertThat(template.find(query(matchingDocumentStructure(schema)), Person.class)).containsExactlyInAnyOrder(jellyBelly);
}
use of org.springframework.data.mongodb.core.schema.MongoJsonSchema in project spring-data-mongodb by spring-projects.
the class JsonSchemaQueryTests method findsDocumentsWithRequiredFieldsReactively.
// DATAMONGO-1835
@Test
public void findsDocumentsWithRequiredFieldsReactively() {
MongoJsonSchema schema = MongoJsonSchema.builder().required("address").build();
new ReactiveMongoTemplate(reactiveClient, DATABASE_NAME).find(query(matchingDocumentStructure(schema)), Person.class).as(StepVerifier::create).expectNextCount(2).verifyComplete();
}
use of org.springframework.data.mongodb.core.schema.MongoJsonSchema in project spring-data-mongodb by spring-projects.
the class JsonSchemaQueryTests method findsDocumentsWithJsonFieldTypesCorrectly.
// DATAMONGO-1835
@Test
public void findsDocumentsWithJsonFieldTypesCorrectly() {
MongoJsonSchema schema = MongoJsonSchema.builder().property(number("value")).build();
assertThat(template.find(query(matchingDocumentStructure(schema)), Person.class)).containsExactlyInAnyOrder(jellyBelly, roseSpringHeart);
}
use of org.springframework.data.mongodb.core.schema.MongoJsonSchema in project spring-data-mongodb by spring-projects.
the class JsonSchemaQueryTests method findsDocumentsWithBsonFieldTypesCorrectly.
// DATAMONGO-1835
@Test
public void findsDocumentsWithBsonFieldTypesCorrectly() {
MongoJsonSchema schema = MongoJsonSchema.builder().property(int32("value")).build();
assertThat(template.find(query(matchingDocumentStructure(schema)), Person.class)).containsExactlyInAnyOrder(jellyBelly);
}
Aggregations