|
4 | 4 |
|
5 | 5 | import com.google.common.collect.Lists; |
6 | 6 | import io.getstream.core.http.Response; |
7 | | -import io.getstream.core.models.BatchDeleteActivitiesRequest; |
| 7 | +import io.getstream.core.models.*; |
8 | 8 | import io.getstream.core.models.BatchDeleteActivitiesRequest.ActivityToDelete; |
9 | | -import io.getstream.core.models.Activity; |
10 | | -import io.getstream.core.models.BatchDeleteReactionsRequest; |
11 | | -import io.getstream.core.models.Reaction; |
12 | 9 | import io.getstream.core.options.Filter; |
13 | 10 | import io.getstream.core.options.Limit; |
14 | 11 | import java8.util.concurrent.CompletableFuture; |
@@ -150,6 +147,46 @@ public void testDeleteReactions() throws Exception { |
150 | 147 |
|
151 | 148 |
|
152 | 149 | } |
| 150 | + @Test |
| 151 | + public void testSoftDeleteReactions() throws Exception { |
| 152 | + String uuid1 = UUID.randomUUID().toString().replace("-", ""); |
| 153 | + FlatFeed feed = client.flatFeed("user", uuid1); |
| 154 | + |
| 155 | + // Insert two activities |
| 156 | + Activity activity1Res = feed.addActivity(Activity.builder() |
| 157 | + .actor("user1") |
| 158 | + .verb("post") |
| 159 | + .object("object1") |
| 160 | + .build()).join(); |
| 161 | + |
| 162 | + Activity activity2Res = feed.addActivity(Activity.builder() |
| 163 | + .actor("user1") |
| 164 | + .verb("like") |
| 165 | + .object("object2") |
| 166 | + .build()).join(); |
| 167 | + |
| 168 | + // Add reactions to both activities |
| 169 | + Reaction u1 = client.reactions().add("user1", "like", activity1Res.getID()).join(); |
| 170 | + Reaction u2 = client.reactions().add("user2", "like", activity1Res.getID()).join(); |
| 171 | + Reaction u3 = client.reactions().add("user1", "like", activity2Res.getID()).join(); |
| 172 | + Reaction u4 = client.reactions().add("user2", "like", activity2Res.getID()).join(); |
| 173 | + |
| 174 | + // Verify reactions were created |
| 175 | + assertNotNull(client.reactions().get(u1.getId()).join()); |
| 176 | + assertNotNull(client.reactions().get(u2.getId()).join()); |
| 177 | + assertNotNull(client.reactions().get(u3.getId()).join()); |
| 178 | + assertNotNull(client.reactions().get(u4.getId()).join()); |
| 179 | + |
| 180 | + // Soft delete reactions |
| 181 | + BatchDeleteReactionsRequest deleteReactionsRequest = |
| 182 | + new BatchDeleteReactionsRequest(Arrays.asList(u1.getId(), u2.getId(), u3.getId()), true); |
| 183 | + client.deleteReactions(deleteReactionsRequest).join(); |
| 184 | + |
| 185 | + // Verify reactions can still be fetched |
| 186 | + assertNotNull(client.reactions().get(u1.getId()).join()); |
| 187 | + assertNotNull(client.reactions().get(u2.getId()).join()); |
| 188 | + assertNotNull(client.reactions().get(u3.getId()).join()); |
| 189 | + } |
153 | 190 |
|
154 | 191 | @Test |
155 | 192 | public void testDeleteActivitiesMultipleFeeds() throws Exception { |
|
0 commit comments