Skip to content

Commit 942a128

Browse files
mogitaclaude
andcommitted
feat: add FlagMessageAndUser moderation integration test
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 660ccfa commit 942a128

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

src/test/java/io/getstream/ModerationIntegrationTest.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,54 @@ void cleanup() {
3434
}
3535
}
3636

37+
@Test
38+
@Order(3)
39+
void testFlagMessageAndUser() throws Exception {
40+
List<String> userIds = createTestUsers(2);
41+
createdUserIds.addAll(userIds);
42+
String userId = userIds.get(0);
43+
String flaggerId = userIds.get(1);
44+
45+
// Create a channel with both users as members
46+
String channelId = createTestChannelWithMembers(userId, userIds);
47+
createdChannelIds.add(channelId);
48+
49+
// Send a message to flag
50+
String msgId = sendTestMessage("messaging", channelId, userId, "Message to be flagged");
51+
52+
ModerationImpl moderation = new ModerationImpl(client.getHttpClient());
53+
54+
// Flag the message
55+
var flagMsgResp =
56+
moderation
57+
.flag(
58+
FlagRequest.builder()
59+
.entityID(msgId)
60+
.entityType("stream:chat:v1:message")
61+
.entityCreatorID(userId)
62+
.userID(flaggerId)
63+
.reason("inappropriate content")
64+
.build())
65+
.execute();
66+
assertNotNull(flagMsgResp.getData(), "Flag message response data should not be null");
67+
assertNotNull(flagMsgResp.getData().getItemID(), "Flag should return an item ID");
68+
69+
// Flag the user
70+
var flagUserResp =
71+
moderation
72+
.flag(
73+
FlagRequest.builder()
74+
.entityID(userId)
75+
.entityType("stream:user")
76+
.entityCreatorID(userId)
77+
.userID(flaggerId)
78+
.reason("spam")
79+
.build())
80+
.execute();
81+
assertNotNull(flagUserResp.getData(), "Flag user response data should not be null");
82+
assertNotNull(flagUserResp.getData().getItemID(), "Flag user should return an item ID");
83+
}
84+
3785
@Test
3886
@Order(2)
3987
void testMuteUnmuteUser() throws Exception {

0 commit comments

Comments
 (0)