Search in sources :

Example 21 with TblOs

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

the class OsBO method updateOs.

/**
     * 
     * @param osData
     * @return 
     */
public String updateOs(OsData osData) {
    try {
        TblOs tblOs = tblOsJpaController.findTblOsByNameVersion(osData.getName(), osData.getVersion());
        if (tblOs == null) {
            throw new ASException(ErrorCode.WS_OS_DOES_NOT_EXIST, osData.getName(), osData.getVersion());
        }
        tblOs.setDescription(osData.getDescription());
        tblOsJpaController.edit(tblOs);
    } catch (ASException ase) {
        throw ase;
    } catch (Exception e) {
        throw new ASException(e);
    }
    return "true";
}
Also used : ASException(com.intel.mountwilson.as.common.ASException) ASException(com.intel.mountwilson.as.common.ASException) TblOs(com.intel.mtwilson.as.data.TblOs)

Example 22 with TblOs

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

the class OsBOTest method testDeleteOs.

@Test
public void testDeleteOs() {
    TblOs tblOs = new TblOs(OS_ID1, "Fedora", "20");
    doReturn(tblOs).when(tblOsJpaController).findTblOsByNameVersion(anyString(), anyString());
    String result = osBO.deleteOs(tblOs.getName(), tblOs.getVersion());
    assertEquals("true", result);
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) TblOs(com.intel.mtwilson.as.data.TblOs) Test(org.junit.Test)

Example 23 with TblOs

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

the class OsBOTest method testGetAllOs.

@Test
public void testGetAllOs() {
    List<TblOs> allRecords = new ArrayList<TblOs>();
    TblOs tblOs1 = new TblOs(OS_ID1, "Fedora", "20");
    TblOs tblOs2 = new TblOs(OS_ID2, "Fedora", "19");
    allRecords.add(tblOs1);
    allRecords.add(tblOs2);
    doReturn(allRecords).when(tblOsJpaController).findTblOsEntities();
    List<OsData> allData = osBO.getAllOs();
    assertNotNull(allData);
    assertEquals(2, allData.size());
}
Also used : ArrayList(java.util.ArrayList) OsData(com.intel.mtwilson.datatypes.OsData) TblOs(com.intel.mtwilson.as.data.TblOs) Test(org.junit.Test)

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