mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
CI Testing - ParentQueryTest cascade on parent.data
This commit is contained in:
@@ -7,26 +7,17 @@ import org.tests.inherit.ChildA;
|
||||
import org.tests.inherit.ChildB;
|
||||
import org.tests.inherit.Data;
|
||||
import org.tests.inherit.Parent;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class ParentQueryTest extends BaseTestCase {
|
||||
|
||||
@Before
|
||||
public void clearDb() {
|
||||
Ebean.deleteAll(Ebean.find(Data.class).findList());
|
||||
Ebean.deleteAll(Ebean.find(Parent.class).findList());
|
||||
//@rob: this does not work as it does not clear the ManyToMany relations.
|
||||
// Ebean.find(Data.class).delete();
|
||||
// Ebean.find(Parent.class).delete();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void QueryParentCollectionFetch() {
|
||||
|
||||
@@ -35,20 +26,21 @@ public class ParentQueryTest extends BaseTestCase {
|
||||
exampleData.add(new Data(1));
|
||||
exampleData.add(new Data(2));
|
||||
|
||||
ChildA a = new ChildA(0, "PA");
|
||||
ChildA a = new ChildA(1000, "PQT-PA");
|
||||
a.setData(exampleData);
|
||||
Ebean.save(a);
|
||||
|
||||
ChildB b = new ChildB(1, "PB");
|
||||
ChildB b = new ChildB(1001, "PQT-PB");
|
||||
b.setData(exampleData);
|
||||
Ebean.save(b);
|
||||
|
||||
ChildA c = new ChildA(2, "PC");
|
||||
ChildA c = new ChildA(1002, "PQT-PC");
|
||||
c.setData(exampleData);
|
||||
Ebean.save(c);
|
||||
|
||||
List<Parent> partial = Ebean.find(Parent.class).where().ge("val", 1).findList();
|
||||
List<Parent> partial = Ebean.find(Parent.class).where().ge("val", 1001).findList();
|
||||
assertNotNull(partial.get(0).getData());
|
||||
assertThat(partial.get(0).getMore()).startsWith("PQT-");
|
||||
assertEquals(partial.get(0).getData().get(0).getVal().intValue(), 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user