diff options
author | Vitaly Takmazov | 2019-02-26 14:48:02 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2019-02-26 15:03:20 +0300 |
commit | dafee9c471e154e375cca19f5e96c9c6fc89033f (patch) | |
tree | 1f21d9545906fa010d961d55a9090867a7055664 /src/test/java/com/juick/server/tests | |
parent | 8531d6c7dd1acb4fdeddc5bad926b61e492ca1b4 (diff) |
Display federated likes
Diffstat (limited to 'src/test/java/com/juick/server/tests')
-rw-r--r-- | src/test/java/com/juick/server/tests/ServerTests.java | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index 5c421f07..c8f07d06 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -26,12 +26,12 @@ import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.css.StyleElement; import com.gargoylesoftware.htmlunit.html.DomElement; import com.gargoylesoftware.htmlunit.html.HtmlPage; -import com.github.jsonldjava.core.JsonLdOptions; -import com.github.jsonldjava.core.JsonLdProcessor; -import com.github.jsonldjava.utils.JsonUtils; import com.jayway.jsonpath.JsonPath; import com.juick.*; -import com.juick.model.*; +import com.juick.model.AnonymousUser; +import com.juick.model.CommandResult; +import com.juick.model.PrivateChats; +import com.juick.model.TagStats; import com.juick.server.*; import com.juick.server.api.activity.model.Context; import com.juick.server.api.activity.model.activities.*; @@ -104,7 +104,6 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.*; -import java.net.ConnectException; import java.net.URI; import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; @@ -901,7 +900,7 @@ public class ServerTests { mockMvc.perform(get("/api/thread?mid=" + mid + "&hash=" + freefdHash)) .andExpect(status().isOk()) .andExpect(jsonPath("$[0].recommendations.length()", is(1))) - .andExpect(jsonPath("$[0].recommendations[0]", is(freefdName))); + .andExpect(jsonPath("$[0].recommendations[0].uname", is(freefdName))); mockMvc.perform(post("/api/like?mid=" + freefdMid + "&hash=" + freefdHash)) .andExpect(status().isForbidden()); } @@ -1354,11 +1353,18 @@ public class ServerTests { assertThat(messagesService.recommendMessage(mid, ermineId), is(MessagesService.RecommendStatus.Added)); assertThat(messagesService.recommendMessage(mid, fmapId), is(MessagesService.RecommendStatus.Added)); assertThat(messagesService.recommendMessage(mid, pogoId), is(MessagesService.RecommendStatus.Added)); - assertThat(messagesService.getMessage(mid).get().getLikes(), is(3)); - assertThat(CollectionUtils.isEqualCollection(messagesService.getMessageRecommendations(mid), Arrays.asList("fmap", "ermine", "pogo")), is(true)); - privacyQueriesService.blacklistUser(userService.getUserByName("monstreek"), userService.getUserByName("pogo")); - assertThat(messagesService.getMessage(mid).get().getLikes(), is(3)); - assertThat(CollectionUtils.isEqualCollection(messagesService.getMessageRecommendations(mid), Arrays.asList("fmap", "ermine")), is(true)); + jdbcTemplate.update("INSERT INTO favorites(user_id, user_uri, message_id, like_id, ts) " + + "values (0, 'http://example.com/u/test', ?, 1, now())", mid); + assertThat(messagesService.getMessage(mid).get().getLikes(), is(4)); + assertThat(CollectionUtils.isEqualCollection(messagesService.getMessageRecommendations(mid) + .stream().map(User::getName).collect(Collectors.toList()), + Arrays.asList("fmap", "ermine", "pogo", "Anonymous")), is(true)); + privacyQueriesService.blacklistUser(userService.getUserByName("monstreek"), + userService.getUserByName("pogo")); + assertThat(messagesService.getMessage(mid).get().getLikes(), is(4)); + assertThat(CollectionUtils.isEqualCollection(messagesService.getMessageRecommendations(mid) + .stream().map(User::getName).collect(Collectors.toList()), + Arrays.asList("fmap", "ermine", "Anonymous")), is(true)); } @Test public void bannedUserShouldNotBeVisibleToOthers() { @@ -1708,6 +1714,7 @@ public class ServerTests { replyNote.setTo(Collections.singletonList(activityPubManager.personUri(ugnich))); replyNote.setContent("HI"); Create create = new Create(); + create.setId(replyNote.getId()); create.setActor("http://localhost:8080/u/freefd"); create.setObject(replyNote); signatureManager.post((Person) signatureManager.getContext(URI.create("http://localhost:8080/u/freefd")).get(), |