No effective change - add additional tests

This commit is contained in:
rob bygrave
2018-10-15 22:13:18 +13:00
parent aa7325b249
commit 9d64352771
2 changed files with 51 additions and 0 deletions
@@ -14,9 +14,48 @@ import org.tests.model.softdelete.EBasicSoftDelete;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
public class TestSoftDeleteBasic extends BaseTestCase {
@Test
public void testCascadeSaveDelete_other() {
EBasicSoftDelete bean = new EBasicSoftDelete();
bean.setName("cascadeOne");
bean.addChild("child1", 10);
bean.addChild("child2", 20);
bean.addChild("child3", 30);
bean.addNoSoftDeleteChild("nsd1", 101);
bean.addNoSoftDeleteChild("nsd2", 102);
Ebean.save(bean);
assertEquals(new Long(1), bean.getVersion());
assertEquals(new Long(1), bean.getChildren().get(0).getVersion());
LoggedSqlCollector.start();
Ebean.delete(bean);
// List<String> loggedSql = LoggedSqlCollector.stop();
//
// assertEquals(new Long(2), bean.getVersion());
// assertEquals(new Long(2), bean.getChildren().get(0).getVersion()); // Fails with 1
//
// // The children without SoftDelete are left as is (so no third statement)
// assertThat(loggedSql).hasSize(2);
//
// // first statement is a single bulk update of the children with SoftDelete
// assertThat(loggedSql.get(0)).contains("update ebasic_sdchild set deleted=");
// assertThat(loggedSql.get(0)).contains("where owner_id = ?");
//
// // second statement is the top level bean
// assertThat(loggedSql.get(1)).contains(
// "update ebasic_soft_delete set version=?, deleted=? where id=? and version=?");
}
@Test
public void testFindIdsWhenIncludeSoftDeletedChlld() {