use of org.orcid.jaxb.model.record_rc2.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());
}
use of org.orcid.jaxb.model.record_rc2.Addresses in project ORCID-Source by ORCID.
the class ManageProfileController method getProfileCountryJson.
@RequestMapping(value = "/countryForm.json", method = RequestMethod.GET)
@ResponseBody
public AddressesForm getProfileCountryJson(HttpServletRequest request) throws NoSuchRequestHandlingMethodException {
long lastModifiedTime = profileEntityManager.getLastModified(getCurrentUserOrcid());
Addresses addresses = addressManager.getAddresses(getCurrentUserOrcid(), lastModifiedTime);
AddressesForm form = AddressesForm.valueOf(addresses);
// Set country name
if (form != null && form.getAddresses() != null) {
Map<String, String> countries = retrieveIsoCountries();
for (AddressForm addressForm : form.getAddresses()) {
addressForm.setCountryName(countries.get(addressForm.getIso2Country().getValue().name()));
}
}
ProfileEntity profile = profileEntityCacheManager.retrieve(getCurrentUserOrcid());
// Set the default visibility
if (profile.getActivitiesVisibilityDefault() != null) {
form.setVisibility(org.orcid.pojo.ajaxForm.Visibility.valueOf(profile.getActivitiesVisibilityDefault()));
}
// Return an empty country in case we dont have any
if (form.getAddresses() == null) {
form.setAddresses(new ArrayList<AddressForm>());
}
if (form.getAddresses().isEmpty()) {
AddressForm address = new AddressForm();
address.setDisplayIndex(1L);
address.setVisibility(org.orcid.pojo.ajaxForm.Visibility.valueOf(profile.getActivitiesVisibilityDefault()));
form.getAddresses().add(address);
}
return form;
}
use of org.orcid.jaxb.model.record_rc2.Addresses in project ORCID-Source by ORCID.
the class AddressManagerTest method getPublicTest.
@Test
public void getPublicTest() {
String orcid = "0000-0000-0000-0003";
Addresses elements = addressManager.getPublicAddresses(orcid, System.currentTimeMillis());
assertNotNull(elements);
assertNotNull(elements.getAddress());
assertEquals(1, elements.getAddress().size());
assertEquals(Long.valueOf(9), elements.getAddress().get(0).getPutCode());
}
use of org.orcid.jaxb.model.record_rc2.Addresses in project ORCID-Source by ORCID.
the class ValidateV2RC2SamplesTest method testUnmarshallAddress.
@Test
public void testUnmarshallAddress() throws SAXException, URISyntaxException {
Addresses addresses = (Addresses) unmarshallFromPath("/record_2.0_rc2/samples/addresses-2.0_rc2.xml", Addresses.class, "/record_2.0_rc2/address-2.0_rc2.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_rc2/samples/address-2.0_rc2.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());
}
use of org.orcid.jaxb.model.record_rc2.Addresses in project ORCID-Source by ORCID.
the class ValidateV2_1SamplesTest method testUnmarshallAddress.
@Test
public void testUnmarshallAddress() throws SAXException, URISyntaxException {
Addresses addresses = (Addresses) unmarshallFromPath("/record_2.1/samples/read_samples/addresses-2.1.xml", Addresses.class, "/record_2.1/address-2.1.xsd");
assertNotNull(addresses);
assertNotNull(addresses.getAddress());
assertEquals(2, addresses.getAddress().size());
for (Address address : addresses.getAddress()) {
validateSourceInHttps(address.getSource());
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.1/samples/read_samples/address-2.1.xml", Address.class);
assertNotNull(address);
assertNotNull(address.getPutCode());
assertNotNull(address.getCreatedDate());
assertNotNull(address.getLastModifiedDate());
assertNotNull(address.getCountry());
validateSourceInHttps(address.getSource());
assertEquals(Iso3166Country.US, address.getCountry().getValue());
assertEquals(Visibility.PUBLIC, address.getVisibility());
}
Aggregations