aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/test/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-04-11 22:52:59 +0300
committerGravatar Vitaly Takmazov2018-04-11 22:52:59 +0300
commit495ee60b34991572c06732674c6e02f290cdbd55 (patch)
tree71b62ed5038f8021bf9086cd4819d66d67a18389 /juick-server/src/test/java/com/juick
parent336517508441ecb9a78418065f5a6c068d15f3cb (diff)
MessagesService::getUnread
Diffstat (limited to 'juick-server/src/test/java/com/juick')
-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 095566ec..a7701511 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));
+ }
}