use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class CustomEmailManagerTest method testUpdateCustomEmail.
@Rollback
public void testUpdateCustomEmail() {
// Check old values
List<CustomEmailEntity> customEmails = customEmailManager.getCustomEmails("4444-4444-4444-4441");
assertNotNull(customEmails);
assertEquals(1, customEmails.size());
CustomEmailEntity customEmail = customEmails.get(0);
assertNotNull(customEmail);
assertEquals("This is the content", customEmail.getContent());
assertEquals(EmailType.CLAIM, customEmail.getEmailType());
assertEquals("angel.montenegro.jimenez@gmail.com", customEmail.getSender());
assertEquals("This is the subject", customEmail.getSubject());
assertTrue(customEmail.isHtml());
// Update
customEmailManager.updateCustomEmail("4444-4444-4444-4441", EmailType.CLAIM, "updated@sender.com", "updated subject", "updated content", false);
// Check new values
customEmails = customEmailManager.getCustomEmails("4444-4444-4444-4441");
assertNotNull(customEmails);
assertEquals(1, customEmails.size());
customEmail = customEmails.get(0);
assertNotNull(customEmail);
assertEquals("updated content", customEmail.getContent());
assertEquals(EmailType.CLAIM, customEmail.getEmailType());
assertEquals("updated@sender.com", customEmail.getSender());
assertEquals("updated subject", customEmail.getSubject());
assertFalse(customEmail.isHtml());
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class CustomEmailManagerTest method testAddAmendCustomEmail.
@Test
@Transactional
@Rollback
public void testAddAmendCustomEmail() {
assertTrue(customEmailManager.createCustomEmail("4444-4444-4444-4441", EmailType.AMEND, "angel.montenegro.jimenez@gmail.com", "Amend subject", "Amend content", false));
List<CustomEmailEntity> customEmails = customEmailManager.getCustomEmails("4444-4444-4444-4441");
assertNotNull(customEmails);
assertEquals(2, customEmails.size());
boolean amend = false, claim = false;
for (CustomEmailEntity customEmail : customEmails) {
if (EmailType.AMEND.equals(customEmail.getEmailType())) {
assertEquals("Amend subject", customEmail.getSubject());
assertEquals("angel.montenegro.jimenez@gmail.com", customEmail.getSender());
assertEquals("Amend content", customEmail.getContent());
assertFalse(customEmail.isHtml());
amend = true;
} else {
assertEquals("This is the content", customEmail.getContent());
assertEquals(EmailType.CLAIM, customEmail.getEmailType());
assertEquals("angel.montenegro.jimenez@gmail.com", customEmail.getSender());
assertEquals("This is the subject", customEmail.getSubject());
claim = true;
}
}
assertTrue(amend);
assertTrue(claim);
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testDefaultVisibilityForItemsAppliedOnUpdate.
@Test
@Transactional
@Rollback(true)
public void testDefaultVisibilityForItemsAppliedOnUpdate() {
OrcidProfile profile = createBasicProfile();
OrcidHistory orcidHistory = new OrcidHistory();
orcidHistory.setClaimed(new Claimed(true));
orcidHistory.setCreationMethod(CreationMethod.DIRECT);
orcidHistory.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
profile.setOrcidHistory(orcidHistory);
Keyword k = new Keyword("word", null);
Keywords kk = new Keywords();
kk.getKeyword().add(k);
kk.setVisibility(Visibility.LIMITED);
ResearcherUrl r = new ResearcherUrl(new Url("http://whatever.com"), null);
ResearcherUrls rr = new ResearcherUrls();
rr.getResearcherUrl().add(r);
rr.setVisibility(Visibility.LIMITED);
ExternalIdentifier i = new ExternalIdentifier(null);
i.setExternalIdReference(new ExternalIdReference("ref"));
i.setExternalIdCommonName(new ExternalIdCommonName("cn"));
ExternalIdentifiers ii = new ExternalIdentifiers();
ii.getExternalIdentifier().add(i);
ii.setVisibility(Visibility.LIMITED);
OtherNames oo = new OtherNames();
oo.addOtherName("other", null);
oo.setVisibility(Visibility.LIMITED);
profile.getOrcidBio().setKeywords(kk);
profile.getOrcidBio().setResearcherUrls(rr);
profile.getOrcidBio().setExternalIdentifiers(ii);
profile.getOrcidBio().getPersonalDetails().setOtherNames(oo);
//Create the profile
profile = orcidProfileManager.createOrcidProfile(profile, true, false);
Preferences preferences = new Preferences();
preferences.setSendChangeNotifications(new SendChangeNotifications(true));
preferences.setSendOrcidNews(new SendOrcidNews(true));
//Default visibility for user will be LIMITED
preferences.setActivitiesVisibilityDefault(new ActivitiesVisibilityDefault(Visibility.LIMITED));
preferences.setNotificationsEnabled(DefaultPreferences.NOTIFICATIONS_ENABLED);
preferences.setSendEmailFrequencyDays(DefaultPreferences.SEND_EMAIL_FREQUENCY_DAYS);
preferences.setSendMemberUpdateRequests(DefaultPreferences.SEND_MEMBER_UPDATE_REQUESTS);
OrcidInternal internal = new OrcidInternal();
internal.setPreferences(preferences);
profile.setOrcidInternal(internal);
profile.getOrcidInternal().getPreferences().setActivitiesVisibilityDefault(new ActivitiesVisibilityDefault(Visibility.LIMITED));
//Claim the profile
profile = orcidProfileManager.updateOrcidProfile(profile);
//now attempt to alter privacy. It should fail as record has been claimed.
profile.getOrcidBio().getKeywords().setVisibility(Visibility.PUBLIC);
profile.getOrcidBio().getResearcherUrls().setVisibility(Visibility.PUBLIC);
profile.getOrcidBio().getExternalIdentifiers().setVisibility(Visibility.PUBLIC);
profile.getOrcidBio().getPersonalDetails().getOtherNames().setVisibility(Visibility.PUBLIC);
profile = orcidProfileManager.updateOrcidProfile(profile);
assertEquals("word", profile.getOrcidBio().getKeywords().getKeyword().iterator().next().getContent());
assertEquals(Visibility.LIMITED, profile.getOrcidBio().getKeywords().getKeyword().iterator().next().getVisibility());
assertEquals(new Url("http://whatever.com"), profile.getOrcidBio().getResearcherUrls().getResearcherUrl().iterator().next().getUrl());
assertEquals(Visibility.LIMITED, profile.getOrcidBio().getResearcherUrls().getResearcherUrl().iterator().next().getVisibility());
assertEquals("cn", profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().iterator().next().getExternalIdCommonName().getContent());
assertEquals(Visibility.LIMITED, profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().iterator().next().getVisibility());
assertEquals("other", profile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().iterator().next().getContent());
assertEquals(Visibility.LIMITED, profile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().iterator().next().getVisibility());
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testDedupeWorks.
@Test
@Transactional
@Rollback(true)
public void testDedupeWorks() {
OrcidWorks orcidWorks = new OrcidWorks();
orcidWorks.getOrcidWork().add(createWork1());
orcidWorks.getOrcidWork().add(createWork1());
assertEquals(2, orcidWorks.getOrcidWork().size());
OrcidWorks dedupedOrcidWorks = orcidProfileManager.dedupeWorks(orcidWorks);
assertEquals(1, dedupedOrcidWorks.getOrcidWork().size());
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testUpdateProfileWhenTokenPresent.
@Test
@Transactional
@Rollback(true)
public void testUpdateProfileWhenTokenPresent() {
OrcidProfile profile1 = orcidProfileManager.retrieveOrcidProfile(DELEGATE_ORCID);
assertNotNull(profile1);
// Applications are not linked with OrcidProfile object anymore.
// assertNotNull(profile1.getOrcidBio().getApplications());
// assertEquals(1, profile1.getOrcidBio().getApplications().getApplicationSummary().size());
OrcidProfile profile2 = createBasicProfile();
profile2.setOrcidIdentifier(DELEGATE_ORCID);
orcidProfileManager.updateOrcidProfile(profile2);
OrcidProfile resultProfile = orcidProfileManager.retrieveOrcidProfile(DELEGATE_ORCID);
assertNotNull(resultProfile);
//Applications are not linked with OrcidProfile object anymore.
//assertNotNull(resultProfile.getOrcidBio().getApplications());
//assertEquals(1, resultProfile.getOrcidBio().getApplications().getApplicationSummary().size());
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());
}
Aggregations