Skip to content

Commit

Permalink
Add convenient MailTemplateInstance#sendAndAwait()
Browse files Browse the repository at this point in the history
  • Loading branch information
mkouba committed Sep 26, 2024
1 parent 3c243a6 commit 40020d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void testMailTemplateRecord() {
// Intentionally use programmatic lookup to obtain the MockMailbox
MockMailbox mockMailbox = Arc.container().instance(MockMailbox.class).get();
new confirmation("Ondrej").to("[email protected]").from("[email protected]").subject("test mailer")
.send().await().indefinitely();
.sendAndAwait();
assertEquals(1, mockMailbox.getMailMessagesSentTo("[email protected]").size());
MailMessage message = mockMailbox.getMailMessagesSentTo("[email protected]").get(0);
assertEquals("[email protected]", message.getFrom());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import io.quarkus.mailer.reactive.ReactiveMailer;
import io.quarkus.qute.TemplateInstance;
import io.smallrye.common.annotation.CheckReturnValue;
import io.smallrye.mutiny.Uni;

/**
Expand Down Expand Up @@ -117,10 +118,20 @@ default MailTemplateInstance setAttribute(String key, Object value) {
* @return a {@link Uni} indicating when the mails have been sent
* @see ReactiveMailer#send(Mail...)
*/
@CheckReturnValue
default Uni<Void> send() {
throw new UnsupportedOperationException();
}

/**
* Sends all e-mail definitions and blocks the current thread while waiting for the result.
*
* @see #send()
*/
default void sendAndAwait() {
send().await().indefinitely();
}

/**
* The returned instance does not represent a specific template but a delegating template.
* <p>
Expand Down

0 comments on commit 40020d0

Please sign in to comment.