Search in sources :

Example 1 with Registration

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));
}
Also used : Registration(org.orcid.pojo.ajaxForm.Registration) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 2 with Registration

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));
    }
}
Also used : Registration(org.orcid.pojo.ajaxForm.Registration) ArrayList(java.util.ArrayList) Text(org.orcid.pojo.ajaxForm.Text) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 3 with Registration

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."));
}
Also used : Registration(org.orcid.pojo.ajaxForm.Registration) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 4 with Registration

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));
}
Also used : Registration(org.orcid.pojo.ajaxForm.Registration) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 5 with Registration

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));
}
Also used : Registration(org.orcid.pojo.ajaxForm.Registration) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Registration (org.orcid.pojo.ajaxForm.Registration)26 Test (org.junit.Test)23 DBUnitTest (org.orcid.test.DBUnitTest)23 Text (org.orcid.pojo.ajaxForm.Text)13 ArrayList (java.util.ArrayList)11 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)5 InvalidRequestException (org.springframework.security.oauth2.common.exceptions.InvalidRequestException)5 Locale (java.util.Locale)2 HttpSession (javax.servlet.http.HttpSession)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Checkbox (org.orcid.pojo.ajaxForm.Checkbox)2 RequestInfoForm (org.orcid.pojo.ajaxForm.RequestInfoForm)2 Principal (java.security.Principal)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 OrcidOAuth2Authentication (org.orcid.core.oauth.OrcidOAuth2Authentication)1 Visibility (org.orcid.jaxb.model.v3.dev1.common.Visibility)1 OauthRegistrationForm (org.orcid.pojo.ajaxForm.OauthRegistrationForm)1 Authentication (org.springframework.security.core.Authentication)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1