use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class ProfileDaoTest method testRemove.
@Test
@Rollback(true)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testRemove() {
ProfileEntity profile = profileDao.find("4444-4444-4444-4442");
profileDao.remove(profile);
profileDao.flush();
profile = profileDao.find("4444-4444-4444-4442");
assertNull(profile);
profile = profileDao.find("4444-4444-4444-4443");
assertNotNull(profile);
profileDao.remove(profile.getId());
profileDao.flush();
profile = profileDao.find("4444-4444-4444-4443");
assertNull(profile);
List<ProfileEntity> all = profileDao.getAll();
assertEquals(18, all.size());
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class ProfileDaoTest method testFindUnclaimedNeedingReminder.
@Test
@Rollback(true)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testFindUnclaimedNeedingReminder() {
List<String> results = profileDao.findUnclaimedNeedingReminder(1, 10, Collections.<String>emptyList());
assertNotNull(results);
assertEquals(3, results.size());
assertTrue(results.contains("4444-4444-4444-4447"));
// Now insert claimed reminder event, result should be excluded
// thereafter.
ProfileEventEntity eventEntity = new ProfileEventEntity();
eventEntity.setOrcid("4444-4444-4444-4447");
eventEntity.setType(ProfileEventType.CLAIM_REMINDER_SENT);
profileEventDao.persist(eventEntity);
results = profileDao.findUnclaimedNeedingReminder(1, 10, Collections.<String>emptyList());
assertEquals(2, results.size());
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class ResearcherUrlDaoTest method testCannotAddDuplicatedResearcherUrl.
@Test
@Rollback(true)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testCannotAddDuplicatedResearcherUrl() {
try {
ResearcherUrlEntity newRUrl = new ResearcherUrlEntity();
newRUrl.setDateCreated(new Date());
newRUrl.setLastModified(new Date());
newRUrl.setClientSourceId("4444-4444-4444-4443");
newRUrl.setUrl("http://www.researcherurl2.com?id=1");
newRUrl.setUrlName("test");
newRUrl.setUser(new ProfileEntity("4444-4444-4444-4443"));
newRUrl.setVisibility(Visibility.PUBLIC);
newRUrl = researcherUrlDao.merge(newRUrl);
assertNotNull(newRUrl);
fail();
} catch (PersistenceException e) {
}
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidOauth2AuthorizationDetailsDaoTest method testFindByTokenValue.
@Test
@Transactional
@Rollback
public void testFindByTokenValue() throws Exception {
List<OrcidOauth2TokenDetail> all = orcidOauth2TokenDetailDao.getAll();
assertEquals(5, all.size());
for (OrcidOauth2TokenDetail detail : all) {
List<OrcidOauth2TokenDetail> another = orcidOauth2TokenDetailDao.findByAuthenticationKey(detail.getAuthenticationKey());
assertNotNull(another);
assertFalse(another.isEmpty());
for (OrcidOauth2TokenDetail token : another) {
assertEquals(detail.getId(), token.getId());
assertTrue(detail.getTokenExpiration().after(new Date()));
assertTrue(detail.getRefreshTokenExpiration().after(new Date()));
}
}
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidOauth2AuthorizationDetailsDaoTest method testFindByUsername.
@Test
@Transactional
@Rollback
public void testFindByUsername() throws Exception {
List<OrcidOauth2TokenDetail> all = orcidOauth2TokenDetailDao.getAll();
assertEquals(5, all.size());
for (OrcidOauth2TokenDetail detail : all) {
List<OrcidOauth2TokenDetail> allForClient = orcidOauth2TokenDetailDao.findByUserName(detail.getProfile().getId());
assertEquals(1, allForClient.size());
}
}
Aggregations