Last active
June 13, 2019 13:08
-
-
Save altuga/5e47b4550b7c29ab79d683af08df2246 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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