Search in sources :

Example 11 with Name

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

the class MemberV3ApiServiceDelegator_OtherNamesTest method testAddOtherName.

@Test
public void testAddOtherName() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4441", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.createOtherName("4444-4444-4444-4441", Utils.getOtherName());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    Map<?, ?> map = response.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List<?> resultWithPutCode = (List<?>) map.get("Location");
    Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    response = serviceDelegator.viewOtherName("4444-4444-4444-4441", putCode);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    OtherName newOtherName = (OtherName) response.getEntity();
    assertNotNull(newOtherName);
    Utils.verifyLastModified(newOtherName.getLastModifiedDate());
    assertEquals("New Other Name", newOtherName.getContent());
    assertEquals(Visibility.PUBLIC, newOtherName.getVisibility());
    assertNotNull(newOtherName.getSource());
    assertEquals("APP-5555555555555555", newOtherName.getSource().retrieveSourcePath());
    assertNotNull(newOtherName.getCreatedDate());
    Utils.verifyLastModified(newOtherName.getLastModifiedDate());
}
Also used : Response(javax.ws.rs.core.Response) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) List(java.util.List) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 12 with Name

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

the class MemberV3ApiServiceDelegator_OtherNamesTest method testUpdateOtherName.

@Test
public void testUpdateOtherName() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewOtherName("4444-4444-4444-4443", 1L);
    assertNotNull(response);
    OtherName otherName = (OtherName) response.getEntity();
    assertNotNull(otherName);
    Utils.verifyLastModified(otherName.getLastModifiedDate());
    LastModifiedDate before = otherName.getLastModifiedDate();
    assertEquals("Slibberdy Slabinah", otherName.getContent());
    assertEquals(Visibility.PUBLIC, otherName.getVisibility());
    otherName.setContent("Updated Other Name");
    response = serviceDelegator.updateOtherName("4444-4444-4444-4443", 1L, otherName);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewOtherName("4444-4444-4444-4443", 1L);
    assertNotNull(response);
    OtherName updatedOtherName = (OtherName) response.getEntity();
    assertNotNull(updatedOtherName);
    Utils.verifyLastModified(updatedOtherName.getLastModifiedDate());
    assertTrue(updatedOtherName.getLastModifiedDate().after(before));
    assertEquals("Updated Other Name", updatedOtherName.getContent());
    assertEquals(Visibility.PUBLIC, updatedOtherName.getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 13 with Name

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

the class MemberV3ApiServiceDelegator_PersonalDetailsTest method testViewPersonalDetails.

@Test
public void testViewPersonalDetails() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.PERSON_READ_LIMITED);
    Response response = serviceDelegator.viewPersonalDetails(ORCID);
    assertNotNull(response);
    PersonalDetails personalDetails = (PersonalDetails) response.getEntity();
    assertNotNull(personalDetails);
    assertEquals("/0000-0000-0000-0003/personal-details", personalDetails.getPath());
    Utils.verifyLastModified(personalDetails.getLastModifiedDate());
    assertNotNull(personalDetails.getBiography());
    Utils.verifyLastModified(personalDetails.getBiography().getLastModifiedDate());
    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.getName());
    Utils.verifyLastModified(personalDetails.getName().getLastModifiedDate());
    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.getOtherNames());
    Utils.verifyLastModified(personalDetails.getOtherNames().getLastModifiedDate());
    assertEquals(4, personalDetails.getOtherNames().getOtherNames().size());
    for (OtherName otherName : personalDetails.getOtherNames().getOtherNames()) {
        Utils.verifyLastModified(otherName.getLastModifiedDate());
        if (otherName.getPutCode().equals(Long.valueOf(13))) {
            assertEquals("Other Name PUBLIC", otherName.getContent());
            assertEquals(Long.valueOf(0), otherName.getDisplayIndex());
            assertEquals("/0000-0000-0000-0003/other-names/13", otherName.getPath());
            assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
            assertEquals(Visibility.PUBLIC.value(), otherName.getVisibility().value());
        } else if (otherName.getPutCode().equals(Long.valueOf(14))) {
            assertEquals("Other Name LIMITED", otherName.getContent());
            assertEquals(Long.valueOf(1), otherName.getDisplayIndex());
            assertEquals("/0000-0000-0000-0003/other-names/14", otherName.getPath());
            assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
            assertEquals(Visibility.LIMITED.value(), otherName.getVisibility().value());
        } else if (otherName.getPutCode().equals(Long.valueOf(15))) {
            assertEquals("Other Name PRIVATE", otherName.getContent());
            assertEquals(Long.valueOf(2), otherName.getDisplayIndex());
            assertEquals("/0000-0000-0000-0003/other-names/15", otherName.getPath());
            assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
            assertEquals(Visibility.PRIVATE.value(), otherName.getVisibility().value());
        } else if (otherName.getPutCode().equals(Long.valueOf(16))) {
            assertEquals("Other Name SELF LIMITED", otherName.getContent());
            assertEquals(Long.valueOf(3), otherName.getDisplayIndex());
            assertEquals("/0000-0000-0000-0003/other-names/16", otherName.getPath());
            assertEquals("0000-0000-0000-0003", otherName.getSource().retrieveSourcePath());
            assertEquals(Visibility.LIMITED.value(), otherName.getVisibility().value());
        } else {
            fail("Invalid put code found: " + otherName.getPutCode());
        }
    }
    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) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) PersonalDetails(org.orcid.jaxb.model.v3.dev1.record.PersonalDetails) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 14 with Name

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

the class MemberV3ApiServiceDelegator_QualificationsTest method testUpdateQualification.

@Test
public void testUpdateQualification() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewQualification(ORCID, 43L);
    assertNotNull(response);
    Qualification qualification = (Qualification) response.getEntity();
    assertNotNull(qualification);
    assertEquals("LIMITED Department", qualification.getDepartmentName());
    assertEquals("LIMITED", qualification.getRoleTitle());
    Utils.verifyLastModified(qualification.getLastModifiedDate());
    LastModifiedDate before = qualification.getLastModifiedDate();
    qualification.setDepartmentName("Updated department name");
    qualification.setRoleTitle("The updated role title");
    // disambiguated org is required in API v3
    DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
    disambiguatedOrg.setDisambiguatedOrganizationIdentifier("abc456");
    disambiguatedOrg.setDisambiguationSource("WDB");
    qualification.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
    response = serviceDelegator.updateQualification(ORCID, 43L, qualification);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewQualification(ORCID, 43L);
    assertNotNull(response);
    qualification = (Qualification) response.getEntity();
    assertNotNull(qualification);
    Utils.verifyLastModified(qualification.getLastModifiedDate());
    assertTrue(qualification.getLastModifiedDate().after(before));
    assertEquals("Updated department name", qualification.getDepartmentName());
    assertEquals("The updated role title", qualification.getRoleTitle());
    // Rollback changes
    qualification.setDepartmentName("LIMITED Department");
    qualification.setRoleTitle("QUALIFICATION");
    response = serviceDelegator.updateQualification(ORCID, 43L, qualification);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 15 with Name

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

the class MemberV3ApiServiceDelegator_ReadPersonTest method assertAllPublicButEmails.

private void assertAllPublicButEmails(Person p) {
    assertNotNull(p);
    Utils.verifyLastModified(p.getLastModifiedDate());
    // Address
    assertNotNull(p.getAddresses());
    Addresses a = p.getAddresses();
    assertNotNull(a);
    Utils.verifyLastModified(a.getLastModifiedDate());
    assertEquals(1, a.getAddress().size());
    assertEquals(Long.valueOf(9), a.getAddress().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, a.getAddress().get(0).getVisibility());
    // Biography
    assertNotNull(p.getBiography());
    Biography b = p.getBiography();
    assertNotNull(b);
    Utils.verifyLastModified(b.getLastModifiedDate());
    assertEquals("Biography for 0000-0000-0000-0003", b.getContent());
    // External identifiers
    assertNotNull(p.getExternalIdentifiers());
    PersonExternalIdentifiers extIds = p.getExternalIdentifiers();
    assertNotNull(extIds);
    Utils.verifyLastModified(extIds.getLastModifiedDate());
    assertEquals(1, extIds.getExternalIdentifiers().size());
    assertEquals(Long.valueOf(13), extIds.getExternalIdentifiers().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, extIds.getExternalIdentifiers().get(0).getVisibility());
    // Keywords
    assertNotNull(p.getKeywords());
    Keywords k = p.getKeywords();
    assertNotNull(k);
    Utils.verifyLastModified(k.getLastModifiedDate());
    assertEquals(1, k.getKeywords().size());
    assertEquals(Long.valueOf(9), k.getKeywords().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, k.getKeywords().get(0).getVisibility());
    // Name
    assertNotNull(p.getName());
    assertEquals("Credit Name", p.getName().getCreditName().getContent());
    assertEquals("Given Names", p.getName().getGivenNames().getContent());
    assertEquals("Family Name", p.getName().getFamilyName().getContent());
    // Other names
    assertNotNull(p.getOtherNames());
    OtherNames o = p.getOtherNames();
    assertNotNull(o);
    Utils.verifyLastModified(o.getLastModifiedDate());
    assertEquals(1, o.getOtherNames().size());
    assertEquals(Long.valueOf(13), o.getOtherNames().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, o.getOtherNames().get(0).getVisibility());
    // Researcher urls
    assertNotNull(p.getResearcherUrls());
    ResearcherUrls ru = p.getResearcherUrls();
    assertNotNull(ru);
    Utils.verifyLastModified(ru.getLastModifiedDate());
    assertEquals(1, ru.getResearcherUrls().size());
    assertEquals(Long.valueOf(13), ru.getResearcherUrls().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, ru.getResearcherUrls().get(0).getVisibility());
}
Also used : Addresses(org.orcid.jaxb.model.v3.dev1.record.Addresses) Keywords(org.orcid.jaxb.model.v3.dev1.record.Keywords) PersonExternalIdentifiers(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers) OtherNames(org.orcid.jaxb.model.v3.dev1.record.OtherNames) Biography(org.orcid.jaxb.model.v3.dev1.record.Biography) ResearcherUrls(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls)

Aggregations

Test (org.junit.Test)175 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)84 Name (org.orcid.jaxb.model.v3.dev1.record.Name)70 DBUnitTest (org.orcid.test.DBUnitTest)53 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)51 OtherNames (org.orcid.jaxb.model.v3.dev1.record.OtherNames)48 Response (javax.ws.rs.core.Response)43 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)43 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)40 Email (org.orcid.jaxb.model.v3.dev1.record.Email)39 Address (org.orcid.jaxb.model.v3.dev1.record.Address)37 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)36 Person (org.orcid.jaxb.model.v3.dev1.record.Person)35 Addresses (org.orcid.jaxb.model.v3.dev1.record.Addresses)33 PersonExternalIdentifiers (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers)33 ResearcherUrls (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls)33 Keywords (org.orcid.jaxb.model.v3.dev1.record.Keywords)31 Emails (org.orcid.jaxb.model.v3.dev1.record.Emails)30 ClientResponse (com.sun.jersey.api.client.ClientResponse)25 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)25