use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testMemberCreateOrcidProfileWithVisibilityOnBioSoThatVisibilityIsSetOnBioElements.
@Test
@Transactional
public void testMemberCreateOrcidProfileWithVisibilityOnBioSoThatVisibilityIsSetOnBioElements() {
//Test setting it LIMITED
OrcidProfile profile = createBasicProfile();
String orcidIdentifier = null;
profile.setOrcidIdentifier(orcidIdentifier);
setBio(profile, Visibility.LIMITED);
profile = orcidProfileManager.createOrcidProfile(profile, true, false);
assertNotNull(profile);
assertNotNull(profile.getOrcidIdentifier());
assertNotNull(profile.getOrcidIdentifier().getPath());
OrcidProfile newProfile = orcidProfileManager.retrieveOrcidProfile(profile.getOrcidIdentifier().getPath());
assertNotNull(newProfile);
assertNotNull(newProfile.getOrcidBio());
OrcidBio bio = newProfile.getOrcidBio();
assertEquals(Visibility.LIMITED, bio.getBiography().getVisibility());
assertEquals(Visibility.LIMITED, bio.getContactDetails().getAddress().getCountry().getVisibility());
assertEquals(Visibility.LIMITED, bio.getExternalIdentifiers().getVisibility());
assertEquals(Visibility.LIMITED, bio.getKeywords().getVisibility());
assertEquals(Visibility.LIMITED, bio.getPersonalDetails().getOtherNames().getVisibility());
assertEquals(Visibility.LIMITED, bio.getResearcherUrls().getVisibility());
//Test again setting everything to PUBLIC
profile = createBasicProfile();
orcidIdentifier = null;
profile.setOrcidIdentifier(orcidIdentifier);
setBio(profile, Visibility.PUBLIC);
profile = orcidProfileManager.createOrcidProfile(profile, true, false);
assertNotNull(profile);
assertNotNull(profile.getOrcidIdentifier());
assertNotNull(profile.getOrcidIdentifier().getPath());
newProfile = orcidProfileManager.retrieveOrcidProfile(profile.getOrcidIdentifier().getPath());
assertNotNull(newProfile);
assertNotNull(newProfile.getOrcidBio());
bio = newProfile.getOrcidBio();
assertEquals(Visibility.PUBLIC, bio.getBiography().getVisibility());
assertEquals(Visibility.PUBLIC, bio.getContactDetails().getAddress().getCountry().getVisibility());
assertEquals(Visibility.PUBLIC, bio.getExternalIdentifiers().getVisibility());
assertEquals(Visibility.PUBLIC, bio.getKeywords().getVisibility());
assertEquals(Visibility.PUBLIC, bio.getPersonalDetails().getOtherNames().getVisibility());
assertEquals(Visibility.PUBLIC, bio.getResearcherUrls().getVisibility());
//Test again setting everything to PRIVATE
profile = createBasicProfile();
orcidIdentifier = null;
profile.setOrcidIdentifier(orcidIdentifier);
setBio(profile, Visibility.PRIVATE);
profile = orcidProfileManager.createOrcidProfile(profile, true, false);
assertNotNull(profile);
assertNotNull(profile.getOrcidIdentifier());
assertNotNull(profile.getOrcidIdentifier().getPath());
newProfile = orcidProfileManager.retrieveOrcidProfile(profile.getOrcidIdentifier().getPath());
assertNotNull(newProfile);
assertNotNull(newProfile.getOrcidBio());
bio = newProfile.getOrcidBio();
assertEquals(Visibility.PRIVATE, bio.getBiography().getVisibility());
assertEquals(Visibility.PRIVATE, bio.getContactDetails().getAddress().getCountry().getVisibility());
assertEquals(Visibility.PRIVATE, bio.getExternalIdentifiers().getVisibility());
assertEquals(Visibility.PRIVATE, bio.getKeywords().getVisibility());
assertEquals(Visibility.PRIVATE, bio.getPersonalDetails().getOtherNames().getVisibility());
assertEquals(Visibility.PRIVATE, bio.getResearcherUrls().getVisibility());
//Test again setting different visibility values to each bio section
profile = createBasicProfile();
orcidIdentifier = null;
profile.setOrcidIdentifier(orcidIdentifier);
setBio(profile, Visibility.PRIVATE);
profile.getOrcidBio().getBiography().setVisibility(Visibility.PUBLIC);
profile.getOrcidBio().getContactDetails().getAddress().getCountry().setVisibility(Visibility.LIMITED);
profile.getOrcidBio().getExternalIdentifiers().setVisibility(Visibility.PUBLIC);
profile.getOrcidBio().getKeywords().setVisibility(Visibility.PRIVATE);
profile.getOrcidBio().getPersonalDetails().getOtherNames().setVisibility(Visibility.LIMITED);
profile.getOrcidBio().getResearcherUrls().setVisibility(Visibility.PRIVATE);
profile = orcidProfileManager.createOrcidProfile(profile, true, false);
assertNotNull(profile);
assertNotNull(profile.getOrcidIdentifier());
assertNotNull(profile.getOrcidIdentifier().getPath());
newProfile = orcidProfileManager.retrieveOrcidProfile(profile.getOrcidIdentifier().getPath());
assertNotNull(newProfile);
assertNotNull(newProfile.getOrcidBio());
bio = newProfile.getOrcidBio();
assertEquals(Visibility.PUBLIC, bio.getBiography().getVisibility());
assertEquals(Visibility.PUBLIC, bio.getExternalIdentifiers().getVisibility());
assertEquals(Visibility.LIMITED, bio.getContactDetails().getAddress().getCountry().getVisibility());
assertEquals(Visibility.LIMITED, bio.getPersonalDetails().getOtherNames().getVisibility());
assertEquals(Visibility.PRIVATE, bio.getKeywords().getVisibility());
assertEquals(Visibility.PRIVATE, bio.getResearcherUrls().getVisibility());
}
use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerTest method testCopyUpdatedExternalIdentifiersToExistingPreservingVisibility.
@Test
public void testCopyUpdatedExternalIdentifiersToExistingPreservingVisibility() throws Exception {
OrcidBio protectedOrcidBio = protectedOrcidMessage.getOrcidProfile().getOrcidBio();
OrcidBio publicOrcidBio = publicOrcidMessage.getOrcidProfile().getOrcidBio();
assertNull(publicOrcidBio.getExternalIdentifiers().getVisibility());
assertEquals(Visibility.PUBLIC, protectedOrcidBio.getExternalIdentifiers().getVisibility());
// first time save upgrades null to public
orcidJaxbCopyManager.copyUpdatedExternalIdentifiersToExistingPreservingVisibility(publicOrcidBio, protectedOrcidBio);
assertEquals(Visibility.PUBLIC, publicOrcidBio.getExternalIdentifiers().getVisibility());
assertEquals(Visibility.PUBLIC, protectedOrcidBio.getExternalIdentifiers().getVisibility());
// now changing the updated one propogates change
protectedOrcidBio.getExternalIdentifiers().setVisibility(Visibility.LIMITED);
orcidJaxbCopyManager.copyUpdatedExternalIdentifiersToExistingPreservingVisibility(publicOrcidBio, protectedOrcidBio);
assertEquals(Visibility.LIMITED, publicOrcidBio.getExternalIdentifiers().getVisibility());
assertEquals(Visibility.LIMITED, protectedOrcidBio.getExternalIdentifiers().getVisibility());
// when existing is null - set to the value if existing
publicOrcidBio.getExternalIdentifiers().setVisibility(null);
protectedOrcidBio.getExternalIdentifiers().setVisibility(Visibility.LIMITED);
orcidJaxbCopyManager.copyUpdatedExternalIdentifiersToExistingPreservingVisibility(publicOrcidBio, protectedOrcidBio);
assertEquals(Visibility.LIMITED, publicOrcidBio.getExternalIdentifiers().getVisibility());
assertEquals(Visibility.LIMITED, protectedOrcidBio.getExternalIdentifiers().getVisibility());
// when existing is null - defaults to public and protected update
// ignored?
protectedOrcidBio.getExternalIdentifiers().setVisibility(Visibility.PRIVATE);
orcidJaxbCopyManager.copyUpdatedExternalIdentifiersToExistingPreservingVisibility(publicOrcidBio, protectedOrcidBio);
assertEquals(Visibility.PRIVATE, publicOrcidBio.getExternalIdentifiers().getVisibility());
assertEquals(Visibility.PRIVATE, protectedOrcidBio.getExternalIdentifiers().getVisibility());
}
use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerTest method testUpdatedBiographyToExistingPreservingVisibility.
@Test
public void testUpdatedBiographyToExistingPreservingVisibility() throws Exception {
OrcidBio existingOrcidBioProtected = protectedOrcidMessage.getOrcidProfile().getOrcidBio();
OrcidBio updatedOrcidBioPublic = publicOrcidMessage.getOrcidProfile().getOrcidBio();
assertEquals(Visibility.LIMITED, existingOrcidBioProtected.getBiography().getVisibility());
String existingContent = "Josiah Stinkney Carberry is a fictional professor.";
assertEquals(existingContent, existingOrcidBioProtected.getBiography().getContent().trim());
assertNull(updatedOrcidBioPublic.getBiography().getVisibility());
updatedOrcidBioPublic.setBiography(new Biography("A new bio"));
updatedOrcidBioPublic.getBiography().setVisibility(Visibility.PRIVATE);
orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingOrcidBioProtected, updatedOrcidBioPublic);
// check that changes have propogated
assertEquals(Visibility.PRIVATE, existingOrcidBioProtected.getBiography().getVisibility());
assertEquals("A new bio", existingOrcidBioProtected.getBiography().getContent());
// reset the variable and attempt to override the content and visibility
updatedOrcidBioPublic = publicOrcidMessage.getOrcidProfile().getOrcidBio();
updatedOrcidBioPublic.setBiography(new Biography("A new and impoved bio"));
orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingOrcidBioProtected, updatedOrcidBioPublic);
// check that the old values have been retained
assertEquals(Visibility.PRIVATE, existingOrcidBioProtected.getBiography().getVisibility());
assertEquals("A new bio", existingOrcidBioProtected.getBiography().getContent());
}
use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerTest method testUpdateOtherNamePreservingVisibility.
@Test
public void testUpdateOtherNamePreservingVisibility() throws Exception {
OrcidBio existingOrcidBioProtected = protectedOrcidMessage.getOrcidProfile().getOrcidBio();
OrcidBio updatedOrcidBioPublic = publicOrcidMessage.getOrcidProfile().getOrcidBio();
PersonalDetails existingOrcidPersonalDetails = protectedOrcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails();
PersonalDetails updatedOrcidPersonalDetails = publicOrcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails();
OtherNames existingOtherNames = existingOrcidPersonalDetails.getOtherNames();
assertEquals(Visibility.LIMITED, existingOtherNames.getVisibility());
assertTrue(existingOtherNames.getOtherName().size() == 2);
assertEquals("Josiah S Carberry", existingOtherNames.getOtherName().get(0).getContent());
assertEquals("Josiah Carberry", existingOtherNames.getOtherName().get(1).getContent());
// check content and visibility update updates the content
OtherNames updatedOtherNames = new OtherNames();
updatedOtherNames.getOtherName().clear();
updatedOtherNames.addOtherName("Another 1", null);
updatedOtherNames.addOtherName("Another 2", null);
updatedOtherNames.setVisibility(Visibility.PRIVATE);
updatedOrcidPersonalDetails.setOtherNames(updatedOtherNames);
Address existingContactDetailsAddress = existingOrcidBioProtected.getContactDetails().getAddress();
assertEquals(Iso3166Country.US, existingContactDetailsAddress.getCountry().getValue());
existingContactDetailsAddress.getCountry().setVisibility(Visibility.LIMITED);
Address nullVisibilityContactAddress = new Address();
nullVisibilityContactAddress.setCountry(new Country(Iso3166Country.BM));
nullVisibilityContactAddress.getCountry().setVisibility(null);
updatedOrcidBioPublic.getContactDetails().setAddress(nullVisibilityContactAddress);
orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingOrcidBioProtected, updatedOrcidBioPublic);
existingOtherNames = existingOrcidPersonalDetails.getOtherNames();
assertTrue(existingOtherNames.getOtherName().size() == 2);
assertEquals("Another 1", existingOtherNames.getOtherName().get(0).getContent());
assertEquals("Another 2", existingOtherNames.getOtherName().get(1).getContent());
assertEquals(Visibility.PRIVATE, existingOtherNames.getVisibility());
// check content and visibility update of null
updatedOtherNames = new OtherNames();
updatedOtherNames.getOtherName().clear();
updatedOtherNames.addOtherName("Yet Another 1", null);
updatedOtherNames.addOtherName("Yet Another 2", null);
updatedOtherNames.setVisibility(null);
updatedOrcidPersonalDetails.setOtherNames(updatedOtherNames);
orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingOrcidBioProtected, updatedOrcidBioPublic);
assertEquals(2, existingOrcidBioProtected.getPersonalDetails().getOtherNames().getOtherName().size());
assertEquals("Yet Another 1", existingOrcidBioProtected.getPersonalDetails().getOtherNames().getOtherName().get(0).getContent());
assertEquals("Yet Another 2", existingOrcidBioProtected.getPersonalDetails().getOtherNames().getOtherName().get(1).getContent());
assertEquals(Visibility.PRIVATE, existingOrcidBioProtected.getPersonalDetails().getOtherNames().getVisibility());
existingContactDetailsAddress = existingOrcidBioProtected.getContactDetails().getAddress();
assertEquals(Visibility.LIMITED, existingContactDetailsAddress.getCountry().getVisibility());
assertEquals(Iso3166Country.BM, existingContactDetailsAddress.getCountry().getValue());
}
use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerTest method testUpdatedContactDetailsToExistingPreservingVisibility.
@Test
public void testUpdatedContactDetailsToExistingPreservingVisibility() throws Exception {
when(sourceManager.retrieveSourceOrcid()).thenReturn("APP-0000000000000000");
OrcidBio existingOrcidBioProtected = protectedOrcidMessage.getOrcidProfile().getOrcidBio();
OrcidBio updatedOrcidBioPublic = publicOrcidMessage.getOrcidProfile().getOrcidBio();
ContactDetails existingContactDetails = existingOrcidBioProtected.getContactDetails();
ContactDetails updatedContactDetails = updatedOrcidBioPublic.getContactDetails();
assertEquals("josiah_carberry@brown.edu", existingContactDetails.retrievePrimaryEmail().getValue());
assertEquals(Visibility.LIMITED, existingContactDetails.retrievePrimaryEmail().getVisibility());
String[] alternativeEmails = new String[] { "josiah_carberry_1@brown.edu" };
for (String alternativeEmail : alternativeEmails) {
Email email = existingContactDetails.getEmailByString(alternativeEmail);
assertNotNull(email);
assertEquals(Visibility.LIMITED, email.getVisibility());
}
assertEquals(2, existingContactDetails.getEmail().size());
Address existingAddress = existingContactDetails.getAddress();
assertTrue(Iso3166Country.US.equals(existingAddress.getCountry().getValue()) && existingAddress.getCountry().getVisibility() == null);
Address updatedAddress = new Address();
Country country = new Country(Iso3166Country.GB);
country.setVisibility(Visibility.LIMITED);
updatedAddress.setCountry(country);
updatedOrcidBioPublic.getContactDetails().setAddress(updatedAddress);
List<Email> updatedEmailList = new ArrayList<>();
Email updatedMainEmail = new Email("jimmyb@semantico.com");
updatedMainEmail.setSourceClientId("APP-0000000000000000");
updatedMainEmail.setVisibility(Visibility.PUBLIC);
updatedMainEmail.setPrimary(true);
updatedEmailList.add(updatedMainEmail);
String[] updatedAlternativeEmails = new String[] { "jimmyb1@semantico.com" };
for (String alternativeEmail : updatedAlternativeEmails) {
Email email = new Email(alternativeEmail);
email.setPrimary(false);
email.setVerified(false);
email.setVisibility(Visibility.PRIVATE);
email.setSourceClientId("APP-0000000000000000");
updatedEmailList.add(email);
}
updatedContactDetails.getEmail().clear();
updatedContactDetails.getEmail().addAll(updatedEmailList);
updatedContactDetails.setAddress(updatedAddress);
orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingOrcidBioProtected, updatedOrcidBioPublic);
existingContactDetails = existingOrcidBioProtected.getContactDetails();
assertEquals("josiah_carberry@brown.edu", existingContactDetails.retrievePrimaryEmail().getValue());
assertEquals(Visibility.LIMITED, existingContactDetails.retrievePrimaryEmail().getVisibility());
//Emails remain unchanged
assertEquals(2, existingContactDetails.getEmail().size());
assertEquals(Iso3166Country.GB, existingContactDetails.getAddress().getCountry().getValue());
assertEquals(OrcidVisibilityDefaults.COUNTRY_DEFAULT.getVisibility(), existingContactDetails.getAddress().getCountry().getVisibility());
updatedContactDetails = new ContactDetails();
updatedOrcidBioPublic.setContactDetails(updatedContactDetails);
updatedAddress = new Address();
country = new Country(Iso3166Country.AU);
country.setVisibility(null);
updatedAddress.setCountry(country);
updatedContactDetails.setAddress(updatedAddress);
updatedEmailList = new ArrayList<>();
updatedMainEmail = new Email("jimmyb1@semantico.com");
updatedMainEmail.setVisibility(Visibility.PUBLIC);
updatedEmailList.add(updatedMainEmail);
String[] moreAlternativeEmails = new String[] { "jimmyb3@semantico.com" };
for (String alternativeEmail : moreAlternativeEmails) {
Email email = new Email(alternativeEmail);
email.setPrimary(false);
email.setVisibility(Visibility.PRIVATE);
email.setSourceClientId("APP-0000000000000000");
updatedEmailList.add(email);
}
updatedContactDetails.getEmail().clear();
updatedContactDetails.getEmail().addAll(updatedEmailList);
orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingOrcidBioProtected, updatedOrcidBioPublic);
existingContactDetails = existingOrcidBioProtected.getContactDetails();
//Emails remain unchanged
assertEquals(2, existingContactDetails.getEmail().size());
assertEquals(Iso3166Country.AU, existingContactDetails.getAddress().getCountry().getValue());
}
Aggregations