-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageTest.java
More file actions
71 lines (66 loc) · 2.26 KB
/
ImageTest.java
File metadata and controls
71 lines (66 loc) · 2.26 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
package blocks;
import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.gson.JsonParser;
import com.slack.api.model.block.ImageBlock;
import com.slack.api.util.json.GsonFactory;
import org.junit.jupiter.api.Test;
public class ImageTest {
@Test
public void testExample01() {
ImageBlock block = Image.example01();
String actual = GsonFactory.createSnakeCase().toJson(block);
String expected = """
{
"type": "image",
"title": {
"type": "plain_text",
"text": "Please enjoy this photo of a kitten"
},
"block_id": "image4",
"image_url": "http://placekitten.com/500/500",
"alt_text": "An incredibly cute kitten."
}
""";
assertEquals(JsonParser.parseString(expected), JsonParser.parseString(actual));
}
@Test
public void testExample02() {
ImageBlock block = Image.example02();
String actual = GsonFactory.createSnakeCase().toJson(block);
String expected = """
{
"type": "image",
"title": {
"type": "plain_text",
"text": "Please enjoy this photo of a kitten"
},
"block_id": "image4",
"slack_file": {
"url": "https://files.slack.com/files-pri/T0123456-F0123456/xyz.png"
},
"alt_text": "An incredibly cute kitten."
}
""";
assertEquals(JsonParser.parseString(expected), JsonParser.parseString(actual));
}
@Test
public void testExample03() {
ImageBlock block = Image.example03();
String actual = GsonFactory.createSnakeCase().toJson(block);
String expected = """
{
"type": "image",
"title": {
"type": "plain_text",
"text": "Please enjoy this photo of a kitten"
},
"block_id": "image4",
"slack_file": {
"id": "F0123456"
},
"alt_text": "An incredibly cute kitten."
}
""";
assertEquals(JsonParser.parseString(expected), JsonParser.parseString(actual));
}
}