aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-04-24 22:22:36 +0300
committerGravatar Vitaly Takmazov2018-04-24 22:22:36 +0300
commit473c9dcec4ff03baf9940bc980371692e369ead2 (patch)
treeab1c527dc65bdaa2f26cc12fb106024954ab9b15
parent100d52a7bf6887b2f8af2fc816041d09553c3617 (diff)
server: allow like reaction
-rw-r--r--juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java12
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java4
2 files changed, 6 insertions, 10 deletions
diff --git a/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java
index 0ca30904..8554b35f 100644
--- a/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -253,13 +253,11 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
@Transactional
@Override
public RecommendStatus likeMessage(int mid, int vuid, int reactionId) throws IllegalArgumentException {
- if(reactionId == Reaction.LIKE) throw new IllegalArgumentException("this reaction type does not support here");
-
- boolean wasAdded = getJdbcTemplate()
- .update("INSERT INTO favorites(user_id, message_id, ts, like_id ) VALUES (?, ?, NOW(), ?)", vuid, mid, reactionId) == 1;
- if (wasAdded) {
- return RecommendStatus.Added;
- }
+ boolean wasAdded = getJdbcTemplate()
+ .update("INSERT INTO favorites(user_id, message_id, ts, like_id ) VALUES (?, ?, NOW(), ?)", vuid, mid, reactionId) == 1;
+ if (wasAdded) {
+ return RecommendStatus.Added;
+ }
return RecommendStatus.Error;
}
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 087acbc4..4ea212f1 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
@@ -286,8 +286,6 @@ public class ServerTests {
assertEquals("tags string should be empty", StringUtils.EMPTY, MessageUtils.getTagsString(msg4));
messagesService.deleteMessage(user_id, mid4);
}
-
- @Rule
public ExpectedException exception = ExpectedException.none();
@Test
@@ -298,10 +296,10 @@ public class ServerTests {
messagesService.likeMessage(mid, freefdId , 2);
messagesService.likeMessage(mid, freefdId,2);
messagesService.likeMessage(mid, freefdId,3);
- exception.expect(IllegalArgumentException.class);
messagesService.likeMessage(mid, freefdId,1);
Message msg4 = messagesService.getMessage(mid);
+ assertThat(msg4.getLikes(), equalTo(1));
Assert.assertEquals(2, msg4.getReactions().stream().filter(r -> r.getId() == 2)
.findFirst().orElseThrow(IllegalStateException::new).getCount());