mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 22:41:35 +00:00
Failing testcase that shows wipe of all old children on save
When adding a child to a newly saved bean (A), all other children are killed on save of A.
This commit is contained in:
1 parent
35a721039d
commit
69e56be459
1 file changed
+19
@@ -6,6 +6,8 @@ import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -26,6 +28,23 @@ public class TestOnlyKillOrphans extends BaseTestCase {
|
||||
DB.delete(check);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2() {
|
||||
final COOne one = setup();
|
||||
|
||||
assertThat(one.getChildren()).hasSize(2);
|
||||
|
||||
one.getChildren().add(new COOneMany("_M1"));
|
||||
|
||||
DB.save(one);
|
||||
|
||||
// assert
|
||||
COOne check = DB.find(COOne.class, one.getId());
|
||||
assertThat(check.getChildren().stream().map(it -> it.getName()).sorted().collect(Collectors.toList()))
|
||||
.isEqualTo(Stream.of("M1", "M2", "_M1").sorted().collect(Collectors.toList()));
|
||||
DB.delete(check);
|
||||
}
|
||||
|
||||
private COOne setup() {
|
||||
COOne one = new COOne("P0");
|
||||
one.setChildren(createManies("M1", "M2"));
|
||||
|
||||
Reference in new issue
Block a user