Search in sources :

Example 81 with Address

use of org.orcid.jaxb.model.record_v2.Address in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorTest method testViewAddress.

@Test
public void testViewAddress() {
    Response response = serviceDelegator.viewAddress(ORCID, 9L);
    assertNotNull(response);
    Address address = (Address) response.getEntity();
    assertNotNull(address);
    assertNotNull(address.getLastModifiedDate());
    assertNotNull(address.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(9), address.getPutCode());
    assertNotNull(address.getCountry());
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertEquals(Visibility.PUBLIC.value(), address.getVisibility().value());
    assertEquals("/0000-0000-0000-0003/address/9", address.getPath());
    assertEquals("APP-5555555555555555", address.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) Address(org.orcid.jaxb.model.record_v2.Address) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 82 with Address

use of org.orcid.jaxb.model.record_v2.Address in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorTest method testGetPublicAddressUsingToken.

// Address
@Test
public void testGetPublicAddressUsingToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewAddress(ORCID, 9L);
    assertNotNull(r);
    Address a = (Address) r.getEntity();
    assertNotNull(a);
    assertNotNull(a.getLastModifiedDate());
    assertNotNull(a.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(9), a.getPutCode());
}
Also used : Response(javax.ws.rs.core.Response) Address(org.orcid.jaxb.model.record_v2.Address) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 83 with Address

use of org.orcid.jaxb.model.record_v2.Address in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_AddressesTest method testAddAddress.

@Test
public void testAddAddress() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.createAddress("4444-4444-4444-4442", Utils.getAddress());
    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.viewAddress("4444-4444-4444-4442", putCode);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    Address newAddress = (Address) response.getEntity();
    assertNotNull(newAddress);
    Utils.verifyLastModified(newAddress.getLastModifiedDate());
    assertEquals(Iso3166Country.ES, newAddress.getCountry().getValue());
    assertEquals(Visibility.LIMITED, newAddress.getVisibility());
    assertNotNull(newAddress.getSource());
    assertEquals("APP-5555555555555555", newAddress.getSource().retrieveSourcePath());
    assertNotNull(newAddress.getCreatedDate());
    Utils.verifyLastModified(newAddress.getLastModifiedDate());
    // Remove it
    response = serviceDelegator.deleteAddress("4444-4444-4444-4442", putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) Address(org.orcid.jaxb.model.record_v2.Address) List(java.util.List) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 84 with Address

use of org.orcid.jaxb.model.record_v2.Address in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_AddressesTest method testViewPublicAddress.

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

Example 85 with Address

use of org.orcid.jaxb.model.record_v2.Address in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_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.common_v2.LastModifiedDate) Address(org.orcid.jaxb.model.record_v2.Address) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)90 Address (org.orcid.jaxb.model.record_v2.Address)84 Addresses (org.orcid.jaxb.model.record_v2.Addresses)48 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)47 OtherName (org.orcid.jaxb.model.record_v2.OtherName)46 Keyword (org.orcid.jaxb.model.record_v2.Keyword)44 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)44 Email (org.orcid.jaxb.model.record_v2.Email)43 Biography (org.orcid.jaxb.model.record_v2.Biography)36 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)36 Keywords (org.orcid.jaxb.model.record_v2.Keywords)34 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)34 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)34 Emails (org.orcid.jaxb.model.record_v2.Emails)32 Name (org.orcid.jaxb.model.record_v2.Name)31 Person (org.orcid.jaxb.model.record_v2.Person)30 DBUnitTest (org.orcid.test.DBUnitTest)21 Response (javax.ws.rs.core.Response)19 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)19 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)18