use of org.orcid.jaxb.model.message.OrcidWork 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.OrcidWork in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testUpdateProfileWithDupeWork.
@Test
@Transactional
@Rollback(true)
public void testUpdateProfileWithDupeWork() {
OrcidProfile profile = createBasicProfile();
OrcidProfile createdProfile = orcidProfileManager.createOrcidProfile(profile, false, false);
List<OrcidWork> orcidWorkList = createdProfile.getOrcidActivities().getOrcidWorks().getOrcidWork();
assertEquals(1, orcidWorkList.size());
orcidWorkList.add(createWork1());
assertEquals(2, orcidWorkList.size());
OrcidProfile updatedProfile = orcidProfileManager.updateOrcidProfile(createdProfile);
List<OrcidWork> updatedOrcidWorkList = updatedProfile.getOrcidActivities().getOrcidWorks().getOrcidWork();
assertEquals(1, updatedOrcidWorkList.size());
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class OrcidProfileManagerBaseTest method createWork.
protected OrcidWork createWork(WorkTitle title, WorkExternalIdentifiers workExternalIdentifiers, WorkContributors workContributors) {
OrcidWork orcidWork = new OrcidWork();
orcidWork.setWorkTitle(title);
orcidWork.setWorkExternalIdentifiers(workExternalIdentifiers);
orcidWork.setWorkContributors(workContributors);
return orcidWork;
}
use of org.orcid.jaxb.model.message.OrcidWork 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.orcid.jaxb.model.message.OrcidWork 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());
}
}
Aggregations