Search in sources :

Example 31 with PersonalDetails

use of org.orcid.jaxb.model.record_rc2.PersonalDetails in project ORCID-Source by ORCID.

the class ValidateV2RC4SamplesTest method testUnmarshallPersonalDetails.

@Test
public void testUnmarshallPersonalDetails() throws SAXException, URISyntaxException {
    PersonalDetails personalDetails = (PersonalDetails) unmarshallFromPath("/record_2.0_rc4/samples/personal-details-2.0_rc4.xml", PersonalDetails.class, "/record_2.0_rc4/personal-details-2.0_rc4.xsd");
    assertNotNull(personalDetails);
    // Check bio
    assertNotNull(personalDetails.getBiography());
    assertEquals("Biography", personalDetails.getBiography().getContent());
    assertEquals(Visibility.PUBLIC.value(), personalDetails.getBiography().getVisibility().value());
    // Check names
    assertNotNull(personalDetails.getName());
    assertNotNull(personalDetails.getName().getCreditName());
    assertEquals("Credit Name", personalDetails.getName().getCreditName().getContent());
    assertNotNull(personalDetails.getName().getGivenNames());
    assertEquals("Give Names", personalDetails.getName().getGivenNames().getContent());
    assertNotNull(personalDetails.getName().getFamilyName());
    assertEquals("Family Name", personalDetails.getName().getFamilyName().getContent());
    assertEquals(Visibility.PUBLIC.value(), personalDetails.getName().getVisibility().value());
    // Check other names
    assertNotNull(personalDetails.getOtherNames());
    assertNotNull(personalDetails.getOtherNames().getOtherNames());
    assertEquals(2, personalDetails.getOtherNames().getOtherNames().size());
    assertEquals("Other Name #1", personalDetails.getOtherNames().getOtherNames().get(0).getContent());
    assertEquals("Other Name #2", personalDetails.getOtherNames().getOtherNames().get(1).getContent());
    assertEquals(Visibility.PUBLIC, personalDetails.getOtherNames().getOtherNames().get(0).getVisibility());
    assertEquals(Visibility.LIMITED, personalDetails.getOtherNames().getOtherNames().get(1).getVisibility());
}
Also used : PersonalDetails(org.orcid.jaxb.model.record_rc4.PersonalDetails) Test(org.junit.Test)

Example 32 with PersonalDetails

use of org.orcid.jaxb.model.record_rc2.PersonalDetails in project ORCID-Source by ORCID.

the class ValidateV2SamplesTest method testUnmarshallPersonalDetails.

@Test
public void testUnmarshallPersonalDetails() throws SAXException, URISyntaxException {
    PersonalDetails personalDetails = (PersonalDetails) unmarshallFromPath("/record_2.0/samples/read_samples/personal-details-2.0.xml", PersonalDetails.class, "/record_2.0/personal-details-2.0.xsd");
    assertNotNull(personalDetails);
    // Check bio
    assertNotNull(personalDetails.getBiography());
    assertEquals("Biography", personalDetails.getBiography().getContent());
    assertEquals(Visibility.PUBLIC.value(), personalDetails.getBiography().getVisibility().value());
    // Check names
    assertNotNull(personalDetails.getName());
    assertNotNull(personalDetails.getName().getCreditName());
    assertEquals("Credit Name", personalDetails.getName().getCreditName().getContent());
    assertNotNull(personalDetails.getName().getGivenNames());
    assertEquals("Give Names", personalDetails.getName().getGivenNames().getContent());
    assertNotNull(personalDetails.getName().getFamilyName());
    assertEquals("Family Name", personalDetails.getName().getFamilyName().getContent());
    assertEquals(Visibility.PUBLIC.value(), personalDetails.getName().getVisibility().value());
    // Check other names
    assertNotNull(personalDetails.getOtherNames());
    assertNotNull(personalDetails.getOtherNames().getOtherNames());
    assertEquals(2, personalDetails.getOtherNames().getOtherNames().size());
    assertEquals("Other Name #1", personalDetails.getOtherNames().getOtherNames().get(0).getContent());
    assertEquals("Other Name #2", personalDetails.getOtherNames().getOtherNames().get(1).getContent());
    assertEquals(Visibility.PUBLIC, personalDetails.getOtherNames().getOtherNames().get(0).getVisibility());
    assertEquals(Visibility.LIMITED, personalDetails.getOtherNames().getOtherNames().get(1).getVisibility());
}
Also used : PersonalDetails(org.orcid.jaxb.model.record_v2.PersonalDetails) Test(org.junit.Test)

Example 33 with PersonalDetails

use of org.orcid.jaxb.model.record_rc2.PersonalDetails in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV2Test method getPersonalDetailsElement.

private PersonalDetails getPersonalDetailsElement(Visibility nameVisibility, Visibility bioVisiblity, Visibility otherNamesVisibility) {
    PersonalDetails p = new PersonalDetails();
    Name name = new Name();
    name.setVisibility(nameVisibility);
    p.setName(name);
    Biography bio = new Biography();
    bio.setVisibility(bioVisiblity);
    bio.setContent("Bio test");
    p.setBiography(bio);
    p.setOtherNames(getOtherNamesElement(otherNamesVisibility));
    return p;
}
Also used : Biography(org.orcid.jaxb.model.record_v2.Biography) PersonalDetails(org.orcid.jaxb.model.record_v2.PersonalDetails) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name)

Example 34 with PersonalDetails

use of org.orcid.jaxb.model.record_rc2.PersonalDetails in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorImpl method viewPersonalDetails.

@Override
public Response viewPersonalDetails(String orcid) {
    PersonalDetails personalDetails = personalDetailsManagerReadOnly.getPublicPersonalDetails(orcid);
    publicAPISecurityManagerV2.filter(personalDetails);
    ElementUtils.setPathToPersonalDetails(personalDetails, orcid);
    Api2_0_LastModifiedDatesHelper.calculateLastModified(personalDetails);
    sourceUtilsReadOnly.setSourceName(personalDetails);
    return Response.ok(personalDetails).build();
}
Also used : PersonalDetails(org.orcid.jaxb.model.record_v2.PersonalDetails)

Example 35 with PersonalDetails

use of org.orcid.jaxb.model.record_rc2.PersonalDetails in project ORCID-Source by ORCID.

the class PersonalDetailsManagerTest method getPublicPersonalDetailsTest2.

@Test
public void getPublicPersonalDetailsTest2() {
    PersonalDetails personalDetails = personalDetailsManager.getPublicPersonalDetails(ORCID2);
    assertNotNull(personalDetails);
    assertNotNull(personalDetails.getOtherNames());
    assertTrue(personalDetails.getOtherNames().getOtherNames().isEmpty());
    assertNull(personalDetails.getBiography());
    assertNull(personalDetails.getName());
}
Also used : PersonalDetails(org.orcid.jaxb.model.record_v2.PersonalDetails) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Aggregations

Test (org.junit.Test)34 PersonalDetails (org.orcid.jaxb.model.record_v2.PersonalDetails)34 OtherName (org.orcid.jaxb.model.record_v2.OtherName)18 Biography (org.orcid.jaxb.model.record_v2.Biography)14 Name (org.orcid.jaxb.model.record_v2.Name)14 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)13 BaseTest (org.orcid.core.BaseTest)6 Response (javax.ws.rs.core.Response)4 DBUnitTest (org.orcid.test.DBUnitTest)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 InputStreamReader (java.io.InputStreamReader)2 Reader (java.io.Reader)2 Date (java.util.Date)2 LastModifiedDate (org.orcid.jaxb.model.common_v2.LastModifiedDate)2 ResearcherUrl (org.orcid.jaxb.model.record_rc2.ResearcherUrl)2 PersonalDetails (org.orcid.jaxb.model.record_rc4.PersonalDetails)2 JsonGenerationException (com.fasterxml.jackson.core.JsonGenerationException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1