22
33import io .getstream .chat .java .models .Permission ;
44import java .util .HashMap ;
5- import java .util .List ;
65import java .util .Map ;
76import org .apache .commons .lang3 .RandomStringUtils ;
87import org .junit .jupiter .api .Assertions ;
@@ -26,98 +25,4 @@ void whenCreatingPermission_thenNoException() {
2625 .condition (condition )
2726 .request ());
2827 }
29-
30- @ DisplayName ("Can update permission" )
31- @ Test
32- void whenUpdatingPermission_thenNoException () {
33- String name = RandomStringUtils .randomAlphabetic (10 );
34- String id = RandomStringUtils .randomAlphabetic (10 );
35- Map <String , Object > condition = new HashMap <>();
36- condition .put ("$subject.magic_custom_field" , "magic_value" );
37- Assertions .assertDoesNotThrow (
38- () ->
39- Permission .create ()
40- .id (id )
41- .name (name )
42- .action ("DeleteChannel" )
43- .condition (condition )
44- .request ());
45- pause ();
46- Assertions .assertDoesNotThrow (
47- () ->
48- Permission .update (id , name )
49- .action ("DeleteChannel" )
50- .condition (condition )
51- .owner (true )
52- .request ());
53- }
54-
55- @ DisplayName ("Can retrieve permission" )
56- @ Test
57- void whenRetrievingPermission_thenCorrectName () {
58- String name = RandomStringUtils .randomAlphabetic (10 );
59- String id = RandomStringUtils .randomAlphabetic (10 );
60- Map <String , Object > condition = new HashMap <>();
61- condition .put ("$subject.magic_custom_field" , "magic_value" );
62- Assertions .assertDoesNotThrow (
63- () ->
64- Permission .create ()
65- .id (id )
66- .name (name )
67- .action ("DeleteChannel" )
68- .condition (condition )
69- .request ());
70- pause ();
71- Permission retrievedPermission =
72- Assertions .assertDoesNotThrow (() -> Permission .get (id ).request ()).getPermission ();
73- Assertions .assertEquals (id , retrievedPermission .getId ());
74- }
75-
76- @ DisplayName ("Can delete permission" )
77- @ Test
78- void whenDeletingPermission_thenDeleted () {
79- String name = RandomStringUtils .randomAlphabetic (10 );
80- String id = RandomStringUtils .randomAlphabetic (10 );
81- Map <String , Object > condition = new HashMap <>();
82- condition .put ("$subject.magic_custom_field" , "magic_value" );
83- Assertions .assertDoesNotThrow (
84- () ->
85- Permission .create ()
86- .id (id )
87- .name (name )
88- .action ("DeleteChannel" )
89- .condition (condition )
90- .request ());
91- pause ();
92- Assertions .assertDoesNotThrow (() -> Permission .delete (id ).request ());
93- pause ();
94- List <Permission > permissions =
95- Assertions .assertDoesNotThrow (() -> Permission .list ().request ()).getPermissions ();
96- Assertions .assertFalse (
97- permissions .stream ()
98- .anyMatch (consideredPermission -> consideredPermission .getId ().equals (id )));
99- }
100-
101- @ DisplayName ("Can list permissions" )
102- @ Test
103- void whenListingPermission_thenCanRetrieve () {
104- String name = RandomStringUtils .randomAlphabetic (10 );
105- String id = RandomStringUtils .randomAlphabetic (10 );
106- Map <String , Object > condition = new HashMap <>();
107- condition .put ("$subject.magic_custom_field" , "magic_value" );
108- Assertions .assertDoesNotThrow (
109- () ->
110- Permission .create ()
111- .id (id )
112- .name (name )
113- .action ("DeleteChannel" )
114- .condition (condition )
115- .request ());
116- pause ();
117- List <Permission > permissions =
118- Assertions .assertDoesNotThrow (() -> Permission .list ().request ()).getPermissions ();
119- Assertions .assertTrue (
120- permissions .stream ()
121- .anyMatch (consideredPermission -> consideredPermission .getId ().equals (id )));
122- }
12328}
0 commit comments