use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class ProfileDaoTest method testGetConfirmedProfileCount.
@Test
@Rollback(true)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testGetConfirmedProfileCount() {
String orcid = "4444-4444-4444-4446";
Long confirmedProfileCount = profileDao.getConfirmedProfileCount();
assertEquals(Long.valueOf(20), confirmedProfileCount);
ProfileEntity profileEntity = profileDao.find(orcid);
profileEntity.setCompletedDate(null);
profileDao.persist(profileEntity);
confirmedProfileCount = profileDao.getConfirmedProfileCount();
assertEquals(Long.valueOf(19), confirmedProfileCount);
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class ProfileDaoTest method testInsert.
@Test
@Rollback(true)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testInsert() throws DataSetException {
String newOrcid = "4444-1111-6666-4441";
ProfileEntity profile = new ProfileEntity();
profile.setId(newOrcid);
profileDao.persist(profile);
Date dateCreated = new Date();
profile.setDateCreated(dateCreated);
profileDao.merge(profile);
profileDao.flush();
profile = profileDao.find(profile.getId());
assertEquals(dateCreated.getTime(), profile.getDateCreated().getTime());
Long count = profileDao.countAll();
assertEquals(Long.valueOf(21), count);
profile = profileDao.find(newOrcid);
assertNotNull(profile);
assertEquals(newOrcid, profile.getId());
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class ProfileDaoTest method testInsertWithPrimaryInstitutions.
@Test
@Rollback(true)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testInsertWithPrimaryInstitutions() throws DataSetException {
String newOrcid = "4444-1111-6666-4442";
ProfileEntity profile = new ProfileEntity();
profile.setId(newOrcid);
profileDao.persist(profile);
Date dateCreated = new Date();
profile.setDateCreated(dateCreated);
profileDao.merge(profile);
profileDao.flush();
profile = profileDao.find(profile.getId());
assertEquals(dateCreated.getTime(), profile.getDateCreated().getTime());
Long count = profileDao.countAll();
assertEquals(Long.valueOf(21), count);
profile = profileDao.find(newOrcid);
assertNotNull(profile);
assertEquals(newOrcid, profile.getId());
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class ProfileDaoTest method testInsertGroupWithClients.
@Test
@Rollback(true)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testInsertGroupWithClients() {
String groupOrcid = "4444-1111-6666-4444";
ProfileEntity groupProfile = new ProfileEntity();
groupProfile.setId(groupOrcid);
groupProfile.setOrcidType(OrcidType.GROUP);
groupProfile.setGroupType(MemberType.BASIC);
SortedSet<ClientDetailsEntity> clients = new TreeSet<>(new OrcidEntityIdComparator<String>());
String clientOrcid1 = "4444-4444-4444-4442";
ClientDetailsEntity clientProfile1 = new ClientDetailsEntity();
clientProfile1.setId(clientOrcid1);
clients.add(clientProfile1);
String clientOrcid2 = "4444-4444-4444-4443";
ClientDetailsEntity clientProfile2 = new ClientDetailsEntity();
clientProfile2.setId(clientOrcid2);
clients.add(clientProfile2);
groupProfile.setClients(clients);
profileDao.persist(groupProfile);
profileDao.flush();
groupProfile = profileDao.find(groupOrcid);
assertNotNull(groupProfile);
assertEquals(groupOrcid, groupProfile.getId());
assertEquals(MemberType.BASIC, groupProfile.getGroupType());
assertNotNull(groupProfile.getClients());
assertEquals(2, groupProfile.getClients().size());
Map<String, ClientDetailsEntity> map = ProfileEntity.mapById(groupProfile.getClients());
assertTrue(map.containsKey(clientOrcid1));
assertTrue(map.containsKey(clientOrcid2));
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class ProfileDaoTest method testUpdateNotificationsPreferences.
@Test
@Rollback(true)
public void testUpdateNotificationsPreferences() {
ProfileEntity entity1 = profileDao.find("1000-0000-0000-0001");
ProfileEntity entity6 = profileDao.find("0000-0000-0000-0006");
assertFalse(entity1.getSendChangeNotifications());
assertFalse(entity1.getSendAdministrativeChangeNotifications());
assertFalse(entity1.getSendOrcidNews());
assertFalse(entity1.getSendMemberUpdateRequests());
assertFalse(entity6.getSendChangeNotifications());
assertFalse(entity6.getSendAdministrativeChangeNotifications());
assertFalse(entity6.getSendOrcidNews());
assertFalse(entity6.getSendMemberUpdateRequests());
// Enable some preferences
assertTrue(profileDao.updateNotificationsPreferences("0000-0000-0000-0006", true, false, true, false));
entity1 = profileDao.find("1000-0000-0000-0001");
entity6 = profileDao.find("0000-0000-0000-0006");
// Nothing changed on entity1
assertFalse(entity1.getSendChangeNotifications());
assertFalse(entity1.getSendAdministrativeChangeNotifications());
assertFalse(entity1.getSendOrcidNews());
assertFalse(entity1.getSendMemberUpdateRequests());
// Updates on entity6
assertTrue(entity6.getSendChangeNotifications());
assertFalse(entity6.getSendAdministrativeChangeNotifications());
assertTrue(entity6.getSendOrcidNews());
assertFalse(entity6.getSendMemberUpdateRequests());
// Enable all preferences
assertTrue(profileDao.updateNotificationsPreferences("0000-0000-0000-0006", true, true, true, true));
entity1 = profileDao.find("1000-0000-0000-0001");
entity6 = profileDao.find("0000-0000-0000-0006");
// Nothing changed on entity1
assertFalse(entity1.getSendChangeNotifications());
assertFalse(entity1.getSendAdministrativeChangeNotifications());
assertFalse(entity1.getSendOrcidNews());
assertFalse(entity1.getSendMemberUpdateRequests());
// Updates on entity6
assertTrue(entity6.getSendChangeNotifications());
assertTrue(entity6.getSendAdministrativeChangeNotifications());
assertTrue(entity6.getSendOrcidNews());
assertTrue(entity6.getSendMemberUpdateRequests());
// Disable all preferences
assertTrue(profileDao.updateNotificationsPreferences("0000-0000-0000-0006", false, false, false, false));
entity1 = profileDao.find("1000-0000-0000-0001");
entity6 = profileDao.find("0000-0000-0000-0006");
// Nothing changed on entity1
assertFalse(entity1.getSendChangeNotifications());
assertFalse(entity1.getSendAdministrativeChangeNotifications());
assertFalse(entity1.getSendOrcidNews());
assertFalse(entity1.getSendMemberUpdateRequests());
// Updates on entity6
assertFalse(entity6.getSendChangeNotifications());
assertFalse(entity6.getSendAdministrativeChangeNotifications());
assertFalse(entity6.getSendOrcidNews());
assertFalse(entity6.getSendMemberUpdateRequests());
}
Aggregations