Search in sources :

Example 1 with LastModifiedDate

use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate 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 LastModifiedDate

use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_DistinctionsTest method testUpdateDistinction.

@Test
public void testUpdateDistinction() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewDistinction(ORCID, 27L);
    assertNotNull(response);
    Distinction distinction = (Distinction) response.getEntity();
    assertNotNull(distinction);
    assertEquals("PUBLIC Department", distinction.getDepartmentName());
    assertEquals("PUBLIC", distinction.getRoleTitle());
    Utils.verifyLastModified(distinction.getLastModifiedDate());
    LastModifiedDate before = distinction.getLastModifiedDate();
    distinction.setDepartmentName("Updated department name");
    distinction.setRoleTitle("The updated role title");
    // disambiguated org is required in API v3
    DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
    disambiguatedOrg.setDisambiguatedOrganizationIdentifier("abc456");
    disambiguatedOrg.setDisambiguationSource("WDB");
    distinction.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
    response = serviceDelegator.updateDistinction(ORCID, 27L, distinction);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewDistinction(ORCID, 27L);
    assertNotNull(response);
    distinction = (Distinction) response.getEntity();
    assertNotNull(distinction);
    Utils.verifyLastModified(distinction.getLastModifiedDate());
    assertTrue(distinction.getLastModifiedDate().after(before));
    assertEquals("Updated department name", distinction.getDepartmentName());
    assertEquals("The updated role title", distinction.getRoleTitle());
    // Rollback changes
    distinction.setDepartmentName("PUBLIC Department");
    distinction.setRoleTitle("PUBLIC");
    response = serviceDelegator.updateDistinction(ORCID, 27L, distinction);
    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) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 3 with LastModifiedDate

use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_EducationsTest method testUpdateEducation.

@Test
public void testUpdateEducation() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewEducation(ORCID, 20L);
    assertNotNull(response);
    Education education = (Education) response.getEntity();
    assertNotNull(education);
    assertEquals("PUBLIC Department", education.getDepartmentName());
    assertEquals("PUBLIC", education.getRoleTitle());
    Utils.verifyLastModified(education.getLastModifiedDate());
    LastModifiedDate before = education.getLastModifiedDate();
    education.setDepartmentName("Updated department name");
    education.setRoleTitle("The updated role title");
    // disambiguated org is required in API v3
    DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
    disambiguatedOrg.setDisambiguatedOrganizationIdentifier("abc456");
    disambiguatedOrg.setDisambiguationSource("WDB");
    education.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
    response = serviceDelegator.updateEducation(ORCID, 20L, education);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewEducation(ORCID, 20L);
    assertNotNull(response);
    education = (Education) response.getEntity();
    assertNotNull(education);
    Utils.verifyLastModified(education.getLastModifiedDate());
    assertTrue(education.getLastModifiedDate().after(before));
    assertEquals("Updated department name", education.getDepartmentName());
    assertEquals("The updated role title", education.getRoleTitle());
    // Rollback changes
    education.setDepartmentName("PUBLIC Department");
    education.setRoleTitle("PUBLIC");
    response = serviceDelegator.updateEducation(ORCID, 20L, education);
    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) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) Education(org.orcid.jaxb.model.v3.dev1.record.Education) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 4 with LastModifiedDate

use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_EmploymentsTest method testUpdateEmployment.

@Test
public void testUpdateEmployment() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewEmployment(ORCID, 18L);
    assertNotNull(response);
    Employment employment = (Employment) response.getEntity();
    assertNotNull(employment);
    assertEquals("LIMITED Department", employment.getDepartmentName());
    assertEquals("LIMITED", employment.getRoleTitle());
    Utils.verifyLastModified(employment.getLastModifiedDate());
    LastModifiedDate before = employment.getLastModifiedDate();
    employment.setDepartmentName("Updated department name");
    employment.setRoleTitle("The updated role title");
    // disambiguated org is required in API v3
    DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
    disambiguatedOrg.setDisambiguatedOrganizationIdentifier("abc456");
    disambiguatedOrg.setDisambiguationSource("WDB");
    employment.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
    response = serviceDelegator.updateEmployment(ORCID, 18L, employment);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewEmployment(ORCID, 18L);
    assertNotNull(response);
    employment = (Employment) response.getEntity();
    assertNotNull(employment);
    Utils.verifyLastModified(employment.getLastModifiedDate());
    assertTrue(employment.getLastModifiedDate().after(before));
    assertEquals("Updated department name", employment.getDepartmentName());
    assertEquals("The updated role title", employment.getRoleTitle());
    // Rollback changes
    employment.setDepartmentName("LIMITED Department");
    employment.setRoleTitle("LIMITED");
    response = serviceDelegator.updateEmployment(ORCID, 18L, employment);
    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) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 5 with LastModifiedDate

use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_ExternalIdentifiersTest method testUpdateExternalIdentifier.

@Test
public void testUpdateExternalIdentifier() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewExternalIdentifier("4444-4444-4444-4442", 2L);
    assertNotNull(response);
    PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(extId);
    Utils.verifyLastModified(extId.getLastModifiedDate());
    LastModifiedDate before = extId.getLastModifiedDate();
    assertEquals("Facebook", extId.getType());
    assertEquals("abc123", extId.getValue());
    assertNotNull(extId.getUrl());
    assertEquals("http://www.facebook.com/abc123", extId.getUrl().getValue());
    extId.setType("updated-common-name");
    extId.setValue("updated-reference");
    extId.setUrl(new Url("http://updatedUrl.com"));
    response = serviceDelegator.updateExternalIdentifier("4444-4444-4444-4442", 2L, extId);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewExternalIdentifier("4444-4444-4444-4442", 2L);
    assertNotNull(response);
    PersonExternalIdentifier updatedExtId = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(updatedExtId);
    Utils.verifyLastModified(updatedExtId.getLastModifiedDate());
    assertTrue(updatedExtId.getLastModifiedDate().after(before));
    assertEquals("updated-common-name", updatedExtId.getType());
    assertEquals("updated-reference", updatedExtId.getValue());
    assertNotNull(updatedExtId.getUrl());
    assertEquals("http://updatedUrl.com", updatedExtId.getUrl().getValue());
    // Revert changes so other tests still works
    extId.setType("Facebook");
    extId.setValue("abc123");
    extId.setUrl(new Url("http://www.facebook.com/abc123"));
    response = serviceDelegator.updateExternalIdentifier("4444-4444-4444-4442", 2L, extId);
    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) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Url(org.orcid.jaxb.model.v3.dev1.common.Url) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

LastModifiedDate (org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate)45 Test (org.junit.Test)18 DBUnitTest (org.orcid.test.DBUnitTest)17 Response (javax.ws.rs.core.Response)15 CreatedDate (org.orcid.jaxb.model.v3.dev1.common.CreatedDate)8 DisambiguatedOrganization (org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization)7 Url (org.orcid.jaxb.model.v3.dev1.common.Url)5 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)5 ArrayList (java.util.ArrayList)4 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)4 FuzzyDate (org.orcid.jaxb.model.v3.dev1.common.FuzzyDate)3 PublicationDate (org.orcid.jaxb.model.v3.dev1.common.PublicationDate)3 Title (org.orcid.jaxb.model.v3.dev1.common.Title)3 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)3 Name (org.orcid.jaxb.model.v3.dev1.record.Name)3 WorkGroup (org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup)3 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)3 Works (org.orcid.jaxb.model.v3.dev1.record.summary.Works)3 Date (java.util.Date)2 CreditName (org.orcid.jaxb.model.v3.dev1.common.CreditName)2