use of org.orcid.jaxb.model.message.WorkExternalIdentifier in project ORCID-Source by ORCID.
the class OrcidProfileCleanerTest method testSimpleClean.
@Test
public void testSimpleClean() {
OrcidWork orcidWork = new OrcidWork();
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(new Title("Test Title"));
workTitle.setSubtitle(new Subtitle(""));
orcidWork.setWorkTitle(workTitle);
WorkExternalIdentifiers workExternalIdentifiers = new WorkExternalIdentifiers();
orcidWork.setWorkExternalIdentifiers(workExternalIdentifiers);
WorkExternalIdentifier workExternalIdentifier1 = new WorkExternalIdentifier();
workExternalIdentifiers.getWorkExternalIdentifier().add(workExternalIdentifier1);
workExternalIdentifier1.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
workExternalIdentifier1.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work-doi"));
orcidProfileCleaner.clean(orcidWork);
assertEquals("Test Title", orcidWork.getWorkTitle().getTitle().getContent());
assertEquals("work-doi", orcidWork.getWorkExternalIdentifiers().getWorkExternalIdentifier().get(0).getWorkExternalIdentifierId().getContent());
assertNull("Subtitle should be null", orcidWork.getWorkTitle().getSubtitle());
}
use of org.orcid.jaxb.model.message.WorkExternalIdentifier in project ORCID-Source by ORCID.
the class OrcidProfileManagerBaseTest method createWork2Identifiers.
protected WorkExternalIdentifiers createWork2Identifiers() {
WorkExternalIdentifiers work2ExternalIdentifiers = new WorkExternalIdentifiers();
WorkExternalIdentifier work2ExternalIdentifier1 = new WorkExternalIdentifier();
work2ExternalIdentifier1.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
work2ExternalIdentifier1.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work2-doi1"));
WorkExternalIdentifier work2ExternalIdentifier2 = new WorkExternalIdentifier();
work2ExternalIdentifier2.setWorkExternalIdentifierType(WorkExternalIdentifierType.PMID);
work2ExternalIdentifier2.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work2-pmid"));
work2ExternalIdentifiers.getWorkExternalIdentifier().add(work2ExternalIdentifier1);
work2ExternalIdentifiers.getWorkExternalIdentifier().add(work2ExternalIdentifier2);
return work2ExternalIdentifiers;
}
use of org.orcid.jaxb.model.message.WorkExternalIdentifier 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.orcid.jaxb.model.message.WorkExternalIdentifier 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.orcid.jaxb.model.message.WorkExternalIdentifier in project ORCID-Source by ORCID.
the class OrcidProfileManagerBaseTest method createWork3Identifiers.
protected WorkExternalIdentifiers createWork3Identifiers() {
WorkExternalIdentifiers work3ExternalIdentifiers = new WorkExternalIdentifiers();
WorkExternalIdentifier work3ExternalIdentifier1 = new WorkExternalIdentifier();
work3ExternalIdentifier1.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
work3ExternalIdentifier1.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work3-doi1"));
WorkExternalIdentifier work3ExternalIdentifier2 = new WorkExternalIdentifier();
work3ExternalIdentifier2.setWorkExternalIdentifierType(WorkExternalIdentifierType.PMID);
work3ExternalIdentifier2.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work3-doi2"));
work3ExternalIdentifiers.getWorkExternalIdentifier().add(work3ExternalIdentifier1);
work3ExternalIdentifiers.getWorkExternalIdentifier().add(work3ExternalIdentifier2);
return work3ExternalIdentifiers;
}
Aggregations