feat: load email templates from classpath with watermark URL resolution
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
68
src/test/java/net/siegeln/cameleer/saas/vendor/EmailTemplateLoadingTest.java
vendored
Normal file
68
src/test/java/net/siegeln/cameleer/saas/vendor/EmailTemplateLoadingTest.java
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
package net.siegeln.cameleer.saas.vendor;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class EmailTemplateLoadingTest {
|
||||
|
||||
private static final String[] TEMPLATE_FILES = {
|
||||
"email-templates/register.html",
|
||||
"email-templates/sign-in.html",
|
||||
"email-templates/forgot-password.html",
|
||||
"email-templates/generic.html"
|
||||
};
|
||||
|
||||
@Test
|
||||
void allTemplateFilesExistOnClasspath() {
|
||||
for (String path : TEMPLATE_FILES) {
|
||||
var resource = new ClassPathResource(path);
|
||||
assertTrue(resource.exists(), "Template file missing: " + path);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void templatesContainCodePlaceholder() throws IOException {
|
||||
for (String path : TEMPLATE_FILES) {
|
||||
String content = new ClassPathResource(path).getContentAsString(StandardCharsets.UTF_8);
|
||||
assertTrue(content.contains("{{code}}"),
|
||||
path + " must contain {{code}} placeholder");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void templatesContainWatermarkPlaceholder() throws IOException {
|
||||
for (String path : TEMPLATE_FILES) {
|
||||
String content = new ClassPathResource(path).getContentAsString(StandardCharsets.UTF_8);
|
||||
assertTrue(content.contains("{{watermarkUrl}}"),
|
||||
path + " must contain {{watermarkUrl}} placeholder");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void watermarkPlaceholderIsReplaced() throws IOException {
|
||||
String content = new ClassPathResource("email-templates/register.html")
|
||||
.getContentAsString(StandardCharsets.UTF_8);
|
||||
String resolved = content.replace("{{watermarkUrl}}",
|
||||
"https://example.com/platform/assets/email-watermark.png");
|
||||
assertFalse(resolved.contains("{{watermarkUrl}}"));
|
||||
assertTrue(resolved.contains("https://example.com/platform/assets/email-watermark.png"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void templatesContainBrandElements() throws IOException {
|
||||
for (String path : TEMPLATE_FILES) {
|
||||
String content = new ClassPathResource(path).getContentAsString(StandardCharsets.UTF_8);
|
||||
assertTrue(content.contains("Cameleer.io"),
|
||||
path + " must contain Cameleer.io header");
|
||||
assertTrue(content.contains("Apache Camel observability"),
|
||||
path + " must contain tagline");
|
||||
assertTrue(content.contains("#C6820E"),
|
||||
path + " must use brand color");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user