aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-06-25 01:14:09 +0300
committerGravatar Vitaly Takmazov2022-06-25 01:14:09 +0300
commit8f3d85a8afa851f4457163d3aade01c1f63075a0 (patch)
treeb1ea8dd6a3c4335b96136604cb5acf9e3f4f4315 /src/test/java
parent4ebc9ab55553a33ef7c3bedb8628ffaf74333f84 (diff)
Fix recommendations counters in html templates
* deprecate `likes` message field, use `recommendations` where possible
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/com/juick/server/tests/ServerTests.java16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index 36483ce8..d5db7269 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -410,10 +410,10 @@ public class ServerTests {
assertThat(messagesService.getMyFeed(freefd.getUid(), mid2, true).get(0), equalTo(mid0));
assertThat(messagesService.recommendMessage(mid0, ugnich.getUid()),
equalTo(MessagesService.RecommendStatus.Added));
- assertThat(messagesService.getMessage(mid0).orElseThrow(IllegalStateException::new).getLikes(), equalTo(1));
+ assertThat(messagesService.getMessage(mid0).orElseThrow(IllegalStateException::new).getRecommendations().size(), equalTo(1));
assertThat(messagesService.recommendMessage(mid0, ugnich.getUid()),
equalTo(MessagesService.RecommendStatus.Deleted));
- assertThat(messagesService.getMessage(mid0).get().getLikes(), equalTo(0));
+ assertThat(messagesService.getMessage(mid0).get().getRecommendations().size(), equalTo(0));
assertThat(messagesService.getAll(ugnich.getUid(), 0).get(0), equalTo(mid3));
Tag yoTag = tagService.getTag("yoyo", true);
assertThat(tagService.getTag("YOYO", false), equalTo(yoTag));
@@ -540,7 +540,7 @@ public class ServerTests {
messagesService.likeMessage(mid, freefdId, 1);
Message msg4 = messagesService.getMessage(mid).get();
- assertThat(msg4.getLikes(), equalTo(1));
+ assertThat(msg4.getRecommendations().size(), equalTo(1));
assertEquals(2, msg4.getReactions().stream().filter(r -> r.getId() == 2).findFirst()
.orElseThrow(IllegalStateException::new).getCount());
@@ -1048,9 +1048,9 @@ public class ServerTests {
.andExpect(status().isOk());
Message msg4 = messagesService.getMessage(mid1).get();
- assertThat(msg4.getLikes(), is(0));
+ assertThat(msg4.getRecommendations().size(), is(0));
assertThat(
- messagesService.getMessages(AnonymousUser.INSTANCE, Collections.singletonList(mid1)).get(0).getLikes(),
+ messagesService.getMessages(AnonymousUser.INSTANCE, Collections.singletonList(mid1)).get(0).getRecommendations().size(),
is(0));
assertEquals(1, msg4.getReactions().stream().filter(r -> r.getId() == 2).findFirst()
.orElseThrow(IllegalStateException::new).getCount());
@@ -1058,7 +1058,7 @@ public class ServerTests {
.andExpect(status().isOk());
mockMvc.perform(post("/api/react?mid=" + mid1 + "&hash=" + freefdHash + "&reactionId=1"))
.andExpect(status().isOk());
- assertThat(messagesService.getMessage(mid1).get().getLikes(), is(1));
+ assertThat(messagesService.getMessage(mid1).get().getRecommendations().size(), is(1));
}
@Test
@@ -1575,13 +1575,13 @@ public class ServerTests {
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, now())", mid);
- assertThat(messagesService.getMessage(mid).get().getLikes(), is(4));
+ assertThat(messagesService.getMessage(mid).get().getRecommendations().size(), is(4));
assertThat(CollectionUtils.isEqualCollection(
messagesService.getMessagesRecommendations(Collections.singletonList(mid)).stream()
.map(p -> p.getRight()).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(messagesService.getMessage(mid).get().getRecommendations().size(), is(4));
assertThat(CollectionUtils.isEqualCollection(
messagesService.getMessagesRecommendations(Collections.singletonList(mid)).stream()
.map(p -> p.getRight()).map(User::getName).collect(Collectors.toList()),