Search in sources :

Example 1 with Person

use of org.springframework.data.mongodb.core.convert.MappingMongoConverterUnitTests.Person in project spring-data-mongodb by spring-projects.

the class DbRefMappingMongoConverterUnitTests method createsDBRefWithClientSpecCorrectly.

// DATAMONGO-347
@Test
public void createsDBRefWithClientSpecCorrectly() {
    PropertyPath path = PropertyPath.from("person", PersonClient.class);
    MongoPersistentProperty property = mappingContext.getPersistentPropertyPath(path).getLeafProperty();
    Person person = new Person();
    person.id = "foo";
    DBRef dbRef = converter.toDBRef(person, property);
    assertThat(dbRef.getId(), is("foo"));
    assertThat(dbRef.getCollectionName(), is("person"));
}
Also used : MongoPersistentProperty(org.springframework.data.mongodb.core.mapping.MongoPersistentProperty) PropertyPath(org.springframework.data.mapping.PropertyPath) DBRef(com.mongodb.DBRef) Person(org.springframework.data.mongodb.core.convert.MappingMongoConverterUnitTests.Person) Test(org.junit.Test)

Example 2 with Person

use of org.springframework.data.mongodb.core.convert.MappingMongoConverterUnitTests.Person in project spring-data-mongodb by spring-projects.

the class DbRefMappingMongoConverterUnitTests method createsSimpleDBRefCorrectly.

// DATAMONGO-347
@Test
public void createsSimpleDBRefCorrectly() {
    Person person = new Person();
    person.id = "foo";
    DBRef dbRef = converter.toDBRef(person, null);
    assertThat(dbRef.getId(), is("foo"));
    assertThat(dbRef.getCollectionName(), is("person"));
}
Also used : DBRef(com.mongodb.DBRef) Person(org.springframework.data.mongodb.core.convert.MappingMongoConverterUnitTests.Person) Test(org.junit.Test)

Aggregations

DBRef (com.mongodb.DBRef)2 Test (org.junit.Test)2 Person (org.springframework.data.mongodb.core.convert.MappingMongoConverterUnitTests.Person)2 PropertyPath (org.springframework.data.mapping.PropertyPath)1 MongoPersistentProperty (org.springframework.data.mongodb.core.mapping.MongoPersistentProperty)1