Commit 9fa9183f2eb006136f793238642e2daae7dff1fe
1 parent
90f0ea13
feat:【system】优化 MailSendServiceImplTest 的单测
Showing
1 changed file
with
11 additions
and
2 deletions
yudao-module-system/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailSendServiceImplTest.java
| ... | ... | @@ -312,8 +312,17 @@ public class MailSendServiceImplTest extends BaseMockitoUnitTest { |
| 312 | 312 | |
| 313 | 313 | // mock 方法(发送邮件) |
| 314 | 314 | Exception e = new NullPointerException("啦啦啦"); |
| 315 | - mailUtilMock.when(() -> MailUtil.send(any(MailAccount.class), any(), any(), any(), | |
| 316 | - any(), any(), eq(true), any(java.io.File[].class))).thenThrow(e); | |
| 315 | + mailUtilMock.when(() -> MailUtil.send(argThat(mailAccount -> { | |
| 316 | + assertEquals("芋艿 <7685@qq.com>", mailAccount.getFrom()); | |
| 317 | + assertTrue(mailAccount.isAuth()); | |
| 318 | + assertEquals(account.getUsername(), mailAccount.getUser()); | |
| 319 | + assertArrayEquals(account.getPassword().toCharArray(), mailAccount.getPass()); | |
| 320 | + assertEquals(account.getHost(), mailAccount.getHost()); | |
| 321 | + assertEquals(account.getPort(), mailAccount.getPort()); | |
| 322 | + assertEquals(account.getSslEnable(), mailAccount.isSslEnable()); | |
| 323 | + return true; | |
| 324 | + }), eq(message.getToMails()), eq(message.getCcMails()), eq(message.getBccMails()), | |
| 325 | + eq(message.getTitle()), eq(message.getContent()), eq(true), same(message.getAttachments()))).thenThrow(e); | |
| 317 | 326 | |
| 318 | 327 | // 调用 |
| 319 | 328 | mailSendService.doSendMail(message); | ... | ... |