From c0ac4aa5824b45ff9543f60c648625869b11b1a3 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 12 Aug 2018 19:12:58 +0300 Subject: do not show banned users in my feed from recommendations --- .../test/java/com/juick/server/tests/ServerTests.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'juick-server/src/test/java/com') 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 b4d91b79..1aff9ca3 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 @@ -176,6 +176,7 @@ public class ServerTests { freefd = userService.getUserByUID(freefdId).orElseThrow(IllegalStateException::new); int juickId = userService.createUser(juickName, juickPassword); juick = userService.getUserByUID(juickId).orElseThrow(IllegalStateException::new); + subscriptionService.subscribeUser(freefd, ugnich); isSetUp = true; } } @@ -190,8 +191,6 @@ public class ServerTests { public void getMyFeed() { int mid0 = messagesService.createMessage(ugnich.getUid(), "test", null, null); int mid2 = messagesService.createMessage(ugnich.getUid(), "test2", null, null); - subscriptionService.subscribeUser(userService.getUserByUID(freefd.getUid()).orElse(AnonymousUser.INSTANCE), - userService.getUserByUID(ugnich.getUid()).orElse(AnonymousUser.INSTANCE)); List freefdFeed = messagesService.getMyFeed(freefd.getUid(), 0, false); assertThat(freefdFeed.get(0), equalTo(mid2)); int tonyaid = userService.createUser("Tonya", "secret"); @@ -942,7 +941,18 @@ public class ServerTests { .stream().noneMatch(m -> m.getTags().contains(banned))); assertFalse(messagesService.getMessages(AnonymousUser.INSTANCE, messagesService.getPopular(ugnich.getUid(), 0)) .stream().noneMatch(m -> m.getTags().contains(banned))); - + assertTrue(messagesService.getMessages(AnonymousUser.INSTANCE, messagesService.getMyFeed(freefd.getUid(), 0, true)) + .stream().noneMatch(m -> m.getTags().contains(banned))); + int newUid = userService.createUser("newUser", "12345"); + int newMid = messagesService.createMessage(newUid, "people", null, Collections.singletonList(banned)); + messagesService.recommendMessage(newMid, ugnich.getUid()); + assertTrue(messagesService.getMessages(AnonymousUser.INSTANCE, messagesService.getMyFeed(freefd.getUid(), 0, true)) + .stream().noneMatch(m -> m.getTags().contains(banned))); + tagService.updateTags(newMid, Collections.singletonList(banned)); + assertThat(messagesService.getMessage(newMid).getTags().size(), is(0)); + privacyQueriesService.blacklistUser(freefd, userService.getUserByUID(newUid).orElse(AnonymousUser.INSTANCE)); + assertTrue(messagesService.getMessages(AnonymousUser.INSTANCE, messagesService.getMyFeed(freefd.getUid(), 0, true)) + .stream().noneMatch(m -> m.getMid() == newMid)); } @Test public void tagsShouldBeDeserializedFromXml() throws JAXBException { -- cgit v1.2.3