|
48 | 48 | import static org.hamcrest.CoreMatchers.notNullValue;
|
49 | 49 | import static org.hamcrest.CoreMatchers.nullValue;
|
50 | 50 | import static org.hamcrest.Matchers.lessThanOrEqualTo;
|
| 51 | +import static org.hamcrest.core.StringContains.containsString; |
51 | 52 | import static org.junit.Assert.assertEquals;
|
52 | 53 | import static org.junit.Assert.assertNotEquals;
|
53 | 54 | import static org.junit.Assert.assertNotNull;
|
@@ -1084,4 +1085,54 @@ public void createTicketForm() throws Exception {
|
1084 | 1085 | assertEquals(givenName, createdForm.getRawName());
|
1085 | 1086 | assertEquals(givenName, createdForm.getRawDisplayName());
|
1086 | 1087 | }
|
| 1088 | + |
| 1089 | + @Test |
| 1090 | + public void getTicketCommentsShouldBeAscending() throws Exception { |
| 1091 | + createClientWithTokenOrPassword(); |
| 1092 | + |
| 1093 | + Ticket t = new Ticket( |
| 1094 | + new Ticket.Requester(config.getProperty("requester.name"), config.getProperty("requester.email")), |
| 1095 | + "This is an automated test ticket", new Comment("1")); |
| 1096 | + Ticket ticket = null; |
| 1097 | + try { |
| 1098 | + ticket = instance.createTicket(t); |
| 1099 | + instance.createComment(ticket.getId(), new Comment("2")); |
| 1100 | + Iterable<Comment> ticketCommentsIt = instance.getTicketComments(ticket.getId()); |
| 1101 | + List<Comment> comments = new ArrayList<>(); |
| 1102 | + ticketCommentsIt.forEach(comments::add); |
| 1103 | + |
| 1104 | + assertThat(comments.size(), is(2)); |
| 1105 | + assertThat(comments.get(0).getBody(), containsString("1")); |
| 1106 | + assertThat(comments.get(1).getBody(), containsString("2")); |
| 1107 | + } finally { |
| 1108 | + if (ticket != null) { |
| 1109 | + instance.deleteTicket(ticket.getId()); |
| 1110 | + } |
| 1111 | + } |
| 1112 | + } |
| 1113 | + |
| 1114 | + @Test |
| 1115 | + public void getTicketCommentsDescending() throws Exception { |
| 1116 | + createClientWithTokenOrPassword(); |
| 1117 | + |
| 1118 | + Ticket t = new Ticket( |
| 1119 | + new Ticket.Requester(config.getProperty("requester.name"), config.getProperty("requester.email")), |
| 1120 | + "This is an automated test ticket", new Comment("1")); |
| 1121 | + Ticket ticket = null; |
| 1122 | + try { |
| 1123 | + ticket = instance.createTicket(t); |
| 1124 | + instance.createComment(ticket.getId(), new Comment("2")); |
| 1125 | + Iterable<Comment> ticketCommentsIt = instance.getTicketComments(ticket.getId(), SortOrder.DESCENDING); |
| 1126 | + List<Comment> comments = new ArrayList<>(); |
| 1127 | + ticketCommentsIt.forEach(comments::add); |
| 1128 | + |
| 1129 | + assertThat(comments.size(), is(2)); |
| 1130 | + assertThat(comments.get(0).getBody(), containsString("2")); |
| 1131 | + assertThat(comments.get(1).getBody(), containsString("1")); |
| 1132 | + } finally { |
| 1133 | + if (ticket != null) { |
| 1134 | + instance.deleteTicket(ticket.getId()); |
| 1135 | + } |
| 1136 | + } |
| 1137 | + } |
1087 | 1138 | }
|
0 commit comments