55import io .getstream .core .http .Response ;
66import io .getstream .core .models .*;
77import io .getstream .core .models .Activity ;
8+
9+ import java .sql .Time ;
810import java .util .Date ;
911import java .util .UUID ;
1012import org .junit .*;
@@ -28,49 +30,51 @@ public void setUp() throws Exception {
2830 }
2931
3032 @ Test
31- public void testFlagUser () throws Exception {
32-
33+ public void testFlagActivity () throws Exception {
3334 ModerationClient moderationClient = client .moderation ();
3435
35- String userId = UUID .randomUUID ().toString ();
36- User user = client .user (userId );
37- user .getOrCreate ().join ();
38- 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 ();
3938
40- 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 ();
4146 assertNotNull (flagResponse );
47+ assertEquals (201 , flagResponse .getCode ());
4248 }
4349
4450 @ Test
45- public void testFlagActivity () throws Exception {
46- ModerationClient moderationClient = client .moderation ();
47-
48- Activity activity = Activity .builder ().actor ("test" ).verb ("test" ).object ("test" ).build ();
51+ public void testFlagUser () throws Exception {
4952
50- Activity activityResponse = client .flatFeed ("flat" , "1" ).addActivity (activity ).join ();
51- assertNotNull (activityResponse );
53+ ModerationClient moderationClient = client .moderation ();
5254
53- Response flagResponse =
54- moderationClient .flagActivity (activityResponse .getID (), "vishal" , "blood" , null ).join ();
55+ Response flagResponse = moderationClient .flagUser ("bad-user" , "reporting-user" , "blood" , null ).join ();
5556 assertNotNull (flagResponse );
57+ assertEquals (201 , flagResponse .getCode ());
5658 }
5759
5860 @ Test
5961 public void testFlagReaction () throws Exception {
6062 ModerationClient moderationClient = client .moderation ();
6163
62- 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 ();
6365
6466 Activity activityResponse = client .flatFeed ("flat" , "1" ).addActivity (activity ).join ();
6567 assertNotNull (activityResponse );
6668
6769 Reaction reactionResponse =
68- client .reactions ().add ("user123 " , "like" , activityResponse .getID ()).join ();
70+ client .reactions ().add ("bad-user " , "like" , activityResponse .getID ()).join ();
6971 assertNotNull (reactionResponse );
7072
7173 Response flagResponse =
72- moderationClient .flagReaction (reactionResponse .getId (), "bobby " , "blood" , null ).join ();
74+ moderationClient .flagReaction (reactionResponse .getId (), "reporting-user " , "blood" , null ).join ();
7375 assertNotNull (flagResponse );
76+ assertEquals (201 , flagResponse .getCode ());
77+
7478 }
7579
7680 @ Test
0 commit comments