-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSectionTest.java
More file actions
78 lines (73 loc) · 2.4 KB
/
SectionTest.java
File metadata and controls
78 lines (73 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package blocks;
import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.gson.JsonParser;
import com.slack.api.model.block.SectionBlock;
import com.slack.api.util.json.GsonFactory;
import org.junit.jupiter.api.Test;
public class SectionTest {
@Test
public void testExample01() {
SectionBlock block = Section.example01();
String actual = GsonFactory.createSnakeCase().toJson(block);
String expected = """
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "A message *with some bold text* and _some italicized text_."
}
}
""";
assertEquals(JsonParser.parseString(expected), JsonParser.parseString(actual));
}
@Test
public void testExample02() {
SectionBlock block = Section.example02();
String actual = GsonFactory.createSnakeCase().toJson(block);
String expected = """
{
"type": "section",
"text": {
"text": "A message *with some bold text* and _some italicized text_.",
"type": "mrkdwn"
},
"fields": [
{
"type": "mrkdwn",
"text": "High"
},
{
"type": "plain_text",
"emoji": true,
"text": "Silly"
}
]
}
""";
assertEquals(JsonParser.parseString(expected), JsonParser.parseString(actual));
}
@Test
public void testExample03() {
SectionBlock block = Section.example03();
String actual = GsonFactory.createSnakeCase().toJson(block);
String expected = """
{
"type": "section",
"text": {
"text": "*Haley* has requested you set a deadline for finding a house",
"type": "mrkdwn"
},
"accessory": {
"type": "datepicker",
"action_id": "datepicker123",
"initial_date": "1990-04-28",
"placeholder": {
"type": "plain_text",
"text": "Select a date"
}
}
}
""";
assertEquals(JsonParser.parseString(expected), JsonParser.parseString(actual));
}
}