mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Refactor tests using assertSql() helper method
This helper method trims column alias from the sql (for Oracle)
This commit is contained in:
@@ -113,8 +113,8 @@ public class TestInheritInsert extends BaseTestCase {
|
||||
|
||||
Car result = query.findOne();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("order by t0.id, t2.location_code");
|
||||
assertThat(query.getGeneratedSql()).contains("left join car_fuse t2 on t2.id = t1.fuse_id");
|
||||
assertSql(query).contains("order by t0.id, t2.location_code");
|
||||
assertSql(query).contains("left join car_fuse t2 on t2.id = t1.fuse_id");
|
||||
|
||||
assertNotNull(result);
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ public class TestInheritanceQuery extends BaseTestCase {
|
||||
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
assertThat(sql).hasSize(4);
|
||||
assertThat(sql.get(1)).contains("where t0.type = 'A'");
|
||||
assertThat(sql.get(2)).contains("where t0.type = 'B'");
|
||||
assertSql(sql.get(1)).contains("where t0.type = 'A'");
|
||||
assertSql(sql.get(2)).contains("where t0.type = 'B'");
|
||||
assertThat(sql.get(3)).contains("where t0.type = 'B'");
|
||||
|
||||
Ebean.delete(a);
|
||||
|
||||
@@ -89,7 +89,7 @@ public class TestInheritanceBothSides extends BaseTestCase {
|
||||
|
||||
final List<String> sql = LoggedSqlCollector.stop();
|
||||
assertThat(sql).hasSize(1);
|
||||
assertThat(sql.get(0)).contains("select t0.dtype, t0.id, t0.name, t0.pos, t1.dtype, t1.id, t1.name from source_base t0 left join target_base t1 on t1.id = t0.target_id where t0.dtype = 'SourceA' order by t0.pos");
|
||||
assertSql(sql.get(0)).contains("select t0.dtype, t0.id, t0.name, t0.pos, t1.dtype, t1.id, t1.name from source_base t0 left join target_base t1 on t1.id = t0.target_id where t0.dtype = 'SourceA' order by t0.pos");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,10 +116,10 @@ public class TestInheritanceBothSides extends BaseTestCase {
|
||||
final List<String> sql = LoggedSqlCollector.stop();
|
||||
|
||||
assertThat(sql).hasSize(3);
|
||||
//assertThat(sql.get(0)).contains("select t0.dtype, t0.id, t0.name, t0.pos, t0.target_id, t0.target_id from source_base t0 order by t0.pos");
|
||||
assertThat(sql.get(0)).contains("select t0.dtype, t0.id, t0.name, t0.pos, t1.dtype, t0.target_id, t1.dtype, t0.target_id from source_base t0 left join target_base t1 on t1.id = t0.target_id order by t0.pos");
|
||||
assertThat(sql.get(1)).contains("select t0.dtype, t0.id, t0.name from target_base t0 where t0.dtype = 'Target1' and t0.id ");
|
||||
assertThat(sql.get(2)).contains("select t0.dtype, t0.id, t0.name from target_base t0 where t0.dtype = 'Target2' and t0.id = ?");
|
||||
//assertSql(sql.get(0)).contains("select t0.dtype, t0.id, t0.name, t0.pos, t0.target_id, t0.target_id from source_base t0 order by t0.pos");
|
||||
assertSql(sql.get(0)).contains("select t0.dtype, t0.id, t0.name, t0.pos, t1.dtype, t0.target_id, t1.dtype, t0.target_id from source_base t0 left join target_base t1 on t1.id = t0.target_id order by t0.pos");
|
||||
assertSql(sql.get(1)).contains("select t0.dtype, t0.id, t0.name from target_base t0 where t0.dtype = 'Target1' and t0.id ");
|
||||
assertSql(sql.get(2)).contains("select t0.dtype, t0.id, t0.name from target_base t0 where t0.dtype = 'Target2' and t0.id = ?");
|
||||
}
|
||||
|
||||
private void assertSourceBaseEqual(SourceBase foundA, SourceBase sourceA) {
|
||||
|
||||
@@ -40,7 +40,7 @@ public class TestInheritanceRefCache extends BaseTestCase {
|
||||
assertThat(gotRef.getRef()).isInstanceOf(CInhOne.class);
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
assertThat(sql).hasSize(1);
|
||||
assertThat(sql.get(0)).contains("from cinh_ref").contains("left join cinh_root");
|
||||
assertSql(sql.get(0)).contains("from cinh_ref").contains("left join cinh_root");
|
||||
|
||||
// fetch again - from cache (but fetch second bean from cache)
|
||||
LoggedSqlCollector.start();
|
||||
@@ -50,7 +50,7 @@ public class TestInheritanceRefCache extends BaseTestCase {
|
||||
assertThat(gotRef.getRef()).isInstanceOf(CInhOne.class);
|
||||
sql = LoggedSqlCollector.stop();
|
||||
assertThat(sql).hasSize(1);
|
||||
assertThat(sql.get(0)).contains("from cinh_root");
|
||||
assertSql(sql.get(0)).contains("from cinh_root");
|
||||
|
||||
|
||||
// fetch again - both from cache
|
||||
@@ -91,7 +91,7 @@ public class TestInheritanceRefCache extends BaseTestCase {
|
||||
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
assertThat(sql).hasSize(1);
|
||||
assertThat(sql.get(0)).contains("from cinh_root");
|
||||
assertSql(sql.get(0)).contains("from cinh_root");
|
||||
|
||||
// try some cache finds
|
||||
Ebean.find(CInhRoot.class).setUseQueryCache(true).findList();
|
||||
|
||||
Reference in New Issue
Block a user