Search in sources :

Example 31 with OrcidMessage

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

the class T2OrcidApiServiceVersionedDelegatorTest method testCreateWithAffiliations.

@Test
public void testCreateWithAffiliations() throws JAXBException {
    setUpSecurityContextForClientOnly();
    OrcidMessage orcidMessage = getOrcidMessage("/orcid-message-for-create-latest.xml");
    Response createResponse = t2OrcidApiServiceDelegatorLatest.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);
    Response readResponse = t2OrcidApiServiceDelegatorLatest.findFullDetails(orcid);
    assertNotNull(readResponse);
    assertEquals(HttpStatus.SC_OK, readResponse.getStatus());
    OrcidMessage retrievedMessage = (OrcidMessage) readResponse.getEntity();
    OrcidProfile orcidProfile = retrievedMessage.getOrcidProfile();
    assertEquals(orcid, orcidProfile.getOrcidIdentifier().getPath());
    Affiliations affiliations = orcidProfile.retrieveAffiliations();
    assertNotNull(affiliations);
    assertEquals(1, affiliations.getAffiliation().size());
    Affiliation affiliation = affiliations.getAffiliation().get(0);
    assertEquals(Visibility.PRIVATE, affiliation.getVisibility());
    Source source = affiliation.getSource();
    assertNotNull(source);
    String sourceOrcid = source.retrieveSourcePath();
    assertNotNull(sourceOrcid);
    assertEquals("4444-4444-4444-4445", sourceOrcid);
}
Also used : Response(javax.ws.rs.core.Response) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Affiliations(org.orcid.jaxb.model.message.Affiliations) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) URI(java.net.URI) Source(org.orcid.jaxb.model.message.Source) Affiliation(org.orcid.jaxb.model.message.Affiliation) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 32 with OrcidMessage

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

the class T2OrcidApiServiceDelegatorTest method testReadPrivacyOnBio3.

@Test
public void testReadPrivacyOnBio3() {
    /*Example C List:
        Item 1 Public
         */
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.READ_LIMITED);
    OrcidProfile p = ((OrcidMessage) t2OrcidApiServiceDelegator.findBioDetails("4444-4444-4444-4443").getEntity()).getOrcidProfile();
    System.out.println(p.toString());
    assertEquals(1, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals("Facebook", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
    assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getVisibility());
    assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getVisibility());
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.READ_PUBLIC);
    p = ((OrcidMessage) t2OrcidApiServiceDelegator.findBioDetails("4444-4444-4444-4443").getEntity()).getOrcidProfile();
    System.out.println(p.toString());
    assertEquals(1, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals("Facebook", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
    assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getVisibility());
    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)

Example 33 with OrcidMessage

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

the class T2OrcidApiServiceVersionedDelegatorTest method testAttemptCreateWithLaterButOtherwiseValidVersion.

@Test(expected = OrcidValidationException.class)
public void testAttemptCreateWithLaterButOtherwiseValidVersion() {
    setUpSecurityContextForClientOnly();
    OrcidMessage orcidMessage = createStubOrcidMessage();
    orcidMessage.setMessageVersion("1.0.22");
    Email email = new Email("madeupemail3@semantico.com");
    orcidMessage.getOrcidProfile().getOrcidBio().getContactDetails().getEmail().add(email);
    t2OrcidApiServiceDelegatorV2_1.createProfile(mockedUriInfo, orcidMessage);
}
Also used : Email(org.orcid.jaxb.model.message.Email) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 34 with OrcidMessage

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

the class JaxbOrcidMessageUtil method getPublicOrcidMessage.

public static OrcidMessage getPublicOrcidMessage() throws JAXBException {
    JAXBContext context = JAXBContext.newInstance(PACKAGE);
    Unmarshaller unmarshaller = context.createUnmarshaller();
    return (OrcidMessage) unmarshaller.unmarshal(JaxbOrcidMessageUtil.class.getResourceAsStream(ORCID_PUBLIC_FULL_XML));
}
Also used : OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 35 with OrcidMessage

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

the class OrcidIndexManagerImplTest method createFilteredOrcidMessage.

private OrcidMessage createFilteredOrcidMessage(OrcidProfile orcidProfile) {
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion(OrcidMessage.DEFAULT_VERSION);
    orcidMessage.setOrcidProfile(orcidProfile);
    visibilityFilter.filter(orcidMessage, Visibility.PUBLIC);
    return orcidMessage;
}
Also used : OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage)

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