aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com/juick/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/juick/server/tests')
-rw-r--r--src/test/java/com/juick/server/tests/ServerTests.java30
1 files changed, 30 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 a942323c..a9f767f7 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -30,6 +30,10 @@ import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.github.scribejava.apis.AppleClientSecretGenerator;
import com.jayway.jsonpath.JsonPath;
import com.juick.*;
+import com.juick.data.MessagesRepository;
+import com.juick.data.UsersRepository;
+import com.juick.data.entities.MessageEntity;
+import com.juick.data.entities.ReplyEntity;
import com.juick.model.Tag;
import com.juick.model.*;
import com.juick.server.MockNotificationListener;
@@ -196,6 +200,10 @@ public class ServerTests {
@Inject
private ProfileUriBuilder profileUriBuilder;
@Inject
+ private MessagesRepository messagesRepository;
+ @Inject
+ private UsersRepository usersRepository;
+ @Inject
private WebApp webApp;
@Value("${ap_base_uri:http://localhost:8080/}")
private String baseUri;
@@ -2717,4 +2725,26 @@ public class ServerTests {
var truncated = StringUtils.abbreviate(text, "…", 47);
assertThat(truncated, is(expected));
}
+ @Test
+ @Transactional
+ public void jpaMessageTests() {
+ var user = usersRepository.findByName(ugnichName);
+ var message = new MessageEntity();
+ message.setUser(user);
+ message.setText("Hello, JPA!");
+ message.setTimestamp(Instant.now());
+ message = messagesRepository.save(message);
+ var msg = messagesService.getMessage(message.getId());
+ assertThat(msg.get().getText(), is(notNullValue()));
+ assertThat(msg.get().getText(), is (message.getText()));
+ }
+ @Test
+ @Transactional
+ public void jpaReplyTests() {
+ var mid = messagesService.createMessage(ugnich.getUid(), "new message", null, Set.of());
+ var rid = messagesService.createReply(mid, 0, ugnich, "reply 1", null);
+ var message = messagesRepository.getReferenceById(mid);
+ var replies = message.getReplies();
+ assertThat(replies.size(), is(1));
+ }
}