forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- an alternative syntax for type-safe templates
- Loading branch information
Showing
27 changed files
with
878 additions
and
102 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
42 changes: 42 additions & 0 deletions
42
extensions/mailer/deployment/src/test/java17/io/quarkus/mailer/MailTemplateRecordTest.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,42 @@ | ||
package io.quarkus.mailer; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.mailer.MailTemplate.MailTemplateInstance; | ||
import io.quarkus.qute.CheckedTemplate; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.vertx.ext.mail.MailMessage; | ||
import jakarta.inject.Inject; | ||
|
||
public class MailTemplateRecordTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot(root -> root | ||
.addClasses(confirmation.class) | ||
.addAsResource("mock-config.properties", "application.properties") | ||
.addAsResource(new StringAsset("" | ||
+ "<html>{name}</html>"), "templates/confirmation.html")); | ||
|
||
@Inject | ||
MockMailbox mockMailbox; | ||
|
||
@Test | ||
public void testMailTemplateRecord() { | ||
new confirmation("Ondrej").to("[email protected]").from("[email protected]").subject("test mailer") | ||
.send().await().indefinitely(); | ||
assertEquals(1, mockMailbox.getMailMessagesSentTo("[email protected]").size()); | ||
MailMessage message = mockMailbox.getMailMessagesSentTo("[email protected]").get(0); | ||
assertEquals("[email protected]", message.getFrom()); | ||
assertEquals("<html>Ondrej</html>", message.getHtml()); | ||
} | ||
|
||
@CheckedTemplate(basePath = "") | ||
record confirmation(String name) implements MailTemplateInstance { | ||
} | ||
|
||
} |
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
Oops, something went wrong.