Skip to content

Bulk Delete Tickets method returns JobStatus #599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/java/org/zendesk/client/v2/Zendesk.java
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,9 @@ public void markTicketAsSpam(long id) {
complete(submit(req("PUT", tmpl("/tickets/{id}/mark_as_spam.json").set("id", id)), handleStatus()));
}

public void deleteTickets(long id, long... ids) {
complete(submit(req("DELETE", tmpl("/tickets/destroy_many.json{?ids}").set("ids", idArray(id, ids))),
handleStatus()));
public JobStatus deleteTickets(long id, long... ids) {
return complete(submit(req("DELETE", tmpl("/tickets/destroy_many.json{?ids}").set("ids", idArray(id, ids))),
handleJobStatus()));
}

public JobStatus permanentlyDeleteTickets(long id, long... ids) {
Expand Down
16 changes: 8 additions & 8 deletions src/test/java/org/zendesk/client/v2/RealSmokeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -617,15 +617,15 @@ public void createPermanentlyDeleteTickets() throws Exception {
final Long[] ticketsIds = tickets.stream().map(Ticket::getId).toArray(Long[]::new);
// when
// We soft delete them
instance.deleteTickets(firstElement(ticketsIds), otherElements(ticketsIds));
waitTicketsDeleted(ticketsIds);
JobStatus softDeleteJobStatus = waitJobCompletion(instance.deleteTickets(firstElement(ticketsIds), otherElements(ticketsIds)));
assertThat("Soft Delete Job is completed", softDeleteJobStatus.getStatus(), is(JobStatus.JobStatusEnum.completed));
// We permanently delete them
JobStatus jobStatus =
JobStatus permDeleteJobStatus =
waitJobCompletion(
instance.permanentlyDeleteTickets(firstElement(ticketsIds), otherElements(ticketsIds)));
// then
assertThat("Job is completed", jobStatus.getStatus(), is(JobStatus.JobStatusEnum.completed));
jobStatus.getResults().forEach(jobResult -> {
assertThat("Job is completed", permDeleteJobStatus.getStatus(), is(JobStatus.JobStatusEnum.completed));
permDeleteJobStatus.getResults().forEach(jobResult -> {
assertThat("The job result has no account_id entry", jobResult.getAccountId(), nullValue());
assertThat("The job result has no action entry", jobResult.getAction(), nullValue());
assertThat("The job result has no details entry", jobResult.getDetails(), nullValue());
Expand Down Expand Up @@ -710,7 +710,7 @@ public void createTickets() throws Exception {
assertThat("A unique ID must be set", id, notNullValue()));
} finally {
// cleanup
instance.deleteTickets(firstElement(createdTicketsIds), otherElements(createdTicketsIds));
waitJobCompletion(instance.deleteTickets(firstElement(createdTicketsIds), otherElements(createdTicketsIds)));
}
}

Expand Down Expand Up @@ -752,7 +752,7 @@ public void updateTickets() throws Exception {
assertThat("The job result has a success entry", jobResult.getSuccess(), is(TRUE));
});
} finally {
instance.deleteTickets(firstElement(ticketsIds), otherElements(ticketsIds));
waitJobCompletion(instance.deleteTickets(firstElement(ticketsIds), otherElements(ticketsIds)));
}
}

Expand Down Expand Up @@ -839,7 +839,7 @@ public void importTickets() throws Exception {
// then
} finally {
// cleanup
instance.deleteTickets(firstElement(createdTicketsIds), otherElements(createdTicketsIds));
waitJobCompletion(instance.deleteTickets(firstElement(createdTicketsIds), otherElements(createdTicketsIds)));
}
}

Expand Down