Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proper json mapping for Trigger #677

Merged
merged 5 commits into from
Mar 27, 2024
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
11 changes: 9 additions & 2 deletions src/main/java/org/zendesk/client/v2/model/Trigger.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.zendesk.client.v2.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
Expand All @@ -20,8 +21,14 @@ public class Trigger implements Serializable {
private int position;
private Conditions conditions;
private List<Action> actions;

@JsonProperty("created_at")
private Date createdAt;

@JsonProperty("updated_at")
private Date updatedAt;

@JsonProperty("category_id")
private String categoryId;

public Long getId() {
Expand Down Expand Up @@ -105,8 +112,6 @@ public String toString() {
+ categoryId
+ ", title="
+ title
+ ", active="
+ active
+ ", position="
+ position
+ ", active="
Expand All @@ -115,6 +120,8 @@ public String toString() {
+ conditions
+ ", actions="
+ actions
+ ", createdAt="
+ createdAt
+ ", updatedAt="
+ updatedAt
+ '}';
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/org/zendesk/client/v2/model/TriggerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Arrays;
import java.util.Date;
import org.junit.Test;
import org.zendesk.client.v2.Utils;

Expand Down Expand Up @@ -44,6 +45,9 @@ public void testTriggerWithComplexActionValues() throws Exception {
trigger.getActions().get(0).getValue());
assertEquals(0, trigger.getConditions().getAll().size());
assertEquals(1, trigger.getConditions().getAny().size());
assertEquals("1", trigger.getCategoryId());
assertEquals(new Date(1710025200000L), trigger.getCreatedAt());
assertEquals(new Date(1710111600000L), trigger.getUpdatedAt());
assertEquals("comment_includes_word", trigger.getConditions().getAny().get(0).getField());
assertEquals("includes", trigger.getConditions().getAny().get(0).getOperator());
assertEquals("@triggerTest", trigger.getConditions().getAny().get(0).getValue());
Expand Down Expand Up @@ -76,6 +80,9 @@ public void testTriggerWithMultilineActionValues() throws Exception {
trigger.getActions().get(1).getValue());
assertEquals(0, trigger.getConditions().getAll().size());
assertEquals(1, trigger.getConditions().getAny().size());
assertEquals("1", trigger.getCategoryId());
assertEquals(new Date(1710025200000L), trigger.getCreatedAt());
assertEquals(new Date(1710111600000L), trigger.getUpdatedAt());
assertEquals("comment_includes_word", trigger.getConditions().getAny().get(0).getField());
assertEquals("includes", trigger.getConditions().getAny().get(0).getOperator());
assertEquals("@triggerTest", trigger.getConditions().getAny().get(0).getValue());
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"id":12345678,"title":"Test Trigger","active":true,"position":45,"conditions":{"all":[],"any":[{"field":"comment_includes_word","operator":"includes","value":"@triggerTest"}]},"actions":[{"field":"notification_target","value":["1234567890",[["key1","value1"],["key2","value2"]]]}],"createdAt":null,"updatedAt":null,"categoryId":null}
{"id":12345678,"title":"Test Trigger","active":true,"position":45,"conditions":{"all":[],"any":[{"field":"comment_includes_word","operator":"includes","value":"@triggerTest"}]},"actions":[{"field":"notification_target","value":["1234567890",[["key1","value1"],["key2","value2"]]]}],"created_at":1710025200000,"updated_at":1710111600000,"category_id":"1"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"id":12345678,"title":"Test Trigger","active":true,"position":45,"conditions":{"all":[],"any":[{"field":"comment_includes_word","operator":"includes","value":"@triggerTest"}]},"actions":[{"field":"notification_user","value":["09876543","Trigger Target 1 {{ticket.title}}","Test Multiline\n\n{{ticket.comments_formatted}}\n\n--------------------------"]},{"field":"notification_target","value":["98765432","{\n \"color\":\"purple\",\n \"message_format\":\"text\",\n \"message\":\"Trigger Target 2 {{ticket.title}}.\"\n}"]}],"createdAt":null,"updatedAt":null,"categoryId":null}
{"id":12345678,"title":"Test Trigger","active":true,"position":45,"conditions":{"all":[],"any":[{"field":"comment_includes_word","operator":"includes","value":"@triggerTest"}]},"actions":[{"field":"notification_user","value":["09876543","Trigger Target 1 {{ticket.title}}","Test Multiline\n\n{{ticket.comments_formatted}}\n\n--------------------------"]},{"field":"notification_target","value":["98765432","{\n \"color\":\"purple\",\n \"message_format\":\"text\",\n \"message\":\"Trigger Target 2 {{ticket.title}}.\"\n}"]}],"created_at":1710025200000,"updated_at":1710111600000,"category_id":"1"}