use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.
the class RegistrationManagerImplTest method testCreateMinimalRegistration.
@Test
public void testCreateMinimalRegistration() {
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));
Map<String, String> map = emailManager.findOricdIdsByCommaSeparatedEmails(email);
assertNotNull(map);
assertEquals(userOrcid, map.get(email));
}
use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.
the class RegistrationControllerTest method regEmailsAdditonalValidateNotSameAsOtherAdditional.
@Test
public void regEmailsAdditonalValidateNotSameAsOtherAdditional() {
String additionalEmail = "email1@test.orcid.org";
Registration reg = new Registration();
List<Text> emailsAdditionalList = new ArrayList<Text>();
Text emailAdditional01 = new Text();
Text emailAdditional02 = new Text();
emailAdditional01.setValue(additionalEmail);
emailAdditional02.setValue(additionalEmail);
emailsAdditionalList.add(emailAdditional01);
emailsAdditionalList.add(emailAdditional02);
reg.setEmailsAdditional(emailsAdditionalList);
reg = registrationController.regEmailsAdditionalValidate(servletRequest, reg, false, true);
assertNotNull(reg);
assertNotNull(reg.getEmailsAdditional());
for (Text emailAdditionalListItem : reg.getEmailsAdditional()) {
assertNotNull(emailAdditionalListItem.getErrors());
assertEquals(1, emailAdditionalListItem.getErrors().size());
assertEquals("Additional email cannot match another email", emailAdditionalListItem.getErrors().get(0));
}
}
use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.
the class RegistrationControllerTest method regEmailValidateClaimedAccountTest.
@Test
public void regEmailValidateClaimedAccountTest() {
String email = "email1@test.orcid.org";
String orcid = "0000-0000-0000-0000";
when(emailManager.emailExists(email)).thenReturn(true);
when(emailManager.findOrcidIdByEmail(email)).thenReturn(orcid);
// Set it as claimed
when(profileEntityManager.isProfileClaimedByEmail(email)).thenReturn(true);
// And set it as active
when(profileEntityManager.isDeactivated(orcid)).thenReturn(false);
Registration reg = new Registration();
reg.setEmail(Text.valueOf("email1@test.orcid.org"));
reg.setEmailConfirm(Text.valueOf("email1@test.orcid.org"));
reg = registrationController.regEmailValidate(servletRequest, reg, false, true);
assertNotNull(reg);
assertNotNull(reg.getEmail());
assertNotNull(reg.getEmail().getErrors());
assertEquals(1, reg.getEmail().getErrors().size());
assertTrue(reg.getEmail().getErrors().get(0).startsWith("email1@test.orcid.org already exists in our system."));
}
use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.
the class RegistrationControllerTest method regEmailValidateUnclaimedAccountButEnableAutoDeprecateDisableOnClientTest.
@Test
public void regEmailValidateUnclaimedAccountButEnableAutoDeprecateDisableOnClientTest() {
String email = "email1@test.orcid.org";
String orcid = "0000-0000-0000-0000";
when(emailManager.emailExists(email)).thenReturn(true);
when(emailManager.findOrcidIdByEmail(email)).thenReturn(orcid);
when(profileEntityManager.isProfileClaimedByEmail(email)).thenReturn(false);
when(profileEntityManager.isDeactivated(orcid)).thenReturn(false);
// Set enable auto deprecate off
when(emailManager.isAutoDeprecateEnableForEmail(email)).thenReturn(false);
when(servletRequest.getScheme()).thenReturn("http");
Registration reg = new Registration();
reg.setEmail(Text.valueOf("email1@test.orcid.org"));
reg.setEmailConfirm(Text.valueOf("email1@test.orcid.org"));
reg = registrationController.regEmailValidate(servletRequest, reg, false, true);
assertNotNull(reg);
assertNotNull(reg.getEmail());
assertNotNull(reg.getEmail().getErrors());
assertEquals(1, reg.getEmail().getErrors().size());
assertEquals("email1@test.orcid.org already exists in our system as an unclaimed record. Would you like to <a href='http://testserver.orcid.org/resend-claim?email=email1%40test.orcid.org'>resend the claim email</a>?", reg.getEmail().getErrors().get(0));
}
use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.
the class RegistrationControllerTest method regActivitiesVisibilityDefaultIsNotNull.
@Test
public void regActivitiesVisibilityDefaultIsNotNull() {
// TODO: Update this test after GDPR privacy selector is live
togglzRule.enable(Features.GDPR_UI);
Registration reg = new Registration();
reg.getActivitiesVisibilityDefault().setVisibility(null);
assertNull(reg.getActivitiesVisibilityDefault().getVisibility());
reg = registrationController.registerActivitiesVisibilityDefaultValidate(reg);
assertNotNull(reg);
assertNotNull(reg.getActivitiesVisibilityDefault().getErrors());
assertEquals(1, reg.getActivitiesVisibilityDefault().getErrors().size());
assertEquals("Please choose a default visibility setting.", reg.getActivitiesVisibilityDefault().getErrors().get(0));
}
Aggregations