1
1
package org .zendesk .client .v2 ;
2
2
3
3
import org .apache .commons .lang3 .time .DateUtils ;
4
+ import org .awaitility .Awaitility ;
4
5
import org .hamcrest .CoreMatchers ;
5
6
import org .hamcrest .Matchers ;
6
7
import org .hamcrest .core .IsCollectionContaining ;
82
83
import static org .hamcrest .Matchers .greaterThan ;
83
84
import static org .hamcrest .Matchers .hasSize ;
84
85
import static org .hamcrest .Matchers .isEmptyString ;
85
- import static org .hamcrest .Matchers .lessThan ;
86
86
import static org .hamcrest .Matchers .lessThanOrEqualTo ;
87
87
import static org .hamcrest .core .StringContains .containsString ;
88
88
import static org .junit .Assert .assertEquals ;
@@ -121,6 +121,9 @@ public static void loadConfig() {
121
121
config = ZendeskConfig .load ();
122
122
assumeThat ("We have a configuration" , config , notNullValue ());
123
123
assumeThat ("Configuration has an url" , config .getProperty ("url" ), not (isEmptyString ()));
124
+ Awaitility .setDefaultTimeout (2 , TimeUnit .MINUTES );
125
+ Awaitility .setDefaultPollDelay (10 , TimeUnit .SECONDS );
126
+ Awaitility .setDefaultPollInterval (20 , TimeUnit .SECONDS );
124
127
}
125
128
126
129
public void assumeHaveToken () {
@@ -1889,8 +1892,8 @@ private JobStatus waitJobCompletion(final JobStatus result) {
1889
1892
assertNotNull (result .getId ());
1890
1893
assertNotNull (result .getStatus ());
1891
1894
1892
- // Let's wait for its completion (5 seconds max)
1893
- await ().atMost ( 10 , TimeUnit . SECONDS ). until (() ->
1895
+ // Let's wait for its completion (2 minutes max)
1896
+ await ().until (() ->
1894
1897
instance .getJobStatus (result ).getStatus () == JobStatus .JobStatusEnum .completed );
1895
1898
1896
1899
// Let's validate and return the completed result
@@ -1909,7 +1912,7 @@ private JobStatus waitJobCompletion(final JobStatus result) {
1909
1912
*/
1910
1913
private void waitTicketDeleted (long ticketId ) {
1911
1914
// Wait for the confirmation
1912
- await ().atMost ( 10 , TimeUnit . SECONDS ). until (() -> StreamSupport
1915
+ await ().until (() -> StreamSupport
1913
1916
.stream (instance .getDeletedTickets ("id" , SortOrder .DESCENDING ).spliterator (), false )
1914
1917
.map (DeletedTicket ::getId )
1915
1918
.collect (Collectors .toList ())
@@ -1923,7 +1926,7 @@ private void waitTicketDeleted(long ticketId) {
1923
1926
*/
1924
1927
private void waitTicketsDeleted (Long [] ticketsIds ) {
1925
1928
// Wait for the confirmation
1926
- await ().atMost ( 10 , TimeUnit . SECONDS ). until (() -> StreamSupport
1929
+ await ().until (() -> StreamSupport
1927
1930
.stream (instance .getDeletedTickets ("id" , SortOrder .DESCENDING ).spliterator (), false )
1928
1931
.map (DeletedTicket ::getId )
1929
1932
.collect (Collectors .toList ())
0 commit comments