use of org.springframework.data.mongodb.core.MongoTemplateTests.Address in project spring-data-mongodb by spring-projects.
the class ReactiveMongoTemplateTests method findAndReplaceShouldConsiderFields.
// DATAMONGO-1827
@Test
void findAndReplaceShouldConsiderFields() {
MyPerson person = new MyPerson("Walter");
person.address = new Address("TX", "Austin");
//
template.save(person).as(//
StepVerifier::create).expectNextCount(//
1).verifyComplete();
Query query = query(where("name").is("Walter"));
query.fields().include("address");
//
template.findAndReplace(query, new MyPerson("Heisenberg")).as(//
StepVerifier::create).consumeNextWith(it -> {
assertThat(it.getName()).isNull();
assertThat(it.getAddress()).isEqualTo(person.address);
}).verifyComplete();
}
Aggregations