use of com.mongodb.client.model.UpdateOptions in project spring-data-mongodb by spring-projects.
the class MongoTemplateUnitTests method updateMultiShouldUseDefaultCollationWhenPresent.
// DATAMONGO-1854
@Test
void updateMultiShouldUseDefaultCollationWhenPresent() {
template.updateMulti(new BasicQuery("{}"), Update.update("foo", "bar"), Sith.class);
ArgumentCaptor<UpdateOptions> options = ArgumentCaptor.forClass(UpdateOptions.class);
verify(collection).updateMany(any(), any(Bson.class), options.capture());
assertThat(options.getValue().getCollation()).isEqualTo(com.mongodb.client.model.Collation.builder().locale("de_AT").build());
}
use of com.mongodb.client.model.UpdateOptions in project spring-data-mongodb by spring-projects.
the class ReactiveMongoTemplateUnitTests method updateMultiShouldPreferExplicitCollationOverDefaultCollation.
// DATAMONGO-1854
@Test
void updateMultiShouldPreferExplicitCollationOverDefaultCollation() {
template.updateMulti(new BasicQuery("{}").collation(Collation.of("fr")), Update.update("foo", "bar"), Sith.class).subscribe();
ArgumentCaptor<UpdateOptions> options = ArgumentCaptor.forClass(UpdateOptions.class);
verify(collection).updateMany(any(), any(Bson.class), options.capture());
assertThat(options.getValue().getCollation()).isEqualTo(com.mongodb.client.model.Collation.builder().locale("fr").build());
}
use of com.mongodb.client.model.UpdateOptions in project spring-data-mongodb by spring-projects.
the class ReactiveMongoTemplateUnitTests method updateManyShouldUseCollationWhenPresent.
// DATAMONGO-1518
@Test
void updateManyShouldUseCollationWhenPresent() {
when(collection.updateMany(any(Bson.class), any(Bson.class), any())).thenReturn(Mono.empty());
template.updateMulti(new BasicQuery("{}").collation(Collation.of("fr")), new Update().set("foo", "bar"), AutogenerateableId.class).subscribe();
ArgumentCaptor<UpdateOptions> options = ArgumentCaptor.forClass(UpdateOptions.class);
verify(collection).updateMany(any(), any(Bson.class), options.capture());
assertThat(options.getValue().getCollation().getLocale()).isEqualTo("fr");
}
use of com.mongodb.client.model.UpdateOptions in project spring-data-mongodb by spring-projects.
the class ReactiveMongoTemplateUnitTests method updateShouldApplyArrayFilters.
// DATAMONGO-2215
@Test
void updateShouldApplyArrayFilters() {
template.updateFirst(new BasicQuery("{}"), new Update().set("grades.$[element]", 100).filterArray(Criteria.where("element").gte(100)), EntityWithListOfSimple.class).subscribe();
ArgumentCaptor<UpdateOptions> options = ArgumentCaptor.forClass(UpdateOptions.class);
verify(collection).updateOne(any(), any(Bson.class), options.capture());
Assertions.assertThat((List<Bson>) options.getValue().getArrayFilters()).contains(new org.bson.Document("element", new Document("$gte", 100)));
}
use of com.mongodb.client.model.UpdateOptions in project spring-data-mongodb by spring-projects.
the class MongoTemplateUnitTests method updateFirstShouldUseDefaultCollationWhenPresent.
// DATAMONGO-1854
@Test
void updateFirstShouldUseDefaultCollationWhenPresent() {
template.updateFirst(new BasicQuery("{}"), Update.update("foo", "bar"), Sith.class);
ArgumentCaptor<UpdateOptions> options = ArgumentCaptor.forClass(UpdateOptions.class);
verify(collection).updateOne(any(), any(Bson.class), options.capture());
assertThat(options.getValue().getCollation()).isEqualTo(com.mongodb.client.model.Collation.builder().locale("de_AT").build());
}
Aggregations