Search in sources :

Example 6 with OrcidProfile

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

the class T2OrcidApiServiceDelegatorTest method testUpdateWorkWhenNotSource.

@Test(expected = WrongSourceException.class)
@Transactional
public void testUpdateWorkWhenNotSource() {
    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);
    orcidWork.setPutCode("6");
    WorkTitle workTitle = new WorkTitle();
    workTitle.setTitle(new Title("Updated 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);
    t2OrcidApiServiceDelegator.updateWorks(mockedUriInfo, "4444-4444-4444-4446", 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) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with OrcidProfile

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

the class T2OrcidApiServiceDelegatorTest method createStubOrcidMessage.

private OrcidMessage createStubOrcidMessage() {
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    OrcidBio orcidBio = new OrcidBio();
    orcidProfile.setOrcidBio(orcidBio);
    PersonalDetails personalDetails = new PersonalDetails();
    orcidBio.setPersonalDetails(personalDetails);
    GivenNames givenNames = new GivenNames("Test given names");
    personalDetails.setGivenNames(givenNames);
    CreditName creditName = new CreditName("Test credit name");
    personalDetails.setCreditName(creditName);
    creditName.setVisibility(Visibility.LIMITED);
    ContactDetails contactDetails = new ContactDetails();
    orcidBio.setContactDetails(contactDetails);
    return orcidMessage;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) GivenNames(org.orcid.jaxb.model.message.GivenNames) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) CreditName(org.orcid.jaxb.model.message.CreditName) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails)

Example 8 with OrcidProfile

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

the class T2OrcidApiServiceDelegatorTest method testAddExternalIdentifiersToDeprecatedAccount.

@Test(expected = OrcidDeprecatedException.class)
public void testAddExternalIdentifiersToDeprecatedAccount() {
    SecurityContextTestUtils.setUpSecurityContext();
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    orcidMessage.setOrcidProfile(new OrcidProfile());
    orcidMessage.getOrcidProfile().setOrcidBio(new OrcidBio());
    ExternalIdentifiers extIds = new ExternalIdentifiers();
    ExternalIdentifier extId1 = new ExternalIdentifier();
    String commonName = "common-name-1-" + System.currentTimeMillis();
    extId1.setExternalIdCommonName(new ExternalIdCommonName(commonName));
    extId1.setExternalIdReference(new ExternalIdReference("ext-id-reference-1"));
    extId1.setExternalIdUrl(new ExternalIdUrl("http://test.orcid.org/" + System.currentTimeMillis()));
    extIds.getExternalIdentifier().add(extId1);
    orcidMessage.getOrcidProfile().getOrcidBio().setExternalIdentifiers(extIds);
    t2OrcidApiServiceDelegator.addExternalIdentifiers(mockedUriInfo, "4444-4444-4444-444X", orcidMessage);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ExternalIdCommonName(org.orcid.jaxb.model.message.ExternalIdCommonName) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) ExternalIdReference(org.orcid.jaxb.model.message.ExternalIdReference) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) FundingExternalIdentifier(org.orcid.jaxb.model.message.FundingExternalIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) FundingExternalIdentifiers(org.orcid.jaxb.model.message.FundingExternalIdentifiers) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers) ExternalIdUrl(org.orcid.jaxb.model.message.ExternalIdUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 9 with OrcidProfile

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

the class T2OrcidApiServiceDelegatorTest method testAddFundingToDeprecatedAccount.

@Test(expected = OrcidDeprecatedException.class)
public void testAddFundingToDeprecatedAccount() {
    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);
    FundingList fundings = new FundingList();
    Funding funding = new Funding();
    OrganizationAddress address = new OrganizationAddress();
    address.setCity("City");
    address.setCountry(Iso3166Country.US);
    Organization org = new Organization();
    org.setAddress(address);
    org.setName("Testing org name");
    funding.setOrganization(org);
    FundingExternalIdentifiers fExtIds = new FundingExternalIdentifiers();
    FundingExternalIdentifier fExtId = new FundingExternalIdentifier();
    fExtId.setType(FundingExternalIdentifierType.GRANT_NUMBER);
    fExtId.setValue("FExtId");
    fExtIds.getFundingExternalIdentifier().add(fExtId);
    funding.setFundingExternalIdentifiers(fExtIds);
    funding.setType(FundingType.AWARD);
    funding.setOrganizationDefinedFundingType(new OrganizationDefinedFundingSubType("fType"));
    FundingTitle title = new FundingTitle();
    title.setTitle(new Title("Funding title"));
    funding.setTitle(title);
    fundings.getFundings().add(funding);
    orcidActivities.setFundings(fundings);
    t2OrcidApiServiceDelegator.addFunding(mockedUriInfo, "4444-4444-4444-444X", orcidMessage);
}
Also used : Organization(org.orcid.jaxb.model.message.Organization) Funding(org.orcid.jaxb.model.message.Funding) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) 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) FundingExternalIdentifier(org.orcid.jaxb.model.message.FundingExternalIdentifier) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) FundingList(org.orcid.jaxb.model.message.FundingList) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) FundingExternalIdentifiers(org.orcid.jaxb.model.message.FundingExternalIdentifiers) OrganizationDefinedFundingSubType(org.orcid.jaxb.model.message.OrganizationDefinedFundingSubType) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 10 with OrcidProfile

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

the class T2OrcidApiServiceDelegatorTest method testReadPrivacyOnBio.

@Test
public void testReadPrivacyOnBio() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4497", ScopePathType.READ_LIMITED);
    /*Example A List on 4444-4444-4444-4497:
        Item 1 Private (client is source)
        Item 2 Private (other source)
        Item 3 Limited
        Item 4 Public 
        */
    OrcidProfile p = ((OrcidMessage) t2OrcidApiServiceDelegator.findBioDetails("4444-4444-4444-4497").getEntity()).getOrcidProfile();
    assertEquals(3, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals("type2", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
    assertEquals(Visibility.PRIVATE, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getVisibility());
    assertEquals("type3", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(1).getExternalIdCommonName().getContent());
    assertEquals(Visibility.LIMITED, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(1).getVisibility());
    assertEquals("type4", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(2).getExternalIdCommonName().getContent());
    assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(2).getVisibility());
    assertEquals(Visibility.PRIVATE, p.getOrcidBio().getExternalIdentifiers().getVisibility());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

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