Search in sources :

Example 21 with PersonalDetails

use of org.orcid.jaxb.model.v3.dev1.record.PersonalDetails in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorTest method testFindPersonalDetails.

@Test
public void testFindPersonalDetails() {
    Response response = serviceDelegator.viewPersonalDetails(ORCID);
    assertNotNull(response);
    PersonalDetails personalDetails = (PersonalDetails) response.getEntity();
    assertNotNull(personalDetails);
    assertNotNull(personalDetails.getLastModifiedDate());
    assertNotNull(personalDetails.getLastModifiedDate().getValue());
    assertNotNull(personalDetails.getBiography());
    assertNotNull(personalDetails.getBiography().getLastModifiedDate());
    assertNotNull(personalDetails.getBiography().getLastModifiedDate().getValue());
    assertEquals("Biography for 0000-0000-0000-0003", personalDetails.getBiography().getContent());
    assertEquals(Visibility.PUBLIC.value(), personalDetails.getBiography().getVisibility().value());
    assertEquals("/0000-0000-0000-0003/biography", personalDetails.getBiography().getPath());
    assertNotNull(personalDetails.getLastModifiedDate());
    assertNotNull(personalDetails.getLastModifiedDate().getValue());
    assertNotNull(personalDetails.getName());
    assertNotNull(personalDetails.getName().getCreatedDate().getValue());
    assertEquals("Credit Name", personalDetails.getName().getCreditName().getContent());
    assertEquals("Family Name", personalDetails.getName().getFamilyName().getContent());
    assertEquals("Given Names", personalDetails.getName().getGivenNames().getContent());
    assertEquals(Visibility.PUBLIC.value(), personalDetails.getName().getVisibility().value());
    assertNotNull(personalDetails.getName().getLastModifiedDate());
    assertNotNull(personalDetails.getName().getLastModifiedDate().getValue());
    assertNotNull(personalDetails.getOtherNames());
    assertNotNull(personalDetails.getOtherNames().getLastModifiedDate());
    assertNotNull(personalDetails.getOtherNames().getLastModifiedDate().getValue());
    assertEquals(1, personalDetails.getOtherNames().getOtherNames().size());
    assertEquals("Other Name PUBLIC", personalDetails.getOtherNames().getOtherNames().get(0).getContent());
    assertEquals(Visibility.PUBLIC.value(), personalDetails.getOtherNames().getOtherNames().get(0).getVisibility().value());
    assertEquals("/0000-0000-0000-0003/other-names", personalDetails.getOtherNames().getPath());
    assertEquals("/0000-0000-0000-0003/personal-details", personalDetails.getPath());
}
Also used : Response(javax.ws.rs.core.Response) PersonalDetails(org.orcid.jaxb.model.v3.dev1.record.PersonalDetails) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 22 with PersonalDetails

use of org.orcid.jaxb.model.v3.dev1.record.PersonalDetails in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorImpl method viewPersonalDetails.

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

Example 23 with PersonalDetails

use of org.orcid.jaxb.model.v3.dev1.record.PersonalDetails in project ORCID-Source by ORCID.

the class OrcidSecurityManager_generalTest method testPersonalDetails_When_ReadLimitedToken_EmptyElement.

@Test
public void testPersonalDetails_When_ReadLimitedToken_EmptyElement() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ORCID_BIO_READ_LIMITED);
    PersonalDetails p = new PersonalDetails();
    orcidSecurityManager.checkAndFilter(ORCID_1, p);
    assertNotNull(p);
}
Also used : PersonalDetails(org.orcid.jaxb.model.v3.dev1.record.PersonalDetails) Test(org.junit.Test)

Example 24 with PersonalDetails

use of org.orcid.jaxb.model.v3.dev1.record.PersonalDetails in project ORCID-Source by ORCID.

the class OrcidSecurityManager_generalTest method testPublicClient_checkAndFilter_PersonalDetails.

@Test(expected = OrcidUnauthorizedException.class)
public void testPublicClient_checkAndFilter_PersonalDetails() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, PUBLIC_CLIENT, ScopePathType.READ_PUBLIC);
    orcidSecurityManager.checkAndFilter(ORCID_1, new PersonalDetails());
}
Also used : PersonalDetails(org.orcid.jaxb.model.v3.dev1.record.PersonalDetails) Test(org.junit.Test)

Example 25 with PersonalDetails

use of org.orcid.jaxb.model.v3.dev1.record.PersonalDetails in project ORCID-Source by ORCID.

the class OrcidSecurityManager_generalTest method testPersonalDetails_When_TokenForOtherUser.

// ---- PERSONAL DETAILS ----
@Test(expected = OrcidUnauthorizedException.class)
public void testPersonalDetails_When_TokenForOtherUser() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ORCID_BIO_READ_LIMITED);
    PersonalDetails p = new PersonalDetails();
    orcidSecurityManager.checkAndFilter(ORCID_2, p);
    fail();
}
Also used : PersonalDetails(org.orcid.jaxb.model.v3.dev1.record.PersonalDetails) Test(org.junit.Test)

Aggregations

PersonalDetails (org.orcid.jaxb.model.v3.dev1.record.PersonalDetails)32 Test (org.junit.Test)28 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)19 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)15 OtherNames (org.orcid.jaxb.model.v3.dev1.record.OtherNames)15 Name (org.orcid.jaxb.model.v3.dev1.record.Name)14 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 LastModifiedDate (org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate)3 ClientResponse (com.sun.jersey.api.client.ClientResponse)2 InputStreamReader (java.io.InputStreamReader)2 Reader (java.io.Reader)2 Date (java.util.Date)2 BlackBoxBaseV3_0_dev1 (org.orcid.integration.blackbox.api.v3.dev1.BlackBoxBaseV3_0_dev1)2 Address (org.orcid.jaxb.model.v3.dev1.record.Address)2 Distinction (org.orcid.jaxb.model.v3.dev1.record.Distinction)2 Education (org.orcid.jaxb.model.v3.dev1.record.Education)2