Search in sources :

Example 1 with EmailRequest

use of org.orcid.pojo.EmailRequest in project ORCID-Source by ORCID.

the class ClaimControllerTest method testResendClaimEmail.

@Test
public void testResendClaimEmail() {
    BindingResult bindingResult = mock(BindingResult.class);
    when(bindingResult.hasErrors()).thenReturn(false);
    when(emailManager.emailExists("billie@holiday.com")).thenReturn(true);
    when(emailManager.findOrcidIdByEmail("billie@holiday.com")).thenReturn("0000-0000-0000-0000");
    when(profileEntityCacheManager.retrieve(Mockito.anyString())).thenReturn(getProfileEntityToTestClaimResend(false));
    EmailRequest emailRequest = new EmailRequest();
    emailRequest.setEmail("billie@holiday.com");
    emailRequest = claimController.resendClaimEmail(emailRequest);
    assertNotNull(emailRequest);
    assertNotNull(emailRequest.getSuccessMessage());
}
Also used : BindingResult(org.springframework.validation.BindingResult) EmailRequest(org.orcid.pojo.EmailRequest) Test(org.junit.Test)

Example 2 with EmailRequest

use of org.orcid.pojo.EmailRequest in project ORCID-Source by ORCID.

the class PasswordResetControllerTest method testPasswordResetUserNotFound.

@Test
public void testPasswordResetUserNotFound() {
    when(orcidProfileManager.retrieveOrcidProfileByEmail(Mockito.anyString(), Mockito.any(LoadOptions.class))).thenReturn(null);
    EmailRequest resetRequest = new EmailRequest();
    resetRequest = passwordResetController.issuePasswordResetRequest(new MockHttpServletRequest(), resetRequest).getBody();
    assertNotNull(resetRequest.getErrors());
    assertFalse(resetRequest.getErrors().isEmpty());
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) LoadOptions(org.orcid.core.manager.LoadOptions) EmailRequest(org.orcid.pojo.EmailRequest) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 3 with EmailRequest

use of org.orcid.pojo.EmailRequest in project ORCID-Source by ORCID.

the class ClaimControllerTest method testResendEmailFailIfTheProfileIsAlreadyClaimed.

@Test
public void testResendEmailFailIfTheProfileIsAlreadyClaimed() {
    BindingResult bindingResult = mock(BindingResult.class);
    when(bindingResult.hasErrors()).thenReturn(false);
    when(emailManager.emailExists("billie@holiday.com")).thenReturn(true);
    when(emailManager.findOrcidIdByEmail("billie@holiday.com")).thenReturn("0000-0000-0000-0000");
    when(profileEntityCacheManager.retrieve(Mockito.anyString())).thenReturn(getProfileEntityToTestClaimResend(true));
    EmailRequest emailRequest = new EmailRequest();
    emailRequest.setEmail("billie@holiday.com");
    emailRequest = claimController.resendClaimEmail(emailRequest);
    assertNotNull(emailRequest);
    assertNull(emailRequest.getSuccessMessage());
    assertNotNull(emailRequest.getErrors());
    assertFalse(emailRequest.getErrors().isEmpty());
}
Also used : BindingResult(org.springframework.validation.BindingResult) EmailRequest(org.orcid.pojo.EmailRequest) Test(org.junit.Test)

Example 4 with EmailRequest

use of org.orcid.pojo.EmailRequest in project ORCID-Source by ORCID.

the class PasswordResetControllerTest method testPasswordResetUserDeactivated.

@Test
public void testPasswordResetUserDeactivated() throws DatatypeConfigurationException {
    GregorianCalendar c = new GregorianCalendar();
    c.setTime(new Date());
    XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
    OrcidHistory orcidHistory = new OrcidHistory();
    orcidHistory.setDeactivationDate(new DeactivationDate(date));
    OrcidProfile deactivatedProfile = new OrcidProfile();
    deactivatedProfile.setOrcidHistory(orcidHistory);
    when(orcidProfileManager.retrieveOrcidProfileByEmail(Mockito.anyString(), Mockito.any(LoadOptions.class))).thenReturn(deactivatedProfile);
    EmailRequest resetRequest = new EmailRequest();
    resetRequest = passwordResetController.issuePasswordResetRequest(new MockHttpServletRequest(), resetRequest).getBody();
    assertNotNull(resetRequest.getErrors());
    assertFalse(resetRequest.getErrors().isEmpty());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) LoadOptions(org.orcid.core.manager.LoadOptions) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DeactivationDate(org.orcid.jaxb.model.message.DeactivationDate) Date(java.util.Date) DeactivationDate(org.orcid.jaxb.model.message.DeactivationDate) EmailRequest(org.orcid.pojo.EmailRequest) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 EmailRequest (org.orcid.pojo.EmailRequest)4 LoadOptions (org.orcid.core.manager.LoadOptions)2 DBUnitTest (org.orcid.test.DBUnitTest)2 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)2 BindingResult (org.springframework.validation.BindingResult)2 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 DeactivationDate (org.orcid.jaxb.model.message.DeactivationDate)1 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)1 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)1