From c5d03ea70ce732e0eabc7ea90b13b8ab95601c07 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 3 Mar 2022 15:15:39 +0300 Subject: Fix *readonly tag --- .../java/com/juick/server/tests/ServerTests.java | 102 ++++++++++----------- 1 file changed, 51 insertions(+), 51 deletions(-) (limited to 'src/test/java/com') diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index df247b66..8cff4826 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -412,12 +412,12 @@ public class ServerTests { jdbcTemplate.execute("DELETE FROM telegram"); jdbcTemplate.execute("DELETE FROM subscr_users"); subscriptionService.subscribeUser(freefd, ugnich); - int mid0 = messagesService.createMessage(ugnich.getUid(), "test", null, null); - int mid2 = messagesService.createMessage(ugnich.getUid(), "test2", null, null); + int mid0 = messagesService.createMessage(ugnich.getUid(), "test", null, Set.of()); + int mid2 = messagesService.createMessage(ugnich.getUid(), "test2", null, Set.of()); List freefdFeed = messagesService.getMyFeed(freefd.getUid(), 0, false); assertThat(freefdFeed.get(0), equalTo(mid2)); User tonya = userService.createUser("Tonya", "secret").orElseThrow(IllegalStateException::new); - int mid3 = messagesService.createMessage(tonya.getUid(), "test3", null, null); + int mid3 = messagesService.createMessage(tonya.getUid(), "test3", null, Set.of()); messagesService.recommendMessage(mid3, ugnich.getUid()); assertThat(messagesService.getMyFeed(freefd.getUid(), 0, false).get(0), equalTo(mid2)); assertThat(messagesService.getMyFeed(freefd.getUid(), 0, true).get(0), equalTo(mid3)); @@ -431,7 +431,7 @@ public class ServerTests { assertThat(messagesService.getAll(ugnich.getUid(), 0).get(0), equalTo(mid3)); Tag yoTag = tagService.getTag("yoyo", true); assertThat(tagService.getTag("YOYO", false), equalTo(yoTag)); - int mid = messagesService.createMessage(ugnich.getUid(), "yo", null, Collections.singletonList(yoTag)); + int mid = messagesService.createMessage(ugnich.getUid(), "yo", null, Set.of(yoTag)); Message msg = messagesService.getMessage(mid).get(); List subscribers = subscriptionService.getSubscribedUsers(ugnich.getUid(), msg); @@ -472,7 +472,7 @@ public class ServerTests { public void messageTests() { User user = userService.createUser("mmmme", "secret").orElseThrow(IllegalStateException::new); assertEquals("mmmme", user.getName()); - int mid = messagesService.createMessage(user.getUid(), "yo", null, new ArrayList<>()); + int mid = messagesService.createMessage(user.getUid(), "yo", null, Set.of()); Message msg = messagesService.getMessage(mid).get(); assertEquals("yo", msg.getText()); User me = msg.getUser(); @@ -480,8 +480,7 @@ public class ServerTests { assertEquals("mmmme", messagesService.getMessageAuthor(mid).getName()); int tagID = tagService.createTag("weather"); Tag tag = tagService.getTag(tagID); - List tagList = new ArrayList<>(); - tagList.add(tag); + Set tagList = Set.of(tag); int mid2 = messagesService.createMessage(user.getUid(), "yo2", null, tagList); Message msg2 = messagesService.getMessage(mid2).get(); assertEquals(1, msg2.getTags().size()); @@ -526,7 +525,7 @@ public class ServerTests { htmlTagStats.setTag(htmlTag); String dbTagName = jdbcTemplate.queryForObject("select name from tags where name=?", String.class, htmlTagName); assertEquals(dbTagName, htmlTag.getName()); - int mid4 = messagesService.createMessage(user.getUid(), "yoyoyo", null, null); + int mid4 = messagesService.createMessage(user.getUid(), "yoyoyo", null, Set.of()); Message msg4 = messagesService.getMessage(mid4).get(); assertEquals(StringUtils.EMPTY, MessageUtils.getTagsString(msg4)); messagesService.deleteMessage(user.getUid(), mid4); @@ -548,7 +547,7 @@ public class ServerTests { public void likeTypeStatsTests() { User dsdss = userService.createUser("dsdss", "secret").orElseThrow(IllegalStateException::new); final int freefdId = freefd.getUid(); - int mid = messagesService.createMessage(dsdss.getUid(), "yo", null, new ArrayList<>()); + int mid = messagesService.createMessage(dsdss.getUid(), "yo", null, Set.of()); messagesService.likeMessage(mid, freefdId, 2); messagesService.likeMessage(mid, freefdId, 2); messagesService.likeMessage(mid, freefdId, 3); @@ -591,7 +590,7 @@ public class ServerTests { @Test public void messageUpdatedTimeShouldMatchLastReplyTime() throws InterruptedException { User hugnich4 = userService.createUser("hugnich4", "x").orElseThrow(IllegalStateException::new); - int mid = messagesService.createMessage(hugnich4.getUid(), "yo", null, null); + int mid = messagesService.createMessage(hugnich4.getUid(), "yo", null, Set.of()); Instant ts = jdbcTemplate .queryForObject("SELECT updated FROM messages WHERE message_id=?", Timestamp.class, mid).toInstant(); Thread.sleep(1000); @@ -686,7 +685,7 @@ public class ServerTests { String freefdHash = userService.getHashByUID(freefd.getUid()); String userIdHash = userService.getHashByUID(dsds4345.getUid()); final int freefdId = freefd.getUid(); - int mid = messagesService.createMessage(dsds4345.getUid(), "yo", null, new ArrayList<>()); + int mid = messagesService.createMessage(dsds4345.getUid(), "yo", null, Set.of()); messagesService.likeMessage(mid, freefdId, 2); messagesService.likeMessage(mid, freefdId, 2); messagesService.likeMessage(mid, freefdId, 3); @@ -704,8 +703,8 @@ public class ServerTests { public void tags() throws Exception { Tag weather = tagService.getTag("weather", true); Tag yo = tagService.getTag("yo", true); - messagesService.createMessage(ugnich.getUid(), "text", null, Arrays.asList(yo, weather)); - messagesService.createMessage(freefd.getUid(), "text2", null, Collections.singletonList(yo)); + messagesService.createMessage(ugnich.getUid(), "text", null, Set.of(yo, weather)); + messagesService.createMessage(freefd.getUid(), "text2", null, Set.of(yo)); MvcResult result = mockMvc.perform(get("/api/tags")).andExpect(status().isOk()).andReturn(); List tagsFromApi = jsonMapper.readValue(result.getResponse().getContentAsString(), new TypeReference<>() { @@ -797,7 +796,7 @@ public class ServerTests { @Test public void topTest() { - int topmid = messagesService.createMessage(ugnich.getUid(), "top message", null, null); + int topmid = messagesService.createMessage(ugnich.getUid(), "top message", null, Set.of()); IntStream.rangeClosed(6, 12).forEach(i -> { User next = new User(); next.setUid(i); @@ -828,7 +827,7 @@ public class ServerTests { tagService.updateTags(topmid, Collections.singletonList(nsfw)); assertThat(messagesService.getPopularCandidates().isEmpty(), is(true)); User recommender = userService.createUser("recommender2", "x").orElseThrow(IllegalStateException::new); - int anotherMid = messagesService.createMessage(ugnich.getUid(), "top2", null, null); + int anotherMid = messagesService.createMessage(ugnich.getUid(), "top2", null, Set.of()); messagesService.recommendMessage(anotherMid, freefd.getUid()); messagesService.recommendMessage(anotherMid, recommender.getUid()); assertThat(messagesService.getPopularCandidates().get(0), is(anotherMid)); @@ -1003,7 +1002,7 @@ public class ServerTests { @Test public void mailParserTest() throws Exception { emailService.addEmail(ugnich.getUid(), "ugnich@example.com"); - int mid = messagesService.createMessage(ugnich.getUid(), "text", StringUtils.EMPTY, Collections.emptyList()); + int mid = messagesService.createMessage(ugnich.getUid(), "text", StringUtils.EMPTY, Set.of()); String mail = String.format( "MIME-Version: 1.0\n" + "Received: by 10.176.0.242 with HTTP; Fri, 16 Mar 2018 05:31:50 -0700 (PDT)\n" + "In-Reply-To: <%d.0@juick.com>\n" + "References: <%d.0@juick.com>\n" @@ -1038,9 +1037,9 @@ public class ServerTests { @Test public void recommendTests() throws Exception { - int mid = messagesService.createMessage(ugnich.getUid(), "to be liked", null, null); + int mid = messagesService.createMessage(ugnich.getUid(), "to be liked", null, Set.of()); String freefdHash = userService.getHashByUID(freefd.getUid()); - int freefdMid = messagesService.createMessage(freefd.getUid(), "to be not liked", null, null); + int freefdMid = messagesService.createMessage(freefd.getUid(), "to be not liked", null, Set.of()); mockMvc.perform(post("/api/like?mid=" + mid + "&hash=" + freefdHash)).andExpect(status().isOk()) .andExpect(jsonPath("$.status", is("Message is added to your recommendations"))); @@ -1054,7 +1053,7 @@ public class ServerTests { public void likesTests() throws Exception { User dsds = userService.createUser("dsds", "secret").orElseThrow(IllegalStateException::new); String freefdHash = userService.getHashByUID(freefd.getUid()); - int mid1 = messagesService.createMessage(dsds.getUid(), "yo", null, new ArrayList<>()); + int mid1 = messagesService.createMessage(dsds.getUid(), "yo", null, Set.of()); mockMvc.perform(post("/api/react?mid=" + mid1 + "&hash=" + freefdHash + "&reactionId=2")) .andExpect(status().isOk()); @@ -1079,7 +1078,7 @@ public class ServerTests { jdbcTemplate.execute("DELETE FROM bl_users"); jdbcTemplate.execute("DELETE FROM messages"); assertThat(userService.isInBLAny(ugnich.getUid(), freefd.getUid()), is(false)); - int mid = messagesService.createMessage(ugnich.getUid(), "to be watched", null, null); + int mid = messagesService.createMessage(ugnich.getUid(), "to be watched", null, Set.of()); subscriptionService.subscribeMessage(messagesService.getMessage(mid).get(), ugnich); messagesService.createReply(mid, 0, freefd, "new reply", null); BiFunction lastRead = (user, m) -> jdbcTemplate.queryForObject( @@ -1118,7 +1117,7 @@ public class ServerTests { @Test public void feedsShouldNotContainMessagesWithBannedTags() { Tag banned = tagService.getTag("banned", true); - int mid = messagesService.createMessage(ugnich.getUid(), "yo", "jpg", Collections.singletonList(banned)); + int mid = messagesService.createMessage(ugnich.getUid(), "yo", "jpg", Set.of(banned)); privacyQueriesService.blacklistTag(freefd, banned); assertThat(messagesService.getMessages(AnonymousUser.INSTANCE, messagesService.getAll(freefd.getUid(), 0)) .stream().noneMatch(m -> m.getTags().contains(banned)), is(true)); @@ -1142,8 +1141,7 @@ public class ServerTests { .stream().noneMatch(m -> m.getTags().contains(banned)), is(true)); User newUser1 = userService.createUser("newUser1", "12345").orElseThrow(IllegalStateException::new); - int newMid = messagesService.createMessage(newUser1.getUid(), "people", null, - Collections.singletonList(banned)); + int newMid = messagesService.createMessage(newUser1.getUid(), "people", null, Set.of(banned)); messagesService.recommendMessage(newMid, ugnich.getUid()); assertThat( messagesService.getMessages(AnonymousUser.INSTANCE, messagesService.getMyFeed(freefd.getUid(), 0, true)) @@ -1291,7 +1289,7 @@ public class ServerTests { assertThat(nonblmsgs.get(0).getReplies(), is(5)); commandsManager.processCommand(ugnich, "BL @freefd", emptyUri); Tag tag = tagService.getTag("linux", true); - int freefdMsg = messagesService.createMessage(freefd.getUid(), "sux", null, Collections.singletonList(tag)); + int freefdMsg = messagesService.createMessage(freefd.getUid(), "sux", null, Set.of(tag)); assertThat(messagesService.getTag(tag.TID, freefd.getUid(), 0, 10).size(), is(1)); assertThat(messagesService.getTag(tag.TID, ugnich.getUid(), 0, 10).size(), is(0)); messagesService.recommendMessage(freefdMsg, serviceUser.getUid()); @@ -1459,7 +1457,7 @@ public class ServerTests { subscriptionService.subscribeUser(reader, lateRecommender); Tag sampleTag = tagService.getTag("banned", true); int posterMid = messagesService.createMessage(poster.getUid(), "YO", null, - Collections.singletonList(sampleTag)); + Set.of(sampleTag)); messagesService.recommendMessage(posterMid, recommender.getUid()); BiFunction> subscribers = (recommId, msg) -> subscriptionService .getUsersSubscribedToUserRecommendations(recommId, msg); @@ -1479,7 +1477,7 @@ public class ServerTests { List lateRecommendSubscribers = subscribers.apply(recommender.getUid(), messagesService.getMessage(posterMid).get()); assertThat(lateRecommendSubscribers.size(), is(0)); - int readerMid = messagesService.createMessage(reader.getUid(), "PEOPLE", null, null); + int readerMid = messagesService.createMessage(reader.getUid(), "PEOPLE", null, Set.of()); messagesService.recommendMessage(readerMid, recommender.getUid()); assertThat(subscribers.apply(recommender.getUid(), messagesService.getMessage(readerMid).get()).size(), is(0)); } @@ -1489,7 +1487,7 @@ public class ServerTests { User poster = userService.createUser("p", "secret").orElseThrow(IllegalStateException::new); User commenter = userService.createUser("cc", "secret").orElseThrow(IllegalStateException::new); User mentioner = userService.createUser("mmm", "secret").orElseThrow(IllegalStateException::new); - int mid = messagesService.createMessage(poster.getUid(), "who is dick?", null, null); + int mid = messagesService.createMessage(poster.getUid(), "who is dick?", null, Set.of()); Message msg = messagesService.getMessage(mid).get(); int rid = messagesService.createReply(mid, 0, commenter, "@mmm is dick", null); Message reply = messagesService.getReply(mid, rid); @@ -1503,12 +1501,12 @@ public class ServerTests { @Test public void mentionsInPosts() { jdbcTemplate.execute("DELETE FROM bl_users"); - int mid = messagesService.createMessage(ugnich.getUid(), "@freefd is dick", null, null); + int mid = messagesService.createMessage(ugnich.getUid(), "@freefd is dick", null, Set.of()); Message msg = messagesService.getMessage(mid).get(); assertThat(subscriptionService.getSubscribedUsers(ugnich.getUid(), msg).get(0), is(freefd)); privacyQueriesService.blacklistUser(freefd, ugnich); assertThat(subscriptionService.getSubscribedUsers(ugnich.getUid(), msg).size(), is(0)); - int mid2 = messagesService.createMessage(freefd.getUid(), "@ugnich is dick", null, null); + int mid2 = messagesService.createMessage(freefd.getUid(), "@ugnich is dick", null, Set.of()); Message msg2 = messagesService.getMessage(mid2).get(); assertThat(subscriptionService.getSubscribedUsers(freefd.getUid(), msg2).get(0), is(ugnich)); jdbcTemplate.execute("DELETE FROM bl_users"); @@ -1547,7 +1545,7 @@ public class ServerTests { String msgText = "автор этого поста был забанен"; User isilmine = userService.createUser(userName, userPassword).orElseThrow(IllegalStateException::new); - int mid = messagesService.createMessage(isilmine.getUid(), msgText, null, null); + int mid = messagesService.createMessage(isilmine.getUid(), msgText, null, Set.of()); mockMvc.perform(get(String.format("/api/thread?mid=%d", mid)).with(httpBasic(ugnichName, ugnichPassword))) .andExpect(status().isOk()); jdbcTemplate.update("UPDATE users SET banned=1 WHERE id=?", isilmine.getUid()); @@ -1579,7 +1577,7 @@ 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, null); + int mid = messagesService.createMessage(monstreek.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)); @@ -1604,12 +1602,12 @@ public class ServerTests { User casualUser = userService.createUser("user", "secret").orElseThrow(IllegalStateException::new); User bannedUser = userService.createUser("banned", "banned").orElseThrow(IllegalStateException::new); jdbcTemplate.update("UPDATE users SET banned=1 WHERE id=?", bannedUser.getUid()); - messagesService.createMessage(bannedUser.getUid(), "KURWA", null, Collections.emptyList()); + messagesService.createMessage(bannedUser.getUid(), "KURWA", null, Set.of()); assertThat(messagesService.getAll(casualUser.getUid(), 0).size(), is(0)); assertThat(messagesService.getDiscussions(casualUser.getUid(), 0L).size(), is(0)); assertThat(messagesService.getDiscussions(0, 0L).size(), is(0)); assertThat(messagesService.getAll(bannedUser.getUid(), 0).size(), is(1)); - int mid = messagesService.createMessage(casualUser.getUid(), "PEACE", null, Collections.emptyList()); + int mid = messagesService.createMessage(casualUser.getUid(), "PEACE", null, Set.of()); User banned = userService.getUserByName("banned"); int bannedRid = messagesService.createReply(mid, 0, banned, "KURWA", null); int casualRid = messagesService.createReply(mid, 0, userService.getUserByName("user"), "DOOR", null); @@ -1640,7 +1638,7 @@ public class ServerTests { jdbcTemplate.execute("DELETE FROM messages"); List mids = IteratorUtils.toList(IntStream.rangeClosed(1, 30) .mapToObj( - i -> messagesService.createMessage(ugnich.getUid(), String.format("message %d", i), null, null)) + i -> messagesService.createMessage(ugnich.getUid(), String.format("message %d", i), null, Set.of())) .collect(Collectors.toCollection(ArrayDeque::new)).descendingIterator()); List midsPage = mids.stream().limit(20).collect(Collectors.toList()); mockMvc.perform(get("/u/ugnich/blog").accept(Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE)) @@ -1652,14 +1650,14 @@ public class ServerTests { @Test public void postWithoutTagsShouldNotHaveAsteriskInTitle() throws Exception { String msgText = "Привет, я - Угнич"; - int mid = messagesService.createMessage(ugnich.getUid(), msgText, null, null); + int mid = messagesService.createMessage(ugnich.getUid(), msgText, null, Set.of()); HtmlPage threadPage = webClient.getPage(String.format("http://localhost:8080/ugnich/%d", mid)); assertThat(threadPage.getTitleText(), equalTo("ugnich:")); } @Test public void repliesList() throws IOException { - int mid = messagesService.createMessage(ugnich.getUid(), "hello", null, null); + int mid = messagesService.createMessage(ugnich.getUid(), "hello", null, Set.of()); IntStream.range(1, 15) .forEach(i -> messagesService.createReply(mid, i - 1, freefd, String.valueOf(i - 1), null)); @@ -1675,7 +1673,7 @@ public class ServerTests { @Test public void userShouldNotSeeReplyButtonToBannedUser() throws Exception { - int mid = messagesService.createMessage(ugnich.getUid(), "freefd bl me", null, null); + int mid = messagesService.createMessage(ugnich.getUid(), "freefd bl me", null, Set.of()); messagesService.createReply(mid, 0, ugnich, "yo", null); MvcResult loginResult = mockMvc .perform(post("/login").param("username", freefdName).param("password", freefdPassword)) @@ -1718,11 +1716,11 @@ public class ServerTests { @Test public void testTwitterCards() throws Exception { - int mid = messagesService.createMessage(ugnich.getUid(), "without image", null, null); + int mid = messagesService.createMessage(ugnich.getUid(), "without image", null, Set.of()); assertThat(fetchMeta(String.format("http://localhost:8080/ugnich/%d", mid), "twitter:card") .getAttribute("content"), equalTo("summary")); - int mid2 = messagesService.createMessage(ugnich.getUid(), "with image", "png", null); + int mid2 = messagesService.createMessage(ugnich.getUid(), "with image", "png", Set.of()); Message message = messagesService.getMessage(mid2).get(); assertThat(fetchMeta(String.format("http://localhost:8080/ugnich/%d", mid2), "twitter:card") .getAttribute("content"), equalTo("summary_large_image")); @@ -1759,8 +1757,8 @@ public class ServerTests { @Test public void discussionsShouldBePageableByTimestamp() throws Exception { String msgText = "Привет, я снова Угнич"; - int mid = messagesService.createMessage(ugnich.getUid(), msgText, null, null); - int midNew = messagesService.createMessage(ugnich.getUid(), "Я более новый Угнич", null, null); + int mid = messagesService.createMessage(ugnich.getUid(), msgText, null, Set.of()); + int midNew = messagesService.createMessage(ugnich.getUid(), "Я более новый Угнич", null, Set.of()); MvcResult loginResult = mockMvc .perform(post("/login").param("username", freefdName).param("password", freefdPassword)) .andExpect(status().is3xxRedirection()).andReturn(); @@ -1792,7 +1790,7 @@ public class ServerTests { assertThat(discussionsOld.querySelectorAll("article").get(0).getAttributes().getNamedItem("data-mid") .getNodeValue(), is(String.valueOf(midNew))); List newMids = IntStream.rangeClosed(1, 19) - .map(i -> messagesService.createMessage(ugnich.getUid(), String.valueOf(i), null, null)).boxed() + .map(i -> messagesService.createMessage(ugnich.getUid(), String.valueOf(i), null, Set.of())).boxed() .collect(Collectors.toList()); for (Integer m : newMids) { subscriptionService.subscribeMessage(messagesService.getMessage(m).get(), freefd); @@ -1828,7 +1826,7 @@ public class ServerTests { @Test public void anythingRedirects() throws Exception { - int mid = messagesService.createMessage(ugnich.getUid(), "yo", null, null); + int mid = messagesService.createMessage(ugnich.getUid(), "yo", null, Set.of()); mockMvc.perform(get(String.format("/%d", mid))).andExpect(status().isMovedPermanently()) .andExpect(redirectedUrl(String.format("/%s/%d", ugnich.getName(), mid))); } @@ -1853,7 +1851,7 @@ public class ServerTests { webClient.setCookieManager(new CookieManager()); webClient.getCookieManager().addCookie(new com.gargoylesoftware.htmlunit.util.Cookie(loginCookie.getDomain(), loginCookie.getName(), loginCookie.getValue())); - int mid = messagesService.createMessage(ugnich.getUid(), "new test", null, null); + int mid = messagesService.createMessage(ugnich.getUid(), "new test", null, Set.of()); subscriptionService.subscribeMessage(messagesService.getMessage(mid).get(), freefd); messagesService.createReply(mid, 0, ugnich, "new reply", null); HtmlPage discussionsPage = webClient.getPage("http://localhost:8080/?show=discuss"); @@ -1932,7 +1930,7 @@ public class ServerTests { String attachment = attachmentObj != null ? (String) attachmentObj.getUrl() : StringUtils.EMPTY; String deleteJsonStr = IOUtils.toString(new ClassPathResource("delete.json").getURI(), StandardCharsets.UTF_8); Delete delete = jsonMapper.readValue(deleteJsonStr, Delete.class); - int mid = messagesService.createMessage(ugnich.getUid(), "YO", "", null); + int mid = messagesService.createMessage(ugnich.getUid(), "YO", "", Set.of()); User extUser = new User(); extUser.setUri(URI.create("http://localhost:8080/users/xwatt")); int rid = messagesService.createReply(mid, 0, extUser, "PEOPLE", null); @@ -2103,7 +2101,7 @@ public class ServerTests { User newUser = userService.createUser("newuser", "assword").orElseThrow(IllegalStateException::new); assertThat(newUser.getUid(), greaterThanOrEqualTo(0)); assertThat(newUser.getSeen(), is(nullValue())); - messagesService.createMessage(newUser.getUid(), "YO", "", null); + messagesService.createMessage(newUser.getUid(), "YO", "", Set.of()); assertThat(userService.getUserByUID(newUser.getUid()).get().getSeen(), greaterThanOrEqualTo(now)); } @@ -2311,7 +2309,7 @@ public class ServerTests { @Test public void federatedAttachmentsAsLinks() throws Exception { - int mid = messagesService.createMessage(ugnich.getUid(), "test", StringUtils.EMPTY, Collections.emptyList()); + int mid = messagesService.createMessage(ugnich.getUid(), "test", StringUtils.EMPTY, Set.of()); Message testMessage = MockUtils.mockMessage(mid, freefd, "reply"); String activity = IOUtils.toString(noteWithDocument.getInputStream(), StandardCharsets.UTF_8); Announce announce = jsonMapper.readValue(activity, Announce.class); @@ -2363,7 +2361,7 @@ public class ServerTests { @Test public void messagePropertiesTest() { - int mid = messagesService.createMessage(ugnich.getUid(), "YO", null, null); + int mid = messagesService.createMessage(ugnich.getUid(), "YO", null, Set.of()); messagesService.setMessageProperty(mid, 0, "tg_id", "YO"); assertThat(messagesService.getMessageProperty(mid, 0, "tg_id"), is("YO")); messagesService.setMessageProperty(mid, 0, "tg_id", "YO2"); @@ -2402,7 +2400,7 @@ public class ServerTests { @Test public void wsThreadsShouldRedirect() throws Exception { - int mid = messagesService.createMessage(ugnich.getUid(), "tst", null, Collections.emptyList()); + int mid = messagesService.createMessage(ugnich.getUid(), "tst", null, Set.of()); mockMvc.perform(get("/ugnich/" + mid)).andExpect(status().isOk()); mockMvc.perform(get("/s/" + mid)).andExpect(status().isFound()).andExpect(redirectedUrl("/ugnich/" + mid)); mockMvc.perform(get("/ws/" + mid)).andExpect(status().isFound()).andExpect(redirectedUrl("/ugnich/" + mid)); @@ -2466,13 +2464,15 @@ public class ServerTests { @Test public void readonlyTest() throws Exception { - var result = commandsManager.processCommand(ugnich, "YO", emptyUri); + var result = commandsManager.processCommand(ugnich, "*readonly YO", emptyUri); var mid = result.getNewMessage().get().getMid(); - jdbcTemplate.update("UPDATE messages SET readonly=1 WHERE message_id=?", mid); var readonlyResult = commandsManager.processCommand(freefd, String.format("#%d PEOPLE", mid), emptyUri); assertThat(readonlyResult.getNewMessage().isPresent(), is(false)); var authorResult = commandsManager.processCommand(ugnich, String.format("#%d PEOPLE", mid), emptyUri); assertThat(authorResult.getNewMessage().isPresent(), is(true)); + commandsManager.processCommand(ugnich, String.format("#%d *readonly", mid), emptyUri); + Message updatedMessage = messagesService.getMessage(mid).orElseThrow(); + assertThat(updatedMessage.ReadOnly, is(false)); } @Test -- cgit v1.2.3