mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
No effective change - Modify some tests to use transaction try with resources
This commit is contained in:
@@ -5,7 +5,7 @@ import org.junit.Before;
|
||||
import org.tests.model.basic.ResetBasicData;
|
||||
|
||||
/**
|
||||
* Transactional test case. Every test is coverered by a transaction, which is roll backed.
|
||||
* Transactional test case. Every test is covered by a transaction, which is roll backed.
|
||||
* So no changes will persist to database.
|
||||
*
|
||||
* Use this test case if you modify data in your test case, so that the test does not interfere
|
||||
|
||||
@@ -3,11 +3,11 @@ package io.ebeaninternal.server.core;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import org.junit.Test;
|
||||
import org.tests.model.basic.Car;
|
||||
import org.tests.model.basic.Customer;
|
||||
import org.tests.model.basic.ResetBasicData;
|
||||
import org.tests.model.basic.Vehicle;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -23,15 +23,11 @@ public class DefaultServer_getReferenceTest extends BaseTestCase {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Ebean.beginTransaction();
|
||||
try {
|
||||
Ebean.execute(() -> {
|
||||
Customer loaded = Ebean.find(Customer.class, 1);
|
||||
Customer reference = Ebean.getReference(Customer.class, 1);
|
||||
assertThat(loaded).isSameAs(reference);
|
||||
|
||||
} finally {
|
||||
Ebean.endTransaction();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -58,16 +54,12 @@ public class DefaultServer_getReferenceTest extends BaseTestCase {
|
||||
car.setDriver("TestForRef");
|
||||
Ebean.save(car);
|
||||
|
||||
Ebean.beginTransaction();
|
||||
try {
|
||||
Vehicle loaded = Ebean.find(Vehicle.class, car.getId());
|
||||
Vehicle reference = Ebean.getReference(Vehicle.class, car.getId());
|
||||
assertThat(reference).isSameAs(loaded);
|
||||
|
||||
} finally {
|
||||
Ebean.endTransaction();
|
||||
}
|
||||
|
||||
Ebean.execute(() -> {
|
||||
Vehicle loaded = Ebean.find(Vehicle.class, car.getId());
|
||||
Vehicle reference = Ebean.getReference(Vehicle.class, car.getId());
|
||||
assertThat(reference).isSameAs(loaded);
|
||||
}
|
||||
);
|
||||
Ebean.delete(car);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user