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
@@ -68,7 +68,7 @@ public class TestOrderTotalAmountReportBean extends BaseTestCase {
query.findList();
assertThat(query.getGeneratedSql()).contains("count(*) as total_items, sum(order_qty*unit_price) as total_amount");
assertSql(query).contains("count(*) as total_items, sum(order_qty*unit_price) as total_amount");
}
@Test
@@ -90,7 +90,7 @@ public class TestOrderTotalAmountReportBean extends BaseTestCase {
query.findList();
assertThat(query.getGeneratedSql()).contains("count(*) as totalItems, sum(order_qty*unit_price) as totalAmount");
assertSql(query).contains("count(*) as totalItems, sum(order_qty*unit_price) as totalAmount");
}
@Test
@@ -99,7 +99,7 @@ public class TestOrderTotalAmountReportBean extends BaseTestCase {
Query<OrderAggregate> query = Ebean.find(OrderAggregate.class);
List<OrderAggregate> list = query.findList();
assertThat(query.getGeneratedSql()).contains("count(*) as total_items, sum(order_qty*unit_price) as total_amount");
assertSql(query).contains("count(*) as total_items, sum(order_qty*unit_price) as total_amount");
assertNotNull(list);
}
@@ -111,7 +111,7 @@ public class TestOrderTotalAmountReportBean extends BaseTestCase {
Query<OrderAggregate> query = Ebean.getDefaultServer().createNamedQuery(OrderAggregate.class, "withMax");
List<OrderAggregate> list = query.findList();
assertThat(query.getGeneratedSql()).contains("count(*) as total_items, sum(order_qty*unit_price) as total_amount, max(order_qty*unit_price) as maxAmount from o_order_detail");
assertSql(query).contains("count(*) as total_items, sum(order_qty*unit_price) as total_amount, max(order_qty*unit_price) as maxAmount from o_order_detail");
assertNotNull(list);
}
@@ -127,8 +127,8 @@ public class TestOrderTotalAmountReportBean extends BaseTestCase {
.order().desc("totalAmount")
.findList();
assertThat(query.getGeneratedSql()).contains("count(*) as total_items, sum(order_qty*unit_price) as total_amount, max(order_qty*unit_price) as maxAmount from o_order_detail");
assertThat(query.getGeneratedSql()).contains("from o_order_detail where order_id > ? group by order_id having count(*) > ? order by sum(order_qty*unit_price) desc");
assertSql(query).contains("count(*) as total_items, sum(order_qty*unit_price) as total_amount, max(order_qty*unit_price) as maxAmount from o_order_detail");
assertSql(query).contains("from o_order_detail where order_id > ? group by order_id having count(*) > ? order by sum(order_qty*unit_price) desc");
assertNotNull(list);
}
@@ -146,8 +146,8 @@ public class TestOrderTotalAmountReportBean extends BaseTestCase {
.setMaxRows(10)
.findList();
assertThat(query.getGeneratedSql()).contains("count(*) as totalItems, sum(order_qty*unit_price) as totalAmount, max(order_qty*unit_price) as maxAmount from o_order_detail");
assertThat(query.getGeneratedSql()).contains("from o_order_detail where id > ? and order_id is not null group by order_id having sum(order_qty*unit_price) < ? order by sum(order_qty*unit_price) desc");
assertSql(query).contains("count(*) as totalItems, sum(order_qty*unit_price) as totalAmount, max(order_qty*unit_price) as maxAmount from o_order_detail");
assertSql(query).contains("from o_order_detail where id > ? and order_id is not null group by order_id having sum(order_qty*unit_price) < ? order by sum(order_qty*unit_price) desc");
assertNotNull(list);
}
}