|
1 | 1 | package io.getstream.client; |
2 | 2 |
|
| 3 | +import static org.junit.Assert.assertEquals; |
| 4 | + |
3 | 5 | import com.google.common.collect.Lists; |
4 | 6 | import io.getstream.client.entities.FootballMatch; |
5 | 7 | import io.getstream.client.entities.Match; |
6 | 8 | import io.getstream.client.entities.VolleyballMatch; |
7 | 9 | import io.getstream.core.http.OKHTTPClientAdapter; |
8 | 10 | import io.getstream.core.models.Activity; |
9 | 11 | import io.getstream.core.models.FeedID; |
| 12 | +import io.getstream.core.models.FollowStats; |
| 13 | +import java.util.Collections; |
10 | 14 | import java.util.Date; |
11 | 15 | import java.util.List; |
| 16 | +import java.util.UUID; |
12 | 17 | import okhttp3.OkHttpClient; |
13 | 18 | import org.junit.Test; |
14 | 19 |
|
@@ -140,6 +145,33 @@ public void unfollow() throws Exception { |
140 | 145 | feed1.unfollow(feed2).join(); |
141 | 146 | } |
142 | 147 |
|
| 148 | + @Test |
| 149 | + public void getFollowStats() throws Exception { |
| 150 | + Client client = |
| 151 | + Client.builder(apiKey, secret) |
| 152 | + .httpClient(new OKHTTPClientAdapter(new OkHttpClient())) |
| 153 | + .build(); |
| 154 | + String uuid1 = UUID.randomUUID().toString().replace("-", ""); |
| 155 | + String uuid2 = UUID.randomUUID().toString().replace("-", ""); |
| 156 | + String feed1Id = "flat:" + uuid1; |
| 157 | + FlatFeed feed1 = client.flatFeed("flat", uuid1); |
| 158 | + FlatFeed feed2 = client.flatFeed("flat", uuid2); |
| 159 | + feed1.follow(feed2).join(); |
| 160 | + |
| 161 | + FollowStats stats = |
| 162 | + feed1.getFollowStats(Collections.emptyList(), Lists.newArrayList("timeline")).join(); |
| 163 | + assertEquals(0, stats.getFollowers().getCount()); |
| 164 | + assertEquals(feed1Id, stats.getFollowers().getFeed()); |
| 165 | + assertEquals(0, stats.getFollowing().getCount()); |
| 166 | + assertEquals(feed1Id, stats.getFollowing().getFeed()); |
| 167 | + |
| 168 | + stats = feed1.getFollowStats(Collections.emptyList(), Lists.newArrayList("flat")).join(); |
| 169 | + assertEquals(0, stats.getFollowers().getCount()); |
| 170 | + assertEquals(feed1Id, stats.getFollowers().getFeed()); |
| 171 | + assertEquals(1, stats.getFollowing().getCount()); |
| 172 | + assertEquals(feed1Id, stats.getFollowing().getFeed()); |
| 173 | + } |
| 174 | + |
143 | 175 | @Test |
144 | 176 | public void updateActivityToTargets() throws Exception { |
145 | 177 | Client client = |
|
0 commit comments