Skip to content

Commit e2a120c

Browse files
committed
[chore] Configure the polling interval/delay to be less aggressive
It avoids APIRateLimitExceeded errors
1 parent d80090b commit e2a120c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

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

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

33
import org.apache.commons.lang3.time.DateUtils;
4+
import org.awaitility.Awaitility;
45
import org.hamcrest.CoreMatchers;
56
import org.hamcrest.Matchers;
67
import org.hamcrest.core.IsCollectionContaining;
@@ -81,7 +82,6 @@
8182
import static org.hamcrest.Matchers.greaterThan;
8283
import static org.hamcrest.Matchers.hasSize;
8384
import static org.hamcrest.Matchers.isEmptyString;
84-
import static org.hamcrest.Matchers.lessThan;
8585
import static org.hamcrest.Matchers.lessThanOrEqualTo;
8686
import static org.hamcrest.core.StringContains.containsString;
8787
import static org.junit.Assert.assertEquals;
@@ -120,6 +120,9 @@ public static void loadConfig() {
120120
config = ZendeskConfig.load();
121121
assumeThat("We have a configuration", config, notNullValue());
122122
assumeThat("Configuration has an url", config.getProperty("url"), not(isEmptyString()));
123+
Awaitility.setDefaultTimeout(2, TimeUnit.MINUTES);
124+
Awaitility.setDefaultPollDelay(10, TimeUnit.SECONDS);
125+
Awaitility.setDefaultPollInterval(20, TimeUnit.SECONDS);
123126
}
124127

125128
public void assumeHaveToken() {
@@ -1874,8 +1877,8 @@ private JobStatus waitJobCompletion(final JobStatus result) {
18741877
assertNotNull(result.getId());
18751878
assertNotNull(result.getStatus());
18761879

1877-
// Let's wait for its completion (5 seconds max)
1878-
await().atMost(10, TimeUnit.SECONDS).until(() ->
1880+
// Let's wait for its completion (30 seconds max)
1881+
await().until(() ->
18791882
instance.getJobStatus(result).getStatus() == JobStatus.JobStatusEnum.completed);
18801883

18811884
// Let's validate and return the completed result
@@ -1894,7 +1897,7 @@ private JobStatus waitJobCompletion(final JobStatus result) {
18941897
*/
18951898
private void waitTicketDeleted(long ticketId) {
18961899
// Wait for the confirmation
1897-
await().atMost(10, TimeUnit.SECONDS).until(() -> StreamSupport
1900+
await().until(() -> StreamSupport
18981901
.stream(instance.getDeletedTickets("id", SortOrder.DESCENDING).spliterator(), false)
18991902
.map(DeletedTicket::getId)
19001903
.collect(Collectors.toList())
@@ -1908,7 +1911,7 @@ private void waitTicketDeleted(long ticketId) {
19081911
*/
19091912
private void waitTicketsDeleted(Long[] ticketsIds) {
19101913
// Wait for the confirmation
1911-
await().atMost(10, TimeUnit.SECONDS).until(() -> StreamSupport
1914+
await().until(() -> StreamSupport
19121915
.stream(instance.getDeletedTickets("id", SortOrder.DESCENDING).spliterator(), false)
19131916
.map(DeletedTicket::getId)
19141917
.collect(Collectors.toList())

0 commit comments

Comments
 (0)