use of com.mongodb.BasicDBList in project spring-data-mongodb by spring-projects.
the class Criteria method orOperator.
/**
* Creates a criteria using the {@code $or} operator for all of the provided criteria.
* <p>
* Note that MongoDB doesn't support an {@code $nor} operator to be wrapped in a {@code $not} operator.
*
* @throws IllegalArgumentException if this method follows a {@link #not()} call directly.
* @param criteria must not be {@literal null}.
* @return this.
* @since 3.2
*/
public Criteria orOperator(Collection<Criteria> criteria) {
Assert.notNull(criteria, "Criteria must not be null!");
BasicDBList bsonList = createCriteriaList(criteria);
return registerCriteriaChainElement(new Criteria("$or").is(bsonList));
}
use of com.mongodb.BasicDBList in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterUnitTests method readsCollectionOfDBRefs.
// DATAMONGO-424
@Test
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).contains(dbRef);
}
use of com.mongodb.BasicDBList in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterUnitTests method readsListOfMapsCorrectly.
// DATAMONGO-259
@Test
void readsListOfMapsCorrectly() {
org.bson.Document map = new org.bson.Document("Foo", "en");
BasicDBList list = new BasicDBList();
list.add(map);
org.bson.Document wrapperSource = new org.bson.Document("listOfMaps", list);
CollectionWrapper wrapper = converter.read(CollectionWrapper.class, wrapperSource);
assertThat(wrapper.listOfMaps).isNotNull();
assertThat(wrapper.listOfMaps.size()).isEqualTo(1);
assertThat(wrapper.listOfMaps.get(0)).isNotNull();
assertThat(wrapper.listOfMaps.get(0).get("Foo")).isEqualTo(Locale.ENGLISH);
}
use of com.mongodb.BasicDBList in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterUnitTests method readsMapListDoublyNestedValuesCorrectly.
// DATAMONGO-245
@Test
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).isInstanceOf(Map.class);
Object doublyNestedObject = ((Map<?, ?>) firstObjectInFoo).get("nested");
assertThat(doublyNestedObject).isInstanceOf(Map.class);
assertThat(((Map<?, ?>) doublyNestedObject).get("Hello")).isEqualTo("World");
}
use of com.mongodb.BasicDBList in project spring-data-mongodb by spring-projects.
the class BsonUtilsTest method supportsBsonShouldReportIfConversionSupported.
// GH-3702
@Test
void supportsBsonShouldReportIfConversionSupported() {
assertThat(BsonUtils.supportsBson("foo")).isFalse();
assertThat(BsonUtils.supportsBson(new Document())).isTrue();
assertThat(BsonUtils.supportsBson(new BasicDBList())).isTrue();
assertThat(BsonUtils.supportsBson(Collections.emptyMap())).isTrue();
}
Aggregations