Skip to content

Commit

Permalink
♻️ mail format spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhir committed Sep 2, 2024
1 parent 9deb1f4 commit 0914811
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ private Mail createMail(final BasicMail mail, final String body, final boolean h
htmlBody,
null,
mail.getReplyTo(),
attachments
);
attachments);
}

private void sendMail(Mail mailModel, String logoPath) throws MailSendException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ void sendMail() throws MessagingException {
false,
null,
"replyTo",
null
);
null);
mailAdapter.sendMail(mail, "logoPath");
verify(emailApi).sendMail(mail, "logoPath");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ void sendMail() throws MessagingException {
false,
null,
mail.getReplyTo(),
List.of()
);
List.of());
verify(mailOutPort).sendMail(mailOutModel, null);
}

Expand All @@ -89,8 +88,7 @@ void sendMailWithAttachments() throws MessagingException {
false,
null,
mail.getReplyTo(),
List.of(fileAttachment)
);
List.of(fileAttachment));
verify(mailOutPort).sendMail(mailOutModel, null);
}

Expand All @@ -113,8 +111,7 @@ void sendMailWithTemplate() throws MessagingException, TemplateException, IOExce
true,
null,
mail.getReplyTo(),
List.of()
);
List.of());
verify(mailOutPort).sendMail(mailOutModel, "templates/email-logo.png");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ void testSendMail() {
"Test",
"This is a test",
null,
List.of("/test/test-pdf.pdf")
);
List.of("/test/test-pdf.pdf"));
sendMailInPort.sendMailWithText(mail);
log.info("Test mail sent");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ void testSendMail() {
"Test",
"This is a test",
null,
List.of("/test/test-pdf.pdf")
);
List.of("/test/test-pdf.pdf"));
sendMailInPort.sendMailWithText(mail);
log.info("Test mail sent");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@

public record FileAttachment(
String fileName,
ByteArrayDataSource file
) {
ByteArrayDataSource file) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@
import org.apache.commons.lang3.StringUtils;

public record Mail(
@NotBlank
String receivers,
@NotBlank String receivers,
String receiversCc,
String receiversBcc,
@NotBlank
String subject,
@NotBlank
String body,
@NotBlank String subject,
@NotBlank String body,
boolean htmlBody,
String sender,
String replyTo,
List<FileAttachment> attachments
) {
List<FileAttachment> attachments) {

public boolean hasAttachment() {
return attachments != null && !attachments.isEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ void testSendMail() throws MessagingException, IOException {
false,
null,
null,
null
);
null);
this.emailApi.sendMail(mail);

final ArgumentCaptor<MimeMessage> messageArgumentCaptor = ArgumentCaptor.forClass(MimeMessage.class);
Expand All @@ -96,8 +95,7 @@ void testSendMailNoDefaultReplyTo() throws MessagingException, IOException {
false,
null,
null,
null
);
null);
new EmailApiImpl(this.javaMailSender, this.resourceLoader, freeMarkerConfigurer, customAddress.getAddress(), null).sendMail(mail);

final ArgumentCaptor<MimeMessage> messageArgumentCaptor = ArgumentCaptor.forClass(MimeMessage.class);
Expand All @@ -122,8 +120,7 @@ void testSendMailWithOptions() throws MessagingException, IOException {
false,
this.sender,
this.replyTo,
null
);
null);
this.emailApi.sendMail(mail);

final ArgumentCaptor<MimeMessage> messageArgumentCaptor = ArgumentCaptor.forClass(MimeMessage.class);
Expand Down Expand Up @@ -155,10 +152,7 @@ void sendMailWithAttachments() throws MessagingException, IOException {
List.of(
new FileAttachment(
"Testanhang",
new ByteArrayDataSource("FooBar".getBytes(), "text/plain")
)
)
);
new ByteArrayDataSource("FooBar".getBytes(), "text/plain"))));
this.emailApi.sendMail(mail);

final ArgumentCaptor<MimeMessage> messageArgumentCaptor = ArgumentCaptor.forClass(MimeMessage.class);
Expand All @@ -184,8 +178,7 @@ void sendMailWithMultipleReplyToAddresses() throws MessagingException, IOExcepti
false,
null,
reply1.getAddress() + "," + reply2.getAddress(),
null
);
null);
this.emailApi.sendMail(mail);

final ArgumentCaptor<MimeMessage> messageArgumentCaptor = ArgumentCaptor.forClass(MimeMessage.class);
Expand All @@ -212,8 +205,7 @@ void sendMailWithDefaultLogo() throws MessagingException, IOException {
false,
null,
null,
null
);
null);
this.emailApi.sendMailWithDefaultLogo(mail);

final ArgumentCaptor<MimeMessage> messageArgumentCaptor = ArgumentCaptor.forClass(MimeMessage.class);
Expand All @@ -239,8 +231,7 @@ void sendMailWithCustomLogo() throws MessagingException, IOException {
false,
null,
null,
null
);
null);
this.emailApi.sendMail(mail, "some/random/path/on/classpath");

final ArgumentCaptor<MimeMessage> messageArgumentCaptor = ArgumentCaptor.forClass(MimeMessage.class);
Expand Down

0 comments on commit 0914811

Please sign in to comment.