Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.slack.api.methods.response.files.FilesUploadResponse;
import com.slack.api.methods.response.files.FilesUploadV2Response;
import com.slack.api.model.*;
import com.slack.api.model.EntityMetadata.EntityPayload.BooleanField;
import com.slack.api.model.EntityMetadata.EntityPayload.FileFields;
import com.slack.api.model.EntityMetadata.EntityPayload.IncidentFields;
import com.slack.api.model.EntityMetadata.EntityPayload;
Expand Down Expand Up @@ -539,10 +540,13 @@ public void unfurl_with_work_object_from_object() throws Exception {
EntityPayload.StringField.builder().value("World").tagColor("green").build()};
EntityPayload.CustomField[] customFields = {
EntityPayload.CustomField.builder().type("string").key("hello_world").label("Message")
.value("Hello World").build(),
.value("Hello World").build(),
EntityPayload.CustomField.builder().type("array").key("array_field")
.label("Array Field").itemType("string")
.value(stringArray).build()};
.label("Array Field").itemType("string")
.value(stringArray).build(),
EntityPayload.CustomField.builder().type("boolean").key("checkbox").label("Checkbox")
.value(true).booleanField(BooleanField.builder().type("checkbox").text("Check the box").build()).build()
Comment on lines +547 to +548
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗳️ praise: Nice improvements to these tests once again!

};
EntityPayload payload = EntityPayload.builder()
.attributes(attributes)
.fileFields(fields)
Expand All @@ -568,6 +572,8 @@ public void unfurl_with_work_object_from_object() throws Exception {
.metadata(metadata)
.build());
assertThat(unfurlResponse.getError(), is(nullValue()));
assertThat(unfurlResponse.getWarning(), is(nullValue()));
assertThat(unfurlResponse.getResponseMetadata(), is(nullValue()));

// Verify if the message can be parsed by the JSON parser
ConversationsHistoryResponse history = slack.methods(botToken).conversationsHistory(r -> r
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ public static class TypedField {

// When type is 'slack#/types/user'
private User user;

// When type is 'slack#/types/entity_ref'
private EntityRef entityRef;

// When type is 'boolean'
@SerializedName("boolean")
private BooleanField booleanField;
}

@Data
Expand All @@ -146,6 +153,36 @@ public static class User {
private Icon icon;
}

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class BooleanField {
private String type;

// Checkbox
private String text;
private String description;

// or text-based
private String trueText;
private String trueDescription;
private String falseText;
private String falseDescription;
}

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class EntityRef {
private String entityUrl;
private ExternalRef externalRef;
private String displayType;
private String title;
private Icon icon;
}

@Data
@Builder
@NoArgsConstructor
Expand All @@ -170,8 +207,6 @@ public static class StringField {
public static class Timestamp {
private String label;
private Integer value;
private String link;
private Icon icon;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These properties weren't valid for this field type

private String type;
private Edit edit;
}
Expand Down Expand Up @@ -220,6 +255,9 @@ public static class CustomField {
private Edit edit;
private String itemType;
private User user;
private EntityRef entityRef;
@SerializedName("boolean")
private BooleanField booleanField;
}

@Data
Expand Down