Search in sources :

Example 21 with Addresses

use of org.orcid.jaxb.model.record_rc4.Addresses in project ORCID-Source by ORCID.

the class ValidateV2RC4SamplesTest method testUnmarshallAddress.

@Test
public void testUnmarshallAddress() throws SAXException, URISyntaxException {
    Addresses addresses = (Addresses) unmarshallFromPath("/record_2.0_rc4/samples/addresses-2.0_rc4.xml", Addresses.class, "/record_2.0_rc4/address-2.0_rc4.xsd");
    assertNotNull(addresses);
    assertNotNull(addresses.getAddress());
    assertEquals(2, addresses.getAddress().size());
    for (Address address : addresses.getAddress()) {
        assertNotNull(address.getPutCode());
        assertNotNull(address.getCreatedDate());
        assertNotNull(address.getLastModifiedDate());
        assertNotNull(address.getCountry());
        if (address.getPutCode().equals(new Long(1))) {
            assertEquals(Iso3166Country.US, address.getCountry().getValue());
            assertEquals(Visibility.PUBLIC, address.getVisibility());
        } else {
            assertEquals(Iso3166Country.CR, address.getCountry().getValue());
            assertEquals(Visibility.LIMITED, address.getVisibility());
        }
    }
    Address address = (Address) unmarshallFromPath("/record_2.0_rc4/samples/address-2.0_rc4.xml", Address.class);
    assertNotNull(address);
    assertNotNull(address.getPutCode());
    assertNotNull(address.getCreatedDate());
    assertNotNull(address.getLastModifiedDate());
    assertNotNull(address.getCountry());
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertEquals(Visibility.PUBLIC, address.getVisibility());
}
Also used : Addresses(org.orcid.jaxb.model.record_rc4.Addresses) Address(org.orcid.jaxb.model.record_rc4.Address) Test(org.junit.Test)

Example 22 with Addresses

use of org.orcid.jaxb.model.record_rc4.Addresses in project ORCID-Source by ORCID.

the class ValidateV2RC4SamplesTest method testMarshallAddress.

@Test
public void testMarshallAddress() throws JAXBException, SAXException, URISyntaxException {
    Addresses object = (Addresses) unmarshallFromPath("/record_2.0_rc4/samples/addresses-2.0_rc4.xml", Addresses.class);
    marshall(object, "/record_2.0_rc4/address-2.0_rc4.xsd");
}
Also used : Addresses(org.orcid.jaxb.model.record_rc4.Addresses) Test(org.junit.Test)

Example 23 with Addresses

use of org.orcid.jaxb.model.record_rc4.Addresses in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorTest method testViewAddresses.

@Test
public void testViewAddresses() {
    Response response = serviceDelegator.viewAddresses(ORCID);
    assertNotNull(response);
    Addresses addresses = (Addresses) response.getEntity();
    assertNotNull(addresses);
    assertNotNull(addresses.getLastModifiedDate());
    assertNotNull(addresses.getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/address", addresses.getPath());
    assertEquals(1, addresses.getAddress().size());
    Address address = addresses.getAddress().get(0);
    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) Addresses(org.orcid.jaxb.model.record_v2.Addresses) Address(org.orcid.jaxb.model.record_v2.Address) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 24 with Addresses

use of org.orcid.jaxb.model.record_rc4.Addresses in project ORCID-Source by ORCID.

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

Example 25 with Addresses

use of org.orcid.jaxb.model.record_rc4.Addresses in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_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.record_v2.Addresses) Address(org.orcid.jaxb.model.record_v2.Address) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) NoResultException(javax.persistence.NoResultException) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) OrcidVisibilityException(org.orcid.core.exception.OrcidVisibilityException) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) WrongSourceException(org.orcid.core.exception.WrongSourceException) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)55 Addresses (org.orcid.jaxb.model.record_v2.Addresses)54 Address (org.orcid.jaxb.model.record_v2.Address)43 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)36 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)36 Emails (org.orcid.jaxb.model.record_v2.Emails)35 Keywords (org.orcid.jaxb.model.record_v2.Keywords)35 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)35 Biography (org.orcid.jaxb.model.record_v2.Biography)34 Email (org.orcid.jaxb.model.record_v2.Email)33 OtherName (org.orcid.jaxb.model.record_v2.OtherName)33 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)32 Keyword (org.orcid.jaxb.model.record_v2.Keyword)31 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)31 Name (org.orcid.jaxb.model.record_v2.Name)29 Person (org.orcid.jaxb.model.record_v2.Person)26 Record (org.orcid.jaxb.model.record_v2.Record)16 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)15 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)15 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)15