package org.hibernate.ogm.test.simpleentity;

import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 * @author Emmanuel Bernard
 */
public class BootstrapTest extends OgmTestCase {

	public void testBootstrap() throws Exception {
		final Session session = openSession();
		Hypothesis hyp = new Hypothesis();
		hyp.setId( "1234567890" );
		hyp.setDescription( "P != NP" );
		hyp.setPosition( 1 );
		final Transaction transaction = session.beginTransaction();
		session.persist( hyp );
		session.flush();
		session.clear();
		final Hypothesis loadedHyp = (Hypothesis) session.get( Hypothesis.class, hyp.getId() );
		assertEquals( hyp.getDescription(), loadedHyp.getDescription() );
		assertEquals( hyp.getPosition(), loadedHyp.getPosition() );
		transaction.rollback();
		session.close();
	}

	@Override
	protected Class<?>[] getAnnotatedClasses() {
		return new Class<?>[] {
				Hypothesis.class
		};
	}
}

@@ -207,25 +207,26 @@
 oid test
-Bootstrap
+SimpleCRUD
 () throw
@@ -279,16 +279,73 @@
 ssion();
+%0A%0A%09%09Transaction transaction = session.beginTransaction();
 %0A%09%09Hypot
@@ -430,14 +430,14 @@
 n( %22
+N
 P != 
-N
 P%22 )
@@ -468,112 +468,470 @@
 ;%0A%09%09
-final Transaction transaction = session.beginTransaction();%0A%09%09session.persist( hyp );%0A%09%09session.flush();
+session.persist( hyp );%0A%09%09transaction.commit();%0A%0A%09%09session.clear();%0A%0A%09%09transaction = session.beginTransaction();%0A%09%09final Hypothesis loadedHyp = (Hypothesis) session.get( Hypothesis.class, hyp.getId() );%0A%09%09assertNotNull( %22Cannot load persisted object%22, loadedHyp );%0A%09%09assertEquals( %22persist and load fails%22, hyp.getDescription(), loadedHyp.getDescription() );%0A%09%09assertEquals( %22@Column fails%22, hyp.getPosition(), loadedHyp.getPosition() );%0A%09%09transaction.commit();%0A
 %0A%09%09s
@@ -942,32 +942,230 @@
 on.clear();%0A
+%0A
 %09%09
-final 
+transaction = session.beginTransaction();%0A%09%09loadedHyp.setDescription( %22P != NP%22);%0A%09%09session.merge( loadedHyp );%0A%09%09transaction.commit();%0A%0A%09%09session.clear();%0A%0A%09%09transaction = session.beginTransaction();%0A%09%09
 Hypothesis l
@@ -1155,33 +1155,39 @@
 );%0A%09%09Hypothesis 
-l
+secondL
 oadedHyp = (Hypo
@@ -1252,25 +1252,46 @@
 sertEquals( 
-h
+%22Merge fails%22, loadedH
 yp.getDescri
@@ -1291,33 +1291,39 @@
 tDescription(), 
-l
+secondL
 oadedHyp.getDesc
@@ -1341,63 +1341,189 @@
 ;%0A%09%09
-assertEquals( hyp.getPosition(), loadedHyp.getPosition(
+session.delete( secondLoadedHyp );%0A%09%09transaction.commit();%0A%0A%09%09session.clear();%0A%0A%09%09transaction = session.beginTransaction();%0A%09%09assertNull( session.get( Hypothesis.class, hyp.getId() 
 ) );
@@ -1541,20 +1541,19 @@
 ion.
-rollback
+commit
 ();%0A
+%0A
 %09%09se

Improve CRUD test for OGM