use of org.jpwh.model.customsql.procedures.User in project microservices by pwillhan.
the class CRUDProcedures method update.
@Test(groups = "MYSQL")
public void update() throws Exception {
CustomSQLTestData testData = create();
Long USER_ID = testData.users.getFirstId();
UserTransaction tx = TM.getUserTransaction();
try {
tx.begin();
EntityManager em = JPA.createEntityManager();
{
User user = em.find(User.class, USER_ID);
user.setUsername("jdoe");
em.flush();
}
em.clear();
loadEventListener.reset();
tx.commit();
em.close();
} finally {
TM.rollback();
}
}
use of org.jpwh.model.customsql.procedures.User in project microservices by pwillhan.
the class CRUDProcedures method read.
@Test(groups = "MYSQL")
public void read() throws Exception {
CustomSQLTestData testData = create();
Long USER_ID = testData.users.getFirstId();
UserTransaction tx = TM.getUserTransaction();
try {
tx.begin();
EntityManager em = JPA.createEntityManager();
{
User user = em.find(User.class, USER_ID);
assertEquals(loadEventListener.getLoadCount(User.class), 1);
assertEquals(user.getId(), USER_ID);
}
em.clear();
loadEventListener.reset();
tx.commit();
em.close();
} finally {
TM.rollback();
}
}
use of org.jpwh.model.customsql.procedures.User in project microservices by pwillhan.
the class CRUDProcedures method create.
public CustomSQLTestData create() throws Exception {
UserTransaction tx = TM.getUserTransaction();
tx.begin();
EntityManager em = JPA.createEntityManager();
CustomSQLTestData testData = new CustomSQLTestData();
testData.users = new TestData(new Long[2]);
User johndoe = new User("johndoe");
em.persist(johndoe);
testData.users.identifiers[0] = johndoe.getId();
tx.commit();
em.close();
return testData;
}
use of org.jpwh.model.customsql.procedures.User in project microservices by pwillhan.
the class CRUDProcedures method delete.
@Test(groups = "MYSQL")
public void delete() throws Exception {
CustomSQLTestData testData = create();
Long USER_ID = testData.users.getFirstId();
UserTransaction tx = TM.getUserTransaction();
try {
tx.begin();
EntityManager em = JPA.createEntityManager();
{
User user = em.find(User.class, USER_ID);
em.remove(user);
em.flush();
em.clear();
assertNull(em.find(User.class, USER_ID));
}
em.clear();
loadEventListener.reset();
tx.commit();
em.close();
} finally {
TM.rollback();
}
}
Aggregations