HHH-15591: added two tests in UnidirectionalOneToManyOrderColumnTest

This commit is contained in:
Burkhard Graves 2022-10-10 20:20:55 +02:00 committed by Burkhard Graves
parent 4bb5bc60e9
commit 7c7021b086
1 changed files with 53 additions and 0 deletions

View File

@ -182,6 +182,59 @@ public class UnidirectionalOneToManyOrderColumnTest {
); );
} }
@Test
public void testSwapElementsAtZeroAndOne(EntityManagerFactoryScope scope) {
long parentId = scope.fromTransaction(
entityManager -> {
ParentData parent = new ParentData();
entityManager.persist( parent );
String[] childrenStr = new String[] {"One", "Two"};
for ( String str : childrenStr ) {
ChildData child = new ChildData( str );
entityManager.persist( child );
parent.getChildren().add( child );
}
entityManager.flush();
List<ChildData> children = parent.getChildren();
ChildData child0 = children.get( 0 );
ChildData child1 = children.get( 1 );
children.set(0, child1);
children.set(1, child0);
return parent.id;
}
);
// if the above works, then test on {"Two", "One"}
}
@Test
public void testAddAtZeroDeleteAtTwo(EntityManagerFactoryScope scope) {
long parentId = scope.fromTransaction(
entityManager -> {
ParentData parent = new ParentData();
entityManager.persist( parent );
String[] childrenStr = new String[] {"One", "Two"};
for ( String str : childrenStr ) {
ChildData child = new ChildData( str );
entityManager.persist( child );
parent.getChildren().add( child );
}
entityManager.flush();
List<ChildData> children = parent.getChildren();
children.add( 0, new ChildData( "Zero" ) );
children.remove( 2 );
return parent.id;
}
);
// if the above works, then test on {"Zero", "One"}
}
@Entity(name = "ParentData") @Entity(name = "ParentData")
@Table(name = "PARENT") @Table(name = "PARENT")
public static class ParentData { public static class ParentData {