Skip to content

Commit 0908fcf

Browse files
authored
Merge branch 'master' into dynamic_content
2 parents 71dfb96 + 9fda174 commit 0908fcf

File tree

5 files changed

+122
-15
lines changed

5 files changed

+122
-15
lines changed

.dependabot/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version: 1
2+
update_configs:
3+
- package_manager: "java:maven"
4+
directory: "/"
5+
update_schedule: "weekly"

pom.xml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<groupId>com.cloudbees</groupId>
2222
<artifactId>cloudbees-oss-parent</artifactId>
23-
<version>8</version>
23+
<version>9</version>
2424
</parent>
2525

2626
<groupId>com.cloudbees.thirdparty</groupId>
@@ -98,7 +98,7 @@
9898
<dependency>
9999
<groupId>com.fasterxml.jackson</groupId>
100100
<artifactId>jackson-bom</artifactId>
101-
<version>2.9.3</version>
101+
<version>2.10.1</version>
102102
<type>pom</type>
103103
<scope>import</scope>
104104
</dependency>
@@ -109,12 +109,12 @@
109109
<dependency>
110110
<groupId>org.slf4j</groupId>
111111
<artifactId>slf4j-api</artifactId>
112-
<version>1.7.25</version>
112+
<version>1.7.29</version>
113113
</dependency>
114114
<dependency>
115115
<groupId>org.asynchttpclient</groupId>
116116
<artifactId>async-http-client</artifactId>
117-
<version>2.3.0</version>
117+
<version>2.10.4</version>
118118
</dependency>
119119
<dependency>
120120
<groupId>com.fasterxml.jackson.core</groupId>
@@ -127,7 +127,7 @@
127127
<dependency>
128128
<groupId>com.damnhandy</groupId>
129129
<artifactId>handy-uri-templates</artifactId>
130-
<version>2.1.6</version>
130+
<version>2.1.8</version>
131131
</dependency>
132132
<dependency>
133133
<groupId>junit</groupId>
@@ -144,7 +144,7 @@
144144
<dependency>
145145
<groupId>org.slf4j</groupId>
146146
<artifactId>slf4j-simple</artifactId>
147-
<version>1.7.25</version>
147+
<version>1.7.29</version>
148148
<scope>test</scope>
149149
</dependency>
150150
</dependencies>
@@ -154,7 +154,14 @@
154154
<plugins>
155155
<plugin>
156156
<artifactId>maven-enforcer-plugin</artifactId>
157-
<version>3.0.0-M1</version>
157+
<version>3.0.0-M2</version>
158+
</plugin>
159+
<plugin>
160+
<groupId>org.apache.maven.plugins</groupId>
161+
<artifactId>maven-surefire-plugin</artifactId>
162+
<configuration>
163+
<rerunFailingTestsCount>3</rerunFailingTestsCount>
164+
</configuration>
158165
</plugin>
159166
</plugins>
160167
</pluginManagement>
@@ -201,12 +208,12 @@
201208
<dependency>
202209
<groupId>org.codehaus.mojo</groupId>
203210
<artifactId>animal-sniffer-enforcer-rule</artifactId>
204-
<version>1.14</version>
211+
<version>1.18</version>
205212
</dependency>
206213
<dependency>
207214
<groupId>org.codehaus.mojo</groupId>
208215
<artifactId>extra-enforcer-rules</artifactId>
209-
<version>1.0-beta-6</version>
216+
<version>1.2</version>
210217
</dependency>
211218
</dependencies>
212219
</plugin>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.zendesk.client.v2;
2+
3+
public enum SortOrder {
4+
ASCENDING("asc"), DESCENDING("desc");
5+
6+
private String queryParameter;
7+
8+
SortOrder(String queryParameter) {
9+
this.queryParameter = queryParameter;
10+
}
11+
12+
public String getQueryParameter() {
13+
return queryParameter;
14+
}
15+
}

src/main/java/org/zendesk/client/v2/Zendesk.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,8 +1050,15 @@ public Iterable<Comment> getRequestComments(long id) {
10501050
}
10511051

10521052
public Iterable<Comment> getTicketComments(long id) {
1053-
return new PagedIterable<>(tmpl("/tickets/{id}/comments.json").set("id", id),
1054-
handleList(Comment.class, "comments"));
1053+
return getTicketComments(id, SortOrder.ASCENDING);
1054+
}
1055+
1056+
public Iterable<Comment> getTicketComments(long id, SortOrder order) {
1057+
return new PagedIterable<>(
1058+
tmpl("/tickets/{id}/comments.json?sort_order={order}")
1059+
.set("id", id)
1060+
.set("order", order.getQueryParameter()),
1061+
handleList(Comment.class, "comments"));
10551062
}
10561063

10571064
public Comment getRequestComment(org.zendesk.client.v2.model.Request request, Comment comment) {

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

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import org.junit.BeforeClass;
55
import org.junit.Ignore;
66
import org.junit.Test;
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
79
import org.zendesk.client.v2.model.AgentRole;
810
import org.zendesk.client.v2.model.Audit;
911
import org.zendesk.client.v2.model.Brand;
@@ -43,13 +45,16 @@
4345
import java.util.List;
4446
import java.util.Properties;
4547
import java.util.UUID;
48+
import java.util.stream.StreamSupport;
4649

4750
import static org.hamcrest.CoreMatchers.anyOf;
4851
import static org.hamcrest.CoreMatchers.is;
4952
import static org.hamcrest.CoreMatchers.not;
5053
import static org.hamcrest.CoreMatchers.notNullValue;
5154
import static org.hamcrest.CoreMatchers.nullValue;
55+
import static org.hamcrest.Matchers.greaterThan;
5256
import static org.hamcrest.Matchers.lessThanOrEqualTo;
57+
import static org.hamcrest.core.StringContains.containsString;
5358
import static org.junit.Assert.assertEquals;
5459
import static org.junit.Assert.assertNotEquals;
5560
import static org.junit.Assert.assertNotNull;
@@ -63,6 +68,8 @@
6368
*/
6469
public class RealSmokeTest {
6570

71+
private static final Logger LOGGER = LoggerFactory.getLogger(RealSmokeTest.class);
72+
6673
// TODO: Find a better way to manage our test environment (this is the PUBLIC_FORM_ID of the cloudbees org)
6774
private static final long CLOUDBEES_ORGANIZATION_ID = 360507899132L;
6875
private static final long PUBLIC_FORM_ID = 360000434032L;
@@ -579,10 +586,25 @@ public void showUserComplianceDeletionStatusExpectValidCompletionStatus() throws
579586

580587
instance.permanentlyDeleteUser(user);
581588

582-
final Iterable<ComplianceDeletionStatus> complianceDeletionStatuses = instance.getComplianceDeletionStatuses(user.getId());
589+
// https://developer.zendesk.com/rest_api/docs/support/users#show-compliance-deletion-statuses
590+
// The deletion is going through different states ( request_deletion -> started -> complete )
591+
// for different applications and they are described in compliance_deletion_statuses
592+
593+
final Iterable<ComplianceDeletionStatus> complianceDeletionStatuses =
594+
instance.getComplianceDeletionStatuses(user.getId());
595+
596+
// Let's validate
597+
598+
assertThat("There is at least one entry",
599+
StreamSupport.stream(complianceDeletionStatuses.spliterator(), false).count(), greaterThan(0L));
600+
601+
assertTrue("There is at least an entry for the application \"all\"",
602+
StreamSupport.stream(complianceDeletionStatuses.spliterator(), false)
603+
.anyMatch(complianceDeletionStatus -> "all".equals(complianceDeletionStatus.getApplication())));
604+
583605
complianceDeletionStatuses.forEach(status -> {
584-
assertThat(status.getAction(), is("request_deletion"));
585-
assertThat(status.getApplication(), is("all"));
606+
LOGGER.info("Compliance Deletion Status : {}", status);
607+
// All entries are about this user
586608
assertThat(status.getUserId(), is(user.getId()));
587609
});
588610
}
@@ -861,7 +883,8 @@ public void getArticleTranslations() throws Exception {
861883
for (Translation t : instance.getArticleTranslations(art.getId())) {
862884
assertNotNull(t.getId());
863885
assertNotNull(t.getTitle());
864-
assertNotNull(t.getBody());
886+
// body is not mandatory <https://developer.zendesk.com/rest_api/docs/help_center/translations.html>
887+
//assertNotNull(t.getBody());
865888
if (++translationCount > 3) {
866889
return;
867890
}
@@ -1119,4 +1142,54 @@ public void getDynamicContentItems() throws Exception {
11191142
}
11201143
}
11211144
}
1145+
1146+
@Test
1147+
public void getTicketCommentsShouldBeAscending() throws Exception {
1148+
createClientWithTokenOrPassword();
1149+
1150+
Ticket t = new Ticket(
1151+
new Ticket.Requester(config.getProperty("requester.name"), config.getProperty("requester.email")),
1152+
"This is an automated test ticket", new Comment("1"));
1153+
Ticket ticket = null;
1154+
try {
1155+
ticket = instance.createTicket(t);
1156+
instance.createComment(ticket.getId(), new Comment("2"));
1157+
Iterable<Comment> ticketCommentsIt = instance.getTicketComments(ticket.getId());
1158+
List<Comment> comments = new ArrayList<>();
1159+
ticketCommentsIt.forEach(comments::add);
1160+
1161+
assertThat(comments.size(), is(2));
1162+
assertThat(comments.get(0).getBody(), containsString("1"));
1163+
assertThat(comments.get(1).getBody(), containsString("2"));
1164+
} finally {
1165+
if (ticket != null) {
1166+
instance.deleteTicket(ticket.getId());
1167+
}
1168+
}
1169+
}
1170+
1171+
@Test
1172+
public void getTicketCommentsDescending() throws Exception {
1173+
createClientWithTokenOrPassword();
1174+
1175+
Ticket t = new Ticket(
1176+
new Ticket.Requester(config.getProperty("requester.name"), config.getProperty("requester.email")),
1177+
"This is an automated test ticket", new Comment("1"));
1178+
Ticket ticket = null;
1179+
try {
1180+
ticket = instance.createTicket(t);
1181+
instance.createComment(ticket.getId(), new Comment("2"));
1182+
Iterable<Comment> ticketCommentsIt = instance.getTicketComments(ticket.getId(), SortOrder.DESCENDING);
1183+
List<Comment> comments = new ArrayList<>();
1184+
ticketCommentsIt.forEach(comments::add);
1185+
1186+
assertThat(comments.size(), is(2));
1187+
assertThat(comments.get(0).getBody(), containsString("2"));
1188+
assertThat(comments.get(1).getBody(), containsString("1"));
1189+
} finally {
1190+
if (ticket != null) {
1191+
instance.deleteTicket(ticket.getId());
1192+
}
1193+
}
1194+
}
11221195
}

0 commit comments

Comments
 (0)