aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src')
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
index 095566ec6..a7701511b 100644
--- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
@@ -66,6 +66,7 @@ import java.nio.file.Paths;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.*;
+import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.IntStream;
@@ -747,4 +748,19 @@ public class ServerTests {
jdbcTemplate.update("INSERT INTO telegram_chats(chat_id) VALUES(1)");
telegramBotManager.processUpdate("{\"message\":{\"chat\":{\"id\":1},\"text\":\"yo\",\"from\":{\"id\":1,\"username\":\"teleugnich\"}}}");
}
+ @Test
+ public void lastReadTests() {
+ int mid = messagesService.createMessage(ugnich.getUid(), "to be watched", null, null);
+ subscriptionService.subscribeMessage(mid, ugnich.getUid());
+ messagesService.createReply(mid, 0, freefd, "new reply", null);
+ BiFunction<User, Integer, Integer> lastRead = (user, m) -> jdbcTemplate.queryForObject(
+ "SELECT last_read_rid FROM subscr_messages WHERE suser_id=? AND message_id=?",
+ Integer.class, user.getUid(), m);
+ assertThat(lastRead.apply(ugnich, mid), is(0));
+ assertThat(messagesService.getUnread(ugnich).size(), is(1));
+ assertThat(messagesService.getUnread(ugnich).get(0), is(mid));
+ messagesService.getReplies(ugnich, mid);
+ assertThat(lastRead.apply(ugnich, mid), is(1));
+ assertThat(messagesService.getUnread(ugnich).size(), is(0));
+ }
}