|
15 | 15 | import org.zendesk.client.v2.model.Identity;
|
16 | 16 | import org.zendesk.client.v2.model.JobStatus;
|
17 | 17 | import org.zendesk.client.v2.model.Organization;
|
| 18 | +import org.zendesk.client.v2.model.Priority; |
18 | 19 | import org.zendesk.client.v2.model.Request;
|
19 | 20 | import org.zendesk.client.v2.model.Status;
|
20 | 21 | import org.zendesk.client.v2.model.SuspendedTicket;
|
|
41 | 42 | import java.util.Properties;
|
42 | 43 | import java.util.UUID;
|
43 | 44 |
|
44 |
| -import static junit.framework.TestCase.assertEquals; |
45 | 45 | import static org.hamcrest.CoreMatchers.*;
|
46 | 46 | import static org.junit.Assert.*;
|
47 | 47 | import static org.junit.Assume.assumeThat;
|
@@ -397,6 +397,47 @@ public void createSolveTickets() throws Exception {
|
397 | 397 | } while (ticket.getId() < firstId + 5L); // seed enough data for the paging tests
|
398 | 398 | }
|
399 | 399 |
|
| 400 | + @Test |
| 401 | + public void testUpdateTickets() throws Exception { |
| 402 | + createClientWithTokenOrPassword(); |
| 403 | + Ticket t = new Ticket( |
| 404 | + new Ticket.Requester(config.getProperty("requester.name"), config.getProperty("requester.email")), |
| 405 | + "This is a test " + UUID.randomUUID().toString(), new Comment("Please ignore this ticket")); |
| 406 | + Ticket ticket1 = instance.createTicket(t); |
| 407 | + Ticket t2 = new Ticket( |
| 408 | + new Ticket.Requester(config.getProperty("requester.name"), config.getProperty("requester.email")), |
| 409 | + "This is a test " + UUID.randomUUID().toString(), new Comment("Please ignore this ticket")); |
| 410 | + Ticket ticket2 = instance.createTicket(t2); |
| 411 | + ticket1.setPriority(Priority.HIGH); |
| 412 | + ticket2.setPriority(Priority.LOW); |
| 413 | + ticket1.setStatus(Status.SOLVED); |
| 414 | + ticket2.setStatus(Status.SOLVED); |
| 415 | + |
| 416 | + JobStatus<Ticket> jobstatus = instance.updateTicketsAsync(Arrays.asList(ticket1, ticket2)).toCompletableFuture().join(); |
| 417 | + assertThat(jobstatus.getStatus(), is(JobStatus.JobStatusEnum.queued)); |
| 418 | + //TODO: uncomment the rest of this test once issue #98 is resolved: https://github.com/cloudbees/zendesk-java-client/issues/98 |
| 419 | +// Instant startUpdateAt = Instant.now(); |
| 420 | +// while (instance.getJobStatus(jobstatus).getStatus() != JobStatus.JobStatusEnum.completed |
| 421 | +// && startUpdateAt.plusSeconds(10).isAfter(Instant.now())) { |
| 422 | +// Thread.sleep(100); |
| 423 | +// } |
| 424 | +// JobStatus<Ticket> completedJobStatus = instance.getJobStatus(jobstatus); |
| 425 | +// assertThat(completedJobStatus.getStatus(), is(JobStatus.JobStatusEnum.completed)); |
| 426 | +// assertNotNull(jobstatus.getResults()); |
| 427 | +// assertThat(jobstatus.getResults().size(), is(2)); |
| 428 | +// jobstatus.getResults().forEach(ticket -> { |
| 429 | +// if (ticket.getId().equals(ticket1.getId())) { |
| 430 | +// assertThat(ticket.getPriority(), is(Priority.HIGH)); |
| 431 | +// assertThat(ticket.getStatus(), is(Status.SOLVED)); |
| 432 | +// } else if (ticket.getId().equals(ticket2.getId())) { |
| 433 | +// assertThat(ticket.getPriority(), is(Priority.LOW)); |
| 434 | +// assertThat(ticket.getStatus(), is(Status.SOLVED)); |
| 435 | +// } else { |
| 436 | +// fail("Received a different ticket back in response: " + ticket.getId()); |
| 437 | +// } |
| 438 | +// }); |
| 439 | + } |
| 440 | + |
400 | 441 | @Test
|
401 | 442 | public void lookupUserByEmail() throws Exception {
|
402 | 443 | createClientWithTokenOrPassword();
|
|
0 commit comments