|
5 | 5 | import com.slack.api.model.Message; |
6 | 6 | import com.slack.api.model.block.*; |
7 | 7 | import com.slack.api.model.block.composition.ConfirmationDialogObject; |
| 8 | +import com.slack.api.model.block.composition.MarkdownTextObject; |
| 9 | +import com.slack.api.model.block.composition.OptionObject; |
| 10 | +import com.slack.api.model.block.composition.PlainTextObject; |
8 | 11 | import com.slack.api.model.block.element.*; |
9 | 12 | import com.slack.api.model.view.View; |
10 | 13 | import org.junit.Test; |
@@ -1128,6 +1131,61 @@ public void parseCheckboxes() { |
1128 | 1131 | assertThat(checkboxes2.getActionId(), is("section-action-id")); |
1129 | 1132 | } |
1130 | 1133 |
|
| 1134 | + @Test |
| 1135 | + public void parseCheckboxesWithMrkdwnOptionDescription() { |
| 1136 | + String json = "{" + |
| 1137 | + " \"blocks\": [\n" + |
| 1138 | + " {\n" + |
| 1139 | + " \"type\": \"actions\",\n" + |
| 1140 | + " \"elements\": [\n" + |
| 1141 | + " {\n" + |
| 1142 | + " \"type\": \"checkboxes\",\n" + |
| 1143 | + " \"action_id\": \"this_is_an_action_id\",\n" + |
| 1144 | + " \"options\": [\n" + |
| 1145 | + " {\n" + |
| 1146 | + " \"value\": \"A1\",\n" + |
| 1147 | + " \"text\": {\n" + |
| 1148 | + " \"type\": \"plain_text\",\n" + |
| 1149 | + " \"text\": \"Checkbox 1\"\n" + |
| 1150 | + " },\n" + |
| 1151 | + " \"description\": {\n" + |
| 1152 | + " \"type\": \"mrkdwn\",\n" + |
| 1153 | + " \"text\": \"*bold* description\"\n" + |
| 1154 | + " }\n" + |
| 1155 | + " },\n" + |
| 1156 | + " {\n" + |
| 1157 | + " \"value\": \"A2\",\n" + |
| 1158 | + " \"text\": {\n" + |
| 1159 | + " \"type\": \"plain_text\",\n" + |
| 1160 | + " \"text\": \"Checkbox 2\"\n" + |
| 1161 | + " },\n" + |
| 1162 | + " \"description\": {\n" + |
| 1163 | + " \"type\": \"plain_text\",\n" + |
| 1164 | + " \"text\": \"plain description\"\n" + |
| 1165 | + " }\n" + |
| 1166 | + " }\n" + |
| 1167 | + " ]\n" + |
| 1168 | + " }\n" + |
| 1169 | + " ]\n" + |
| 1170 | + " }\n" + |
| 1171 | + " ]\n" + |
| 1172 | + "}"; |
| 1173 | + Message message = GsonFactory.createSnakeCase().fromJson(json, Message.class); |
| 1174 | + assertThat(message, is(notNullValue())); |
| 1175 | + ActionsBlock block = (ActionsBlock) message.getBlocks().get(0); |
| 1176 | + CheckboxesElement checkboxes = (CheckboxesElement) block.getElements().get(0); |
| 1177 | + |
| 1178 | + OptionObject mrkdwnOption = checkboxes.getOptions().get(0); |
| 1179 | + assertThat(mrkdwnOption.getDescription(), instanceOf(MarkdownTextObject.class)); |
| 1180 | + assertThat(mrkdwnOption.getDescription().getType(), is("mrkdwn")); |
| 1181 | + assertThat(((MarkdownTextObject) mrkdwnOption.getDescription()).getText(), is("*bold* description")); |
| 1182 | + |
| 1183 | + OptionObject plainOption = checkboxes.getOptions().get(1); |
| 1184 | + assertThat(plainOption.getDescription(), instanceOf(PlainTextObject.class)); |
| 1185 | + assertThat(plainOption.getDescription().getType(), is("plain_text")); |
| 1186 | + assertThat(((PlainTextObject) plainOption.getDescription()).getText(), is("plain description")); |
| 1187 | + } |
| 1188 | + |
1131 | 1189 | @Test |
1132 | 1190 | public void confirm_style() { |
1133 | 1191 | String json = "{\n" + |
|
0 commit comments