use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testAddOrcidWorksWhenDefaultVisibilityIsLimited.
@Test
@Transactional
@Rollback(true)
public void testAddOrcidWorksWhenDefaultVisibilityIsLimited() {
OrcidProfile profile1 = createBasicProfile();
OrcidHistory history = new OrcidHistory();
history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
profile1.setOrcidHistory(history);
history.setClaimed(new Claimed(true));
profile1.getOrcidInternal().getPreferences().setActivitiesVisibilityDefault(new ActivitiesVisibilityDefault(Visibility.LIMITED));
orcidProfileManager.createOrcidProfile(profile1, false, false);
OrcidProfile profile2 = new OrcidProfile();
profile2.setOrcidIdentifier(TEST_ORCID);
OrcidWorks orcidWorks = new OrcidWorks();
profile2.setOrcidWorks(orcidWorks);
WorkTitle workTitle1 = new WorkTitle();
workTitle1.setTitle(new Title("Another Title"));
workTitle1.setSubtitle(new Subtitle("Journal of Cloud Spotting"));
OrcidWork work1 = createWork1(workTitle1);
Source source = new Source(TEST_ORCID);
work1.setSource(source);
orcidWorks.getOrcidWork().add(work1);
WorkTitle workTitle2 = new WorkTitle();
workTitle2.setTitle(new Title("New Title"));
workTitle2.setSubtitle(new Subtitle("Another New subtitle"));
OrcidWork work2 = createWork2(workTitle2);
orcidWorks.getOrcidWork().add(work2);
// Try to add a duplicate
WorkTitle workTitle3 = new WorkTitle();
workTitle3.setTitle(new Title("Further Title"));
workTitle3.setSubtitle(new Subtitle("Further subtitle"));
OrcidWork work3 = createWork3(workTitle3);
work3.setVisibility(Visibility.LIMITED);
orcidWorks.getOrcidWork().add(work3);
orcidProfileManager.addOrcidWorks(profile2);
OrcidProfile resultProfile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
assertEquals("Will", resultProfile.getOrcidBio().getPersonalDetails().getGivenNames().getContent());
List<OrcidWork> works = resultProfile.retrieveOrcidWorks().getOrcidWork();
assertEquals(4, works.size());
assertEquals("Another Title", works.get(0).getWorkTitle().getTitle().getContent());
assertEquals("Journal of Cloud Spotting", works.get(0).getWorkTitle().getSubtitle().getContent());
for (OrcidWork work : works) {
if ("Test Title".equals(work.getWorkTitle().getTitle().getContent()))
assertEquals(Visibility.PRIVATE, work.getVisibility());
else
assertEquals(Visibility.LIMITED, work.getVisibility());
}
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testUpdateProfileWithEmailVerified.
@Test
@Transactional
@Rollback(true)
public void testUpdateProfileWithEmailVerified() {
OrcidProfile profile = createBasicProfile();
profile = orcidProfileManager.createOrcidProfile(profile, false, false);
assertNotNull(profile.getOrcidBio().getContactDetails().retrievePrimaryEmail());
assertFalse(profile.getOrcidBio().getContactDetails().retrievePrimaryEmail().isVerified());
profile.getOrcidBio().getContactDetails().retrievePrimaryEmail().setVerified(true);
orcidProfileManager.updateOrcidProfile(profile);
OrcidProfile resultProfile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
assertNotNull(resultProfile);
assertEquals("Will", resultProfile.getOrcidBio().getPersonalDetails().getGivenNames().getContent());
assertEquals(1, resultProfile.retrieveOrcidWorks().getOrcidWork().size());
assertEquals(1, resultProfile.getOrcidBio().getResearcherUrls().getResearcherUrl().size());
assertEquals("http://www.wjrs.co.uk", resultProfile.getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).getUrl().getValue());
assertTrue(profile.getOrcidBio().getContactDetails().retrievePrimaryEmail().isVerified());
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class WebhookDaoTest method testMergeFindAndRemove.
@Test
@Rollback(true)
public void testMergeFindAndRemove() {
ProfileEntity profile = new ProfileEntity("1234-1234-1234-1234");
profileDao.merge(profile);
ProfileEntity clientProfile = new ProfileEntity("4444-4444-4444-4449");
profileDao.merge(clientProfile);
ClientDetailsEntity clientDetails = new ClientDetailsEntity();
clientDetails.setGroupProfileId(clientProfile.getId());
clientDetails.setId(clientProfile.getId());
clientDetailsDao.merge(clientDetails);
WebhookEntity webhook = new WebhookEntity();
webhook.setProfile(profile);
webhook.setUri("http://semantico.com/orcid/1234");
webhook.setClientDetails(clientDetails);
webhookDao.merge(webhook);
WebhookEntityPk pk = new WebhookEntityPk();
pk.setProfile(profile);
pk.setUri("http://semantico.com/orcid/1234");
WebhookEntity retrieved = webhookDao.find(pk);
assertNotNull(retrieved);
assertEquals("1234-1234-1234-1234", retrieved.getProfile().getId());
assertEquals("http://semantico.com/orcid/1234", retrieved.getUri());
assertEquals("4444-4444-4444-4449", retrieved.getClientDetails().getClientId());
assertTrue(retrieved.isEnabled());
assertEquals(0, retrieved.getFailedAttemptCount());
assertNull(retrieved.getLastFailed());
webhookDao.remove(pk);
retrieved = webhookDao.find(pk);
assertNull(retrieved);
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class WebhookDaoTest method testFindWebhooksReadyToProcess.
@Test
@Rollback(true)
public void testFindWebhooksReadyToProcess() {
Date now = new Date();
List<WebhookEntity> results = webhookDao.findWebhooksReadyToProcess(now, 5, 10);
assertNotNull(results);
assertEquals(1, results.size());
Set<String> orcids = new HashSet<>();
for (WebhookEntity result : results) {
orcids.add(result.getProfile().getId());
}
assertTrue(orcids.contains("4444-4444-4444-4443"));
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class WebhookDaoTest method testCountWebhooksReadyToProcess.
@Test
@Rollback(true)
public void testCountWebhooksReadyToProcess() {
Date now = new Date();
long count = webhookDao.countWebhooksReadyToProcess(now, 5);
assertNotNull(count);
assertEquals(1, count);
}
Aggregations