Skip to content

Commit c2f6846

Browse files
committed
fix: jdk 1.8 build errors
1 parent 70121ae commit c2f6846

File tree

2 files changed

+193
-115
lines changed

2 files changed

+193
-115
lines changed

slack-api-client/src/test/java/test_locally/api/methods/SlackListsTest.java

Lines changed: 107 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import org.junit.Test;
1010
import util.MockSlackApiServer;
1111

12-
import java.util.List;
1312
import java.util.Arrays;
13+
import java.util.HashMap;
1414
import java.util.Map;
1515

1616
import static org.hamcrest.CoreMatchers.is;
@@ -37,38 +37,56 @@ public void tearDown() throws Exception {
3737
// Create a new list
3838
@Test
3939
public void slackListsCreate() throws Exception {
40+
Map<String, Object> taskNameCol = new HashMap<>();
41+
taskNameCol.put("key", "task_name");
42+
taskNameCol.put("name", "Task Name");
43+
taskNameCol.put("type", "text");
44+
taskNameCol.put("is_primary_column", true);
45+
46+
Map<String, Object> dueDateCol = new HashMap<>();
47+
dueDateCol.put("key", "due_date");
48+
dueDateCol.put("name", "Due Date");
49+
dueDateCol.put("type", "date");
50+
51+
Map<String, Object> choice1 = new HashMap<>();
52+
choice1.put("value", "not_started");
53+
choice1.put("label", "Not Started");
54+
choice1.put("color", "red");
55+
56+
Map<String, Object> choice2 = new HashMap<>();
57+
choice2.put("value", "in_progress");
58+
choice2.put("label", "In Progress");
59+
choice2.put("color", "yellow");
60+
61+
Map<String, Object> choice3 = new HashMap<>();
62+
choice3.put("value", "completed");
63+
choice3.put("label", "Completed");
64+
choice3.put("color", "green");
65+
66+
Map<String, Object> options = new HashMap<>();
67+
options.put("choices", Arrays.asList(choice1, choice2, choice3));
68+
69+
Map<String, Object> statusCol = new HashMap<>();
70+
statusCol.put("key", "status");
71+
statusCol.put("name", "Status");
72+
statusCol.put("type", "select");
73+
statusCol.put("options", options);
74+
75+
Map<String, Object> assigneeCol = new HashMap<>();
76+
assigneeCol.put("key", "assignee");
77+
assigneeCol.put("name", "Assignee");
78+
assigneeCol.put("type", "user");
79+
4080
assertThat(slack.methods(ValidToken).slackListsCreate(r -> r
4181
.name("Test List - SlackLists API")
42-
.descriptionBlocks(List.of(RichTextBlock.builder()
43-
.elements(List.of(RichTextSectionElement.builder()
44-
.elements(List.of(RichTextSectionElement.Text.builder()
82+
.descriptionBlocks(Arrays.asList(RichTextBlock.builder()
83+
.elements(Arrays.asList(RichTextSectionElement.builder()
84+
.elements(Arrays.asList(RichTextSectionElement.Text.builder()
4585
.text("List to keep track of tasks!")
4686
.build()))
4787
.build()))
4888
.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"))))
89+
.schema(Arrays.asList(taskNameCol, dueDateCol, statusCol, assigneeCol)))
7290
.isOk(), is(true));
7391
}
7492

@@ -84,7 +102,7 @@ public void slackListsAccessSet() throws Exception {
84102
assertThat(slack.methods(ValidToken).slackListsAccessSet(r -> r
85103
.listId("F1234567")
86104
.accessLevel("write")
87-
.channelIds(List.of("C1234567")))
105+
.channelIds(Arrays.asList("C1234567")))
88106
.isOk(), is(true));
89107
}
90108

@@ -93,24 +111,32 @@ public void slackListsAccessSet_async() throws Exception {
93111
assertThat(slack.methodsAsync(ValidToken).slackListsAccessSet(r -> r
94112
.listId("F1234567")
95113
.accessLevel("write")
96-
.channelIds(List.of("C1234567")))
114+
.channelIds(Arrays.asList("C1234567")))
97115
.get().isOk(), is(true));
98116
}
99117

100118
// Create several list items
101119
@Test
102120
public void slackListsItemsCreate() throws Exception {
121+
Map<String, Object> textElement = new HashMap<>();
122+
textElement.put("type", "text");
123+
textElement.put("text", "Test task item");
124+
125+
Map<String, Object> richTextSection = new HashMap<>();
126+
richTextSection.put("type", "rich_text_section");
127+
richTextSection.put("elements", Arrays.asList(textElement));
128+
129+
Map<String, Object> richText = new HashMap<>();
130+
richText.put("type", "rich_text");
131+
richText.put("elements", Arrays.asList(richTextSection));
132+
133+
Map<String, Object> field = new HashMap<>();
134+
field.put("column_id", "C1234567");
135+
field.put("rich_text", Arrays.asList(richText));
136+
103137
assertThat(slack.methods(ValidToken).slackListsItemsCreate(r -> r
104138
.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"))))))))))
139+
.initialFields(Arrays.asList(field)))
114140
.isOk(), is(true));
115141
}
116142

@@ -142,15 +168,15 @@ public void slackListsItemsDelete_async() throws Exception {
142168
public void slackListsItemsDeleteMultiple() throws Exception {
143169
assertThat(slack.methods(ValidToken).slackListsItemsDeleteMultiple(r -> r
144170
.listId("F1234567")
145-
.ids(List.of("Rec018ALE9720", "Rec018ALE9721")))
171+
.ids(Arrays.asList("Rec018ALE9720", "Rec018ALE9721")))
146172
.isOk(), is(true));
147173
}
148174

149175
@Test
150176
public void slackListsItemsDeleteMultiple_async() throws Exception {
151177
assertThat(slack.methodsAsync(ValidToken).slackListsItemsDeleteMultiple(r -> r
152178
.listId("F1234567")
153-
.ids(List.of("Rec1234567890", "Rec1234567891")))
179+
.ids(Arrays.asList("Rec1234567890", "Rec1234567891")))
154180
.get().isOk(), is(true));
155181
}
156182

@@ -228,35 +254,51 @@ public void slackListsDownloadGet_async() throws Exception {
228254
// Update an existing list item
229255
@Test
230256
public void slackListsItemsUpdate() throws Exception {
257+
Map<String, Object> textElement = new HashMap<>();
258+
textElement.put("type", "text");
259+
textElement.put("text", "new task name");
260+
261+
Map<String, Object> richTextSection = new HashMap<>();
262+
richTextSection.put("type", "rich_text_section");
263+
richTextSection.put("elements", Arrays.asList(textElement));
264+
265+
Map<String, Object> richText = new HashMap<>();
266+
richText.put("type", "rich_text");
267+
richText.put("elements", Arrays.asList(richTextSection));
268+
269+
Map<String, Object> cell = new HashMap<>();
270+
cell.put("row_id", "Rec1234567890");
271+
cell.put("column_id", "C1234567");
272+
cell.put("rich_text", Arrays.asList(richText));
273+
231274
assertThat(slack.methods(ValidToken).slackListsItemsUpdate(r -> r
232275
.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"))))))))))
276+
.cells(Arrays.asList(cell)))
243277
.isOk(), is(true));
244278
}
245279

246280
@Test
247281
public void slackListsItemsUpdate_async() throws Exception {
282+
Map<String, Object> textElement = new HashMap<>();
283+
textElement.put("type", "text");
284+
textElement.put("text", "new task name");
285+
286+
Map<String, Object> richTextSection = new HashMap<>();
287+
richTextSection.put("type", "rich_text_section");
288+
richTextSection.put("elements", Arrays.asList(textElement));
289+
290+
Map<String, Object> richText = new HashMap<>();
291+
richText.put("type", "rich_text");
292+
richText.put("elements", Arrays.asList(richTextSection));
293+
294+
Map<String, Object> cell = new HashMap<>();
295+
cell.put("row_id", "Rec1234567890");
296+
cell.put("column_id", "C1234567");
297+
cell.put("rich_text", Arrays.asList(richText));
298+
248299
assertThat(slack.methodsAsync(ValidToken).slackListsItemsUpdate(r -> r
249300
.listId("F1234567")
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"))))))))))
301+
.cells(Arrays.asList(cell)))
260302
.get().isOk(), is(true));
261303
}
262304

@@ -282,24 +324,24 @@ public void slackListsUpdate_async() throws Exception {
282324
public void slackListsAccessDelete() throws Exception {
283325
assertThat(slack.methods(ValidToken).slackListsAccessDelete(r -> r
284326
.listId("F1234567")
285-
.userIds(List.of("U1234567")))
327+
.userIds(Arrays.asList("U1234567")))
286328
.isOk(), is(true));
287329
}
288330

289331
@Test
290332
public void slackListsAccessDelete_async() throws Exception {
291333
assertThat(slack.methodsAsync(ValidToken).slackListsAccessDelete(r -> r
292334
.listId("F1234567")
293-
.userIds(List.of("U1234567")))
335+
.userIds(Arrays.asList("U1234567")))
294336
.get().isOk(), is(true));
295337
}
296338

297339
// Helper methods
298340
private RichTextBlock createRichTextBlock(String text) {
299341
return RichTextBlock.builder()
300-
.elements(List.of(
342+
.elements(Arrays.asList(
301343
RichTextSectionElement.builder()
302-
.elements(List.of(
344+
.elements(Arrays.asList(
303345
RichTextSectionElement.Text.builder()
304346
.text(text)
305347
.build()
@@ -308,4 +350,4 @@ private RichTextBlock createRichTextBlock(String text) {
308350
))
309351
.build();
310352
}
311-
}
353+
}

0 commit comments

Comments
 (0)