Refactor tests using assertSql() helper method

This helper method trims column alias from the sql (for Oracle)
This commit is contained in:
rob bygrave
2020-02-20 15:08:43 +13:00
parent 78b9066345
commit de42655bbd
123 changed files with 767 additions and 743 deletions
@@ -109,11 +109,11 @@ public class TestDeleteByQuery extends BaseTestCase {
List<String> sql = LoggedSqlCollector.stop();
if (isPlatformSupportsDeleteTableAlias()) {
assertThat(sql.get(0)).contains("delete from bbookmark_user t0 where t0.id = ?");
assertThat(sql.get(1)).contains("delete from bbookmark_user t0 where t0.id = ?");
assertSql(sql.get(0)).contains("delete from bbookmark_user t0 where t0.id = ?");
assertSql(sql.get(1)).contains("delete from bbookmark_user t0 where t0.id = ?");
} else if (!isMySql()) {
assertThat(sql.get(0)).contains("delete from bbookmark_user where id = ?");
assertThat(sql.get(1)).contains("delete from bbookmark_user where id = ?");
assertSql(sql.get(0)).contains("delete from bbookmark_user where id = ?");
assertSql(sql.get(1)).contains("delete from bbookmark_user where id = ?");
}
// and note this is the easiest option
@@ -130,8 +130,8 @@ public class TestDeleteByQuery extends BaseTestCase {
List<String> sql = LoggedSqlCollector.stop();
// escalate to fetch ids then delete ... but no rows found
assertThat(sql.get(0)).contains("select t0.id from contact t0 where t0.id = ?");
assertThat(sql.get(1)).contains("select t0.id from contact t0 where t0.id = ?");
assertSql(sql.get(0)).contains("select t0.id from contact t0 where t0.id = ?");
assertSql(sql.get(1)).contains("select t0.id from contact t0 where t0.id = ?");
// and note this is the easiest option
Ebean.delete(Contact.class, 7000);
@@ -152,9 +152,9 @@ public class TestDeleteByQuery extends BaseTestCase {
List<String> sql = LoggedSqlCollector.stop();
if (isPlatformSupportsDeleteTableAlias()) {
assertThat(sql.get(0)).contains("delete from contact t0 where t0.id = ?");
assertSql(sql.get(0)).contains("delete from contact t0 where t0.id = ?");
} else if (!isMySql()){
assertThat(sql.get(0)).contains("delete from contact where id = ?");
assertSql(sql.get(0)).contains("delete from contact where id = ?");
}
}
@@ -171,9 +171,9 @@ public class TestDeleteByQuery extends BaseTestCase {
List<String> sql = LoggedSqlCollector.stop();
assertThat(sql).hasSize(1);
if (isSqlServer()) {
assertThat(sql.get(0)).contains("select t0.id from o_customer t0 with (updlock) where t0.name = ?");
assertSql(sql.get(0)).contains("select t0.id from o_customer t0 with (updlock) where t0.name = ?");
} else {
assertThat(sql.get(0)).contains("select t0.id from o_customer t0 where t0.name = ?");
assertSql(sql.get(0)).contains("select t0.id from o_customer t0 where t0.name = ?");
}
}