HHH-11587 : Added FailureExpected test case
This commit is contained in:
parent
aaa6df26e1
commit
f8c1417e3c
|
@ -7,9 +7,7 @@
|
|||
package org.hibernate.jpa.test.mapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
|
@ -103,6 +101,39 @@ public class UnidirectionalOneToManyOrderColumnTest extends BaseEntityManagerFun
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemovingOneAndAddingTwoElements() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
|
||||
ParentData parent = new ParentData();
|
||||
entityManager.persist( parent );
|
||||
|
||||
String[] childrenStr = new String[] {"One", "Two", "Three"};
|
||||
for ( String str : childrenStr ) {
|
||||
ChildData child = new ChildData( str );
|
||||
entityManager.persist( child );
|
||||
parent.getChildren().add( child );
|
||||
}
|
||||
|
||||
entityManager.flush();
|
||||
|
||||
List<ChildData> children = parent.getChildren();
|
||||
children.remove( 0 );
|
||||
children.add( 1, new ChildData( "Another" ) );
|
||||
children.add( new ChildData( "Another Another" ) );
|
||||
} );
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
|
||||
ParentData parent = entityManager.find( ParentData.class, 1L );
|
||||
List<String> childIds = parent.getChildren().stream().map( ChildData::toString ).collect( Collectors.toList() );
|
||||
int i = 0;
|
||||
assertEquals( "Two", childIds.get( i++ ));
|
||||
assertEquals( "Another", childIds.get( i++ ));
|
||||
assertEquals( "Three", childIds.get( i++ ));
|
||||
assertEquals( "Another Another", childIds.get( i++ ));
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] {
|
||||
|
|
Loading…
Reference in New Issue