diff --git a/hibernate-core/src/test/java/org/hibernate/cfg/annotations/CollectionBinderTest.java b/hibernate-core/src/test/java/org/hibernate/cfg/annotations/CollectionBinderTest.java index 5720400588..edc30e455e 100644 --- a/hibernate-core/src/test/java/org/hibernate/cfg/annotations/CollectionBinderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/cfg/annotations/CollectionBinderTest.java @@ -6,8 +6,12 @@ */ package org.hibernate.cfg.annotations; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import java.sql.SQLException; -import java.util.Map; +import java.util.HashMap; import org.hibernate.MappingException; import org.hibernate.annotations.common.reflection.XClass; @@ -17,17 +21,11 @@ import org.hibernate.cfg.PropertyHolder; import org.hibernate.mapping.Collection; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Table; - import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseUnitTestCase; import org.junit.Test; - import org.mockito.Mockito; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - /** * Test for HHH-10106 * @@ -39,20 +37,18 @@ public class CollectionBinderTest extends BaseUnitTestCase { @TestForIssue(jiraKey = "HHH-10106") public void testAssociatedClassException() throws SQLException { final Collection collection = mock(Collection.class); - final Map persistentClasses = mock(Map.class); final XClass collectionType = mock(XClass.class); final MetadataBuildingContext buildingContext = mock(MetadataBuildingContext.class); final InFlightMetadataCollector inFly = mock(InFlightMetadataCollector.class); final PersistentClass persistentClass = mock(PersistentClass.class); final Table table = mock(Table.class); - + when(buildingContext.getMetadataCollector()).thenReturn(inFly); - when(persistentClasses.get(null)).thenReturn(null); when(collection.getOwner()).thenReturn(persistentClass); when(collectionType.getName()).thenReturn("List"); when(persistentClass.getTable()).thenReturn(table); when(table.getName()).thenReturn("Hibernate"); - + CollectionBinder collectionBinder = new CollectionBinder(false) { @Override protected Collection createCollection(PersistentClass persistentClass) { @@ -69,7 +65,7 @@ public class CollectionBinderTest extends BaseUnitTestCase { String expectMessage = "Association [abc] for entity [CollectionBinderTest] references unmapped class [List]"; try { - collectionBinder.bindOneToManySecondPass(collection, persistentClasses, null, collectionType, false, false, buildingContext, null); + collectionBinder.bindOneToManySecondPass(collection, new HashMap(), null, collectionType, false, false, buildingContext, null); } catch (MappingException e) { assertEquals(expectMessage, e.getMessage()); }