|
6 | 6 | import io.getstream.core.models.Paginated; |
7 | 7 | import io.getstream.core.models.Reaction; |
8 | 8 | import java.util.List; |
| 9 | + |
| 10 | +import io.getstream.core.options.Filter; |
| 11 | +import io.getstream.core.options.Limit; |
9 | 12 | import org.junit.Test; |
10 | 13 |
|
| 14 | +import static org.junit.Assert.assertEquals; |
| 15 | + |
11 | 16 | public class ReactionsClientTest { |
12 | 17 | private static final String apiKey = |
13 | 18 | System.getenv("STREAM_KEY") != null |
@@ -49,6 +54,37 @@ public void filter() throws Exception { |
49 | 54 | .join(); |
50 | 55 | } |
51 | 56 |
|
| 57 | + @Test |
| 58 | + public void filterWithUserID() throws Exception { |
| 59 | + Client client = Client.builder(apiKey, secret).build(); |
| 60 | + |
| 61 | + Activity activity = |
| 62 | + client |
| 63 | + .flatFeed("flat", "reactor") |
| 64 | + .addActivity(Activity.builder().actor("this").verb("done").object("that").build()) |
| 65 | + .join(); |
| 66 | + |
| 67 | + client.reactions().add("user1", "like", activity.getID()).join(); |
| 68 | + client.reactions().add("user1", "comment", activity.getID()).join(); |
| 69 | + client.reactions().add("user1", "share", activity.getID()).join(); |
| 70 | + client.reactions().add("user2", "like", activity.getID()).join(); |
| 71 | + client.reactions().add("user2", "comment", activity.getID()).join(); |
| 72 | + client.reactions().add("user3", "comment", activity.getID()).join(); |
| 73 | + |
| 74 | + List<Reaction> result = client.reactions().filter(LookupKind.ACTIVITY, activity.getID(), new Filter(), new Limit(10), "",false, "user1").join(); |
| 75 | + assertEquals(3, result.size()); |
| 76 | + |
| 77 | + result = client.reactions().filter(LookupKind.ACTIVITY, activity.getID(), new Filter(), new Limit(10), "like",false, "user1").join(); |
| 78 | + assertEquals(1, result.size()); |
| 79 | + |
| 80 | + |
| 81 | + result = client.reactions().filter(LookupKind.ACTIVITY, activity.getID(), new Filter(), new Limit(10), "",false, "user2").join(); |
| 82 | + assertEquals(2, result.size()); |
| 83 | + |
| 84 | + result = client.reactions().filter(LookupKind.ACTIVITY, activity.getID(), new Filter(), new Limit(10), "",false, "user3").join(); |
| 85 | + assertEquals(1, result.size()); |
| 86 | + } |
| 87 | + |
52 | 88 | @Test |
53 | 89 | public void pagedFilter() throws Exception { |
54 | 90 | Client client = Client.builder(apiKey, secret).build(); |
|
0 commit comments