ProfileManagerImpl implements ProfileManager { @Override public Profile addProfile(Profile profile) throws ProfileManagementException { Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime()); profile.setCreatedDate(currentTimestamp); profile.setUpdatedDate(currentTimestamp); try { PolicyManagementDAOFactory.beginTransaction(); profile = profileDAO.addProfile(profile); featureDAO.addProfileFeatures(profile.getProfileFeaturesList(), profile.getProfileId()); PolicyManagementDAOFactory.commitTransaction(); } catch (ProfileManagerDAOException e) { PolicyManagementDAOFactory.rollbackTransaction(); throw new ProfileManagementException("Error occurred while adding the profile (" + profile.getProfileName() + ")", e); } catch (FeatureManagerDAOException e) { PolicyManagementDAOFactory.rollbackTransaction(); throw new ProfileManagementException("Error occurred while adding the profile features (" + profile.getProfileName() + ")", e); } catch (PolicyManagerDAOException e) { throw new ProfileManagementException("Error occurred while adding 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 adding new profile") public void testAddProfile() throws Exception { Profile profile = ProfileCreator.getProfile(FeatureCreator.getFeatureList(), DEVICE_TYPE_C); profile1 = profileManager.addProfile(profile); Assert.assertEquals(profile1.getProfileName(), profile.getProfileName()); Assert.assertEquals(profile1.getTenantId(), profile.getTenantId()); Assert.assertEquals(profile1.getDeviceType(), profile.getDeviceType()); }