Search in sources :

Example 1 with VersionedPerson

use of org.springframework.data.mongodb.core.MongoTemplateTests.VersionedPerson in project spring-data-mongodb by spring-projects.

the class ReactiveMongoTemplateTests method nullsPropertiesForVersionObjectUpdates.

// DATAMONGO-1444
@Test
void nullsPropertiesForVersionObjectUpdates() {
    VersionedPerson person = new VersionedPerson();
    person.firstname = "Dave";
    person.lastname = "Matthews";
    // 
    template.save(person).as(// 
    StepVerifier::create).expectNextCount(// 
    1).verifyComplete();
    assertThat(person.id).isNotNull();
    person.lastname = null;
    // 
    template.save(person).as(// 
    StepVerifier::create).expectNextCount(// 
    1).verifyComplete();
    // 
    template.findOne(query(where("id").is(person.id)), VersionedPerson.class).as(// 
    StepVerifier::create).consumeNextWith(actual -> {
        assertThat(actual.lastname).isNull();
    }).verifyComplete();
}
Also used : Document(org.bson.Document) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) StepVerifier(reactor.test.StepVerifier) Metrics(org.springframework.data.geo.Metrics) Version(org.springframework.data.annotation.Version) Wither(lombok.experimental.Wither) Disabled(org.junit.jupiter.api.Disabled) Index(org.springframework.data.mongodb.core.index.Index) AbstractMongoEventListener(org.springframework.data.mongodb.core.mapping.event.AbstractMongoEventListener) Address(org.springframework.data.mongodb.core.MongoTemplateTests.Address) OptimisticLockingFailureException(org.springframework.dao.OptimisticLockingFailureException) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException) PersonWithConvertedId(org.springframework.data.mongodb.core.MongoTemplateTests.PersonWithConvertedId) Duration(java.time.Duration) Map(java.util.Map) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) Assertions(org.assertj.core.api.Assertions) Update(org.springframework.data.mongodb.core.query.Update) Sort(org.springframework.data.domain.Sort) VersionedPerson(org.springframework.data.mongodb.core.MongoTemplateTests.VersionedPerson) GeoSpatialIndexType(org.springframework.data.mongodb.core.index.GeoSpatialIndexType) NearQuery(org.springframework.data.mongodb.core.query.NearQuery) BlockingQueue(java.util.concurrent.BlockingQueue) Instant(java.time.Instant) Aggregation(org.springframework.data.mongodb.core.aggregation.Aggregation) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Collectors(java.util.stream.Collectors) Client(org.springframework.data.mongodb.test.util.Client) Test(org.junit.jupiter.api.Test) List(java.util.List) ReactiveMongoDatabaseFactory(org.springframework.data.mongodb.ReactiveMongoDatabaseFactory) Id(org.springframework.data.annotation.Id) EnableIfMongoServerVersion(org.springframework.data.mongodb.test.util.EnableIfMongoServerVersion) GeospatialIndex(org.springframework.data.mongodb.core.index.GeospatialIndex) IntStream(java.util.stream.IntStream) Disposable(reactor.core.Disposable) ReactiveMongoTestTemplate(org.springframework.data.mongodb.test.util.ReactiveMongoTestTemplate) HashMap(java.util.HashMap) InvalidDataAccessApiUsageException(org.springframework.dao.InvalidDataAccessApiUsageException) AtomicReference(java.util.concurrent.atomic.AtomicReference) BsonDocument(org.bson.BsonDocument) MongoClient(com.mongodb.reactivestreams.client.MongoClient) MappingException(org.springframework.data.mapping.MappingException) BsonTimestamp(org.bson.BsonTimestamp) Direction(org.springframework.data.domain.Sort.Direction) Mono(reactor.core.publisher.Mono) IndexOperationsAdapter(org.springframework.data.mongodb.core.index.IndexOperationsAdapter) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) Criteria(org.springframework.data.mongodb.core.query.Criteria) Query(org.springframework.data.mongodb.core.query.Query) TimeUnit(java.util.concurrent.TimeUnit) Flux(reactor.core.publisher.Flux) DuplicateKeyException(org.springframework.dao.DuplicateKeyException) AfterSaveEvent(org.springframework.data.mongodb.core.mapping.event.AfterSaveEvent) Data(lombok.Data) ObjectId(org.bson.types.ObjectId) AllArgsConstructor(lombok.AllArgsConstructor) WriteConcern(com.mongodb.WriteConcern) Collections(java.util.Collections) MongoClientExtension(org.springframework.data.mongodb.test.util.MongoClientExtension) MongoServerCondition(org.springframework.data.mongodb.test.util.MongoServerCondition) NoArgsConstructor(lombok.NoArgsConstructor) EnableIfReplicaSetAvailable(org.springframework.data.mongodb.test.util.EnableIfReplicaSetAvailable) VersionedPerson(org.springframework.data.mongodb.core.MongoTemplateTests.VersionedPerson) StepVerifier(reactor.test.StepVerifier) Test(org.junit.jupiter.api.Test)

Aggregations

WriteConcern (com.mongodb.WriteConcern)1 MongoClient (com.mongodb.reactivestreams.client.MongoClient)1 Duration (java.time.Duration)1 Instant (java.time.Instant)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 BlockingQueue (java.util.concurrent.BlockingQueue)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 TimeUnit (java.util.concurrent.TimeUnit)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 AllArgsConstructor (lombok.AllArgsConstructor)1 Data (lombok.Data)1 NoArgsConstructor (lombok.NoArgsConstructor)1 Wither (lombok.experimental.Wither)1 Assertions (org.assertj.core.api.Assertions)1