mirror of
https://github.com/google/nomulus.git
synced 2025-07-08 20:23:24 +02:00
Implement remaining methods in JpaTransactionManager (#633)
This commit is contained in:
parent
31841ccc55
commit
2f600e3e69
2 changed files with 37 additions and 10 deletions
|
@ -116,6 +116,30 @@ public class TransactionManagerTest {
|
|||
assertEntityExists(theEntity);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void transactNew_succeeds() {
|
||||
assertEntityNotExist(theEntity);
|
||||
tm().transactNew(() -> tm().saveNew(theEntity));
|
||||
assertEntityExists(theEntity);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void transactNewReadOnly_succeeds() {
|
||||
assertEntityNotExist(theEntity);
|
||||
tm().transact(() -> tm().saveNew(theEntity));
|
||||
assertEntityExists(theEntity);
|
||||
TestEntity persisted = tm().transactNewReadOnly(() -> tm().load(theEntity.key()));
|
||||
assertThat(persisted).isEqualTo(theEntity);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void transactNewReadOnly_throwsWhenWritingEntity() {
|
||||
assertEntityNotExist(theEntity);
|
||||
assertThrows(
|
||||
RuntimeException.class, () -> tm().transactNewReadOnly(() -> tm().saveNew(theEntity)));
|
||||
assertEntityNotExist(theEntity);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void saveNew_succeeds() {
|
||||
assertEntityNotExist(theEntity);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue