HHH-8127 Corrected failing test

This commit is contained in:
Brett Meyer 2013-04-03 10:29:12 -04:00
parent bae5a85c26
commit 47443bcf57
1 changed files with 32 additions and 39 deletions

View File

@ -53,27 +53,24 @@ public class EmbeddableIntegratorTest extends BaseUnitTestCase {
/** /**
* Throws a mapping exception because DollarValue is not mapped * Throws a mapping exception because DollarValue is not mapped
*/ */
@Test(expected=GenericJDBCException.class) @Test(expected = GenericJDBCException.class)
public void testWithoutIntegrator() { public void testWithoutIntegrator() {
ServiceRegistry reg = new StandardServiceRegistryBuilder(new BootstrapServiceRegistryImpl()) ServiceRegistry reg = new StandardServiceRegistryBuilder( new BootstrapServiceRegistryImpl() ).build();
.build();
SessionFactory sf = new Configuration() SessionFactory sf = new Configuration().addAnnotatedClass( Investor.class )
.addAnnotatedClass( Investor.class ) .setProperty( "hibernate.hbm2ddl.auto", "create-drop" ).buildSessionFactory( reg );
.buildSessionFactory(reg);
Session sess = sf.openSession(); Session sess = sf.openSession();
Investor myInv = getInvestor(); Investor myInv = getInvestor();
myInv.setId(1L); myInv.setId( 1L );
sess.save(myInv); sess.save( myInv );
sess.flush(); sess.flush();
sess.clear(); sess.clear();
Investor inv = (Investor) sess.get(Investor.class, 1L); Investor inv = (Investor) sess.get( Investor.class, 1L );
assertEquals(new BigDecimal("100"), inv.getInvestments().get(0).getAmount().getAmount()); assertEquals( new BigDecimal( "100" ), inv.getInvestments().get( 0 ).getAmount().getAmount() );
sess.close(); sess.close();
sf.close(); sf.close();
@ -82,26 +79,22 @@ public class EmbeddableIntegratorTest extends BaseUnitTestCase {
@Test @Test
public void testWithIntegrator() { public void testWithIntegrator() {
StandardServiceRegistry reg = new StandardServiceRegistryBuilder( StandardServiceRegistry reg = new StandardServiceRegistryBuilder( new BootstrapServiceRegistryBuilder().with(
new BootstrapServiceRegistryBuilder().with( new InvestorIntegrator() ).build() new InvestorIntegrator() ).build() ).build();
).build();
SessionFactory sf = new Configuration() SessionFactory sf = new Configuration().addAnnotatedClass( Investor.class )
.addAnnotatedClass( Investor.class ) .setProperty( "hibernate.hbm2ddl.auto", "create-drop" ).buildSessionFactory( reg );
.setProperty("hibernate.hbm2ddl.auto", "create-drop")
.buildSessionFactory(reg);
Session sess = sf.openSession(); Session sess = sf.openSession();
Investor myInv = getInvestor(); Investor myInv = getInvestor();
myInv.setId(2L); myInv.setId( 2L );
sess.save(myInv); sess.save( myInv );
sess.flush(); sess.flush();
sess.clear(); sess.clear();
Investor inv = (Investor) sess.get(Investor.class, 2L); Investor inv = (Investor) sess.get( Investor.class, 2L );
assertEquals(new BigDecimal("100"), inv.getInvestments().get(0).getAmount().getAmount()); assertEquals( new BigDecimal( "100" ), inv.getInvestments().get( 0 ).getAmount().getAmount() );
sess.close(); sess.close();
sf.close(); sf.close();
@ -112,11 +105,11 @@ public class EmbeddableIntegratorTest extends BaseUnitTestCase {
Investor i = new Investor(); Investor i = new Investor();
List<Investment> investments = new ArrayList<Investment>(); List<Investment> investments = new ArrayList<Investment>();
Investment i1 = new Investment(); Investment i1 = new Investment();
i1.setAmount(new DollarValue(new BigDecimal("100"))); i1.setAmount( new DollarValue( new BigDecimal( "100" ) ) );
i1.setDate(new MyDate(new Date())); i1.setDate( new MyDate( new Date() ) );
i1.setDescription("Test Investment"); i1.setDescription( "Test Investment" );
investments.add(i1); investments.add( i1 );
i.setInvestments(investments); i.setInvestments( investments );
return i; return i;
} }