use of org.springframework.data.mongodb.core.Person in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method createsAndQueryCorrectly.
// DATAMONGO-469
@Test
public void createsAndQueryCorrectly() {
Person person = new Person();
MongoQueryCreator creator = new MongoQueryCreator(new PartTree("findByFirstNameAndFriend", Person.class), getAccessor(converter, "Oliver", person), context);
Query query = creator.createQuery();
assertThat(query, is(query(where("firstName").is("Oliver").and("friend").is(person))));
}
use of org.springframework.data.mongodb.core.Person in project spring-data-mongodb by spring-projects.
the class QueryMapperUnitTests method handlesAllPropertiesIfDocument.
// DATAMONGO-369
@Test
public void handlesAllPropertiesIfDocument() {
org.bson.Document query = new org.bson.Document();
query.put("foo", new org.bson.Document("$in", Arrays.asList(1, 2)));
query.put("bar", new Person());
org.bson.Document result = mapper.getMappedObject(query, Optional.empty());
assertThat(result.get("bar"), is(notNullValue()));
}
use of org.springframework.data.mongodb.core.Person in project spring-data-mongodb by spring-projects.
the class SpelExpressionTransformerUnitTests method shouldRenderCompoundExpressionsWithIndexerAndFieldReference.
// DATAMONGO-840
@Test
public void shouldRenderCompoundExpressionsWithIndexerAndFieldReference() {
Person person = new Person();
person.setAge(10);
assertThat(transform("[0].age + a.c", person), is((Object) Document.parse("{ \"$add\" : [ 10 , \"$a.c\"] }")));
}
use of org.springframework.data.mongodb.core.Person in project spring-data-mongodb by spring-projects.
the class AbstractMongoQueryUnitTests method doesNotTryToPostProcessQueryResultIntoWrapperType.
// DATAMONGO-1080
@Test
public void doesNotTryToPostProcessQueryResultIntoWrapperType() {
Person reference = new Person();
doReturn(reference).when(withQueryMock).oneValue();
AbstractMongoQuery query = createQueryForMethod("findByLastname", String.class);
assertThat(query.execute(new Object[] { "lastname" }), is(reference));
}
use of org.springframework.data.mongodb.core.Person in project spring-data-mongodb by spring-projects.
the class AbstractMongoQueryUnitTests method limitingSingleEntityQueryCallsFirst.
// DATAMONGO-1865
@Test
public void limitingSingleEntityQueryCallsFirst() {
Person reference = new Person();
doReturn(reference).when(withQueryMock).firstValue();
AbstractMongoQuery query = createQueryForMethod("findFirstByLastname", String.class).setLimitingQuery(true);
assertThat(query.execute(new Object[] { "lastname" }), is(reference));
}