Search in sources :

Example 1 with MailService

use of org.thingsboard.rule.engine.api.MailService in project thingsboard by thingsboard.

the class TestMailService method mailService.

@Bean
@Primary
public MailService mailService() throws ThingsboardException {
    MailService mailService = Mockito.mock(MailService.class);
    Mockito.doAnswer(new Answer<Void>() {

        public Void answer(InvocationOnMock invocation) {
            Object[] args = invocation.getArguments();
            String activationLink = (String) args[0];
            currentActivateToken = activationLink.split("=")[1];
            return null;
        }
    }).when(mailService).sendActivationEmail(Mockito.anyString(), Mockito.anyString());
    Mockito.doAnswer(new Answer<Void>() {

        public Void answer(InvocationOnMock invocation) {
            Object[] args = invocation.getArguments();
            String passwordResetLink = (String) args[0];
            currentResetPasswordToken = passwordResetLink.split("=")[1];
            return null;
        }
    }).when(mailService).sendResetPasswordEmailAsync(Mockito.anyString(), Mockito.anyString());
    return mailService;
}
Also used : MailService(org.thingsboard.rule.engine.api.MailService) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Aggregations

InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Bean (org.springframework.context.annotation.Bean)1 Primary (org.springframework.context.annotation.Primary)1 MailService (org.thingsboard.rule.engine.api.MailService)1