aboutsummaryrefslogtreecommitdiff
path: root/juick-server-jdbc/src/test/java/com/juick/service
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-09-11 21:00:02 +0300
committerGravatar Vitaly Takmazov2017-09-11 21:01:55 +0300
commit49c4b7f3ccbd4e22f500ea2f46e520786d8a8ab1 (patch)
tree2443c30e860c8df691db8358547462377da94b2f /juick-server-jdbc/src/test/java/com/juick/service
parente49843282fec85ac29a4b83ab384ab7bc1c6ae1f (diff)
no more recommended tab
Diffstat (limited to 'juick-server-jdbc/src/test/java/com/juick/service')
-rw-r--r--juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java34
1 files changed, 24 insertions, 10 deletions
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 fae938cc..64de9424 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
@@ -18,11 +18,13 @@
package com.juick.service;
import com.juick.configuration.RepositoryConfiguration;
+import com.juick.server.helpers.AnonymousUser;
import org.junit.Test;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
import javax.inject.Inject;
+import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
@@ -36,20 +38,32 @@ public class MessageServiceTest extends AbstractJUnit4SpringContextTests {
private MessagesService messagesService;
@Inject
private UserService userService;
+ @Inject
+ private SubscriptionService subscriptionService;
+
+ int ugnichId, freefdId, mid;
@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));
+ ugnichId = userService.createUser("ugnich", "secret");
+ freefdId = userService.createUser("freefd", "secret");
+ mid = messagesService.createMessage(ugnichId, "test", null, null);
+ int mid2 = messagesService.createMessage(ugnichId, "test2", null, null);
+ subscriptionService.subscribeUser(userService.getUserByUID(freefdId).orElse(AnonymousUser.INSTANCE),
+ userService.getUserByUID(ugnichId).orElse(AnonymousUser.INSTANCE));
+ List<Integer> freefdFeed = messagesService.getMyFeed(freefdId, 0, false);
+ assertThat(freefdFeed.size(), equalTo(2));
+ int tonyaid = userService.createUser("Tonya", "secret");
+ int mid3 = messagesService.createMessage(tonyaid, "test3", null, null);
+ messagesService.recommendMessage(mid3, ugnichId);
+ assertThat(messagesService.getMyFeed(freefdId, 0, false).size(), equalTo(2));
+ assertThat(messagesService.getMyFeed(freefdId, 0, true).size(), equalTo(3));
+ assertThat(messagesService.getMyFeed(freefdId, mid2, true).size(), equalTo(1));
+ assertThat(messagesService.getMyFeed(freefdId, mid, false).size(), equalTo(0));
+ assertThat(messagesService.recommendMessage(mid, ugnichId), equalTo(true));
assertThat(messagesService.getMessage(mid).getLikes(), equalTo(1));
- assertThat(messagesService.recommendMessage(mid, uid), equalTo(false));
+ assertThat(messagesService.recommendMessage(mid, ugnichId), equalTo(false));
assertThat(messagesService.getMessage(mid).getLikes(), equalTo(0));
- assertThat(messagesService.getAll(uid, 0).size(), equalTo(2));
+ assertThat(messagesService.getAll(ugnichId, 0).size(), equalTo(3));
}
}