From ca2db58145c4663a22f44f5f98a67aa03fbe8d38 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 23 Aug 2017 11:59:55 +0300 Subject: server-jdbc: fix favorites count --- .../test/java/com/juick/service/MessageServiceTest.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'juick-server-jdbc/src/test/java') diff --git a/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java b/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java index fed5dad8..fae938cc 100644 --- a/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java +++ b/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java @@ -24,6 +24,9 @@ import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; import javax.inject.Inject; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; + /** * Created by aalexeev on 11/25/16. */ @@ -31,10 +34,22 @@ import javax.inject.Inject; public class MessageServiceTest extends AbstractJUnit4SpringContextTests { @Inject private MessagesService messagesService; - + @Inject + private UserService userService; @Test public void getMyFeed() { messagesService.getMyFeed(1, 1000000); } + @Test + public void likesCountShouldMatch() { + int uid = userService.createUser("ugnich", "secret"); + int mid = messagesService.createMessage(uid, "test", null, null); + int mid2 = messagesService.createMessage(uid, "test2", null, null); + assertThat(messagesService.recommendMessage(mid, uid), equalTo(true)); + assertThat(messagesService.getMessage(mid).getLikes(), equalTo(1)); + assertThat(messagesService.recommendMessage(mid, uid), equalTo(false)); + assertThat(messagesService.getMessage(mid).getLikes(), equalTo(0)); + assertThat(messagesService.getAll(uid, 0).size(), equalTo(2)); + } } -- cgit v1.2.3