Skip to content

Commit

Permalink
Test only - update TestQueryMultiManyOrder sql asserts
Browse files Browse the repository at this point in the history
No effective change.
  • Loading branch information
rbygrave committed Feb 25, 2025
1 parent 40637bd commit 0a5c3ce
Showing 1 changed file with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.tests.query;

import io.ebean.test.LoggedSql;
import io.ebean.xtest.BaseTestCase;
import io.ebean.DB;
import io.ebean.Query;
Expand All @@ -9,28 +10,28 @@

import java.util.List;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;

public class TestQueryMultiManyOrder extends BaseTestCase {
class TestQueryMultiManyOrder extends BaseTestCase {

@Test
public void test() {

void test() {
ResetBasicData.reset();
LoggedSql.start();

Query<Order> q = DB.find(Order.class).fetch("shipments").fetch("details")
.fetch("details.product").fetch("customer").where().gt("id", 0).query();
Query<Order> q = DB.find(Order.class)
.fetch("shipments")
.fetch("details")
.fetch("details.product")
.fetch("customer")
.where().gt("id", 0).query();

List<Order> list = q.findList();
String sql = q.getGeneratedSql();

assertTrue(!list.isEmpty());
assertTrue(sql.contains("join o_customer "));

assertFalse(sql.contains("left join contact "));
assertFalse(sql.contains("left join o_order_detail "));
assertFalse(sql.contains("left join o_product "));
assertThat(list).isNotEmpty();

List<String> sql = LoggedSql.stop();
assertThat(sql).hasSize(2);
assertThat(sql.get(0)).contains("from o_order t0 join o_customer t1 on t1.id = t0.kcustomer_id left join or_order_ship t2 on t2.order_id = t0.id where");
assertThat(sql.get(1)).contains("from o_order_detail t0 left join o_product t1 on t1.id = t0.product_id");
}
}

0 comments on commit 0a5c3ce

Please sign in to comment.