Skip to content

Instantly share code, notes, and snippets.

@altuga altuga/FlightIT.java
Last active Jun 13, 2019

Embed
What would you like to do?
import com.airhacks.ping.boundary.Flight;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
*
* @author altuga
*/
public class FlightIT {
private EntityManager entityManager;
private EntityTransaction tx;
@Before
public void initEM() {
this.entityManager =
Persistence.
createEntityManagerFactory("it").
createEntityManager();
this.tx = this.entityManager.getTransaction();
}
@Test
public void crudTest() {
Flight flight = new Flight("new flight", 2) ;
this.tx.begin();
this.entityManager.persist(flight);
this.tx.commit();
List<Flight> flightList = this.entityManager.
createNamedQuery("all", Flight.class).getResultList();
Assert.assertFalse(flightList.isEmpty());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.