Search in sources :

Example 11 with TblOs

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

the class TblOsJpaControllerTest method testDestroy.

@Test
public void testDestroy() throws NonexistentEntityException {
    TblOs tblOs = new TblOs(OS_ID, "Fedora", "20");
    doReturn(tblOs).when(em).getReference(TblOs.class, OS_ID);
    tblOsJpaController.destroy(OS_ID);
    verify(em).remove(tblOs);
    verify(em).close();
    verify(transaction).begin();
    verify(transaction).commit();
}
Also used : TblOs(com.intel.mtwilson.as.data.TblOs) Test(org.junit.Test)

Example 12 with TblOs

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

the class TblOsJpaControllerTest method testCreate.

@Test
public void testCreate() {
    TblOs tblOs = new TblOs(OS_ID, "Fedora", "20");
    tblOsJpaController.create(tblOs);
    verify(em).persist(tblOs);
    verify(em).close();
    verify(transaction).begin();
    verify(transaction).commit();
}
Also used : TblOs(com.intel.mtwilson.as.data.TblOs) Test(org.junit.Test)

Example 13 with TblOs

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

the class TblOsJpaController method getTblOsCount.

public int getTblOsCount() {
    EntityManager em = getEntityManager();
    try {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        Root<TblOs> rt = cq.from(TblOs.class);
        cq.select(em.getCriteriaBuilder().count(rt));
        Query q = em.createQuery(cq);
        return ((Long) q.getSingleResult()).intValue();
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) TblOs(com.intel.mtwilson.as.data.TblOs)

Example 14 with TblOs

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

the class TblOsJpaController method findTblOsByNameVersion.

public TblOs findTblOsByNameVersion(String name, String version) {
    EntityManager em = getEntityManager();
    try {
        Query query = em.createNamedQuery("TblOs.findTblOsByNameVersion");
        query.setParameter("name", name);
        query.setParameter("version", version);
        query.setHint(QueryHints.REFRESH, HintValues.TRUE);
        query.setHint(QueryHints.CACHE_USAGE, CacheUsage.DoNotCheckCache);
        TblOs tblOs = (TblOs) query.getSingleResult();
        return tblOs;
    } catch (NoResultException e) {
        return null;
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query) NoResultException(javax.persistence.NoResultException) TblOs(com.intel.mtwilson.as.data.TblOs)

Example 15 with TblOs

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

the class HostBOTest method mockGetHost.

public TblHosts mockGetHost() {
    TblHosts tblHosts = new TblHosts();
    tblHosts.setId(1);
    tblHosts.setName(SERVER_NAME);
    tblHosts.setIPAddress(SERVER_NAME);
    String biosName = "DELL";
    String biosVersion = "A08";
    String oemName = "DELL";
    TblMle biosMle = new TblMle();
    biosMle.setId(1);
    biosMle.setName(biosName);
    biosMle.setVersion(biosVersion);
    TblOem oem = new TblOem();
    oem.setId(1);
    oem.setName(oemName);
    biosMle.setOemId(oem);
    Collection<TblPcrManifest> tblPcrManifestCollection = new ArrayList<TblPcrManifest>();
    TblPcrManifest tblPcrManifest = new TblPcrManifest();
    tblPcrManifest.setId(1);
    tblPcrManifest.setName("0");
    tblPcrManifest.setValue("31B97D97B4679917EC3C1D943635693FFBAB4143");
    tblPcrManifestCollection.add(tblPcrManifest);
    biosMle.setTblPcrManifestCollection(tblPcrManifestCollection);
    tblHosts.setBiosMleId(biosMle);
    String vmmName = "XEN";
    String vmmVersion = "4.3";
    String osName = "Fedora";
    String osVersion = "20";
    TblMle vmmMle = new TblMle();
    vmmMle.setId(1);
    vmmMle.setName(vmmName);
    vmmMle.setVersion(vmmVersion);
    TblOs os = new TblOs();
    os.setId(1);
    os.setName(osName);
    os.setVersion(osVersion);
    vmmMle.setOsId(os);
    Collection<TblPcrManifest> tblPcrManifestCollectionVMM = new ArrayList<TblPcrManifest>();
    TblPcrManifest tblPcrManifestVMM = new TblPcrManifest();
    tblPcrManifestVMM.setId(2);
    tblPcrManifestVMM.setName("18");
    tblPcrManifestVMM.setValue("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
    tblPcrManifestCollection.add(tblPcrManifestVMM);
    vmmMle.setTblPcrManifestCollection(tblPcrManifestCollectionVMM);
    tblHosts.setVmmMleId(vmmMle);
    tblHosts.setTlsPolicyName("");
    tblHosts.setPort(8181);
    return tblHosts;
}
Also used : TblHosts(com.intel.mtwilson.as.data.TblHosts) TblMle(com.intel.mtwilson.as.data.TblMle) TblOem(com.intel.mtwilson.as.data.TblOem) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) TblPcrManifest(com.intel.mtwilson.as.data.TblPcrManifest) TblOs(com.intel.mtwilson.as.data.TblOs)

Aggregations

TblOs (com.intel.mtwilson.as.data.TblOs)23 Matchers.anyString (org.mockito.Matchers.anyString)10 TblMle (com.intel.mtwilson.as.data.TblMle)9 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)8 TblOem (com.intel.mtwilson.as.data.TblOem)7 TblPcrManifest (com.intel.mtwilson.as.data.TblPcrManifest)6 ASException (com.intel.mountwilson.as.common.ASException)5 OsData (com.intel.mtwilson.datatypes.OsData)4 EntityManager (javax.persistence.EntityManager)4 TblHosts (com.intel.mtwilson.as.data.TblHosts)3 Query (javax.persistence.Query)3 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)3 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)2 NoResultException (javax.persistence.NoResultException)2 TblOemJpaController (com.intel.mtwilson.as.controller.TblOemJpaController)1 TblOsJpaController (com.intel.mtwilson.as.controller.TblOsJpaController)1 ASDataException (com.intel.mtwilson.as.controller.exceptions.ASDataException)1 IllegalOrphanException (com.intel.mtwilson.as.controller.exceptions.IllegalOrphanException)1 ManifestData (com.intel.mtwilson.datatypes.ManifestData)1