mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-19 23:02:24 +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
@@ -0,0 +1,42 @@
|
||||
package org.tests.iud;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.Transaction;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.EBasicVer;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
public class TestInsertUpdateTrans extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
try (Transaction txn = DB.beginTransaction()) {
|
||||
|
||||
EBasicVer e0 = new EBasicVer("onInsert");
|
||||
e0.setDescription("something");
|
||||
DB.save(e0);
|
||||
|
||||
assertNotNull(e0.getId());
|
||||
assertNotNull(e0.getLastUpdate());
|
||||
assertEquals("onInsert", e0.getName());
|
||||
|
||||
e0.setName("onUpdate");
|
||||
e0.setDescription("differentFromInsert");
|
||||
|
||||
DB.save(e0);
|
||||
|
||||
EBasicVer e1 = DB.find(EBasicVer.class, e0.getId());
|
||||
|
||||
// we should fetch back the updated data (not inserted)
|
||||
assertEquals(e0.getId(), e1.getId());
|
||||
assertEquals("onUpdate", e1.getName());
|
||||
assertEquals("differentFromInsert", e1.getDescription());
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user