Search in sources :

Example 21 with OtherName

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

the class ValidateV2SamplesTest method testUnmarshallPerson.

@Test
public void testUnmarshallPerson() throws SAXException, URISyntaxException {
    Person person = (Person) unmarshallFromPath("/record_2.0/samples/read_samples/person-2.0.xml", Person.class, "/record_2.0/person-2.0.xsd");
    assertNotNull(person);
    assertNotNull(person.getName());
    assertEquals("give-names", person.getName().getGivenNames().getContent());
    assertEquals("family-name", person.getName().getFamilyName().getContent());
    assertEquals("credit-name", person.getName().getCreditName().getContent());
    assertEquals(Visibility.PUBLIC, person.getName().getVisibility());
    assertNotNull(person.getOtherNames());
    assertNotNull(person.getOtherNames().getOtherNames());
    assertEquals(1, person.getOtherNames().getOtherNames().size());
    OtherName otherName = person.getOtherNames().getOtherNames().get(0);
    assertEquals("other-name-1", otherName.getContent());
    assertNotNull(otherName.getCreatedDate());
    assertNotNull(otherName.getCreatedDate().getValue());
    assertEquals(2001, otherName.getCreatedDate().getValue().getYear());
    assertEquals(12, otherName.getCreatedDate().getValue().getMonth());
    assertEquals(31, otherName.getCreatedDate().getValue().getDay());
    assertNotNull(otherName.getLastModifiedDate().getValue());
    assertEquals(2001, otherName.getLastModifiedDate().getValue().getYear());
    assertEquals(12, otherName.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, otherName.getLastModifiedDate().getValue().getDay());
    assertNotNull(otherName.getSource());
    assertEquals("8888-8888-8888-8880", otherName.getSource().retrieveSourcePath());
    assertNotNull(person.getBiography());
    assertEquals(Visibility.PUBLIC, person.getBiography().getVisibility());
    assertEquals("biography", person.getBiography().getContent());
    assertNotNull(person.getResearcherUrls());
    assertNotNull(person.getResearcherUrls().getResearcherUrls());
    assertEquals(1, person.getResearcherUrls().getResearcherUrls().size());
    ResearcherUrl rUrl = person.getResearcherUrls().getResearcherUrls().get(0);
    assertEquals(Visibility.PUBLIC, rUrl.getVisibility());
    assertEquals(Long.valueOf(1248), rUrl.getPutCode());
    assertEquals("url-name-1", rUrl.getUrlName());
    assertNotNull(rUrl.getUrl());
    assertEquals("http://url.com/", rUrl.getUrl().getValue());
    assertNotNull(rUrl.getCreatedDate());
    assertEquals(2001, rUrl.getCreatedDate().getValue().getYear());
    assertEquals(12, rUrl.getCreatedDate().getValue().getMonth());
    assertEquals(31, rUrl.getCreatedDate().getValue().getDay());
    assertNotNull(rUrl.getLastModifiedDate());
    assertEquals(2001, rUrl.getLastModifiedDate().getValue().getYear());
    assertEquals(12, rUrl.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, rUrl.getLastModifiedDate().getValue().getDay());
    assertNotNull(rUrl.getSource());
    assertEquals("8888-8888-8888-8880", rUrl.getSource().retrieveSourcePath());
    assertNotNull(person.getEmails());
    assertNotNull(person.getEmails().getEmails());
    assertEquals(1, person.getEmails().getEmails().size());
    Email email = person.getEmails().getEmails().get(0);
    assertEquals(Visibility.PUBLIC, email.getVisibility());
    assertEquals("user1@email.com", email.getEmail());
    assertNotNull(email.getCreatedDate());
    assertNotNull(email.getCreatedDate().getValue());
    assertEquals(2001, email.getCreatedDate().getValue().getYear());
    assertEquals(12, email.getCreatedDate().getValue().getMonth());
    assertEquals(31, email.getCreatedDate().getValue().getDay());
    assertNotNull(email.getLastModifiedDate());
    assertNotNull(email.getLastModifiedDate().getValue());
    assertEquals(2001, email.getLastModifiedDate().getValue().getYear());
    assertEquals(12, email.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, email.getLastModifiedDate().getValue().getDay());
    assertNotNull(email.getSource());
    assertEquals("8888-8888-8888-8880", email.retrieveSourcePath());
    assertNotNull(person.getAddresses());
    assertNotNull(person.getAddresses().getAddress());
    assertEquals(1, person.getAddresses().getAddress().size());
    Address address = person.getAddresses().getAddress().get(0);
    assertEquals(Visibility.PUBLIC, address.getVisibility());
    assertEquals(Long.valueOf(1), address.getPutCode());
    assertNotNull(address.getCountry());
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertNotNull(address.getCreatedDate());
    assertNotNull(address.getCreatedDate().getValue());
    assertEquals(2001, address.getCreatedDate().getValue().getYear());
    assertEquals(12, address.getCreatedDate().getValue().getMonth());
    assertEquals(31, address.getCreatedDate().getValue().getDay());
    assertNotNull(address.getLastModifiedDate());
    assertNotNull(address.getLastModifiedDate().getValue());
    assertEquals(2001, address.getLastModifiedDate().getValue().getYear());
    assertEquals(12, address.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, address.getLastModifiedDate().getValue().getDay());
    assertNotNull(address.getSource());
    assertEquals("8888-8888-8888-8880", address.getSource().retrieveSourcePath());
    assertNotNull(person.getKeywords());
    assertNotNull(person.getKeywords().getKeywords());
    assertEquals(1, person.getKeywords().getKeywords().size());
    Keyword keyword = person.getKeywords().getKeywords().get(0);
    assertEquals(Visibility.PUBLIC, keyword.getVisibility());
    assertEquals(Long.valueOf(1), keyword.getPutCode());
    assertEquals("keyword1", keyword.getContent());
    assertNotNull(keyword.getCreatedDate());
    assertNotNull(keyword.getCreatedDate().getValue());
    assertEquals(2001, keyword.getCreatedDate().getValue().getYear());
    assertEquals(12, keyword.getCreatedDate().getValue().getMonth());
    assertEquals(31, keyword.getCreatedDate().getValue().getDay());
    assertNotNull(keyword.getLastModifiedDate());
    assertNotNull(keyword.getLastModifiedDate().getValue());
    assertEquals(2001, keyword.getLastModifiedDate().getValue().getYear());
    assertEquals(12, keyword.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, keyword.getLastModifiedDate().getValue().getDay());
    assertNotNull(keyword.getSource());
    assertEquals("8888-8888-8888-8880", keyword.getSource().retrieveSourcePath());
    assertNotNull(person.getExternalIdentifiers());
    assertNotNull(person.getExternalIdentifiers().getExternalIdentifiers());
    assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
    PersonExternalIdentifier extId = person.getExternalIdentifiers().getExternalIdentifiers().get(0);
    assertEquals(Visibility.PUBLIC, extId.getVisibility());
    assertEquals(Long.valueOf(1), extId.getPutCode());
    assertEquals("type-1", extId.getType());
    assertEquals("value-1", extId.getValue());
    assertNotNull(extId.getUrl());
    assertEquals("http://url.com/1", extId.getUrl().getValue());
    assertNotNull(extId.getCreatedDate());
    assertNotNull(extId.getCreatedDate().getValue());
    assertEquals(2001, extId.getCreatedDate().getValue().getYear());
    assertEquals(12, extId.getCreatedDate().getValue().getMonth());
    assertEquals(31, extId.getCreatedDate().getValue().getDay());
    assertNotNull(extId.getLastModifiedDate());
    assertNotNull(extId.getLastModifiedDate().getValue());
    assertEquals(2001, extId.getLastModifiedDate().getValue().getYear());
    assertEquals(12, extId.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, extId.getLastModifiedDate().getValue().getDay());
    assertNotNull(extId.getSource());
    assertEquals("8888-8888-8888-8880", extId.getSource().retrieveSourcePath());
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) Address(org.orcid.jaxb.model.record_v2.Address) Keyword(org.orcid.jaxb.model.record_v2.Keyword) OtherName(org.orcid.jaxb.model.record_v2.OtherName) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) Person(org.orcid.jaxb.model.record_v2.Person) Test(org.junit.Test)

Example 22 with OtherName

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

the class ValidateV2_1SamplesTest method testUnmarshallOtherNames.

@Test
public void testUnmarshallOtherNames() throws SAXException, URISyntaxException {
    OtherNames otherNames = (OtherNames) unmarshallFromPath("/record_2.1/samples/read_samples/other-names-2.1.xml", OtherNames.class, "/record_2.1/personal-details-2.1.xsd");
    assertNotNull(otherNames);
    assertNotNull(otherNames.getOtherNames());
    assertEquals(2, otherNames.getOtherNames().size());
    for (OtherName otherName : otherNames.getOtherNames()) {
        assertThat(otherName.getContent(), anyOf(is("Other Name #1"), is("Other Name #2")));
        assertThat(otherName.getPutCode(), anyOf(is(1L), is(2L)));
        assertEquals(Visibility.PUBLIC.value(), otherName.getVisibility().value());
        assertNotNull(otherName.getCreatedDate());
        assertNotNull(otherName.getLastModifiedDate());
        assertNotNull(otherName.getSource());
        validateSourceInHttps(otherName.getSource());
        assertEquals("8888-8888-8888-8880", otherName.getSource().retrieveSourcePath());
    }
    OtherName otherName = (OtherName) unmarshallFromPath("/record_2.1/samples/read_samples/other-name-2.1.xml", OtherName.class);
    assertNotNull(otherName);
    assertEquals("Other Name #1", otherName.getContent());
    assertEquals(Long.valueOf(1), otherName.getPutCode());
    assertEquals(Visibility.PUBLIC.value(), otherName.getVisibility().value());
    assertNotNull(otherName.getCreatedDate());
    assertNotNull(otherName.getLastModifiedDate());
    assertNotNull(otherName.getSource());
    validateSourceInHttps(otherName.getSource());
    assertEquals("8888-8888-8888-8880", otherName.getSource().retrieveSourcePath());
}
Also used : OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Test(org.junit.Test)

Example 23 with OtherName

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

the class MemberV2ApiServiceDelegator_GeneralTest method testOrcidProfileCreate_CAN_CRUDOnUnclaimedAccounts.

@Test
public void testOrcidProfileCreate_CAN_CRUDOnUnclaimedAccounts() {
    String orcid = "0000-0000-0000-0001";
    SecurityContextTestUtils.setUpSecurityContextForClientOnly();
    // Test address
    Response response = serviceDelegator.createAddress(orcid, Utils.getAddress());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    Long putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewAddress(orcid, putCode);
    assertNotNull(response);
    Address address = (Address) response.getEntity();
    assertNotNull(address);
    address.getCountry().setValue(Iso3166Country.ZW);
    response = serviceDelegator.updateAddress(orcid, putCode, address);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteAddress(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test education
    response = serviceDelegator.createEducation(orcid, Utils.getEducation());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewEducation(orcid, putCode);
    assertNotNull(response);
    Education education = (Education) response.getEntity();
    assertNotNull(education);
    education.setDepartmentName("Updated department name");
    response = serviceDelegator.updateEducation(orcid, putCode, education);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteAffiliation(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test employment
    response = serviceDelegator.createEmployment(orcid, Utils.getEmployment());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewEmployment(orcid, putCode);
    assertNotNull(response);
    Employment employment = (Employment) response.getEntity();
    assertNotNull(employment);
    employment.setDepartmentName("Updated department name");
    response = serviceDelegator.updateEmployment(orcid, putCode, employment);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteAffiliation(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test external identifiers
    response = serviceDelegator.createExternalIdentifier(orcid, Utils.getPersonExternalIdentifier());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewExternalIdentifier(orcid, putCode);
    assertNotNull(response);
    PersonExternalIdentifier externalIdentifier = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(externalIdentifier);
    response = serviceDelegator.updateExternalIdentifier(orcid, putCode, externalIdentifier);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteExternalIdentifier(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test funding
    response = serviceDelegator.createFunding(orcid, Utils.getFunding());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewFunding(orcid, putCode);
    assertNotNull(response);
    Funding funding = (Funding) response.getEntity();
    assertNotNull(funding);
    response = serviceDelegator.updateFunding(orcid, putCode, funding);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteFunding(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test keyword
    response = serviceDelegator.createKeyword(orcid, Utils.getKeyword());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewKeyword(orcid, putCode);
    assertNotNull(response);
    Keyword keyword = (Keyword) response.getEntity();
    assertNotNull(keyword);
    response = serviceDelegator.updateKeyword(orcid, putCode, keyword);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteKeyword(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test other names
    response = serviceDelegator.createOtherName(orcid, Utils.getOtherName());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewOtherName(orcid, putCode);
    assertNotNull(response);
    OtherName otherName = (OtherName) response.getEntity();
    assertNotNull(otherName);
    response = serviceDelegator.updateOtherName(orcid, putCode, otherName);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteOtherName(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test peer review
    response = serviceDelegator.createPeerReview(orcid, Utils.getPeerReview());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewPeerReview(orcid, putCode);
    assertNotNull(response);
    PeerReview peerReview = (PeerReview) response.getEntity();
    assertNotNull(peerReview);
    response = serviceDelegator.updatePeerReview(orcid, putCode, peerReview);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deletePeerReview(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test researcher url
    response = serviceDelegator.createResearcherUrl(orcid, Utils.getResearcherUrl());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewResearcherUrl(orcid, putCode);
    assertNotNull(response);
    ResearcherUrl rUrl = (ResearcherUrl) response.getEntity();
    assertNotNull(rUrl);
    response = serviceDelegator.updateResearcherUrl(orcid, putCode, rUrl);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteResearcherUrl(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test work
    response = serviceDelegator.createWork(orcid, Utils.getWork("work # 1 " + System.currentTimeMillis()));
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewWork(orcid, putCode);
    assertNotNull(response);
    Work work = (Work) response.getEntity();
    assertNotNull(work);
    response = serviceDelegator.updateWork(orcid, putCode, work);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteWork(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
}
Also used : Address(org.orcid.jaxb.model.record_v2.Address) Keyword(org.orcid.jaxb.model.record_v2.Keyword) Funding(org.orcid.jaxb.model.record_v2.Funding) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) Response(javax.ws.rs.core.Response) Education(org.orcid.jaxb.model.record_v2.Education) Employment(org.orcid.jaxb.model.record_v2.Employment) Work(org.orcid.jaxb.model.record_v2.Work) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 24 with OtherName

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

the class MemberV2ApiServiceDelegator_GeneralTest method testOrcidProfileCreate_CANT_UpdateOnClaimedAccounts.

@Test
public void testOrcidProfileCreate_CANT_UpdateOnClaimedAccounts() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewAddress(ORCID, 9L);
    assertNotNull(response);
    Address a = (Address) response.getEntity();
    assertNotNull(a);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateAddress(ORCID, a.getPutCode(), a);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewEducation(ORCID, 20L);
    assertNotNull(response);
    Education edu = (Education) response.getEntity();
    assertNotNull(edu);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateEducation(ORCID, edu.getPutCode(), edu);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewEmployment(ORCID, 17L);
    assertNotNull(response);
    Employment emp = (Employment) response.getEntity();
    assertNotNull(emp);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateEmployment(ORCID, emp.getPutCode(), emp);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewExternalIdentifier(ORCID, 13L);
    assertNotNull(response);
    PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(extId);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateExternalIdentifier(ORCID, extId.getPutCode(), extId);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewFunding(ORCID, 10L);
    assertNotNull(response);
    Funding f = (Funding) response.getEntity();
    assertNotNull(f);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateFunding(ORCID, f.getPutCode(), f);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewKeyword(ORCID, 9L);
    assertNotNull(response);
    Keyword k = (Keyword) response.getEntity();
    assertNotNull(k);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateKeyword(ORCID, k.getPutCode(), k);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewOtherName(ORCID, 13L);
    assertNotNull(response);
    OtherName o = (OtherName) response.getEntity();
    assertNotNull(o);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateOtherName(ORCID, o.getPutCode(), o);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewPeerReview(ORCID, 9L);
    assertNotNull(response);
    PeerReview p = (PeerReview) response.getEntity();
    assertNotNull(p);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updatePeerReview(ORCID, p.getPutCode(), p);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewResearcherUrl(ORCID, 13L);
    assertNotNull(response);
    ResearcherUrl r = (ResearcherUrl) response.getEntity();
    assertNotNull(r);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateResearcherUrl(ORCID, r.getPutCode(), r);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewWork(ORCID, 11L);
    assertNotNull(response);
    Work w = (Work) response.getEntity();
    assertNotNull(w);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateWork(ORCID, w.getPutCode(), w);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
}
Also used : Response(javax.ws.rs.core.Response) Address(org.orcid.jaxb.model.record_v2.Address) Keyword(org.orcid.jaxb.model.record_v2.Keyword) Education(org.orcid.jaxb.model.record_v2.Education) Employment(org.orcid.jaxb.model.record_v2.Employment) Funding(org.orcid.jaxb.model.record_v2.Funding) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Work(org.orcid.jaxb.model.record_v2.Work) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 25 with OtherName

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

the class MemberV2ApiServiceDelegator_OtherNamesTest method testViewOtherNameReadPublic.

@Test
public void testViewOtherNameReadPublic() {
    SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewOtherName(ORCID, 13L);
    OtherName element = (OtherName) r.getEntity();
    assertNotNull(element);
    assertEquals("/0000-0000-0000-0003/other-names/13", element.getPath());
    Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
Also used : Response(javax.ws.rs.core.Response) OtherName(org.orcid.jaxb.model.record_v2.OtherName) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

OtherName (org.orcid.jaxb.model.record_v2.OtherName)110 Test (org.junit.Test)98 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)55 Biography (org.orcid.jaxb.model.record_v2.Biography)44 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)44 Name (org.orcid.jaxb.model.record_v2.Name)43 Address (org.orcid.jaxb.model.record_v2.Address)42 Keyword (org.orcid.jaxb.model.record_v2.Keyword)40 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)40 Email (org.orcid.jaxb.model.record_v2.Email)38 Addresses (org.orcid.jaxb.model.record_v2.Addresses)33 Emails (org.orcid.jaxb.model.record_v2.Emails)33 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)33 Keywords (org.orcid.jaxb.model.record_v2.Keywords)32 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)32 Person (org.orcid.jaxb.model.record_v2.Person)31 ArrayList (java.util.ArrayList)21 Response (javax.ws.rs.core.Response)20 DBUnitTest (org.orcid.test.DBUnitTest)20 Record (org.orcid.jaxb.model.record_v2.Record)19