Search in sources :

Example 61 with Address

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

the class MemberV3ApiServiceDelegator_AddressesTest method testViewLimitedAddress.

@Test
public void testViewLimitedAddress() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.PERSON_READ_LIMITED);
    Response response = serviceDelegator.viewAddress("4444-4444-4444-4447", 3L);
    assertNotNull(response);
    Address address = (Address) response.getEntity();
    assertNotNull(address);
    assertEquals("/4444-4444-4444-4447/address/3", address.getPath());
    Utils.verifyLastModified(address.getLastModifiedDate());
    assertEquals(Visibility.LIMITED, 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 62 with Address

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

the class MemberV3ApiServiceDelegator_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.v3.dev1.record.Address) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 63 with Address

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

the class MemberV3ApiServiceDelegator_AddressesTest method testViewAddresses.

@Test
public void testViewAddresses() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.PERSON_READ_LIMITED);
    Response response = serviceDelegator.viewAddresses("4444-4444-4444-4447");
    assertNotNull(response);
    Addresses addresses = (Addresses) response.getEntity();
    assertNotNull(addresses);
    assertEquals("/4444-4444-4444-4447/address", addresses.getPath());
    Utils.verifyLastModified(addresses.getLastModifiedDate());
    assertNotNull(addresses.getAddress());
    assertEquals(3, addresses.getAddress().size());
    for (Address address : addresses.getAddress()) {
        Utils.verifyLastModified(address.getLastModifiedDate());
        assertThat(address.getPutCode(), anyOf(is(2L), is(3L), is(4L)));
        assertThat(address.getCountry().getValue(), anyOf(is(Iso3166Country.CR), is(Iso3166Country.US)));
        if (address.getPutCode() == 2L) {
            assertEquals(Visibility.PUBLIC, address.getVisibility());
            assertEquals("4444-4444-4444-4447", address.getSource().retrieveSourcePath());
        } else if (address.getPutCode() == 3L) {
            assertEquals(Visibility.LIMITED, address.getVisibility());
            assertEquals("APP-5555555555555555", address.getSource().retrieveSourcePath());
        } else if (address.getPutCode() == 4L) {
            assertEquals(Visibility.PRIVATE, address.getVisibility());
            assertEquals("APP-5555555555555555", address.getSource().retrieveSourcePath());
        }
    }
}
Also used : Response(javax.ws.rs.core.Response) Addresses(org.orcid.jaxb.model.v3.dev1.record.Addresses) Address(org.orcid.jaxb.model.v3.dev1.record.Address) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 64 with Address

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

the class MemberV3ApiServiceDelegator_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.v3.dev1.record.Address) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 65 with Address

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

the class MemberV3ApiServiceDelegator_AddressesTest method testReadPublicScope_Address.

@Test
public void testReadPublicScope_Address() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    // Public works
    Response r = serviceDelegator.viewAddresses(ORCID);
    assertNotNull(r);
    assertEquals(Addresses.class.getName(), r.getEntity().getClass().getName());
    Addresses a = (Addresses) r.getEntity();
    assertNotNull(a);
    assertEquals("/0000-0000-0000-0003/address", a.getPath());
    Utils.verifyLastModified(a.getLastModifiedDate());
    assertEquals(3, a.getAddress().size());
    boolean found9 = false, found10 = false, found11 = false;
    for (Address address : a.getAddress()) {
        if (address.getPutCode() == 9) {
            found9 = true;
        } else if (address.getPutCode() == 10) {
            found10 = true;
        } else if (address.getPutCode() == 11) {
            found11 = true;
        } else {
            fail("Invalid put code " + address.getPutCode());
        }
    }
    assertTrue(found9);
    assertTrue(found10);
    assertTrue(found11);
    r = serviceDelegator.viewAddress(ORCID, 9L);
    assertNotNull(r);
    assertEquals(Address.class.getName(), r.getEntity().getClass().getName());
    // Limited where am the source should work
    serviceDelegator.viewAddress(ORCID, 10L);
    try {
        // Limited am not the source should fail
        serviceDelegator.viewAddress(ORCID, 12L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    // Private where am the source should work
    serviceDelegator.viewAddress(ORCID, 11L);
    try {
        // Private am not the source should fail
        serviceDelegator.viewAddress(ORCID, 13L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) Addresses(org.orcid.jaxb.model.v3.dev1.record.Addresses) Address(org.orcid.jaxb.model.v3.dev1.record.Address) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) OrcidVisibilityException(org.orcid.core.exception.OrcidVisibilityException) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) 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