Search in sources :

Example 26 with Registration

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));
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) 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)

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