From 70810eb92ff7810eb0df133d157078064d666a33 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 8 Dec 2023 14:26:43 +0300 Subject: Do not count recommendations from banned users * Previosly only own message recommendations were filtered, now all message recommendations filter banned users --- src/test/java/com/juick/server/tests/ServerTests.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/test/java/com/juick/server/tests') diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index 9a46f691..81718cab 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -1580,27 +1580,25 @@ public class ServerTests { User monstreek = userService.createUser("monstreek", "secret").orElseThrow(IllegalStateException::new); User pogo = userService.createUser("pogo", "secret").orElseThrow(IllegalStateException::new); User fmap = userService.createUser("fmap", "secret").orElseThrow(IllegalStateException::new); - int mid = messagesService.createMessage(monstreek.getUid(), "KURWA", null, Set.of()); + int mid = messagesService.createMessage(fmap.getUid(), "KURWA", null, Set.of()); assertThat(messagesService.recommendMessage(mid, ermine.getUid()), is(MessagesService.RecommendStatus.Added)); - assertThat(messagesService.recommendMessage(mid, fmap.getUid()), - is(MessagesService.RecommendStatus.Added)); assertThat(messagesService.recommendMessage(mid, pogo.getUid()), is(MessagesService.RecommendStatus.Added)); jdbcTemplate.update("INSERT INTO favorites(user_id, user_uri, message_id, like_id, ts) " + "values (0, 'http://example.com/u/test', ?, 1, ?)", mid, Date.from(Instant.now())); - assertThat(messagesService.getMessage(mid).get().getRecommendations().size(), is(4)); + assertThat(messagesService.getMessage(mid).get().getRecommendations().size(), is(3)); assertThat(CollectionUtils.isEqualCollection( - messagesService.getMessagesRecommendations(Collections.singletonList(mid)).stream() + messagesService.getMessagesRecommendations(monstreek.getUid(), Collections.singletonList(mid)).stream() .map(Pair::getRight).map(User::getName).toList(), - Arrays.asList("fmap", "ermine", "pogo", "Anonymous")), is(true)); + Arrays.asList("ermine", "pogo", "Anonymous")), is(true)); privacyQueriesService.blacklistUser(userService.getUserByName("monstreek"), userService.getUserByName("pogo")); assertThat(messagesService.getMessage(mid).get().getRecommendations().size(), is(3)); assertThat(CollectionUtils.isEqualCollection( - messagesService.getMessagesRecommendations(Collections.singletonList(mid)).stream() + messagesService.getMessagesRecommendations(monstreek.getUid(), Collections.singletonList(mid)).stream() .map(Pair::getRight).map(User::getName).toList(), - Arrays.asList("fmap", "ermine", "Anonymous")), is(true)); + Arrays.asList("ermine", "Anonymous")), is(true)); jdbcTemplate.execute("DELETE FROM favorites"); } -- cgit v1.2.3