Search in sources :

Example 1 with TblRequestQueue

use of com.intel.mtwilson.as.data.TblRequestQueue in project OpenAttestation by OpenAttestation.

the class TblRequestQueueJpaControllerTest method testEdit.

@Test
public void testEdit() throws NonexistentEntityException, ASDataException {
    TblRequestQueue tblRequestQueue = new TblRequestQueue(RequestQueue_ID);
    doReturn(tblRequestQueue).when(tblRequestQueueJpaController).findTblRequestQueue(RequestQueue_ID);
    tblRequestQueueJpaController.edit(tblRequestQueue);
    verify(em).merge(tblRequestQueue);
    verify(em).close();
    verify(transaction).begin();
    verify(transaction).commit();
}
Also used : TblRequestQueue(com.intel.mtwilson.as.data.TblRequestQueue) Test(org.junit.Test)

Example 2 with TblRequestQueue

use of com.intel.mtwilson.as.data.TblRequestQueue in project OpenAttestation by OpenAttestation.

the class TblRequestQueueJpaControllerTest method testDestroy.

@Test
public void testDestroy() throws NonexistentEntityException {
    TblRequestQueue tblRequestQueue = new TblRequestQueue(RequestQueue_ID);
    doReturn(tblRequestQueue).when(em).getReference(TblRequestQueue.class, RequestQueue_ID);
    tblRequestQueueJpaController.destroy(RequestQueue_ID);
    verify(em).remove(tblRequestQueue);
    verify(em).close();
    verify(transaction).begin();
    verify(transaction).commit();
}
Also used : TblRequestQueue(com.intel.mtwilson.as.data.TblRequestQueue) Test(org.junit.Test)

Example 3 with TblRequestQueue

use of com.intel.mtwilson.as.data.TblRequestQueue in project OpenAttestation by OpenAttestation.

the class TblRequestQueueJpaControllerTest method testCreate.

@Test
public void testCreate() {
    TblRequestQueue tblRequestQueue = new TblRequestQueue(RequestQueue_ID);
    tblRequestQueueJpaController.create(tblRequestQueue);
    verify(em).persist(tblRequestQueue);
    verify(em).close();
    verify(transaction).begin();
    verify(transaction).commit();
}
Also used : TblRequestQueue(com.intel.mtwilson.as.data.TblRequestQueue) Test(org.junit.Test)

Example 4 with TblRequestQueue

use of com.intel.mtwilson.as.data.TblRequestQueue in project OpenAttestation by OpenAttestation.

the class TblRequestQueueJpaController method findTblRequestQueueEntities.

private List<TblRequestQueue> findTblRequestQueueEntities(boolean all, int maxResults, int firstResult) {
    EntityManager em = getEntityManager();
    try {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(TblRequestQueue.class));
        Query q = em.createQuery(cq);
        if (!all) {
            q.setMaxResults(maxResults);
            q.setFirstResult(firstResult);
        }
        return q.getResultList();
    } finally {
        em.close();
    }
}
Also used : TblRequestQueue(com.intel.mtwilson.as.data.TblRequestQueue) EntityManager(javax.persistence.EntityManager) Query(javax.persistence.Query) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) CriteriaQuery(javax.persistence.criteria.CriteriaQuery)

Example 5 with TblRequestQueue

use of com.intel.mtwilson.as.data.TblRequestQueue in project OpenAttestation by OpenAttestation.

the class TblRequestQueueJpaController method destroy.

public void destroy(Integer id) throws NonexistentEntityException {
    EntityManager em = getEntityManager();
    try {
        em.getTransaction().begin();
        TblRequestQueue tblRequestQueue;
        try {
            tblRequestQueue = em.getReference(TblRequestQueue.class, id);
            tblRequestQueue.getId();
        } catch (EntityNotFoundException enfe) {
            throw new NonexistentEntityException("The tblRequestQueue with id " + id + " no longer exists.", enfe);
        }
        em.remove(tblRequestQueue);
        em.getTransaction().commit();
    } finally {
        em.close();
    }
}
Also used : TblRequestQueue(com.intel.mtwilson.as.data.TblRequestQueue) EntityManager(javax.persistence.EntityManager) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Aggregations

TblRequestQueue (com.intel.mtwilson.as.data.TblRequestQueue)6 EntityManager (javax.persistence.EntityManager)3 Test (org.junit.Test)3 Query (javax.persistence.Query)2 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)2 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)1 EntityNotFoundException (javax.persistence.EntityNotFoundException)1