mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
ADD: failing testcase for orderColumn when tree depth > 1
This commit is contained in:
@@ -2,8 +2,11 @@ package org.tests.order;
|
||||
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.TransactionalTestCase;
|
||||
import org.ebeantest.LoggedSqlCollector;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestOrderColumn extends TransactionalTestCase {
|
||||
@@ -28,4 +31,50 @@ public class TestOrderColumn extends TransactionalTestCase {
|
||||
assertThat(result.getChildren()).extracting(OrderReferencedChild::getChildName).containsExactly("c0", "c1", "c2", "c3", "c4");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifyTree() {
|
||||
final OrderMaster master = new OrderMaster();
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
final OrderReferencedChild child = new OrderReferencedChild("p" + i);
|
||||
child.setChildName("c" + i);
|
||||
|
||||
for (int j = 0; j < 3; j++) {
|
||||
final OrderToy toy = new OrderToy("t" + i + j);
|
||||
child.getToys().add(toy);
|
||||
}
|
||||
|
||||
master.getChildren().add(child);
|
||||
}
|
||||
|
||||
Ebean.save(master);
|
||||
|
||||
final OrderMaster result = Ebean.find(OrderMaster.class).findOne();
|
||||
|
||||
final List<OrderReferencedChild> children = result.getChildren();
|
||||
assertThat(children).hasSize(5);
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
final List<OrderToy> toys = children.get(i).getToys();
|
||||
|
||||
for (int j = 0; j < 3; j++) {
|
||||
final OrderToy toy = toys.get(j);
|
||||
assertThat(toy.getTitle()).isEqualTo("t" + i + j);
|
||||
}
|
||||
}
|
||||
|
||||
// modify two toys
|
||||
children.get(1).getToys().get(0).setTitle("tt10");
|
||||
children.get(3).getToys().get(2).setTitle("tt32");
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
Ebean.save(result);
|
||||
final List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(3);
|
||||
|
||||
assertThat(sql.get(0)).contains("update order_toy set title=?, sort_order=? where id=?");
|
||||
assertThat(sql.get(1)).contains("bind(tt10");
|
||||
assertThat(sql.get(2)).contains("bind(tt32");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user