use of com.mongodb.BasicDBList in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterUnitTests method readsEmptyCollectionIntoConstructorCorrectly.
// DATAMONGO-497
@Test
public void readsEmptyCollectionIntoConstructorCorrectly() {
org.bson.Document source = new org.bson.Document("attributes", new BasicDBList());
TypWithCollectionConstructor result = converter.read(TypWithCollectionConstructor.class, source);
assertThat(result.attributes, is(notNullValue()));
}
use of com.mongodb.BasicDBList in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterUnitTests method readsMapListDoublyNestedValuesCorrectly.
// DATAMONGO-245
@Test
public void readsMapListDoublyNestedValuesCorrectly() {
BasicDBList list = new BasicDBList();
org.bson.Document nested = new org.bson.Document();
org.bson.Document doubly = new org.bson.Document();
doubly.append("Hello", "World");
nested.append("nested", doubly);
list.add(nested);
org.bson.Document source = new org.bson.Document("mapOfObjects", new org.bson.Document("Foo", list));
ClassWithMapProperty result = converter.read(ClassWithMapProperty.class, source);
Object firstObjectInFoo = ((List<?>) result.mapOfObjects.get("Foo")).get(0);
assertThat(firstObjectInFoo, is(instanceOf(Map.class)));
Object doublyNestedObject = ((Map<?, ?>) firstObjectInFoo).get("nested");
assertThat(doublyNestedObject, is(instanceOf(Map.class)));
assertThat(((Map<?, ?>) doublyNestedObject).get("Hello"), is(equalTo("World")));
}
use of com.mongodb.BasicDBList in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterUnitTests method readsMapListValuesCorrectly.
// DATAMONGO-235
@Test
public void readsMapListValuesCorrectly() {
BasicDBList list = new BasicDBList();
list.add("Bar");
org.bson.Document source = new org.bson.Document("mapOfLists", new org.bson.Document("Foo", list));
ClassWithMapProperty result = converter.read(ClassWithMapProperty.class, source);
assertThat(result.mapOfLists, is(not(nullValue())));
}
use of com.mongodb.BasicDBList in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterUnitTests method readsMapOfObjectsListValuesCorrectly.
// DATAMONGO-235
@Test
public void readsMapOfObjectsListValuesCorrectly() {
BasicDBList list = new BasicDBList();
list.add("Bar");
org.bson.Document source = new org.bson.Document("mapOfObjects", new org.bson.Document("Foo", list));
ClassWithMapProperty result = converter.read(ClassWithMapProperty.class, source);
assertThat(result.mapOfObjects, is(not(nullValue())));
}
Aggregations