Skip to content

Commit 18cf3c2

Browse files
author
Vvenediktov
committed
add Via to Comment class according to Zendesk API spec
1 parent ee08ec6 commit 18cf3c2

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/main/java/org/zendesk/client/v2/model/Comment.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class Comment implements Serializable {
2424
private Date createdAt;
2525
private Boolean publicComment;
2626
private CommentType type;
27+
private Via via;
2728

2829

2930
public Comment() {
@@ -115,6 +116,13 @@ public void setType(CommentType type) {
115116
this.type = type;
116117
}
117118

119+
@JsonProperty("via")
120+
public Via getVia() {
121+
return via;
122+
}
123+
124+
public void setVia(Via via) { this.via = via; }
125+
118126
@Override
119127
public String toString() {
120128
return "Comment{" + "id=" + id +

src/test/java/org/zendesk/client/v2/RealSmokeTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.zendesk.client.v2.model.Type;
4343
import org.zendesk.client.v2.model.User;
4444
import org.zendesk.client.v2.model.View;
45+
import org.zendesk.client.v2.model.Via;
4546
import org.zendesk.client.v2.model.dynamic.DynamicContentItem;
4647
import org.zendesk.client.v2.model.dynamic.DynamicContentItemVariant;
4748
import org.zendesk.client.v2.model.events.Event;
@@ -62,12 +63,14 @@
6263
import java.util.Collections;
6364
import java.util.Date;
6465
import java.util.HashSet;
66+
import java.util.HashMap;
6567
import java.util.List;
6668
import java.util.Objects;
6769
import java.util.Optional;
6870
import java.util.Properties;
6971
import java.util.Random;
7072
import java.util.Set;
73+
import java.util.Map;
7174
import java.util.UUID;
7275
import java.util.concurrent.TimeUnit;
7376
import java.util.stream.Collectors;
@@ -113,6 +116,9 @@ public class RealSmokeTest {
113116
private static final Random RANDOM = new Random();
114117
private static final String TICKET_COMMENT1 = "Please ignore this ticket";
115118
private static final String TICKET_COMMENT2 = "Yes ignore this ticket";
119+
private static final String VIA_CHANNEL = "chat";
120+
private static final Map<String, Object> VIA_SOURCE = new HashMap<>();
121+
private static final Via VIA = new Via();
116122

117123
private static Properties config;
118124

@@ -134,6 +140,12 @@ public static void loadConfig() {
134140
Awaitility.setDefaultPollInterval(20, TimeUnit.SECONDS);
135141
}
136142

143+
@BeforeClass
144+
public static void initializeVia() {
145+
VIA.setChannel(VIA_CHANNEL);
146+
VIA.setSource(VIA_SOURCE);
147+
}
148+
137149
public void assumeHaveToken() {
138150
assumeThat("We have a username", config.getProperty("username"), not(isEmptyOrNullString()));
139151
assumeThat("We have a token", config.getProperty("token"), not(isEmptyOrNullString()));
@@ -1897,6 +1909,7 @@ public void getTicketCommentsShouldBeAscending() throws Exception {
18971909
ticket = instance.createTicket(t);
18981910
final Comment comment = new Comment(TICKET_COMMENT2);
18991911
comment.setType(CommentType.COMMENT);
1912+
comment.setVia(VIA);
19001913
instance.createComment(ticket.getId(), comment);
19011914
Iterable<Comment> ticketCommentsIt = instance.getTicketComments(ticket.getId());
19021915
List<Comment> comments = new ArrayList<>();
@@ -1924,6 +1937,7 @@ public void getTicketCommentsDescending() throws Exception {
19241937
ticket = instance.createTicket(t);
19251938
final Comment comment = new Comment(TICKET_COMMENT2);
19261939
comment.setType(CommentType.COMMENT);
1940+
comment.setVia(VIA);
19271941
instance.createComment(ticket.getId(), comment);
19281942
Iterable<Comment> ticketCommentsIt = instance.getTicketComments(ticket.getId(), SortOrder.DESCENDING);
19291943
List<Comment> comments = new ArrayList<>();
@@ -1932,8 +1946,10 @@ public void getTicketCommentsDescending() throws Exception {
19321946
assertThat(comments.size(), is(2));
19331947
assertThat(comments.get(0).getBody(), containsString(TICKET_COMMENT2));
19341948
assertThat(comments.get(0).getType(), is(CommentType.COMMENT));
1949+
assertThat(comments.get(0).getVia(), is(VIA));
19351950
assertThat(comments.get(1).getBody(), containsString(TICKET_COMMENT1));
19361951
assertThat(comments.get(1).getType(), is(CommentType.COMMENT));
1952+
assertThat(comments.get(1).getVia(), is(VIA));
19371953
} finally {
19381954
if (ticket != null) {
19391955
instance.deleteTicket(ticket.getId());

0 commit comments

Comments
 (0)