OsBO { public String createOs(OsData osData, String uuid) { try { TblOs tblOs = tblOsJpaController.findTblOsByNameVersion(osData.getName(), osData.getVersion()); if (tblOs != null) { throw new ASException(ErrorCode.WS_OS_ALREADY_EXISTS, osData.getName(), osData.getVersion()); } tblOs = new TblOs(); tblOs.setName(osData.getName()); tblOs.setVersion(osData.getVersion()); tblOs.setDescription(osData.getDescription()); if (uuid != null && !uuid.isEmpty()) { tblOs.setUuid_hex(uuid); } else { tblOs.setUuid_hex(new UUID().toString()); } tblOsJpaController.create(tblOs); } catch (ASException ase) { throw ase; } catch (Exception e) { log.error("Error during OS creation.", e); throw new ASException(ErrorCode.WS_OS_CREATE_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 testCreateOs() { System.out.println("createOs"); 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.deleteOs(osData.getName(), osData.getVersion(), null); } String expResult = "true"; String result = instance.createOs(osData, null); assertEquals(expResult, result); }