|
3 | 3 | import static org.junit.Assert.*; |
4 | 4 |
|
5 | 5 | import com.google.common.collect.Lists; |
| 6 | +import io.getstream.core.http.Response; |
6 | 7 | import io.getstream.core.models.BatchDeleteActivitiesRequest; |
7 | 8 | import io.getstream.core.models.BatchDeleteActivitiesRequest.ActivityToDelete; |
8 | 9 | import io.getstream.core.models.Activity; |
| 10 | +import io.getstream.core.models.BatchDeleteReactionsRequest; |
| 11 | +import io.getstream.core.models.Reaction; |
9 | 12 | import io.getstream.core.options.Filter; |
10 | 13 | import io.getstream.core.options.Limit; |
11 | 14 | import java8.util.concurrent.CompletableFuture; |
@@ -83,6 +86,71 @@ public void testDeleteActivities() throws Exception { |
83 | 86 | assertEquals(0, deletedActivity2.size()); |
84 | 87 | } |
85 | 88 |
|
| 89 | + @Test |
| 90 | + public void testDeleteReactions() throws Exception { |
| 91 | + String uuid1 = UUID.randomUUID().toString().replace("-", ""); |
| 92 | + FlatFeed feed = client.flatFeed("user", uuid1); |
| 93 | + |
| 94 | + // Insert some activities |
| 95 | + Activity activity1 = Activity.builder() |
| 96 | + .actor("user1") |
| 97 | + .verb("post") |
| 98 | + .object("object1") |
| 99 | + .build(); |
| 100 | + Activity activity1Res = feed.addActivity(activity1).join(); |
| 101 | + |
| 102 | + Activity activity2 = Activity.builder() |
| 103 | + .actor("user1") |
| 104 | + .verb("like") |
| 105 | + .object("object2") |
| 106 | + .build(); |
| 107 | + Activity activity2Res = feed.addActivity(activity2).join(); |
| 108 | + |
| 109 | + //add reactions for activity1 |
| 110 | + Reaction u1=client.reactions().add("user1", "like", activity1Res.getID()).join(); |
| 111 | + Reaction u2=client.reactions().add("user2", "like", activity1Res.getID()).join(); |
| 112 | + |
| 113 | + Reaction u3=client.reactions().add("user1", "like", activity2Res.getID()).join(); |
| 114 | + Reaction u4=client.reactions().add("user2", "like", activity2Res.getID()).join(); |
| 115 | + |
| 116 | + |
| 117 | + //fetch test reactions |
| 118 | + Reaction r1=client.reactions().get(u1.getId()).join(); |
| 119 | + assertNotNull(r1); |
| 120 | + |
| 121 | + Reaction r2=client.reactions().get(u2.getId()).join(); |
| 122 | + assertNotNull(r2); |
| 123 | + |
| 124 | + Reaction r3=client.reactions().get(u3.getId()).join(); |
| 125 | + assertNotNull(r3); |
| 126 | + |
| 127 | + Reaction r4=client.reactions().get(u4.getId()).join(); |
| 128 | + assertNotNull(r4); |
| 129 | + |
| 130 | + // Create reaction delete request |
| 131 | + BatchDeleteReactionsRequest deleteReactionsRequest= |
| 132 | + new BatchDeleteReactionsRequest(Arrays.asList |
| 133 | + (u1.getId(), u2.getId(), u3.getId())); |
| 134 | + |
| 135 | + |
| 136 | + client.deleteReactions(deleteReactionsRequest).join(); |
| 137 | + |
| 138 | + //fetch test reactions |
| 139 | + |
| 140 | + // DoesNotExistException |
| 141 | + assertThrows(Exception.class, () -> { |
| 142 | + client.reactions().get(u1.getId()).join(); |
| 143 | + }); |
| 144 | + assertThrows(Exception.class, () -> { |
| 145 | + client.reactions().get(u2.getId()).join(); |
| 146 | + }); |
| 147 | + assertThrows(Exception.class, () -> { |
| 148 | + client.reactions().get(u3.getId()).join(); |
| 149 | + }); |
| 150 | + |
| 151 | + |
| 152 | + } |
| 153 | + |
86 | 154 | @Test |
87 | 155 | public void testDeleteActivitis() throws Exception { |
88 | 156 |
|
|
0 commit comments