use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testOrcidWorksHashCodeAndEquals.
@Test
@Transactional
@Rollback(true)
public void testOrcidWorksHashCodeAndEquals() {
OrcidWork workA = createWork1();
OrcidWork workB = createWork1();
assertEquals(workA, workB);
assertEquals(workA.hashCode(), workB.hashCode());
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testDuplicatedExternalIdentifiersThrowsException.
@Test
@Transactional
@Rollback(true)
public void testDuplicatedExternalIdentifiersThrowsException() {
OrcidWork work2 = createWork2();
OrcidWork work3 = createWork3();
WorkExternalIdentifier sharedExternalIdentifier1 = new WorkExternalIdentifier();
sharedExternalIdentifier1.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
sharedExternalIdentifier1.setWorkExternalIdentifierId(new WorkExternalIdentifierId("shared-doi1"));
work2.getWorkExternalIdentifiers().getWorkExternalIdentifier().add(sharedExternalIdentifier1);
work3.getWorkExternalIdentifiers().getWorkExternalIdentifier().add(sharedExternalIdentifier1);
OrcidProfile profile = createBasicProfile();
profile = orcidProfileManager.createOrcidProfile(profile, false, false);
assertNotNull(profile);
assertNotNull(profile.getOrcidActivities());
assertNotNull(profile.getOrcidActivities().getOrcidWorks());
assertNotNull(profile.getOrcidActivities().getOrcidWorks().getOrcidWork());
assertEquals(1, profile.getOrcidActivities().getOrcidWorks().getOrcidWork().size());
profile.getOrcidActivities().getOrcidWorks().getOrcidWork().add(work2);
profile.getOrcidActivities().getOrcidWorks().getOrcidWork().add(work3);
try {
orcidProfileManager.addOrcidWorks(profile);
fail("This should not pass since we add works with duplicated external identifiers");
} catch (IllegalArgumentException iae) {
assertEquals("Works \"Test Title # 2\" and \"Test Title # 3\" have the same external id \"shared-doi1\"", iae.getMessage());
}
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testUpdateProfileButRemoveWorkExternalIdentifier.
@Test
@Transactional
@Rollback(true)
public void testUpdateProfileButRemoveWorkExternalIdentifier() {
OrcidProfile profile1 = createBasicProfile();
profile1 = orcidProfileManager.createOrcidProfile(profile1, false, false);
List<WorkExternalIdentifier> workExternalIdentifiers = profile1.getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getWorkExternalIdentifiers().getWorkExternalIdentifier();
assertEquals(3, workExternalIdentifiers.size());
Iterator<WorkExternalIdentifier> workExternalIdentifiersIterator = workExternalIdentifiers.iterator();
while (workExternalIdentifiersIterator.hasNext()) {
if (WorkExternalIdentifierType.PMID.equals(workExternalIdentifiersIterator.next().getWorkExternalIdentifierType())) {
workExternalIdentifiersIterator.remove();
}
}
profile1 = orcidProfileManager.updateOrcidProfile(profile1);
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());
assertEquals(2, resultProfile.getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getWorkExternalIdentifiers().getWorkExternalIdentifier().size());
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testRetrieveProfileWhenNonExistant.
@Test
@Transactional
@Rollback(true)
public void testRetrieveProfileWhenNonExistant() {
OrcidProfile orcidProfile = orcidProfileManager.retrievePublicOrcidProfile("1234-5678-8765-4321");
assertNull(orcidProfile);
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testUpdatePersonalInformationRemovesOrcidIndexFields.
@Test
@Transactional
@Rollback(true)
public void testUpdatePersonalInformationRemovesOrcidIndexFields() throws Exception {
// re-use the createFull method but add some extra criteria so we can
// use our specific orcidAllSolrFieldsPopulatedForSave matcher
OrcidProfile profile = createFullOrcidProfile();
OtherNames otherNames = new OtherNames();
otherNames.getOtherName().add(new OtherName("Stan", null));
otherNames.getOtherName().add(new OtherName("Willis", null));
profile.getOrcidBio().getPersonalDetails().setOtherNames(otherNames);
OrcidWorks orcidWorks = new OrcidWorks();
profile.setOrcidWorks(orcidWorks);
WorkTitle singleWorkTitle = new WorkTitle();
singleWorkTitle.setTitle(new Title("Single works"));
singleWorkTitle.setSubtitle(new Subtitle("Single works"));
OrcidWork orcidWork = createWork1(singleWorkTitle);
// TODO JB some doi testing here?
// orcidWork.getElectronicResourceNum().add(new
// ElectronicResourceNum("10.1016/S0021-8502(00)90373-2",
// ElectronicResourceNumType.DOI));
orcidWorks.getOrcidWork().add(orcidWork);
orcidProfileManager.createOrcidProfile(profile, false, false);
// now negate all fields that form part of a solr query, leaving only
// the orcid itself
// we do this by passing through an orcid missing the fields from an
// OrcidSolrDocument
OrcidProfile negatedProfile = createBasicProfile();
negatedProfile.getOrcidBio().getPersonalDetails().setFamilyName(null);
negatedProfile.getOrcidBio().getPersonalDetails().setGivenNames(null);
negatedProfile.getOrcidBio().getPersonalDetails().setCreditName(null);
negatedProfile.getOrcidBio().getPersonalDetails().setOtherNames(null);
negatedProfile.getOrcidActivities().setAffiliations(null);
orcidProfileManager.updateOrcidBio(negatedProfile);
assertEquals(IndexingStatus.PENDING, profileDao.find(TEST_ORCID).getIndexingStatus());
}
Aggregations