use of org.springframework.data.mongodb.test.util.EnableIfMongoServerVersion in project spring-data-mongodb by spring-projects.
the class SimpleMongoRepositoryTests method countShouldBePossibleInTransaction.
// DATAMONGO-2130
@Test
@EnableIfReplicaSetAvailable
@EnableIfMongoServerVersion(isGreaterThanEqual = "4.0")
void countShouldBePossibleInTransaction() {
MongoTransactionManager txmgr = new MongoTransactionManager(template.getMongoDbFactory());
TransactionTemplate tt = new TransactionTemplate(txmgr);
tt.afterPropertiesSet();
long countPreTx = repository.count();
long count = tt.execute(status -> {
Person sample = new Person();
sample.setLastname("Matthews");
repository.save(sample);
return repository.count();
});
assertThat(count).isEqualTo(countPreTx + 1);
}
use of org.springframework.data.mongodb.test.util.EnableIfMongoServerVersion 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