-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Manuel Klaus
committed
Jan 16, 2025
1 parent
5a9670b
commit 1f7e0bd
Showing
6 changed files
with
77 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.Duration; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
|
@@ -37,7 +38,7 @@ void shouldSendMail() { | |
InMemorySource<Mail> mailSender = connector.source("mail"); | ||
mailSender.runOnVertxContext(true); | ||
|
||
Mail mail = new Mail(new String[]{"[email protected]"}, MailTemplates.TEMP, Map.of("name", "Peter")); | ||
Mail mail = new Mail(new String[] { "[email protected]" }, MailTemplates.TEMP, Map.of("name", "Peter")); | ||
|
||
// when | ||
mailSender.send(mail); | ||
|
@@ -48,4 +49,24 @@ void shouldSendMail() { | |
assertEquals(1, mailsSentTo.size()); | ||
assertEquals(1, mockMailbox.getTotalMessagesSent()); | ||
} | ||
} | ||
|
||
@Test | ||
void shouldSendMultipleMailsParallel() { | ||
// given | ||
InMemorySource<Mail> mailSender = connector.source("mail"); | ||
mailSender.runOnVertxContext(true); | ||
|
||
Mail mail = new Mail(new String[] { "[email protected]" }, MailTemplates.TEMP, Map.of("name", "Peter")); | ||
|
||
// when | ||
for (int i = 0; i < 500; i++) { | ||
mailSender.send(mail); | ||
} | ||
await().atMost(Duration.ofSeconds(1)).until(() -> mockMailbox.getTotalMessagesSent() == 500); | ||
|
||
// then | ||
List<io.quarkus.mailer.Mail> mailsSentTo = mockMailbox.getMailsSentTo("[email protected]"); | ||
assertEquals(500, mailsSentTo.size()); | ||
assertEquals(500, mockMailbox.getTotalMessagesSent()); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
backend/app.hopps.mailservice/src/test/java/app/hopps/mailservice/MailTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package app.hopps.mailservice; | ||
|
||
import nl.jqno.equalsverifier.EqualsVerifier; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class MailTest { | ||
@Test | ||
void testEquals() { | ||
EqualsVerifier.forClass(Mail.class).verify(); | ||
} | ||
|
||
@Test | ||
void testToString() { | ||
Mail mail = new Mail(new String[] { "[email protected]", "[email protected]" }, MailTemplates.TEMP, Map.of()); | ||
|
||
String expected = "{\"mailReceivers\":[\"[email protected]\",\"[email protected]\"],\"templateId\":\"TEMP\",\"variables\":{}}"; | ||
|
||
String actual = mail.toString(); | ||
|
||
assertEquals(expected, actual); | ||
} | ||
} |