Search in sources :

Example 11 with Id

use of org.springframework.data.annotation.Id in project spring-data-mongodb by spring-projects.

the class ReactiveMongoTemplateTests method nullsValuesForUpdatesOfUnversionedEntity.

// DATAMONGO-1444
@Test
public void nullsValuesForUpdatesOfUnversionedEntity() {
    Person person = new Person("Dave");
    StepVerifier.create(template.save(person)).expectNextCount(1).verifyComplete();
    person.setFirstName(null);
    StepVerifier.create(template.save(person)).expectNextCount(1).verifyComplete();
    // 
    StepVerifier.create(template.findOne(query(where("id").is(person.getId())), Person.class)).consumeNextWith(actual -> {
        assertThat(actual.getFirstName(), is(nullValue()));
    }).verifyComplete();
}
Also used : Document(org.bson.Document) Arrays(java.util.Arrays) StepVerifier(reactor.test.StepVerifier) Metrics(org.springframework.data.geo.Metrics) ReplicaSet(org.springframework.data.mongodb.test.util.ReplicaSet) Autowired(org.springframework.beans.factory.annotation.Autowired) Index(org.springframework.data.mongodb.core.index.Index) OptimisticLockingFailureException(org.springframework.dao.OptimisticLockingFailureException) SpringJUnit4ClassRunner(org.springframework.test.context.junit4.SpringJUnit4ClassRunner) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException) PersonWithConvertedId(org.springframework.data.mongodb.core.MongoTemplateTests.PersonWithConvertedId) Map(java.util.Map) After(org.junit.After) 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) Aggregation(org.springframework.data.mongodb.core.aggregation.Aggregation) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Collectors(java.util.stream.Collectors) List(java.util.List) Id(org.springframework.data.annotation.Id) GeospatialIndex(org.springframework.data.mongodb.core.index.GeospatialIndex) IntStream(java.util.stream.IntStream) Disposable(reactor.core.Disposable) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) BsonDocument(org.bson.BsonDocument) MappingException(org.springframework.data.mapping.MappingException) Direction(org.springframework.data.domain.Sort.Direction) ExpectedException(org.junit.rules.ExpectedException) Before(org.junit.Before) Matchers(org.hamcrest.Matchers) Mono(reactor.core.publisher.Mono) Test(org.junit.Test) IndexOperationsAdapter(org.springframework.data.mongodb.core.index.IndexOperationsAdapter) Criteria(org.springframework.data.mongodb.core.query.Criteria) Query(org.springframework.data.mongodb.core.query.Query) TimeUnit(java.util.concurrent.TimeUnit) Assumptions(org.assertj.core.api.Assumptions) Flux(reactor.core.publisher.Flux) DuplicateKeyException(org.springframework.dao.DuplicateKeyException) Rule(org.junit.Rule) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Data(lombok.Data) ObjectId(org.bson.types.ObjectId) Assert(org.junit.Assert) WriteConcern(com.mongodb.WriteConcern) Collections(java.util.Collections) VersionedPerson(org.springframework.data.mongodb.core.MongoTemplateTests.VersionedPerson) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)11 Id (org.springframework.data.annotation.Id)11 Arrays (java.util.Arrays)9 HashMap (java.util.HashMap)9 List (java.util.List)9 Assertions (org.assertj.core.api.Assertions)9 Map (java.util.Map)8 Data (lombok.Data)6 Before (org.junit.Before)6 WriteConcern (com.mongodb.WriteConcern)5 ArrayList (java.util.ArrayList)5 Collectors (java.util.stream.Collectors)5 IntStream (java.util.stream.IntStream)5 ObjectId (org.bson.types.ObjectId)5 Matchers (org.hamcrest.Matchers)5 After (org.junit.After)5 Assert (org.junit.Assert)5 Rule (org.junit.Rule)5 ExpectedException (org.junit.rules.ExpectedException)5 RunWith (org.junit.runner.RunWith)5