use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.
the class RegistrationManagerImplTest method testCreateMinimalRegistrationMultipleEmails.
@Test
public void testCreateMinimalRegistrationMultipleEmails() {
String email = "new_user_" + System.currentTimeMillis() + "@test.orcid.org";
String additionalEmail = "new_user_addl_" + System.currentTimeMillis() + "@test.orcid.org";
List<Text> emailsAdditionalList = new ArrayList<Text>();
Text emailAdditional = new Text();
emailAdditional.setValue(additionalEmail);
emailsAdditionalList.add(emailAdditional);
Registration form = createRegistrationFormMultipleEmails(email, emailsAdditionalList, true);
String userOrcid = registrationManager.createMinimalRegistration(form, true, java.util.Locale.ENGLISH, "0.0.0.0");
assertNotNull(userOrcid);
assertTrue(OrcidStringUtils.isValidOrcid(userOrcid));
Map<String, String> map = emailManager.findOricdIdsByCommaSeparatedEmails(email + "," + additionalEmail);
assertNotNull(map);
assertEquals(userOrcid, map.get(email));
assertEquals(userOrcid, map.get(additionalEmail));
}
use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.
the class RegistrationManagerImplTest method testCreateMinimalRegistrationWithExistingEmailThatCanBeAutoDeprecated.
@Test
public void testCreateMinimalRegistrationWithExistingEmailThatCanBeAutoDeprecated() {
// 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, this time claimed and without source
Registration form = createRegistrationForm(email, 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);
assertNotNull(map2);
assertEquals(orcidAfter, map2.get(email));
}
use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.
the class RegistrationManagerImplTest method testCreateMinimalRegistrationWithExistingClaimedEmailAdditional.
@Test
public void testCreateMinimalRegistrationWithExistingClaimedEmailAdditional() {
// Create the user
String email = "new_user_" + System.currentTimeMillis() + "@test.orcid.org";
Registration form = createRegistrationForm(email, true);
String userOrcid = registrationManager.createMinimalRegistration(form, true, java.util.Locale.ENGLISH, "0.0.0.0");
assertNotNull(userOrcid);
assertTrue(OrcidStringUtils.isValidOrcid(userOrcid));
// 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);
form = createRegistrationFormMultipleEmails(email2, emailsAdditionalList, true);
try {
registrationManager.createMinimalRegistration(form, true, java.util.Locale.ENGLISH, "0.0.0.0");
fail();
} catch (InvalidRequestException e) {
assertEquals("Unable to register user due: Email " + email + " already exists and is claimed, so, it can't be used again", e.getMessage());
} catch (Exception e) {
fail();
}
}
use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.
the class RegistrationManagerImplTest method createRegistrationFormMultipleEmails.
private Registration createRegistrationFormMultipleEmails(String email, List<Text> emailsAdditionalList, boolean claimed) {
Registration registration = new Registration();
registration.setPassword(Text.valueOf("password"));
registration.setEmail(Text.valueOf(email));
registration.setEmailsAdditional(emailsAdditionalList);
registration.setFamilyNames(Text.valueOf("User"));
registration.setGivenNames(Text.valueOf("New"));
registration.setCreationType(Text.valueOf(CreationMethod.DIRECT.value()));
return registration;
}
use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.
the class RegistrationManagerImplTest method testCreateMinimalRegistrationWithExistingUnclaimedEmailNotAutoDeprecatable.
@Test
public void testCreateMinimalRegistrationWithExistingUnclaimedEmailNotAutoDeprecatable() {
// 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_DISABLED);
orcidProfile = orcidProfileManager.createOrcidProfile(orcidProfile, true, true);
assertNotNull(orcidProfile);
assertNotNull(orcidProfile.getOrcidIdentifier());
assertNotNull(orcidProfile.getOrcidIdentifier().getPath());
try {
Registration form = createRegistrationForm(email, true);
registrationManager.createMinimalRegistration(form, true, java.util.Locale.ENGLISH, "0.0.0.0");
fail();
} catch (InvalidRequestException e) {
assertEquals("Unable to register user due: Autodeprecate is not enabled for " + email, e.getMessage());
} catch (Exception e) {
fail();
}
}
Aggregations