99import org .junit .Test ;
1010import util .MockSlackApiServer ;
1111
12+ import java .util .List ;
1213import java .util .Arrays ;
13- import java .util .HashMap ;
1414import java .util .Map ;
1515
1616import static org .hamcrest .CoreMatchers .is ;
@@ -37,44 +37,44 @@ public void tearDown() throws Exception {
3737 // Create a new list
3838 @ Test
3939 public void slackListsCreate () throws Exception {
40- Map <String , Object > taskNameColumn = new HashMap <>();
41- taskNameColumn .put ("key" , "task_name" );
42- taskNameColumn .put ("name" , "Task Name" );
43- taskNameColumn .put ("type" , "text" );
44- taskNameColumn .put ("is_primary_column" , true );
45-
46- Map <String , Object > dueDateColumn = new HashMap <>();
47- dueDateColumn .put ("key" , "due_date" );
48- dueDateColumn .put ("name" , "Due Date" );
49- dueDateColumn .put ("type" , "date" );
50-
51- Map <String , Object > statusChoices = new HashMap <>();
52- statusChoices .put ("choices" , Arrays .asList (
53- createChoice ("not_started" , "Not Started" , "red" ),
54- createChoice ("in_progress" , "In Progress" , "yellow" ),
55- createChoice ("completed" , "Completed" , "green" )
56- ));
57- Map <String , Object > statusColumn = new HashMap <>();
58- statusColumn .put ("key" , "status" );
59- statusColumn .put ("name" , "Status" );
60- statusColumn .put ("type" , "select" );
61- statusColumn .put ("options" , statusChoices );
62-
63- Map <String , Object > assigneeColumn = new HashMap <>();
64- assigneeColumn .put ("key" , "assignee" );
65- assigneeColumn .put ("name" , "Assignee" );
66- assigneeColumn .put ("type" , "user" );
67-
6840 assertThat (slack .methods (ValidToken ).slackListsCreate (r -> r
69- .name ("Backlog" )
70- .descriptionBlocks (Arrays .asList (createRichTextBlock ("List to keep track of tasks!" )))
71- .schema (Arrays .asList (taskNameColumn , dueDateColumn , statusColumn , assigneeColumn )))
72- .isOk (), is (true ));
41+ .name ("Test List - SlackLists API" )
42+ .descriptionBlocks (List .of (RichTextBlock .builder ()
43+ .elements (List .of (RichTextSectionElement .builder ()
44+ .elements (List .of (RichTextSectionElement .Text .builder ()
45+ .text ("List to keep track of tasks!" )
46+ .build ()))
47+ .build ()))
48+ .build ()))
49+ .schema (List .of (
50+ Map .of (
51+ "key" , "task_name" ,
52+ "name" , "Task Name" ,
53+ "type" , "text" ,
54+ "is_primary_column" , true ),
55+ Map .of (
56+ "key" , "due_date" ,
57+ "name" , "Due Date" ,
58+ "type" , "date" ),
59+ Map .of (
60+ "key" , "status" ,
61+ "name" , "Status" ,
62+ "type" , "select" ,
63+ "options" , Map .of (
64+ "choices" , List .of (
65+ Map .of ("value" , "not_started" , "label" , "Not Started" , "color" , "red" ),
66+ Map .of ("value" , "in_progress" , "label" , "In Progress" , "color" , "yellow" ),
67+ Map .of ("value" , "completed" , "label" , "Completed" , "color" , "green" )))),
68+ Map .of (
69+ "key" , "assignee" ,
70+ "name" , "Assignee" ,
71+ "type" , "user" ))))
72+ .isOk (), is (true ));
7373 }
7474
7575 @ Test
7676 public void slackListsCreate_async () throws Exception {
77- assertThat (slack .methodsAsync (ValidToken ).slackListsCreate (r -> r .name ("Backlog " ))
77+ assertThat (slack .methodsAsync (ValidToken ).slackListsCreate (r -> r .name ("Test List Async - SlackLists API " ))
7878 .get ().isOk (), is (true ));
7979 }
8080
@@ -84,7 +84,7 @@ public void slackListsAccessSet() throws Exception {
8484 assertThat (slack .methods (ValidToken ).slackListsAccessSet (r -> r
8585 .listId ("F1234567" )
8686 .accessLevel ("write" )
87- .userIds ( Arrays . asList ( "U09G4FG3TRN " )))
87+ .channelIds ( List . of ( "C1234567 " )))
8888 .isOk (), is (true ));
8989 }
9090
@@ -93,21 +93,25 @@ public void slackListsAccessSet_async() throws Exception {
9393 assertThat (slack .methodsAsync (ValidToken ).slackListsAccessSet (r -> r
9494 .listId ("F1234567" )
9595 .accessLevel ("write" )
96- .userIds ( Arrays . asList ( "U09G4FG3TRN " )))
96+ .channelIds ( List . of ( "C1234567 " )))
9797 .get ().isOk (), is (true ));
9898 }
9999
100100 // Create several list items
101101 @ Test
102102 public void slackListsItemsCreate () throws Exception {
103- Map <String , Object > initialField = new HashMap <>();
104- initialField .put ("column_id" , "col123" );
105- initialField .put ("rich_text" , Arrays .asList (createRichTextBlock ("CLI app unlink command" )));
106-
107103 assertThat (slack .methods (ValidToken ).slackListsItemsCreate (r -> r
108- .listId ("F1234567" )
109- .initialFields (Arrays .asList (initialField )))
110- .isOk (), is (true ));
104+ .listId ("F1234567" )
105+ .initialFields (List .of (Map .of (
106+ "column_id" , "C1234567" ,
107+ "rich_text" , List .of (Map .of (
108+ "type" , "rich_text" ,
109+ "elements" , List .of (Map .of (
110+ "type" , "rich_text_section" ,
111+ "elements" , List .of (Map .of (
112+ "type" , "text" ,
113+ "text" , "Test task item" ))))))))))
114+ .isOk (), is (true ));
111115 }
112116
113117 @ Test
@@ -117,7 +121,7 @@ public void slackListsItemsCreate_async() throws Exception {
117121 .get ().isOk (), is (true ));
118122 }
119123
120- // Delete specific list items
124+ // delete specific list items
121125 @ Test
122126 public void slackListsItemsDelete () throws Exception {
123127 assertThat (slack .methods (ValidToken ).slackListsItemsDelete (r -> r
@@ -138,15 +142,15 @@ public void slackListsItemsDelete_async() throws Exception {
138142 public void slackListsItemsDeleteMultiple () throws Exception {
139143 assertThat (slack .methods (ValidToken ).slackListsItemsDeleteMultiple (r -> r
140144 .listId ("F1234567" )
141- .ids (Arrays . asList ("Rec018ALE9720" , "Rec018ALE9721" )))
145+ .ids (List . of ("Rec018ALE9720" , "Rec018ALE9721" )))
142146 .isOk (), is (true ));
143147 }
144148
145149 @ Test
146150 public void slackListsItemsDeleteMultiple_async () throws Exception {
147151 assertThat (slack .methodsAsync (ValidToken ).slackListsItemsDeleteMultiple (r -> r
148152 .listId ("F1234567" )
149- .ids (Arrays . asList ( "Rec018ALE9720 " , "Rec018ALE9721 " )))
153+ .ids (List . of ( "Rec1234567890 " , "Rec1234567891 " )))
150154 .get ().isOk (), is (true ));
151155 }
152156
@@ -155,7 +159,7 @@ public void slackListsItemsDeleteMultiple_async() throws Exception {
155159 public void slackListsItemsInfo () throws Exception {
156160 assertThat (slack .methods (ValidToken ).slackListsItemsInfo (r -> r
157161 .listId ("F1234567" )
158- .id ("Rec018ALE9718 " )
162+ .id ("Rec1234567890 " )
159163 .includeIsSubscribed (true ))
160164 .isOk (), is (true ));
161165 }
@@ -164,7 +168,7 @@ public void slackListsItemsInfo() throws Exception {
164168 public void slackListsItemsInfo_async () throws Exception {
165169 assertThat (slack .methodsAsync (ValidToken ).slackListsItemsInfo (r -> r
166170 .listId ("F1234567" )
167- .id ("Rec018ALE9718 " )
171+ .id ("Rec1234567890 " )
168172 .includeIsSubscribed (true ))
169173 .get ().isOk (), is (true ));
170174 }
@@ -224,27 +228,35 @@ public void slackListsDownloadGet_async() throws Exception {
224228 // Update an existing list item
225229 @ Test
226230 public void slackListsItemsUpdate () throws Exception {
227- Map <String , Object > cell = new HashMap <>();
228- cell .put ("column_id" , "col123" );
229- cell .put ("rich_text" , Arrays .asList (createRichTextBlock ("Updated text" )));
230- cell .put ("row_id" , "item_id_1" );
231-
232231 assertThat (slack .methods (ValidToken ).slackListsItemsUpdate (r -> r
233- .listId ("F1234567" )
234- .cells (Arrays .asList (cell )))
232+ .listId ("F1234567" )
233+ .cells (List .of (Map .of (
234+ "row_id" , "Rec1234567890" ,
235+ "column_id" , "C1234567" ,
236+ "rich_text" , List .of (Map .of (
237+ "type" , "rich_text" ,
238+ "elements" , List .of (Map .of (
239+ "type" , "rich_text_section" ,
240+ "elements" , List .of (Map .of (
241+ "type" , "text" ,
242+ "text" , "new task name" ))))))))))
235243 .isOk (), is (true ));
236244 }
237245
238246 @ Test
239247 public void slackListsItemsUpdate_async () throws Exception {
240- Map <String , Object > cell = new HashMap <>();
241- cell .put ("column_id" , "col123" );
242- cell .put ("rich_text" , Arrays .asList (createRichTextBlock ("Updated text" )));
243- cell .put ("row_id" , "item_id_1" );
244-
245248 assertThat (slack .methodsAsync (ValidToken ).slackListsItemsUpdate (r -> r
246249 .listId ("F1234567" )
247- .cells (Arrays .asList (cell )))
250+ .cells (List .of (Map .of (
251+ "row_id" , "Rec1234567890" ,
252+ "column_id" , "C1234567" ,
253+ "rich_text" , List .of (Map .of (
254+ "type" , "rich_text" ,
255+ "elements" , List .of (Map .of (
256+ "type" , "rich_text_section" ,
257+ "elements" , List .of (Map .of (
258+ "type" , "text" ,
259+ "text" , "new task name" ))))))))))
248260 .get ().isOk (), is (true ));
249261 }
250262
@@ -253,19 +265,15 @@ public void slackListsItemsUpdate_async() throws Exception {
253265 public void slackListsUpdate () throws Exception {
254266 assertThat (slack .methods (ValidToken ).slackListsUpdate (r -> r
255267 .id ("F1234567" )
256- .name ("Test List - UPDATED" )
257- .descriptionBlocks (Arrays .asList (createRichTextBlock ("This list has been updated via API" )))
258- .todoMode (false ))
268+ .name ("Test List - UPDATED" ))
259269 .isOk (), is (true ));
260270 }
261271
262272 @ Test
263273 public void slackListsUpdate_async () throws Exception {
264274 assertThat (slack .methodsAsync (ValidToken ).slackListsUpdate (r -> r
265275 .id ("F1234567" )
266- .name ("Test List - UPDATED" )
267- .descriptionBlocks (Arrays .asList (createRichTextBlock ("This list has been updated via API" )))
268- .todoMode (false ))
276+ .name ("Test List - UPDATED" ))
269277 .get ().isOk (), is (true ));
270278 }
271279
@@ -274,24 +282,24 @@ public void slackListsUpdate_async() throws Exception {
274282 public void slackListsAccessDelete () throws Exception {
275283 assertThat (slack .methods (ValidToken ).slackListsAccessDelete (r -> r
276284 .listId ("F1234567" )
277- .userIds (Arrays . asList ( "U09G4FG3TRN " )))
285+ .userIds (List . of ( "U1234567 " )))
278286 .isOk (), is (true ));
279287 }
280288
281289 @ Test
282290 public void slackListsAccessDelete_async () throws Exception {
283291 assertThat (slack .methodsAsync (ValidToken ).slackListsAccessDelete (r -> r
284292 .listId ("F1234567" )
285- .userIds (Arrays . asList ( "U09G4FG3TRN " )))
293+ .userIds (List . of ( "U1234567 " )))
286294 .get ().isOk (), is (true ));
287295 }
288296
289297 // Helper methods
290298 private RichTextBlock createRichTextBlock (String text ) {
291299 return RichTextBlock .builder ()
292- .elements (Arrays . asList (
300+ .elements (List . of (
293301 RichTextSectionElement .builder ()
294- .elements (Arrays . asList (
302+ .elements (List . of (
295303 RichTextSectionElement .Text .builder ()
296304 .text (text )
297305 .build ()
@@ -300,12 +308,4 @@ private RichTextBlock createRichTextBlock(String text) {
300308 ))
301309 .build ();
302310 }
303-
304- private Map <String , Object > createChoice (String value , String label , String color ) {
305- Map <String , Object > choice = new HashMap <>();
306- choice .put ("value" , value );
307- choice .put ("label" , label );
308- choice .put ("color" , color );
309- return choice ;
310- }
311- }
311+ }
0 commit comments