Search in sources :

Example 21 with OrcidMessage

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

the class T2OrcidApiServiceDelegatorTest method testReadUnclaimedWhenNotOwnCreation.

@Test
public void testReadUnclaimedWhenNotOwnCreation() {
    SecurityContextTestUtils.setUpSecurityContextForClientOnly();
    OrcidMessage orcidMessage = createStubOrcidMessage();
    Email email = new Email("madeupemail2@semantico.com");
    email.setPrimary(true);
    orcidMessage.getOrcidProfile().getOrcidBio().getContactDetails().getEmail().add(email);
    Response createResponse = t2OrcidApiServiceDelegator.createProfile(mockedUriInfo, orcidMessage);
    assertNotNull(createResponse);
    assertEquals(HttpStatus.SC_CREATED, createResponse.getStatus());
    String location = ((URI) createResponse.getMetadata().getFirst("Location")).getPath();
    assertNotNull(location);
    String orcid = location.substring(1, 20);
    SecurityContextTestUtils.setUpSecurityContextForClientOnly("4444-4444-4444-4448");
    Response readResponse = t2OrcidApiServiceDelegator.findFullDetails(orcid);
    assertNotNull(readResponse);
    assertEquals(HttpStatus.SC_OK, readResponse.getStatus());
    OrcidMessage retrievedMessage = (OrcidMessage) readResponse.getEntity();
    assertEquals(orcid, retrievedMessage.getOrcidProfile().getOrcidIdentifier().getPath());
    GivenNames givenNames = retrievedMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getGivenNames();
    assertNotNull(givenNames);
    assertEquals("Reserved For Claim", givenNames.getContent());
}
Also used : Response(javax.ws.rs.core.Response) Email(org.orcid.jaxb.model.message.Email) GivenNames(org.orcid.jaxb.model.message.GivenNames) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) URI(java.net.URI) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 22 with OrcidMessage

use of org.orcid.jaxb.model.message.OrcidMessage 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 23 with OrcidMessage

use of org.orcid.jaxb.model.message.OrcidMessage 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 24 with OrcidMessage

use of org.orcid.jaxb.model.message.OrcidMessage 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)

Example 25 with OrcidMessage

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

the class T2OrcidApiServiceDelegatorTest method testReadPrivacyOnBioAsPublic.

@Test
public void testReadPrivacyOnBioAsPublic() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4497", ScopePathType.READ_PUBLIC);
    /*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(1, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals("type4", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
    assertEquals(Visibility.PUBLIC, 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

OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)173 Test (org.junit.Test)108 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)64 DBUnitTest (org.orcid.test.DBUnitTest)49 ClientResponse (com.sun.jersey.api.client.ClientResponse)36 Response (javax.ws.rs.core.Response)26 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)22 Transactional (org.springframework.transaction.annotation.Transactional)22 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)20 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)19 Email (org.orcid.jaxb.model.message.Email)18 BaseTest (org.orcid.core.BaseTest)17 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)16 Affiliation (org.orcid.jaxb.model.message.Affiliation)13 OrcidSearchResult (org.orcid.jaxb.model.message.OrcidSearchResult)12 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)12 JAXBContext (javax.xml.bind.JAXBContext)11 Unmarshaller (javax.xml.bind.Unmarshaller)11 Organization (org.orcid.jaxb.model.message.Organization)11 OrganizationAddress (org.orcid.jaxb.model.message.OrganizationAddress)11