use of org.springframework.data.mongodb.repository.VersionedPerson in project spring-data-mongodb by spring-projects.
the class SimpleMongoRepositoryVersionedEntityTests method deleteNonExistingInTx.
// DATAMONGO-2195
@Test
@EnableIfMongoServerVersion(isGreaterThanEqual = "4.0")
public void deleteNonExistingInTx() {
assumeThat(ReplicaSet.required().runsAsReplicaSet()).isTrue();
initTxTemplate().execute(status -> {
assertThatThrownBy(() -> repository.delete(new VersionedPerson("T-800"))).isInstanceOf(OptimisticLockingFailureException.class);
return Void.TYPE;
});
}
use of org.springframework.data.mongodb.repository.VersionedPerson in project spring-data-mongodb by spring-projects.
the class SimpleReactiveMongoRepositoryVersionedEntityTests method setUp.
@Before
public void setUp() {
MongoPersistentEntity entity = template.getConverter().getMappingContext().getRequiredPersistentEntity(VersionedPerson.class);
personEntityInformation = new MappingMongoEntityInformation(entity);
repository = new SimpleReactiveMongoRepository<>(personEntityInformation, template);
repository.deleteAll().as(StepVerifier::create).verifyComplete();
sarah = repository.save(new VersionedPerson("Sarah", "Connor")).block();
}
use of org.springframework.data.mongodb.repository.VersionedPerson in project spring-data-mongodb by spring-projects.
the class SimpleMongoRepositoryVersionedEntityTests method setUp.
@BeforeEach
public void setUp() {
MongoPersistentEntity entity = template.getConverter().getMappingContext().getRequiredPersistentEntity(VersionedPerson.class);
personEntityInformation = new MappingMongoEntityInformation(entity);
repository = new SimpleMongoRepository<>(personEntityInformation, template);
repository.deleteAll();
sarah = repository.save(new VersionedPerson("Sarah", "Connor"));
}
use of org.springframework.data.mongodb.repository.VersionedPerson in project spring-data-mongodb by spring-projects.
the class SimpleMongoRepositoryVersionedEntityTests method deleteWithMatchingVersionInTx.
// DATAMONGO-2195
@Test
@EnableIfMongoServerVersion(isGreaterThanEqual = "4.0")
public void deleteWithMatchingVersionInTx() {
assumeThat(ReplicaSet.required().runsAsReplicaSet()).isTrue();
long countBefore = repository.count();
initTxTemplate().execute(status -> {
VersionedPerson t800 = repository.save(new VersionedPerson("T-800"));
repository.delete(t800);
return Void.TYPE;
});
assertThat(repository.count()).isEqualTo(countBefore);
}
Aggregations