ProfileManagerImpl implements ProfileManager { @Override public Profile updateProfile(Profile profile) throws ProfileManagementException { Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime()); profile.setUpdatedDate(currentTimestamp); try { PolicyManagementDAOFactory.beginTransaction(); profileDAO.updateProfile(profile); featureDAO.updateProfileFeatures(profile.getProfileFeaturesList(), profile.getProfileId()); PolicyManagementDAOFactory.commitTransaction(); } catch (ProfileManagerDAOException e) { PolicyManagementDAOFactory.rollbackTransaction(); throw new ProfileManagementException("Error occurred while updating the profile (" + profile.getProfileName() + ")", e); } catch (FeatureManagerDAOException e) { PolicyManagementDAOFactory.rollbackTransaction(); throw new ProfileManagementException("Error occurred while updating the profile features (" + profile.getProfileName() + ")", e); } catch (PolicyManagerDAOException e) { throw new ProfileManagementException("Error occurred while updating the profile (" + profile.getProfileName() + ") to the database", e); } finally { PolicyManagementDAOFactory.closeConnection(); } return profile; } ProfileManagerImpl(); @Override Profile addProfile(Profile profile); @Override Profile updateProfile(Profile profile); @Override boolean deleteProfile(Profile profile); @Override Profile getProfile(int profileId); @Override List<Profile> getAllProfiles(); @Override List<Profile> getProfilesOfDeviceType(String deviceType);  }
@Test(description = "This test case tests updating profile", dependsOnMethods = "testAddProfile") public void testUpdateProfile() throws Exception { String newProfileName = "Updated Test Profile"; Profile savedProfile = profileManager.getProfile(profile1.getProfileId()); savedProfile.setProfileName(newProfileName); Profile updateProfile = profileManager.updateProfile(savedProfile); Assert.assertEquals(updateProfile.getProfileName(), newProfileName); }