Skip to content

Commit

Permalink
chore : test code modify
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeJeongGi committed Apr 13, 2024
1 parent f826eed commit e2cd9a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void mailSender() throws Exception {


// when
when(mailSender.sendMail(any())).thenReturn(res);
when(mailSender.sendMail(any(), any())).thenReturn(res);

// then
mockMvc.perform(post("/api/mail/certification")
Expand Down Expand Up @@ -94,7 +94,7 @@ public void mailFormatErrorTest() throws Exception {


// when
when(mailSender.sendMail(any())).thenReturn(res);
when(mailSender.sendMail(any(), any())).thenReturn(res);

// then
mockMvc.perform(post("/api/mail/certification")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import jakarta.mail.MessagingException;
import jakarta.mail.internet.MimeMessage;
import jakarta.transaction.Transactional;
import org.benchmarker.bmcontroller.mail.common.factory.EmailBodyGenerator;
import org.benchmarker.bmcontroller.mail.common.factory.EmailVerificationFactory;
import org.benchmarker.bmcontroller.mail.controller.dto.EmailCertificationDto;
import org.benchmarker.bmcontroller.mail.controller.dto.EmailResDto;
import org.benchmarker.bmcontroller.mail.service.impl.MailSenderImpl;
Expand Down Expand Up @@ -43,10 +45,12 @@ public void sendMailTest() {
.certificationCode(authNum)
.build();

when(mailSender.sendMail(any())).thenReturn(res);
EmailBodyGenerator emailBodyGenerator = new EmailVerificationFactory();

when(mailSender.sendMail(any(), any())).thenReturn(res);

// When
EmailResDto emailResDto = mailSender.sendMail(emailCertificationDto);
EmailResDto emailResDto = mailSender.sendMail(emailCertificationDto, emailBodyGenerator);

// Then
assertThat(emailResDto.getMail()).isEqualTo(emailCertificationDto.getEmail());
Expand Down

0 comments on commit e2cd9a9

Please sign in to comment.