Skip to content

Commit da1d966

Browse files
committed
Update some tests
1 parent 79d5d89 commit da1d966

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.zendesk.client.v2;
22

33
import java.io.IOException;
4+
import java.text.MessageFormat;
45

56
import com.ning.http.client.Response;
67

@@ -17,7 +18,7 @@ public ZendeskResponseException(Response resp) throws IOException {
1718
}
1819

1920
public ZendeskResponseException(int statusCode, String statusText, String body) {
20-
super(statusText);
21+
super(MessageFormat.format("HTTP/{0}: {1}", statusCode, statusText));
2122
this.statusCode = statusCode;
2223
this.statusText = statusText;
2324
this.body = body;

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

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
import org.zendesk.client.v2.model.Identity;
1212
import org.zendesk.client.v2.model.Organization;
1313
import org.zendesk.client.v2.model.Request;
14+
import org.zendesk.client.v2.model.Status;
1415
import org.zendesk.client.v2.model.Ticket;
1516
import org.zendesk.client.v2.model.User;
1617
import org.zendesk.client.v2.model.events.Event;
1718

1819
import java.util.Collections;
1920
import java.util.Properties;
21+
import java.util.UUID;
2022

2123
import static org.hamcrest.CoreMatchers.is;
2224
import static org.hamcrest.CoreMatchers.not;
@@ -54,7 +56,8 @@ public void assumeHavePassword() {
5456

5557
public void assumeHaveTokenOrPassword() {
5658
assumeThat("We have a username", config.getProperty("username"), notNullValue());
57-
assumeThat("We have a token or password", config.getProperty("token") != null || config.getProperty("password") != null, is(true));
59+
assumeThat("We have a token or password", config.getProperty("token") != null || config.getProperty("password") != null, is(
60+
true));
5861
}
5962

6063
@After
@@ -124,12 +127,12 @@ public void getRecentTickets() throws Exception {
124127
public void getTicketsById() throws Exception {
125128
createClientWithTokenOrPassword();
126129
long count = 1;
127-
for (Ticket t : instance.getTickets(1, 3, 5)) {
130+
for (Ticket t : instance.getTickets(1, 6, 11)) {
128131
assertThat(t.getSubject(), notNullValue());
129132
assertThat(t.getId(), is(count));
130-
count += 2;
133+
count += 5;
131134
}
132-
assertThat(count, is(7L));
135+
assertThat(count, is(16L));
133136
}
134137

135138
@Test
@@ -174,7 +177,7 @@ public void createAnonymousClient() {
174177
}
175178

176179
@Test
177-
@Ignore("Don't spam the production zendesk")
180+
@Ignore("Don't spam zendesk")
178181
public void createDeleteTicket() throws Exception {
179182
createClientWithTokenOrPassword();
180183
assumeThat("Must have a requester email", config.getProperty("requester.email"), notNullValue());
@@ -198,6 +201,33 @@ public void createDeleteTicket() throws Exception {
198201
assertThat(instance.getTicket(ticket.getId()), nullValue());
199202
}
200203

204+
@Test
205+
@Ignore("Don't spam zendesk")
206+
public void createSolveTickets() throws Exception {
207+
createClientWithTokenOrPassword();
208+
assumeThat("Must have a requester email", config.getProperty("requester.email"), notNullValue());
209+
Ticket ticket;
210+
do {
211+
Ticket t = new Ticket(
212+
new Ticket.Requester(config.getProperty("requester.name"), config.getProperty("requester.email")),
213+
"This is a test " + UUID.randomUUID().toString(), new Comment("Please ignore this ticket"));
214+
ticket = instance.createTicket(t);
215+
System.out.println(ticket.getId() + " -> " + ticket.getUrl());
216+
assertThat(ticket.getId(), notNullValue());
217+
Ticket t2 = instance.getTicket(ticket.getId());
218+
assertThat(t2, notNullValue());
219+
assertThat(t2.getId(), is(ticket.getId()));
220+
t2.setAssigneeId(instance.getCurrentUser().getId());
221+
t2.setStatus(Status.CLOSED);
222+
instance.updateTicket(t2);
223+
assertThat(ticket.getSubject(), is(t.getSubject()));
224+
assertThat(ticket.getRequester(), nullValue());
225+
assertThat(ticket.getRequesterId(), notNullValue());
226+
assertThat(ticket.getDescription(), is(t.getComment().getBody()));
227+
assertThat(instance.getTicket(ticket.getId()), notNullValue());
228+
} while (ticket.getId() < 200L); // seed enough data for the paging tests
229+
}
230+
201231
@Test
202232
public void lookupUserByEmail() throws Exception {
203233
createClientWithTokenOrPassword();

0 commit comments

Comments
 (0)