use of org.springframework.data.mongodb.core.schema.MongoJsonSchema in project spring-data-mongodb by spring-projects.
the class JsonSchemaQueryTests method usesMappedFieldNameForRequiredProperties.
// DATAMONGO-1835
@Test
public void usesMappedFieldNameForRequiredProperties() {
MongoJsonSchema schema = MongoJsonSchema.builder().required("name").build();
assertThat(template.find(query(matchingDocumentStructure(schema)), Person.class)).containsExactlyInAnyOrder(jellyBelly, roseSpringHeart, kazmardBoombub);
}
use of org.springframework.data.mongodb.core.schema.MongoJsonSchema in project spring-data-mongodb by spring-projects.
the class JsonSchemaQueryTests method mapsEnumValuesCorrectly.
// DATAMONGO-1835
@Test
public void mapsEnumValuesCorrectly() {
MongoJsonSchema schema = MongoJsonSchema.builder().property(untyped("gender").possibleValues(Gender.PIXY, Gender.GOBLIN)).build();
assertThat(template.find(query(matchingDocumentStructure(schema)), Person.class)).containsExactlyInAnyOrder(jellyBelly, kazmardBoombub);
}
use of org.springframework.data.mongodb.core.schema.MongoJsonSchema in project spring-data-mongodb by spring-projects.
the class JsonSchemaQueryTests method findsWithSchemaReturningRawDocument.
// DATAMONGO-1835
@Test
public void findsWithSchemaReturningRawDocument() {
MongoJsonSchema schema = MongoJsonSchema.builder().required("address").build();
assertThat(template.find(query(matchingDocumentStructure(schema)), Document.class, template.getCollectionName(Person.class))).hasSize(2);
}
use of org.springframework.data.mongodb.core.schema.MongoJsonSchema in project spring-data-mongodb by spring-projects.
the class JsonSchemaQueryTests method usesMappedFieldNameForProperties.
// DATAMONGO-1835
@Test
public void usesMappedFieldNameForProperties() {
MongoJsonSchema schema = MongoJsonSchema.builder().property(string("name").matching("^R.*")).build();
assertThat(template.find(query(matchingDocumentStructure(schema)), Person.class)).containsExactlyInAnyOrder(roseSpringHeart);
}
use of org.springframework.data.mongodb.core.schema.MongoJsonSchema in project spring-data-mongodb by spring-projects.
the class CriteriaUnitTests method extractsJsonSchemaInChainCorrectly.
// DATAMONGO-1835
@Test
public void extractsJsonSchemaInChainCorrectly() {
MongoJsonSchema schema = MongoJsonSchema.builder().required("name").build();
Criteria criteria = Criteria.where("foo").is("bar").andDocumentStructureMatches(schema);
assertThat(criteria.getCriteriaObject()).isEqualTo(new Document("foo", "bar").append("$jsonSchema", new Document("type", "object").append("required", Collections.singletonList("name"))));
}
Aggregations