use of com.mongodb.BasicDBList in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterUnitTests method readsEnumSetCorrectly.
// DATAMONGO-833
@Test
public void readsEnumSetCorrectly() {
BasicDBList enumSet = new BasicDBList();
enumSet.add("SECOND");
org.bson.Document document = new org.bson.Document("enumSet", enumSet);
ClassWithEnumProperty result = converter.read(ClassWithEnumProperty.class, document);
assertThat(result.enumSet, is(instanceOf(EnumSet.class)));
assertThat(result.enumSet.size(), is(1));
assertThat(result.enumSet, hasItem(SampleEnum.SECOND));
}
use of com.mongodb.BasicDBList in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterUnitTests method resolvesNestedComplexTypeForConstructorCorrectly.
@Test
public void resolvesNestedComplexTypeForConstructorCorrectly() {
org.bson.Document address = new org.bson.Document("street", "110 Southwark Street");
address.put("city", "London");
BasicDBList addresses = new BasicDBList();
addresses.add(address);
org.bson.Document person = new org.bson.Document("firstname", "Oliver");
person.put("addresses", addresses);
Person result = converter.read(Person.class, person);
assertThat(result.addresses, is(notNullValue()));
}
use of com.mongodb.BasicDBList in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterUnitTests method readsEnumCollectionsCorrectly.
// DATAMONGO-209
@Test
public void readsEnumCollectionsCorrectly() {
BasicDBList enums = new BasicDBList();
enums.add("FIRST");
org.bson.Document document = new org.bson.Document("enums", enums);
ClassWithEnumProperty result = converter.read(ClassWithEnumProperty.class, document);
assertThat(result.enums, is(instanceOf(List.class)));
assertThat(result.enums.size(), is(1));
assertThat(result.enums, hasItem(SampleEnum.FIRST));
}
use of com.mongodb.BasicDBList in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterUnitTests method writesPlainMapOfCollectionsCorrectly.
// DATAMONGO-259
@Test
public void writesPlainMapOfCollectionsCorrectly() {
Map<String, List<Locale>> map = Collections.singletonMap("Foo", Arrays.asList(Locale.US));
org.bson.Document result = new org.bson.Document();
converter.write(map, result);
assertThat(result.containsKey("Foo"), is(true));
assertThat(result.get("Foo"), is(notNullValue()));
assertThat(result.get("Foo"), is(instanceOf(BasicDBList.class)));
BasicDBList list = (BasicDBList) result.get("Foo");
assertThat(list.size(), is(1));
assertThat(list.get(0), is(Locale.US.toString()));
}
use of com.mongodb.BasicDBList in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterUnitTests method readsCollectionOfDBRefs.
// DATAMONGO-424
@Test
public void readsCollectionOfDBRefs() {
DBRef dbRef = new DBRef("foo", 2);
BasicDBList refs = new BasicDBList();
refs.add(dbRef);
org.bson.Document document = new org.bson.Document("refs", refs);
DBRefWrapper result = converter.read(DBRefWrapper.class, document);
assertThat(result.refs, hasSize(1));
assertThat(result.refs, hasItem(dbRef));
}
Aggregations