OemBO { public String updateOem(OemData oemData, String uuid) { TblOem tblOem; try { if (uuid != null && !uuid.isEmpty()) { tblOem = tblOemJpaController.findTblOemByUUID(uuid); } else { tblOem = tblOemJpaController.findTblOemByName(oemData.getName()); } if (tblOem == null) { throw new ASException(ErrorCode.WS_OEM_DOES_NOT_EXIST, oemData.getName()); } tblOem.setDescription(oemData.getDescription()); tblOemJpaController.edit(tblOem); } catch (ASException ase) { throw ase; } catch (Exception e) { log.error("Error during OEM update.", e); throw new ASException(ErrorCode.WS_OEM_UPDATE_ERROR, e.getClass().getSimpleName()); } return "true"; } OemBO(); List<OemData> getAllOem(); String updateOem(OemData oemData, String uuid); String createOem(OemData oemData, String uuid); String deleteOem(String oemName, String uuid);  }
@Test public void testUpdateOem() { System.out.println("updateOem"); OemData oemData = getOemData(); OemBO instance = new OemBO(); String expResult = "true"; boolean found = false; List<OemData> list = instance.getAllOem(); for(OemData r : list) { if( r.getName() != null && r.getName().equals(oemData.getName()) ) { found = true; } } if( !found ) { instance.createOem(oemData,null); } String updatedDescription = "updated "+rnd.nextInt(99); oemData.setDescription(updatedDescription); String result = instance.updateOem(oemData,null); assertEquals(expResult, result); boolean isUpdated = false; List<OemData> list2 = instance.getAllOem(); for(OemData r : list2) { if(r.getName().equals(oemData.getName()) && r.getDescription().equals(updatedDescription)) { isUpdated = true; } } assertTrue(isUpdated); }