HHH-8127 Corrected failing test
This commit is contained in:
parent
bae5a85c26
commit
47443bcf57
|
@ -53,28 +53,25 @@ 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())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
SessionFactory sf = new Configuration()
|
|
||||||
.addAnnotatedClass( Investor.class )
|
|
||||||
|
|
||||||
.buildSessionFactory(reg);
|
ServiceRegistry reg = new StandardServiceRegistryBuilder( new BootstrapServiceRegistryImpl() ).build();
|
||||||
|
|
||||||
|
SessionFactory sf = new Configuration().addAnnotatedClass( Investor.class )
|
||||||
|
.setProperty( "hibernate.hbm2ddl.auto", "create-drop" ).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();
|
||||||
StandardServiceRegistryBuilder.destroy( reg );
|
StandardServiceRegistryBuilder.destroy( reg );
|
||||||
|
@ -82,42 +79,38 @@ 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().addAnnotatedClass( Investor.class )
|
||||||
SessionFactory sf = new Configuration()
|
.setProperty( "hibernate.hbm2ddl.auto", "create-drop" ).buildSessionFactory( reg );
|
||||||
.addAnnotatedClass( Investor.class )
|
|
||||||
|
|
||||||
.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();
|
||||||
StandardServiceRegistryBuilder.destroy( reg );
|
StandardServiceRegistryBuilder.destroy( reg );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Investor getInvestor() {
|
private Investor getInvestor() {
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue