Skip to content

Commit

Permalink
Fix test BackrefCompositeMapKeyTest
Browse files Browse the repository at this point in the history
  • Loading branch information
dreab8 committed Feb 26, 2019
1 parent 2581ade commit f984d85
Showing 1 changed file with 14 additions and 7 deletions.
Expand Up @@ -6,6 +6,8 @@
*/
package org.hibernate.orm.test.collection.backref.map.compkey;

import java.util.Map;

import org.hibernate.Hibernate;
import org.hibernate.LockMode;
import org.hibernate.internal.util.SerializationHelper;
Expand All @@ -14,9 +16,11 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* BackrefCompositeMapKeyTest implementation. Test access to a composite map-key
Expand Down Expand Up @@ -228,10 +232,11 @@ public void testOrphanDelete() {
inTransaction(
session -> {
Product prod = session.get( Product.class, "Widget" );
assertTrue( Hibernate.isInitialized( prod.getParts() ) );
Part part = session.get( Part.class, "Widge" );
prod.getParts().remove( mapKey );

assertFalse( Hibernate.isInitialized( prod.getParts() ) );
Map parts = prod.getParts();
assertThat( parts.size(), is(2) );
session.get( Part.class, "Widge" );
parts.remove( mapKey );
}
);

Expand All @@ -241,8 +246,10 @@ public void testOrphanDelete() {
inTransaction(
session -> {
Product prod = session.get( Product.class, "Widget" );
assertTrue( Hibernate.isInitialized( prod.getParts() ) );
assertNull( prod.getParts().get( new MapKey( "Top" ) ) );
assertFalse( Hibernate.isInitialized( prod.getParts() ) );
Map parts = prod.getParts();
assertThat( parts.size(), is( 1 ) );
assertNull( parts.get( new MapKey( "Top" ) ) );
assertNotNull( session.get( Part.class, "Get" ) );
session.delete( session.get( Product.class, "Widget" ) );
}
Expand Down

0 comments on commit f984d85

Please sign in to comment.