Fix EntityWithManyToOneSelfReferenceTest

This commit is contained in:
Christian Beikov 2022-02-15 10:11:15 +01:00
parent b85f530b42
commit 98816362e2
1 changed files with 39 additions and 6 deletions

View File

@ -194,7 +194,6 @@ public class EntityWithManyToOneSelfReferenceTest {
} }
@Test @Test
@NotImplementedYet(strict = false)
public void testGetByMultipleIds(SessionFactoryScope scope) { public void testGetByMultipleIds(SessionFactoryScope scope) {
scope.inTransaction( scope.inTransaction(
@ -202,10 +201,11 @@ public class EntityWithManyToOneSelfReferenceTest {
final List<EntityWithManyToOneSelfReference> list = session.byMultipleIds( final List<EntityWithManyToOneSelfReference> list = session.byMultipleIds(
EntityWithManyToOneSelfReference.class ) EntityWithManyToOneSelfReference.class )
.multiLoad( 1, 3 ); .multiLoad( 1, 3 );
assert list.size() == 1; assertThat( list.size(), equalTo( 2 ) );
final EntityWithManyToOneSelfReference loaded = list.get( 0 ); final EntityWithManyToOneSelfReference loaded = list.get( 0 );
assert loaded != null; assertThat( loaded, is(notNullValue()) );
assertThat( loaded.getName(), equalTo( "first" ) ); assertThat( loaded.getName(), equalTo( "first" ) );
assertThat( list.get( 1 ), is(nullValue()) );
} }
); );
@ -214,11 +214,44 @@ public class EntityWithManyToOneSelfReferenceTest {
final List<EntityWithManyToOneSelfReference> list = session.byMultipleIds( final List<EntityWithManyToOneSelfReference> list = session.byMultipleIds(
EntityWithManyToOneSelfReference.class ) EntityWithManyToOneSelfReference.class )
.multiLoad( 2, 3 ); .multiLoad( 2, 3 );
assert list.size() == 1; assertThat( list.size(), equalTo( 2 ) );
final EntityWithManyToOneSelfReference loaded = list.get( 0 ); final EntityWithManyToOneSelfReference loaded = list.get( 0 );
assert loaded != null; assertThat( loaded, is(notNullValue()) );
assertThat( loaded.getName(), equalTo( "second" ) ); assertThat( loaded.getName(), equalTo( "second" ) );
assert loaded.getOther() != null; assertThat( loaded.getOther(), is(notNullValue()) );
assertThat( loaded.getOther().getName(), equalTo( "first" ) );
assertThat( list.get( 1 ), is(nullValue()) );
}
);
}
@Test
public void testGetByMultipleIdsUnordered(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
final List<EntityWithManyToOneSelfReference> list = session.byMultipleIds(
EntityWithManyToOneSelfReference.class )
.enableOrderedReturn( false )
.multiLoad( 1, 3 );
assertThat( list.size(), equalTo( 1 ) );
final EntityWithManyToOneSelfReference loaded = list.get( 0 );
assertThat( loaded, is(notNullValue()) );
assertThat( loaded.getName(), equalTo( "first" ) );
}
);
scope.inTransaction(
session -> {
final List<EntityWithManyToOneSelfReference> list = session.byMultipleIds(
EntityWithManyToOneSelfReference.class )
.enableOrderedReturn( false )
.multiLoad( 2, 3 );
assertThat( list.size(), equalTo( 1 ) );
final EntityWithManyToOneSelfReference loaded = list.get( 0 );
assertThat( loaded, is(notNullValue()) );
assertThat( loaded.getName(), equalTo( "second" ) );
assertThat( loaded.getOther(), is(notNullValue()) );
assertThat( loaded.getOther().getName(), equalTo( "first" ) ); assertThat( loaded.getOther().getName(), equalTo( "first" ) );
} }
); );