Skip to content

Commit

Permalink
chore(mail-connector): run mvn spotless to format the `SmtpSendEmailT…
Browse files Browse the repository at this point in the history
…est` class
  • Loading branch information
itsnuyen committed Dec 18, 2024
1 parent 7b8a18a commit d3fb393
Showing 1 changed file with 54 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -1,64 +1,61 @@
package io.camunda.connector.email.outbound.protocols.actions;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

class SmtpSendEmailTest {

@Test
void isEmailMessageValidPlainTextWithBody() {
SmtpSendEmail smtpSendEmail = mockSmtpSendEmail(ContentType.PLAIN, "text", null);
assertTrue(smtpSendEmail.isEmailMessageValid());
}

@Test
void isEmailMessageNotValidPlainTextWithoutBody() {
SmtpSendEmail smtpSendEmail = mockSmtpSendEmail(ContentType.PLAIN, null, null);
assertFalse(smtpSendEmail.isEmailMessageValid());
}

@Test
void isEmailMessageValidHtmlTextWithBody() {
SmtpSendEmail smtpSendEmail = mockSmtpSendEmail(ContentType.HTML, null, "text");
assertTrue(smtpSendEmail.isEmailMessageValid());
}

@Test
void isEmailMessageNotValidHtmlWithoutBody() {
SmtpSendEmail smtpSendEmail = mockSmtpSendEmail(ContentType.HTML, null, null);
assertFalse(smtpSendEmail.isEmailMessageValid());
}

@Test
void isEmailMessageValidMultiWithBody() {
SmtpSendEmail smtpSendEmail = mockSmtpSendEmail(ContentType.MULTIPART, "text", "text2");
assertTrue(smtpSendEmail.isEmailMessageValid());
}

@Test
void isEmailMessageNotValidHtmlTextWithoutBothBodies() {
SmtpSendEmail smtpSendEmail = mockSmtpSendEmail(ContentType.MULTIPART, null, null);
assertFalse(smtpSendEmail.isEmailMessageValid());
}

@Test
void isEmailMessageNotValidMultiWithoutHtmlBody() {
SmtpSendEmail smtpSendEmail = mockSmtpSendEmail(ContentType.MULTIPART, "text", null);
assertFalse(smtpSendEmail.isEmailMessageValid());
}

@Test
void isEmailMessageNotValidMultiWithoutBody() {
SmtpSendEmail smtpSendEmail = mockSmtpSendEmail(ContentType.MULTIPART, null, "text");
assertFalse(smtpSendEmail.isEmailMessageValid());
}

import org.junit.jupiter.api.Test;

class SmtpSendEmailTest {

private SmtpSendEmail mockSmtpSendEmail(ContentType contentType, String body, String htmlBody) {
return new SmtpSendEmail("", "", "", "", null, "", contentType,
body, htmlBody, null);
}
}
@Test
void isEmailMessageValidPlainTextWithBody() {
SmtpSendEmail smtpSendEmail = mockSmtpSendEmail(ContentType.PLAIN, "text", null);
assertTrue(smtpSendEmail.isEmailMessageValid());
}

@Test
void isEmailMessageNotValidPlainTextWithoutBody() {
SmtpSendEmail smtpSendEmail = mockSmtpSendEmail(ContentType.PLAIN, null, null);
assertFalse(smtpSendEmail.isEmailMessageValid());
}

@Test
void isEmailMessageValidHtmlTextWithBody() {
SmtpSendEmail smtpSendEmail = mockSmtpSendEmail(ContentType.HTML, null, "text");
assertTrue(smtpSendEmail.isEmailMessageValid());
}

@Test
void isEmailMessageNotValidHtmlWithoutBody() {
SmtpSendEmail smtpSendEmail = mockSmtpSendEmail(ContentType.HTML, null, null);
assertFalse(smtpSendEmail.isEmailMessageValid());
}

@Test
void isEmailMessageValidMultiWithBody() {
SmtpSendEmail smtpSendEmail = mockSmtpSendEmail(ContentType.MULTIPART, "text", "text2");
assertTrue(smtpSendEmail.isEmailMessageValid());
}

@Test
void isEmailMessageNotValidHtmlTextWithoutBothBodies() {
SmtpSendEmail smtpSendEmail = mockSmtpSendEmail(ContentType.MULTIPART, null, null);
assertFalse(smtpSendEmail.isEmailMessageValid());
}

@Test
void isEmailMessageNotValidMultiWithoutHtmlBody() {
SmtpSendEmail smtpSendEmail = mockSmtpSendEmail(ContentType.MULTIPART, "text", null);
assertFalse(smtpSendEmail.isEmailMessageValid());
}

@Test
void isEmailMessageNotValidMultiWithoutBody() {
SmtpSendEmail smtpSendEmail = mockSmtpSendEmail(ContentType.MULTIPART, null, "text");
assertFalse(smtpSendEmail.isEmailMessageValid());
}

private SmtpSendEmail mockSmtpSendEmail(ContentType contentType, String body, String htmlBody) {
return new SmtpSendEmail("", "", "", "", null, "", contentType, body, htmlBody, null);
}
}

0 comments on commit d3fb393

Please sign in to comment.