66import io .getstream .core .models .*;
77import io .getstream .core .models .Activity ;
88
9- import java .io .BufferedReader ;
10- import java .io .InputStreamReader ;
11- import java .nio .Buffer ;
9+ import java .sql .Time ;
1210import java .util .Date ;
1311import java .util .UUID ;
1412import org .junit .*;
@@ -32,51 +30,50 @@ public void setUp() throws Exception {
3230 }
3331
3432 @ Test
35- public void testFlagUser () throws Exception {
36-
33+ public void testFlagActivity () throws Exception {
3734 ModerationClient moderationClient = client .moderation ();
3835
39- String userId = UUID .randomUUID ().toString ();
40- User user = client .user (userId );
41- user .getOrCreate ().join ();
42- Data result = user .get ().join ();
36+ Activity activity = Activity .builder ().actor ("bad-user" ).verb ("test" ).object ("test" ).moderationTemplate ("moderation_template_activity" ).time (new Date ()).foreignID ("fid" ).build ();
37+ Activity activityResponse = client .flatFeed ("user" , "1" ).addActivity (activity ).join ();
4338
44- Response flagResponse = moderationClient .flagUser (userId , "blood" , null ).join ();
39+ String reportingUser ="reporting-user" ;
40+ Activity activity1 = Activity .builder ().actor (reportingUser ).verb ("verb" ).object ("test" ).moderationTemplate ("moderation_template_activity" ).time (new Date ()).foreignID ("fid" ).build ();
41+ Activity activityResponse1 = client .flatFeed ("user" , "1" ).addActivity (activity1 ).join ();
42+ assertNotNull (activityResponse );
43+
44+ Response flagResponse =
45+ moderationClient .flagActivity (activityResponse .getID (), reportingUser , "blood" , null ).join ();
4546 assertNotNull (flagResponse );
47+ assertEquals (201 , flagResponse .getCode ());
4648 }
4749
4850 @ Test
49- public void testFlagActivity () throws Exception {
50- ModerationClient moderationClient = client .moderation ();
51-
52- Activity activity = Activity .builder ().actor ("test" ).verb ("test" ).object ("test" ).build ();
51+ public void testFlagUser () throws Exception {
5352
54- Activity activityResponse = client .flatFeed ("flat" , "1" ).addActivity (activity ).join ();
55- assertNotNull (activityResponse );
53+ ModerationClient moderationClient = client .moderation ();
5654
57- Response flagResponse =
58- moderationClient .flagActivity (activityResponse .getID (), "vishal" , "blood" , null ).join ();
55+ Response flagResponse = moderationClient .flagUser ("bad-user" , "reporting-user" , "blood" , null ).join ();
5956 assertNotNull (flagResponse );
57+ assertEquals (201 , flagResponse .getCode ());
6058 }
6159
6260 @ Test
6361 public void testFlagReaction () throws Exception {
6462 ModerationClient moderationClient = client .moderation ();
6563
66- Activity activity = Activity .builder ().actor ("test " ).verb ("test" ).object ("test" ).build ();
64+ Activity activity = Activity .builder ().actor ("bad-user " ).verb ("test" ).object ("test" ). moderationTemplate ( "moderation_template_reaction" ). time ( new Date ()). foreignID ( "fid " ).build ();
6765
6866 Activity activityResponse = client .flatFeed ("flat" , "1" ).addActivity (activity ).join ();
6967 assertNotNull (activityResponse );
7068
7169 Reaction reactionResponse =
72- client .reactions ().add ("test " , "like" , activityResponse .getID ()).join ();
70+ client .reactions ().add ("bad-user " , "like" , activityResponse .getID ()).join ();
7371 assertNotNull (reactionResponse );
7472
7573 Response flagResponse =
76- moderationClient .flagReaction (reactionResponse .getId (), "test " , "blood" , null ).join ();
74+ moderationClient .flagReaction (reactionResponse .getId (), "reporting-user " , "blood" , null ).join ();
7775 assertNotNull (flagResponse );
7876 assertEquals (201 , flagResponse .getCode ());
79- assertNotNull (flagResponse );
8077
8178 }
8279
0 commit comments