Search in sources :

Example 91 with Address

use of io.grpc.channelz.v1.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 92 with Address

use of io.grpc.channelz.v1.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 93 with Address

use of io.grpc.channelz.v1.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 94 with Address

use of io.grpc.channelz.v1.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)

Example 95 with Address

use of io.grpc.channelz.v1.Address in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_AddressesTest method testViewAddressReadPublic.

@Test
public void testViewAddressReadPublic() {
    SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewAddress(ORCID, 9L);
    Address element = (Address) r.getEntity();
    assertNotNull(element);
    assertEquals("/0000-0000-0000-0003/address/9", element.getPath());
    Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
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)

Aggregations

Test (org.junit.Test)86 Address (org.orcid.jaxb.model.record_v2.Address)82 Addresses (org.orcid.jaxb.model.record_v2.Addresses)43 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)43 Keyword (org.orcid.jaxb.model.record_v2.Keyword)42 OtherName (org.orcid.jaxb.model.record_v2.OtherName)42 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)42 Email (org.orcid.jaxb.model.record_v2.Email)41 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)35 Biography (org.orcid.jaxb.model.record_v2.Biography)34 Emails (org.orcid.jaxb.model.record_v2.Emails)34 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 Name (org.orcid.jaxb.model.record_v2.Name)31 Person (org.orcid.jaxb.model.record_v2.Person)31 Record (org.orcid.jaxb.model.record_v2.Record)19 Response (javax.ws.rs.core.Response)18 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)18 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)18