use of org.orcid.jaxb.model.record_rc4.Address in project ORCID-Source by ORCID.
the class ValidateV2_1SamplesTest method unmarshallFromPath.
private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
Object obj = unmarshall(reader, type, schemaPath);
Object result = null;
if (ResearcherUrls.class.equals(type)) {
result = (ResearcherUrls) obj;
} else if (ResearcherUrl.class.equals(type)) {
result = (ResearcherUrl) obj;
} else if (PersonalDetails.class.equals(type)) {
result = (PersonalDetails) obj;
} else if (PersonExternalIdentifier.class.equals(type)) {
result = (PersonExternalIdentifier) obj;
} else if (PersonExternalIdentifiers.class.equals(type)) {
result = (PersonExternalIdentifiers) obj;
} else if (Biography.class.equals(type)) {
result = (Biography) obj;
} else if (Name.class.equals(type)) {
result = (Name) obj;
} else if (CreditName.class.equals(type)) {
result = (CreditName) obj;
} else if (OtherName.class.equals(type)) {
result = (OtherName) obj;
} else if (OtherNames.class.equals(type)) {
result = (OtherNames) obj;
} else if (Keywords.class.equals(type)) {
result = (Keywords) obj;
} else if (Keyword.class.equals(type)) {
result = (Keyword) obj;
} else if (Addresses.class.equals(type)) {
result = (Addresses) obj;
} else if (Address.class.equals(type)) {
result = (Address) obj;
} else if (Emails.class.equals(type)) {
result = (Emails) obj;
} else if (Email.class.equals(type)) {
result = (Email) obj;
} else if (Person.class.equals(type)) {
result = (Person) obj;
} else if (Deprecated.class.equals(type)) {
result = (Deprecated) obj;
} else if (Preferences.class.equals(type)) {
result = (Preferences) obj;
} else if (History.class.equals(type)) {
result = (History) obj;
} else if (Record.class.equals(type)) {
result = (Record) obj;
} else if (ActivitiesSummary.class.equals(type)) {
result = (ActivitiesSummary) obj;
} else if (Works.class.equals(type)) {
result = (Works) obj;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
use of org.orcid.jaxb.model.record_rc4.Address 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());
}
use of org.orcid.jaxb.model.record_rc4.Address 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());
}
}
}
use of org.orcid.jaxb.model.record_rc4.Address 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();
}
}
use of org.orcid.jaxb.model.record_rc4.Address in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_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());
}
Aggregations