use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class SecurityQuestionDaoTest method testMergeFindAndRemove.
@Test
@Rollback(true)
public void testMergeFindAndRemove() {
SecurityQuestionEntity question = new SecurityQuestionEntity();
question.setQuestion("What is your pet's name?");
securityQuestionDao.merge(question);
assertNotNull(question.getId());
SecurityQuestionEntity retrieved = securityQuestionDao.find(question.getId());
assertNotNull(retrieved);
assertEquals("What is your pet's name?", retrieved.getQuestion());
securityQuestionDao.remove(question.getId());
retrieved = securityQuestionDao.find(question.getId());
assertNull(retrieved);
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testUpdatePreferences.
@Test
@Transactional
@Rollback(true)
public void testUpdatePreferences() {
OrcidProfile profile1 = createBasicProfile();
profile1 = orcidProfileManager.createOrcidProfile(profile1, false, false);
assertEquals(Visibility.PRIVATE, profile1.getOrcidInternal().getPreferences().getActivitiesVisibilityDefault().getValue());
OrcidProfile profile2 = new OrcidProfile();
profile2.setOrcidIdentifier(TEST_ORCID);
OrcidInternal internal = new OrcidInternal();
profile2.setOrcidInternal(internal);
Preferences preferences = new Preferences();
internal.setPreferences(preferences);
preferences.setSendChangeNotifications(new SendChangeNotifications(false));
preferences.setSendOrcidNews(new SendOrcidNews(true));
preferences.setDeveloperToolsEnabled(new DeveloperToolsEnabled(true));
preferences.setActivitiesVisibilityDefault(new ActivitiesVisibilityDefault(Visibility.PUBLIC));
orcidProfileManager.updatePreferences(profile2.getOrcidIdentifier().getPath(), profile2.getOrcidInternal().getPreferences());
OrcidProfile retrievedProfile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
assertEquals(false, retrievedProfile.getOrcidInternal().getPreferences().getSendChangeNotifications().isValue());
assertEquals(true, retrievedProfile.getOrcidInternal().getPreferences().getSendOrcidNews().isValue());
assertEquals(true, retrievedProfile.getOrcidInternal().getPreferences().getDeveloperToolsEnabled().isValue());
assertEquals(Visibility.PUBLIC, retrievedProfile.getOrcidInternal().getPreferences().getActivitiesVisibilityDefault().getValue());
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method addNewWorksModifyExistingWorksDisplayIndex.
@Test
@Transactional
@Rollback(true)
public void addNewWorksModifyExistingWorksDisplayIndex() {
OrcidProfile profile1 = createBasicProfile();
String orcidIdentifier = null;
profile1.setOrcidIdentifier(orcidIdentifier);
setBio(profile1, Visibility.PUBLIC);
profile1 = orcidProfileManager.createOrcidProfile(profile1, true, false);
assertNotNull(profile1);
assertNotNull(profile1.getOrcidIdentifier());
String orcidId = profile1.getOrcidIdentifier().getPath();
OrcidProfile profile = getWorkInsideOrcidProfile("w1", orcidId);
orcidProfileManager.addOrcidWorks(profile);
profile = getWorkInsideOrcidProfile("w2", orcidId);
orcidProfileManager.addOrcidWorks(profile);
profile = getWorkInsideOrcidProfile("w3", orcidId);
orcidProfileManager.addOrcidWorks(profile);
List<MinimizedWorkEntity> all = workDao.findWorks(orcidId, System.currentTimeMillis());
assertNotNull(all);
Long displayIndex1 = null;
Long displayIndex2 = null;
Long displayIndex3 = null;
for (MinimizedWorkEntity entity : all) {
Long displayIndex = entity.getDisplayIndex();
if ("w1".equals(entity.getTitle())) {
displayIndex1 = displayIndex;
} else if ("w2".equals(entity.getTitle())) {
displayIndex2 = displayIndex;
} else if ("w3".equals(entity.getTitle())) {
displayIndex3 = displayIndex;
}
}
assertNotNull(displayIndex1);
assertNotNull(displayIndex2);
assertNotNull(displayIndex3);
assertEquals(Long.valueOf(0L), displayIndex3);
//TODO: Might need to be readed in a later release
//assertTrue(displayIndex3 < displayIndex2);
//assertTrue(displayIndex2 < displayIndex1);
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testAddOrcidWorks.
@Test
@Transactional
@Rollback(true)
public void testAddOrcidWorks() {
OrcidProfile profile1 = createBasicProfile();
OrcidHistory history = new OrcidHistory();
history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
profile1.setOrcidHistory(history);
history.setClaimed(new Claimed(true));
profile1 = orcidProfileManager.createOrcidProfile(profile1, false, false);
String originalPutCode = profile1.getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getPutCode();
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("New Title"));
workTitle3.setSubtitle(new Subtitle("Another New subtitle"));
OrcidWork work3 = createWork2(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(3, 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) {
assertEquals(Visibility.PRIVATE, work.getVisibility());
}
assertEquals("Put code of original work should not have changed", originalPutCode, works.get(2).getPutCode());
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidIndexManagerImplTest method visibilityConstraintsAppliedToSolr.
@Test
@Rollback
@Ignore
public void visibilityConstraintsAppliedToSolr() throws Exception {
OrcidProfile hiddenNamesOrcid = orcidProfileLimitedVisiblityCreditNameAndOtherNames();
orcidIndexManager.persistProfileInformationForIndexing(hiddenNamesOrcid);
// check that limited fields are hidden from solr indexing
OrcidSolrDocument namesHiddenSolrDoc = solrDocFilteredByNameVisibility();
verify(solrDao).persist(eq(namesHiddenSolrDoc));
// reset orcid test data and check affilations
OrcidProfile limitedOrcid = orcidProfileLimitedVisiblityAffiliations();
orcidIndexManager.persistProfileInformationForIndexing(limitedOrcid);
OrcidSolrDocument hiddenPastAffiliations = solrDocFilteredByAffilliationVisibility();
verify(solrDao).persist(eq(hiddenPastAffiliations));
OrcidProfile orcidAllWorksPrivate = orcidProfileAllLimitedVisibilityWorks();
orcidIndexManager.persistProfileInformationForIndexing(orcidAllWorksPrivate);
OrcidSolrDocument hiddenWorks = solrDocFilteredByAffilliationVisibility();
verify(solrDao).persist(eq(hiddenWorks));
}
Aggregations