mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
Refactor move tests from ebean-core to ebean-test
This commit is contained in:
1 parent
0b00a14fd3
commit
eab56d323b
1650 files changed
+185
-147
No files matched your search
+43
@@ -0,0 +1,43 @@
|
||||
package org.tests.persistencecontext;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.Database;
|
||||
import org.tests.model.basic.EBasic;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestPersistenceContextOnUpdateDuringTxn extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
Database server = DB.getDefault();
|
||||
|
||||
server.beginTransaction();
|
||||
try {
|
||||
|
||||
EBasic bean1 = new EBasic();
|
||||
bean1.setName("hello");
|
||||
|
||||
server.save(bean1);
|
||||
|
||||
EBasic updatedEntity = new EBasic();
|
||||
updatedEntity.setId(bean1.getId());
|
||||
updatedEntity.setName("hello-changed");
|
||||
|
||||
server.update(updatedEntity);
|
||||
|
||||
// actually the bean is not in the persistence context so ... the assert is fine
|
||||
EBasic loadedEntity = server.find(EBasic.class, bean1.getId());
|
||||
|
||||
assertThat(loadedEntity.getName()).isEqualTo("hello-changed");
|
||||
|
||||
} finally {
|
||||
server.endTransaction();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user