@@ -306,7 +306,7 @@ public void shouldParsePlainTextErrorResponse() throws Exception {
306306 @ Test
307307 public void shouldReceiveRateLimitsResponse () throws Exception {
308308 CustomRequest <List > request = new CustomRequest <>(client , server .getBaseUrl (), "GET" , listType );
309- server .rateLimitReachedResponse (100 , 10 , 5 );
309+ server .rateLimitReachedResponse (100 , - 1 , 5 );
310310 Exception exception = null ;
311311 try {
312312 request .execute ();
@@ -324,8 +324,33 @@ public void shouldReceiveRateLimitsResponse() throws Exception {
324324 assertThat (rateLimitException .getValue ("non_existing_key" ), is (nullValue ()));
325325 assertThat (rateLimitException .getStatusCode (), is (429 ));
326326 assertThat (rateLimitException .getLimit (), is (100L ));
327- assertThat (rateLimitException .getRemaining (), is (10L ));
327+ assertThat (rateLimitException .getRemaining (), is (- 1L ));
328328 assertThat (rateLimitException .getReset (), is (5L ));
329329 }
330+
331+ @ Test
332+ public void shouldReceiveDefaultsRateLimitsResponse () throws Exception {
333+ CustomRequest <List > request = new CustomRequest <>(client , server .getBaseUrl (), "GET" , listType );
334+ server .rateLimitReachedResponse (-1 , -1 , -1 );
335+ Exception exception = null ;
336+ try {
337+ request .execute ();
338+ server .takeRequest ();
339+ } catch (Exception e ) {
340+ exception = e ;
341+ }
342+ assertThat (exception , is (notNullValue ()));
343+ assertThat (exception , is (instanceOf (RateLimitException .class )));
344+ assertThat (exception .getCause (), is (nullValue ()));
345+ assertThat (exception .getMessage (), is ("Request failed with status code 429: Rate limit reached" ));
346+ RateLimitException rateLimitException = (RateLimitException ) exception ;
347+ assertThat (rateLimitException .getDescription (), is ("Rate limit reached" ));
348+ assertThat (rateLimitException .getError (), is (nullValue ()));
349+ assertThat (rateLimitException .getValue ("non_existing_key" ), is (nullValue ()));
350+ assertThat (rateLimitException .getStatusCode (), is (429 ));
351+ assertThat (rateLimitException .getLimit (), is (-1L ));
352+ assertThat (rateLimitException .getRemaining (), is (-1L ));
353+ assertThat (rateLimitException .getReset (), is (-1L ));
354+ }
330355
331356}
0 commit comments