@@ -34,6 +34,65 @@ void cleanup() {
3434 }
3535 }
3636
37+ @ Test
38+ @ Order (2 )
39+ void testMuteUnmuteUser () throws Exception {
40+ List <String > userIds = createTestUsers (2 );
41+ createdUserIds .addAll (userIds );
42+ String muterId = userIds .get (0 );
43+ String targetId = userIds .get (1 );
44+
45+ ModerationImpl moderation = new ModerationImpl (client .getHttpClient ());
46+
47+ // Mute target user as muter (no timeout)
48+ var muteResp =
49+ moderation
50+ .mute (
51+ MuteRequest .builder ()
52+ .targetIds (List .of (targetId ))
53+ .userID (muterId )
54+ .build ())
55+ .execute ();
56+
57+ assertNotNull (muteResp .getData (), "Mute response data should not be null" );
58+ assertNotNull (muteResp .getData ().getMutes (), "Mutes list should not be null" );
59+ assertFalse (muteResp .getData ().getMutes ().isEmpty (), "Mutes list should not be empty" );
60+
61+ var mute = muteResp .getData ().getMutes ().get (0 );
62+ assertNotNull (mute .getUser (), "Mute should have a User" );
63+ assertNotNull (mute .getTarget (), "Mute should have a Target" );
64+ assertNull (mute .getExpires (), "Mute without timeout should have no Expires" );
65+
66+ // Verify mute appears in QueryUsers for the muting user
67+ var queryResp =
68+ client
69+ .queryUsers (
70+ QueryUsersRequest .builder ()
71+ .Payload (
72+ QueryUsersPayload .builder ()
73+ .filterConditions (Map .of ("id" , Map .of ("$eq" , muterId )))
74+ .build ())
75+ .build ())
76+ .execute ();
77+ assertNotNull (queryResp .getData ().getUsers ());
78+ assertFalse (queryResp .getData ().getUsers ().isEmpty (), "Should find the muting user" );
79+ var muterUser = queryResp .getData ().getUsers ().get (0 );
80+ assertNotNull (muterUser .getMutes (), "User should have mutes after muting" );
81+ assertFalse (muterUser .getMutes ().isEmpty (), "User mutes list should not be empty" );
82+
83+ // Unmute the target user
84+ var unmuteResp =
85+ moderation
86+ .unmute (
87+ UnmuteRequest .builder ()
88+ .targetIds (List .of (targetId ))
89+ .userID (muterId )
90+ .build ())
91+ .execute ();
92+
93+ assertNotNull (unmuteResp .getData (), "Unmute response data should not be null" );
94+ }
95+
3796 @ Test
3897 @ Order (1 )
3998 void testBanUnbanUser () throws Exception {
0 commit comments