Search in sources :

Example 1 with OrcidProfile

use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.

the class T2OrcidApiServiceDelegatorTest method testAddWorkToDeprecatedAccount.

@Test(expected = OrcidDeprecatedException.class)
public void testAddWorkToDeprecatedAccount() {
    SecurityContextTestUtils.setUpSecurityContext();
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-444X"));
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    OrcidWork work = new OrcidWork();
    WorkTitle title = new WorkTitle();
    title.setTitle(new Title("Title"));
    work.setWorkTitle(title);
    WorkExternalIdentifiers weis = new WorkExternalIdentifiers();
    WorkExternalIdentifier wei = new WorkExternalIdentifier();
    wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId("00000001"));
    wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    weis.getWorkExternalIdentifier().add(wei);
    work.setWorkExternalIdentifiers(weis);
    OrcidWorks orcidWorks = new OrcidWorks();
    orcidActivities.setOrcidWorks(orcidWorks);
    t2OrcidApiServiceDelegator.addWorks(mockedUriInfo, "4444-4444-4444-444X", orcidMessage);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) WorkExternalIdentifierId(org.orcid.jaxb.model.message.WorkExternalIdentifierId) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 2 with OrcidProfile

use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.

the class T2OrcidApiServiceDelegatorTest method testUpdateWithNewWork.

@Test
@Transactional
public void testUpdateWithNewWork() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.ORCID_WORKS_UPDATE);
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4446"));
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    OrcidWorks orcidWorks = new OrcidWorks();
    orcidActivities.setOrcidWorks(orcidWorks);
    OrcidWork orcidWork = new OrcidWork();
    orcidWorks.getOrcidWork().add(orcidWork);
    WorkTitle workTitle = new WorkTitle();
    workTitle.setTitle(new Title("Added by works update"));
    orcidWork.setWorkTitle(workTitle);
    orcidWork.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
    WorkExternalIdentifiers workExternalIdentifiers = new WorkExternalIdentifiers();
    WorkExternalIdentifier wei = new WorkExternalIdentifier();
    wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId("abc123"));
    workExternalIdentifiers.getWorkExternalIdentifier().add(wei);
    orcidWork.setWorkExternalIdentifiers(workExternalIdentifiers);
    Response response = t2OrcidApiServiceDelegator.updateWorks(mockedUriInfo, "4444-4444-4444-4446", orcidMessage);
    assertNotNull(response);
    OrcidProfile retrievedProfile = orcidProfileManager.retrieveOrcidProfile("4444-4444-4444-4446");
    List<OrcidWork> retreivedWorksList = retrievedProfile.getOrcidActivities().getOrcidWorks().getOrcidWork();
    boolean foundWorkFromAnotherSource = false;
    boolean foundExisting = false;
    boolean foundNew = false;
    boolean foundExistingPrivate = false;
    // another source
    for (OrcidWork retrievedWork : retreivedWorksList) {
        if ("6".equals(retrievedWork.getPutCode())) {
            assertEquals("Journal article B", retrievedWork.getWorkTitle().getTitle().getContent());
            assertEquals(Visibility.LIMITED, retrievedWork.getVisibility());
            foundWorkFromAnotherSource = true;
        } else if ("7".equals(retrievedWork.getPutCode())) {
            // Existing private work
            assertEquals("Journal article C", retrievedWork.getWorkTitle().getTitle().getContent());
            assertEquals(Visibility.PRIVATE, retrievedWork.getVisibility());
            foundExisting = true;
        } else if ("8".equals(retrievedWork.getPutCode())) {
            // Existing private work added by the user
            assertEquals("Journal article D", retrievedWork.getWorkTitle().getTitle().getContent());
            assertEquals(Visibility.PRIVATE, retrievedWork.getVisibility());
            foundExistingPrivate = true;
        } else {
            // The added work
            assertEquals("Added by works update", retrievedWork.getWorkTitle().getTitle().getContent());
            foundNew = true;
        }
    }
    assertTrue("Work from other source should be there", foundWorkFromAnotherSource);
    assertTrue("New work should be there", foundNew);
    assertTrue("Existing private work should be there", foundExisting);
    assertTrue("Existing private work added by the user should be there", foundExistingPrivate);
    assertEquals(4, retreivedWorksList.size());
}
Also used : OrcidWork(org.orcid.jaxb.model.message.OrcidWork) WorkExternalIdentifierId(org.orcid.jaxb.model.message.WorkExternalIdentifierId) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Response(javax.ws.rs.core.Response) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with OrcidProfile

use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.

the class T2OrcidApiServiceDelegatorTest method testUpdateAffiliationWhenNotSource.

@Test(expected = WrongSourceException.class)
@Transactional
public void testUpdateAffiliationWhenNotSource() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.AFFILIATIONS_UPDATE);
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4443"));
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    Affiliations affiliations = new Affiliations();
    orcidActivities.setAffiliations(affiliations);
    Affiliation affiliation1 = new Affiliation();
    affiliations.getAffiliation().add(affiliation1);
    affiliation1.setPutCode("2");
    affiliation1.setType(AffiliationType.EDUCATION);
    Organization organization1 = new Organization();
    affiliation1.setOrganization(organization1);
    organization1.setName("Different org");
    OrganizationAddress organizationAddress = new OrganizationAddress();
    organization1.setAddress(organizationAddress);
    organizationAddress.setCity("Edinburgh");
    organizationAddress.setCountry(Iso3166Country.GB);
    t2OrcidApiServiceDelegator.updateAffiliations(mockedUriInfo, "4444-4444-4444-4443", orcidMessage);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Organization(org.orcid.jaxb.model.message.Organization) Affiliations(org.orcid.jaxb.model.message.Affiliations) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) Affiliation(org.orcid.jaxb.model.message.Affiliation) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with OrcidProfile

use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.

the class T2OrcidApiServiceDelegatorTest method testAddAffilliations.

@Test
public void testAddAffilliations() {
    SecurityContextTestUtils.setUpSecurityContext(ScopePathType.AFFILIATIONS_CREATE);
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4441"));
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    Affiliations affiliations = new Affiliations();
    orcidActivities.setAffiliations(affiliations);
    Affiliation affiliation1 = new Affiliation();
    affiliations.getAffiliation().add(affiliation1);
    affiliation1.setType(AffiliationType.EDUCATION);
    Organization organization1 = new Organization();
    affiliation1.setOrganization(organization1);
    organization1.setName("A new affiliation");
    OrganizationAddress organizationAddress = new OrganizationAddress();
    organization1.setAddress(organizationAddress);
    organizationAddress.setCity("Edinburgh");
    organizationAddress.setCountry(Iso3166Country.GB);
    Response response = t2OrcidApiServiceDelegator.addAffiliations(mockedUriInfo, "4444-4444-4444-4441", orcidMessage);
    assertNotNull(response);
    assertEquals(HttpStatus.SC_CREATED, response.getStatus());
    String location = ((URI) response.getMetadata().getFirst("Location")).getPath();
    assertNotNull(location);
    OrcidProfile retrievedProfile = orcidProfileManager.retrieveOrcidProfile("4444-4444-4444-4441");
    List<Affiliation> affiliationsList = retrievedProfile.getOrcidActivities().getAffiliations().getAffiliation();
    assertEquals(1, affiliationsList.size());
    Affiliation affiliation = affiliationsList.get(0);
    assertEquals("A new affiliation", affiliation.getOrganization().getName());
    assertEquals("APP-5555555555555555", affiliation.getSource().retrieveSourcePath());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Response(javax.ws.rs.core.Response) Organization(org.orcid.jaxb.model.message.Organization) Affiliations(org.orcid.jaxb.model.message.Affiliations) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) URI(java.net.URI) Affiliation(org.orcid.jaxb.model.message.Affiliation) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 5 with OrcidProfile

use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.

the class T2OrcidApiServiceDelegatorTest method testUpdateWithNewAffiliation.

@Test
@Transactional
public void testUpdateWithNewAffiliation() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.AFFILIATIONS_UPDATE);
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4443"));
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    Affiliations affiliations = new Affiliations();
    orcidActivities.setAffiliations(affiliations);
    Affiliation affiliation1 = new Affiliation();
    affiliations.getAffiliation().add(affiliation1);
    affiliation1.setType(AffiliationType.EDUCATION);
    Organization organization1 = new Organization();
    affiliation1.setOrganization(organization1);
    organization1.setName("A new affiliation");
    OrganizationAddress organizationAddress = new OrganizationAddress();
    organization1.setAddress(organizationAddress);
    organizationAddress.setCity("Edinburgh");
    organizationAddress.setCountry(Iso3166Country.GB);
    Response response = t2OrcidApiServiceDelegator.updateAffiliations(mockedUriInfo, "4444-4444-4444-4443", orcidMessage);
    assertNotNull(response);
    OrcidProfile retrievedProfile = orcidProfileManager.retrieveOrcidProfile("4444-4444-4444-4443");
    List<Affiliation> retreivedAffiliationsList = retrievedProfile.getOrcidActivities().getAffiliations().getAffiliation();
    assertEquals(3, retreivedAffiliationsList.size());
    Affiliation newAffiliation = retreivedAffiliationsList.get(0);
    assertEquals("A new affiliation", newAffiliation.getOrganization().getName());
    assertEquals("APP-5555555555555555", newAffiliation.getSource().retrieveSourcePath());
    Affiliation existingAffiliation = retreivedAffiliationsList.get(1);
    assertEquals(Visibility.PRIVATE, existingAffiliation.getVisibility());
    assertEquals("Eine Institution", existingAffiliation.getOrganization().getName());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Response(javax.ws.rs.core.Response) Organization(org.orcid.jaxb.model.message.Organization) Affiliations(org.orcid.jaxb.model.message.Affiliations) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) Affiliation(org.orcid.jaxb.model.message.Affiliation) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)241 Test (org.junit.Test)118 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)77 Transactional (org.springframework.transaction.annotation.Transactional)50 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)45 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)43 DBUnitTest (org.orcid.test.DBUnitTest)43 Rollback (org.springframework.test.annotation.Rollback)40 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)36 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)35 Date (java.util.Date)27 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)27 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)25 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)23 Affiliations (org.orcid.jaxb.model.message.Affiliations)22 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)22 Title (org.orcid.jaxb.model.message.Title)22 Email (org.orcid.jaxb.model.message.Email)21 GivenNames (org.orcid.jaxb.model.message.GivenNames)21 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)21