mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-05 16:31:34 +00:00
Improve tests TestQueryForUpdate and TestSoftDeleteBasic
This commit is contained in:
1 parent
c3cdecaa60
commit
1a4377da29
2 files changed
+26
-14
No files matched your search
@@ -27,11 +27,15 @@ public class TestQueryForUpdate extends BaseTestCase {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = DB.find(Customer.class)
|
||||
.forUpdate()
|
||||
.order().desc("id");
|
||||
Query<Customer> query;
|
||||
try (final Transaction transaction = DB.beginTransaction()) {
|
||||
query = DB.find(Customer.class)
|
||||
.forUpdate()
|
||||
.order().desc("id");
|
||||
|
||||
query.findList();
|
||||
}
|
||||
|
||||
query.findList();
|
||||
if (isSqlServer()) {
|
||||
assertThat(sqlOf(query)).contains("with (updlock)");
|
||||
} else if (isPostgres()) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.tests.model.softdelete.EBasicNoSDChild;
|
||||
import org.tests.model.softdelete.EBasicSDChild;
|
||||
import org.tests.model.softdelete.EBasicSoftDelete;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
@@ -173,13 +174,17 @@ public class TestSoftDeleteBasic extends BaseTestCase {
|
||||
.query();
|
||||
|
||||
List<EBasicSoftDelete> list = query.findList();
|
||||
assertSql(query).contains("t0.deleted = false");
|
||||
// Make sure that query includes that the child mustn't've been deleted
|
||||
assertSql(query).contains("u1.deleted = false");
|
||||
if (isMySql() || isMariaDB()) {
|
||||
assertSql(query).contains("t0.deleted = 0");
|
||||
assertSql(query).contains("u1.deleted = 0");
|
||||
} else {
|
||||
assertSql(query).contains("t0.deleted = false");
|
||||
// Make sure that query includes that the child mustn't've been deleted
|
||||
assertSql(query).contains("u1.deleted = false");
|
||||
}
|
||||
assertThat(list).hasSize(0);
|
||||
|
||||
// Cleanup created entity
|
||||
query.delete();
|
||||
DB.deleteAllPermanent(singletonList(child));
|
||||
DB.deleteAllPermanent(singletonList(bean));
|
||||
}
|
||||
@@ -205,13 +210,17 @@ public class TestSoftDeleteBasic extends BaseTestCase {
|
||||
|
||||
List<EBasicNoSDChild> list = query.findList();
|
||||
// Make sure that query includes that the child mustn't've been deleted
|
||||
assertSql(query).contains("u1.deleted = false");
|
||||
assertSql(query).contains("u2.deleted = false");
|
||||
if (isMySql() || isMariaDB()) {
|
||||
assertSql(query).contains("u1.deleted = 0");
|
||||
assertSql(query).contains("u2.deleted = 0");
|
||||
} else {
|
||||
assertSql(query).contains("u1.deleted = false");
|
||||
assertSql(query).contains("u2.deleted = false");
|
||||
}
|
||||
assertThat(list).hasSize(0);
|
||||
|
||||
// Cleanup created entity
|
||||
query.delete();
|
||||
DB.deleteAllPermanent(singletonList(child));
|
||||
DB.deleteAllPermanent(Arrays.asList(child, secondChild));
|
||||
DB.deleteAllPermanent(singletonList(bean));
|
||||
}
|
||||
|
||||
@@ -242,8 +251,7 @@ public class TestSoftDeleteBasic extends BaseTestCase {
|
||||
assertThat(list).hasSize(1);
|
||||
|
||||
// Cleanup created entity
|
||||
query.delete();
|
||||
DB.deleteAllPermanent(singletonList(child));
|
||||
DB.deleteAllPermanent(Arrays.asList(child, secondChild));
|
||||
DB.deleteAllPermanent(singletonList(bean));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user