use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.
the class RegistrationManagerImplTest method testCreateMinimalRegistrationWithExistingEmailAdditionalThatCanBeAutoDeprecated.
@Test
public void testCreateMinimalRegistrationWithExistingEmailAdditionalThatCanBeAutoDeprecated() {
// Create the user, but set it as unclaimed
String email = "new_user_" + System.currentTimeMillis() + "@test.orcid.org";
// Create a record by a member
OrcidProfile orcidProfile = createBasicProfile(email, false, CLIENT_ID_AUTODEPRECATE_ENABLED);
orcidProfile = orcidProfileManager.createOrcidProfile(orcidProfile, true, true);
assertNotNull(orcidProfile);
assertNotNull(orcidProfile.getOrcidIdentifier());
assertNotNull(orcidProfile.getOrcidIdentifier().getPath());
String orcidBefore = orcidProfile.getOrcidIdentifier().getPath();
Map<String, String> map1 = emailManager.findOricdIdsByCommaSeparatedEmails(email);
assertNotNull(map1);
assertEquals(orcidBefore, map1.get(email));
// Then try to create it again, with additional email set to primary email of existing user
String email2 = "new_user2_" + System.currentTimeMillis() + "@test.orcid.org";
List<Text> emailsAdditionalList = new ArrayList<Text>();
Text emailAdditional = new Text();
emailAdditional.setValue(email);
emailsAdditionalList.add(emailAdditional);
Registration form = createRegistrationFormMultipleEmails(email2, emailsAdditionalList, true);
String orcidAfter = registrationManager.createMinimalRegistration(form, true, java.util.Locale.ENGLISH, "0.0.0.0");
assertTrue(OrcidStringUtils.isValidOrcid(orcidAfter));
assertThat(orcidAfter, is(not(equalTo(orcidBefore))));
Map<String, String> map2 = emailManager.findOricdIdsByCommaSeparatedEmails(email + "," + email2);
assertNotNull(map2);
assertEquals(orcidAfter, map2.get(email));
assertEquals(orcidAfter, map2.get(email2));
}
Aggregations