aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com/juick/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/juick/server')
-rw-r--r--src/test/java/com/juick/server/tests/ServerTests.java36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index 4c72913e..de742447 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -28,6 +28,7 @@ import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.jayway.jsonpath.JsonPath;
import com.juick.*;
+import com.juick.formatters.PlainTextFormatter;
import com.juick.model.AnonymousUser;
import com.juick.model.CommandResult;
import com.juick.model.PrivateChats;
@@ -218,10 +219,16 @@ public class ServerTests {
@Inject
private Profile profileController;
- @Value("classpath:mocks/activity/testuser.json")
+ @Value("classpath:snapshots/activity/testuser.json")
private Resource testuserResponse;
- @Value("classpath:mocks/activity/testfollow.json")
+ @Value("classpath:snapshots/activity/testfollow.json")
private Resource testfollowRequest;
+ @Value("classpath:snapshots/email/subscription.html")
+ private Resource testSubscriptionHtmlEmail;
+ @Value("classpath:snapshots/email/private.html")
+ private Resource testPrivateHtmlEmail;
+ @Value("classpath:snapshots/email/subscription.txt")
+ private Resource testSubscriptionTextEmail;
@Value("classpath:static/av-96.png")
private Resource defaultAvatar;
@Value("classpath:cmyk.jpg")
@@ -241,6 +248,8 @@ public class ServerTests {
@Inject
private KeystoreManager testKeystoreManager;
+ @Inject
+ private EmailManager emailManager;
@Inject
private ApplicationEventPublisher applicationEventPublisher;
@@ -2121,4 +2130,27 @@ public class ServerTests {
.findFirst().orElseThrow(IllegalStateException::new);
assertThat(rareTagStats.getUsageCount(), is(1));
}
+ private String getSnapshot(Resource resource) throws IOException {
+ return IOUtils.toString(resource.getInputStream(), StandardCharsets.UTF_8);
+ }
+ @Test
+ public void emailTemplatesTest() throws IOException {
+ String plainText = emailManager.renderPlaintext("yo", "https://localhost/m/1").orElseThrow();
+ assertThat(plainText, is(getSnapshot(testSubscriptionTextEmail)));
+ User demo = MockUtils.mockUser(45, ugnichName, ugnichPassword);
+ Message html = MockUtils.mockMessage(56, demo, "yo");
+ String htmlText = emailManager.renderHtml(
+ MessageUtils.formatHtml(html),
+ PlainTextFormatter.formatUrl(html),
+ html, "12345")
+ .orElseThrow();
+ assertThat(htmlText, is(getSnapshot(testSubscriptionHtmlEmail)));
+ html.setMid(0);
+ String htmlPM = emailManager.renderHtml(
+ MessageUtils.formatHtml(html),
+ PlainTextFormatter.formatUrl(html),
+ html, "12345")
+ .orElseThrow();
+ assertThat(htmlPM, is(getSnapshot(testPrivateHtmlEmail)));
+ }
}