Search in sources :

Example 1 with UserAccountExpiryInfo

use of org.hisp.dhis.user.UserAccountExpiryInfo in project dhis2-core by dhis2.

the class AccountExpiryAlertJobTest method testEnabledJobSendsEmail.

@Test
void testEnabledJobSendsEmail() {
    when(userService.getExpiringUserAccounts(anyInt())).thenReturn(singletonList(new UserAccountExpiryInfo("username", "email@example.com", Date.valueOf("2021-08-23"))));
    job.execute(new JobConfiguration(), NoopJobProgress.INSTANCE);
    ArgumentCaptor<String> subject = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> text = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> recipient = ArgumentCaptor.forClass(String.class);
    verify(messageSender).sendMessage(subject.capture(), text.capture(), recipient.capture());
    assertEquals("Account Expiry Alert", subject.getValue());
    assertEquals("Dear username, your account is about to expire on 2021-08-23. If your use of the account needs to continue, get in touch with your system administrator.", text.getValue());
    assertEquals("email@example.com", recipient.getValue());
}
Also used : UserAccountExpiryInfo(org.hisp.dhis.user.UserAccountExpiryInfo) JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

JobConfiguration (org.hisp.dhis.scheduling.JobConfiguration)1 UserAccountExpiryInfo (org.hisp.dhis.user.UserAccountExpiryInfo)1 Test (org.junit.jupiter.api.Test)1