use of org.springframework.data.mongodb.core.query.Update in project spring-data-mongodb by spring-projects.
the class DefaultBulkOperationsUnitTests method appliesArrayFilterWhenPresent.
// DATAMONGO-2450
@Test
void appliesArrayFilterWhenPresent() {
ops.updateOne(new BasicQuery("{}"), new Update().filterArray(Criteria.where("element").gte(100))).execute();
verify(collection).bulkWrite(captor.capture(), any());
UpdateOneModel<Document> updateModel = (UpdateOneModel<Document>) captor.getValue().get(0);
assertThat(updateModel.getOptions().getArrayFilters().get(0)).isEqualTo(new org.bson.Document("element", new Document("$gte", 100)));
}
use of org.springframework.data.mongodb.core.query.Update in project spring-data-mongodb by spring-projects.
the class DefaultBulkOperationsUnitTests method writeConcernNotAppliedWhenNotSet.
// DATAMONGO-2330
@Test
void writeConcernNotAppliedWhenNotSet() {
ops.updateOne(new BasicQuery("{}").collation(Collation.of("de")), new Update().set("lastName", "targaryen")).execute();
verify(collection, never()).withWriteConcern(any());
}
use of org.springframework.data.mongodb.core.query.Update in project spring-data-mongodb by spring-projects.
the class DefaultBulkOperationsUnitTests method updateOneShouldUseCollationWhenPresent.
// DATAMONGO-1518
@Test
void updateOneShouldUseCollationWhenPresent() {
ops.updateOne(new BasicQuery("{}").collation(Collation.of("de")), new Update().set("lastName", "targaryen")).execute();
verify(collection).bulkWrite(captor.capture(), any());
assertThat(captor.getValue().get(0)).isInstanceOf(UpdateOneModel.class);
assertThat(((UpdateOneModel<Document>) captor.getValue().get(0)).getOptions().getCollation()).isEqualTo(com.mongodb.client.model.Collation.builder().locale("de").build());
}
use of org.springframework.data.mongodb.core.query.Update in project spring-data-mongodb by spring-projects.
the class DefaultBulkOperationsUnitTests method writeConcernAppliedCorrectlyWhenSet.
// DATAMONGO-2330
@Test
void writeConcernAppliedCorrectlyWhenSet() {
ops.setDefaultWriteConcern(WriteConcern.MAJORITY);
ops.updateOne(new BasicQuery("{}").collation(Collation.of("de")), new Update().set("lastName", "targaryen")).execute();
verify(collection).withWriteConcern(eq(WriteConcern.MAJORITY));
}
use of org.springframework.data.mongodb.core.query.Update in project spring-data-mongodb by spring-projects.
the class DefaultBulkOperationsUnitTests method updateManyShouldUseCollationWhenPresent.
// DATAMONGO-1518
@Test
void updateManyShouldUseCollationWhenPresent() {
ops.updateMulti(new BasicQuery("{}").collation(Collation.of("de")), new Update().set("lastName", "targaryen")).execute();
verify(collection).bulkWrite(captor.capture(), any());
assertThat(captor.getValue().get(0)).isInstanceOf(UpdateManyModel.class);
assertThat(((UpdateManyModel<Document>) captor.getValue().get(0)).getOptions().getCollation()).isEqualTo(com.mongodb.client.model.Collation.builder().locale("de").build());
}
Aggregations