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.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index a8fc45638..5b3d87ebc 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -57,6 +57,7 @@ import com.juick.util.MessageUtils;
import com.mitchellbosecke.pebble.PebbleEngine;
import com.mitchellbosecke.pebble.error.PebbleException;
import com.mitchellbosecke.pebble.template.PebbleTemplate;
+import com.overzealous.remark.Remark;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
import io.jsonwebtoken.Jwts;
@@ -244,12 +245,16 @@ public class ServerTests {
private Resource hubzillaFollow;
@Value("classpath:announce.json")
private Resource noteWithDocument;
+ @Value("classpath:note_with_attachment.json")
+ private Resource noteWithAttachment;
@Value("classpath:2936611-57.jpg")
private Resource jpegNoJfifTiff;
@Value("classpath:Transparent.gif")
private Resource invisiblePixel;
@Inject
AppleClientSecretGenerator clientSecretGenerator;
+ @Inject
+ private Remark remarkConverter;
@Inject
private KeystoreManager testKeystoreManager;
@@ -2158,6 +2163,17 @@ public class ServerTests {
Message testMessage = MockUtils.mockMessage(mid, freefd, "reply");
String activity = IOUtils.toString(noteWithDocument.getInputStream(), StandardCharsets.UTF_8);
Announce announce = jsonMapper.readValue(activity, Announce.class);
+ String noteString = IOUtils.toString(noteWithAttachment.getInputStream(), StandardCharsets.UTF_8);
+ Create create = jsonMapper.readValue(noteString, Create.class);
+ Map<String, Object> note = (Map<String, Object>) create.getObject();
+ String markdown = remarkConverter.convertFragment((String) note.get("content"));
+ String commandBody = note.get("attachment") == null ? markdown :
+ ((List<Object>) note.get("attachment")).stream().map(attachmentObj -> {
+ Map<String, String> attachment = (Map<String, String>) attachmentObj;
+ String attachmentUrl = attachment.get("url");
+ String attachmentName = attachment.get("name");
+ return PlainTextFormatter.markdownUrl(attachmentUrl, attachmentName);
+ }).reduce(markdown, (current, next) -> String.format("%s\n%s", current, next));
}
@Test