|
4 | 4 | import org.junit.BeforeClass;
|
5 | 5 | import org.junit.Ignore;
|
6 | 6 | import org.junit.Test;
|
| 7 | +import org.slf4j.Logger; |
| 8 | +import org.slf4j.LoggerFactory; |
7 | 9 | import org.zendesk.client.v2.model.AgentRole;
|
8 | 10 | import org.zendesk.client.v2.model.Audit;
|
9 | 11 | import org.zendesk.client.v2.model.Brand;
|
|
43 | 45 | import java.util.List;
|
44 | 46 | import java.util.Properties;
|
45 | 47 | import java.util.UUID;
|
| 48 | +import java.util.stream.StreamSupport; |
46 | 49 |
|
47 | 50 | import static org.hamcrest.CoreMatchers.anyOf;
|
48 | 51 | import static org.hamcrest.CoreMatchers.is;
|
49 | 52 | import static org.hamcrest.CoreMatchers.not;
|
50 | 53 | import static org.hamcrest.CoreMatchers.notNullValue;
|
51 | 54 | import static org.hamcrest.CoreMatchers.nullValue;
|
| 55 | +import static org.hamcrest.Matchers.greaterThan; |
52 | 56 | import static org.hamcrest.Matchers.lessThanOrEqualTo;
|
| 57 | +import static org.hamcrest.core.StringContains.containsString; |
53 | 58 | import static org.junit.Assert.assertEquals;
|
54 | 59 | import static org.junit.Assert.assertNotEquals;
|
55 | 60 | import static org.junit.Assert.assertNotNull;
|
|
63 | 68 | */
|
64 | 69 | public class RealSmokeTest {
|
65 | 70 |
|
| 71 | + private static final Logger LOGGER = LoggerFactory.getLogger(RealSmokeTest.class); |
| 72 | + |
66 | 73 | // TODO: Find a better way to manage our test environment (this is the PUBLIC_FORM_ID of the cloudbees org)
|
67 | 74 | private static final long CLOUDBEES_ORGANIZATION_ID = 360507899132L;
|
68 | 75 | private static final long PUBLIC_FORM_ID = 360000434032L;
|
@@ -579,10 +586,25 @@ public void showUserComplianceDeletionStatusExpectValidCompletionStatus() throws
|
579 | 586 |
|
580 | 587 | instance.permanentlyDeleteUser(user);
|
581 | 588 |
|
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 | + |
583 | 605 | 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 |
586 | 608 | assertThat(status.getUserId(), is(user.getId()));
|
587 | 609 | });
|
588 | 610 | }
|
@@ -861,7 +883,8 @@ public void getArticleTranslations() throws Exception {
|
861 | 883 | for (Translation t : instance.getArticleTranslations(art.getId())) {
|
862 | 884 | assertNotNull(t.getId());
|
863 | 885 | 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()); |
865 | 888 | if (++translationCount > 3) {
|
866 | 889 | return;
|
867 | 890 | }
|
@@ -1119,4 +1142,54 @@ public void getDynamicContentItems() throws Exception {
|
1119 | 1142 | }
|
1120 | 1143 | }
|
1121 | 1144 | }
|
| 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 | + } |
1122 | 1195 | }
|
0 commit comments