Search in sources :

Example 11 with Document

use of org.springframework.data.mongodb.core.mapping.Document in project spring-data-mongodb by spring-projects.

the class QueryMapperUnitTests method resolvesSimpleNestedMappedFieldnameWithUnderscoresCorrectly.

// GH-3601
@Test
void resolvesSimpleNestedMappedFieldnameWithUnderscoresCorrectly() {
    Query query = query(where("simple.renamed_fieldname_with_underscores").exists(true));
    org.bson.Document document = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(WrapperAroundWithPropertyUsingUnderscoreInName.class));
    assertThat(document).isEqualTo(new org.bson.Document("simple.renamed", new org.bson.Document("$exists", true)));
}
Also used : BasicQuery(org.springframework.data.mongodb.core.query.BasicQuery) TextQuery(org.springframework.data.mongodb.core.query.TextQuery) Query(org.springframework.data.mongodb.core.query.Query) Document(org.springframework.data.mongodb.core.mapping.Document) Test(org.junit.jupiter.api.Test)

Example 12 with Document

use of org.springframework.data.mongodb.core.mapping.Document in project spring-data-mongodb by spring-projects.

the class QueryMapperUnitTests method resolvesMappedFieldnameWithUnderscoresCorrectly.

// GH-3601
@Test
void resolvesMappedFieldnameWithUnderscoresCorrectly() {
    Query query = query(where("renamed_fieldname_with_underscores").exists(true));
    org.bson.Document document = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(WithPropertyUsingUnderscoreInName.class));
    assertThat(document).isEqualTo(new org.bson.Document("renamed", new org.bson.Document("$exists", true)));
}
Also used : BasicQuery(org.springframework.data.mongodb.core.query.BasicQuery) TextQuery(org.springframework.data.mongodb.core.query.TextQuery) Query(org.springframework.data.mongodb.core.query.Query) Document(org.springframework.data.mongodb.core.mapping.Document) Test(org.junit.jupiter.api.Test)

Example 13 with Document

use of org.springframework.data.mongodb.core.mapping.Document in project spring-data-mongodb by spring-projects.

the class QueryMapperUnitTests method resolvesFieldNameWithUnderscoreOnNestedMappedFieldnameWithUnderscoresCorrectly.

// GH-3601
@Test
void resolvesFieldNameWithUnderscoreOnNestedMappedFieldnameWithUnderscoresCorrectly() {
    Query query = query(where("double_underscore.renamed_fieldname_with_underscores").exists(true));
    org.bson.Document document = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(WrapperAroundWithPropertyUsingUnderscoreInName.class));
    assertThat(document).isEqualTo(new org.bson.Document("double_underscore.renamed", new org.bson.Document("$exists", true)));
}
Also used : BasicQuery(org.springframework.data.mongodb.core.query.BasicQuery) TextQuery(org.springframework.data.mongodb.core.query.TextQuery) Query(org.springframework.data.mongodb.core.query.Query) Document(org.springframework.data.mongodb.core.mapping.Document) Test(org.junit.jupiter.api.Test)

Example 14 with Document

use of org.springframework.data.mongodb.core.mapping.Document in project spring-data-mongodb by spring-projects.

the class QueryMapperUnitTests method resolvesFieldNameWithUnderscoreOnNestedFieldnameWithUnderscoresCorrectly.

// GH-3601
@Test
void resolvesFieldNameWithUnderscoreOnNestedFieldnameWithUnderscoresCorrectly() {
    Query query = query(where("double_underscore.fieldname_with_underscores").exists(true));
    org.bson.Document document = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(WrapperAroundWithPropertyUsingUnderscoreInName.class));
    assertThat(document).isEqualTo(new org.bson.Document("double_underscore.fieldname_with_underscores", new org.bson.Document("$exists", true)));
}
Also used : BasicQuery(org.springframework.data.mongodb.core.query.BasicQuery) TextQuery(org.springframework.data.mongodb.core.query.TextQuery) Query(org.springframework.data.mongodb.core.query.Query) Document(org.springframework.data.mongodb.core.mapping.Document) Test(org.junit.jupiter.api.Test)

Example 15 with Document

use of org.springframework.data.mongodb.core.mapping.Document in project spring-data-mongodb by spring-projects.

the class QueryMapperUnitTests method resolvesFieldnameWithUnderscoresCorrectly.

// GH-3601
@Test
void resolvesFieldnameWithUnderscoresCorrectly() {
    Query query = query(where("fieldname_with_underscores").exists(true));
    org.bson.Document document = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(WithPropertyUsingUnderscoreInName.class));
    assertThat(document).isEqualTo(new org.bson.Document("fieldname_with_underscores", new org.bson.Document("$exists", true)));
}
Also used : BasicQuery(org.springframework.data.mongodb.core.query.BasicQuery) TextQuery(org.springframework.data.mongodb.core.query.TextQuery) Query(org.springframework.data.mongodb.core.query.Query) Document(org.springframework.data.mongodb.core.mapping.Document) Test(org.junit.jupiter.api.Test)

Aggregations

Document (org.springframework.data.mongodb.core.mapping.Document)55 Test (org.junit.jupiter.api.Test)53 BasicQuery (org.springframework.data.mongodb.core.query.BasicQuery)16 Query (org.springframework.data.mongodb.core.query.Query)16 TextQuery (org.springframework.data.mongodb.core.query.TextQuery)16 Point (org.springframework.data.geo.Point)12 BasicDBList (com.mongodb.BasicDBList)8 BasicDBObject (com.mongodb.BasicDBObject)6 DBObject (com.mongodb.DBObject)5 DBRef (com.mongodb.DBRef)5 Sphere (org.springframework.data.mongodb.core.geo.Sphere)5 ObjectId (org.bson.types.ObjectId)4 Distance (org.springframework.data.geo.Distance)4 LocalDate (org.joda.time.LocalDate)3 MongoException (com.mongodb.MongoException)2 BigInteger (java.math.BigInteger)2 HashSet (java.util.HashSet)2 DataAccessException (org.springframework.dao.DataAccessException)2 Circle (org.springframework.data.geo.Circle)2 Polygon (org.springframework.data.geo.Polygon)2