Search in sources :

Example 51 with OrcidWork

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());
}
Also used : Subtitle(org.orcid.jaxb.model.message.Subtitle) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) WorkExternalIdentifierId(org.orcid.jaxb.model.message.WorkExternalIdentifierId) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) Title(org.orcid.jaxb.model.message.Title) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) BaseTest(org.orcid.core.BaseTest) Test(org.junit.Test)

Example 52 with OrcidWork

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());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 53 with OrcidWork

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;
}
Also used : OrcidWork(org.orcid.jaxb.model.message.OrcidWork)

Example 54 with 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());
}
Also used : OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 55 with OrcidWork

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());
    }
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) WorkExternalIdentifierId(org.orcid.jaxb.model.message.WorkExternalIdentifierId) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

OrcidWork (org.orcid.jaxb.model.message.OrcidWork)81 Test (org.junit.Test)44 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)42 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)32 Transactional (org.springframework.transaction.annotation.Transactional)26 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)24 Title (org.orcid.jaxb.model.message.Title)23 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)20 WorkTitle (org.orcid.jaxb.model.message.WorkTitle)18 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)16 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)16 Source (org.orcid.jaxb.model.message.Source)14 Rollback (org.springframework.test.annotation.Rollback)13 ArrayList (java.util.ArrayList)12 Funding (org.orcid.jaxb.model.message.Funding)12 WorkExternalIdentifierId (org.orcid.jaxb.model.message.WorkExternalIdentifierId)12 BaseTest (org.orcid.core.BaseTest)11 Contributor (org.orcid.jaxb.model.message.Contributor)11 WorkExternalIdentifiers (org.orcid.jaxb.model.message.WorkExternalIdentifiers)11 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)10