Search in sources :

Example 1 with BooleanOperation

use of com.querydsl.core.types.dsl.BooleanOperation in project spring-data-mongodb by spring-projects.

the class SpringDataMongodbSerializerUnitTests method convertsIdPropertyCorrectly.

// DATAMONGO-467
@Test
public void convertsIdPropertyCorrectly() {
    ObjectId id = new ObjectId();
    PathBuilder<Address> builder = new PathBuilder<Address>(Address.class, "address");
    StringPath idPath = builder.getString("id");
    DBObject result = (DBObject) serializer.visit((BooleanOperation) idPath.eq(id.toString()), (Void) null);
    assertThat(result.get("_id"), is(notNullValue()));
    assertThat(result.get("_id"), is(instanceOf(ObjectId.class)));
    assertThat(result.get("_id"), is((Object) id));
}
Also used : PathBuilder(com.querydsl.core.types.dsl.PathBuilder) QAddress(org.springframework.data.mongodb.repository.QAddress) ObjectId(org.bson.types.ObjectId) BooleanOperation(com.querydsl.core.types.dsl.BooleanOperation) StringPath(com.querydsl.core.types.dsl.StringPath) DBObject(com.mongodb.DBObject) BasicDBObject(com.mongodb.BasicDBObject) DBObject(com.mongodb.DBObject) BasicDBObject(com.mongodb.BasicDBObject) Test(org.junit.Test)

Aggregations

BasicDBObject (com.mongodb.BasicDBObject)1 DBObject (com.mongodb.DBObject)1 BooleanOperation (com.querydsl.core.types.dsl.BooleanOperation)1 PathBuilder (com.querydsl.core.types.dsl.PathBuilder)1 StringPath (com.querydsl.core.types.dsl.StringPath)1 ObjectId (org.bson.types.ObjectId)1 Test (org.junit.Test)1 QAddress (org.springframework.data.mongodb.repository.QAddress)1