OsBO { public String deleteOs(String osName, String osVersion, String uuid) { TblOs tblOs; try { if (uuid != null && !uuid.isEmpty()) { tblOs = tblOsJpaController.findTblOsByUUID(uuid); } else { tblOs = tblOsJpaController.findTblOsByNameVersion(osName, osVersion); } if (tblOs == null) { throw new ASException(ErrorCode.WS_OS_DOES_NOT_EXIST, osName, osVersion); } Collection<TblMle> tblMleCollection = tblOs.getTblMleCollection(); if (tblMleCollection != null) { log.debug("OS is currently associated with # MLEs: " + tblMleCollection.size()); if (!tblMleCollection.isEmpty()) { throw new ASException(ErrorCode.WS_OS_ASSOCIATION_EXISTS, osName, osVersion, tblMleCollection.size()); } } tblOsJpaController.destroy(tblOs.getId()); } catch (ASException ase) { throw ase; } catch (Exception e) { log.error("Error during OS deletion.", e); throw new ASException(ErrorCode.WS_OS_DELETE_ERROR, e.getClass().getSimpleName()); } return "true"; } OsBO(); List<OsData> getAllOs(); String updateOs(OsData osData, String uuid); String createOs(OsData osData, String uuid); String deleteOs(String osName, String osVersion, String uuid);  }
@Test public void testDeleteOs() { System.out.println("deletOs"); OsData osData = getOsData(); OsBO instance = new OsBO(); boolean found = false; List<OsData> list = instance.getAllOs(); for(OsData r : list) { if( r.getName() != null && r.getName().equals(osData.getName())) { found = true; } } if( !found ) { instance.createOs(osData, null); } String expResult = "true"; String result = instance.deleteOs(osData.getName(), osData.getVersion(), null); assertEquals(expResult, result); }