Search in sources :

Example 1 with Address

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

the class MemberV3ApiServiceDelegator_AddressesTest method testUpdateAddress.

@Test
public void testUpdateAddress() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewAddress("4444-4444-4444-4442", 1L);
    assertNotNull(response);
    Address address = (Address) response.getEntity();
    assertNotNull(address);
    Utils.verifyLastModified(address.getLastModifiedDate());
    LastModifiedDate before = address.getLastModifiedDate();
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertEquals(Visibility.PUBLIC, address.getVisibility());
    address.getCountry().setValue(Iso3166Country.PA);
    response = serviceDelegator.updateAddress("4444-4444-4444-4442", 1L, address);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewAddress("4444-4444-4444-4442", 1L);
    assertNotNull(response);
    address = (Address) response.getEntity();
    assertNotNull(address);
    Utils.verifyLastModified(address.getLastModifiedDate());
    LastModifiedDate after = address.getLastModifiedDate();
    assertTrue(after.after(before));
    assertEquals(Iso3166Country.PA, address.getCountry().getValue());
    // Set it back to US again
    address.getCountry().setValue(Iso3166Country.US);
    response = serviceDelegator.updateAddress("4444-4444-4444-4442", 1L, address);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewAddress("4444-4444-4444-4442", 1L);
    address = (Address) response.getEntity();
    assertNotNull(address);
    Utils.verifyLastModified(address.getLastModifiedDate());
    assertNotNull(address.getLastModifiedDate());
    assertTrue(address.getLastModifiedDate().after(after));
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertEquals(Visibility.PUBLIC, address.getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) Address(org.orcid.jaxb.model.v3.dev1.record.Address) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 2 with Address

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

the class MemberV3ApiServiceDelegator_AddressesTest method testUpdateAddressLeavingVisibilityNullTest.

@Test
public void testUpdateAddressLeavingVisibilityNullTest() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewAddress("4444-4444-4444-4442", 1L);
    assertNotNull(response);
    Address address = (Address) response.getEntity();
    assertNotNull(address);
    assertEquals(Visibility.PUBLIC, address.getVisibility());
    address.setVisibility(null);
    response = serviceDelegator.updateAddress("4444-4444-4444-4442", 1L, address);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    address = (Address) response.getEntity();
    assertNotNull(address);
    assertEquals(Visibility.PUBLIC, address.getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) Address(org.orcid.jaxb.model.v3.dev1.record.Address) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 3 with Address

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

the class MemberV3ApiServiceDelegator_AddressesTest method testUpdateAddressYouAreNotTheSourceOf.

@Test(expected = WrongSourceException.class)
public void testUpdateAddressYouAreNotTheSourceOf() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewAddress("4444-4444-4444-4447", 2L);
    assertNotNull(response);
    Address address = (Address) response.getEntity();
    assertNotNull(address);
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertEquals(Visibility.PUBLIC, address.getVisibility());
    assertNotNull(address.getSource());
    assertEquals("4444-4444-4444-4447", address.getSource().retrieveSourcePath());
    address.getCountry().setValue(Iso3166Country.BR);
    serviceDelegator.updateAddress("4444-4444-4444-4447", 2L, address);
    fail();
}
Also used : Response(javax.ws.rs.core.Response) Address(org.orcid.jaxb.model.v3.dev1.record.Address) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 4 with Address

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

the class MemberV3ApiServiceDelegator_AddressesTest method testViewPrivateAddress.

@Test
public void testViewPrivateAddress() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.PERSON_READ_LIMITED);
    Response response = serviceDelegator.viewAddress("4444-4444-4444-4447", 4L);
    assertNotNull(response);
    Address address = (Address) response.getEntity();
    assertNotNull(address);
    assertEquals("/4444-4444-4444-4447/address/4", address.getPath());
    Utils.verifyLastModified(address.getLastModifiedDate());
    assertEquals(Visibility.PRIVATE, address.getVisibility());
    assertEquals("APP-5555555555555555", address.getSource().retrieveSourcePath());
    assertEquals(Iso3166Country.CR, address.getCountry().getValue());
}
Also used : Response(javax.ws.rs.core.Response) Address(org.orcid.jaxb.model.v3.dev1.record.Address) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 5 with Address

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

the class MemberV3ApiServiceDelegator_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
    Education education = (Education) Utils.getAffiliation(AffiliationType.EDUCATION);
    response = serviceDelegator.createEducation(orcid, education);
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewEducation(orcid, putCode);
    assertNotNull(response);
    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, (Employment) Utils.getAffiliation(AffiliationType.EMPLOYMENT));
    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.v3.dev1.record.Address) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) Response(javax.ws.rs.core.Response) Education(org.orcid.jaxb.model.v3.dev1.record.Education) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) Work(org.orcid.jaxb.model.v3.dev1.record.Work) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Address (org.orcid.jaxb.model.v3.dev1.record.Address)77 Test (org.junit.Test)59 Addresses (org.orcid.jaxb.model.v3.dev1.record.Addresses)44 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)39 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)39 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)38 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)38 Email (org.orcid.jaxb.model.v3.dev1.record.Email)37 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)33 OtherNames (org.orcid.jaxb.model.v3.dev1.record.OtherNames)33 Keywords (org.orcid.jaxb.model.v3.dev1.record.Keywords)32 PersonExternalIdentifiers (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers)32 ResearcherUrls (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls)32 Emails (org.orcid.jaxb.model.v3.dev1.record.Emails)30 Person (org.orcid.jaxb.model.v3.dev1.record.Person)28 Name (org.orcid.jaxb.model.v3.dev1.record.Name)27 DBUnitTest (org.orcid.test.DBUnitTest)21 Response (javax.ws.rs.core.Response)19 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)16 Record (org.orcid.jaxb.model.v3.dev1.record.Record)15