Skip to content

Commit

Permalink
Merge pull request #73 from LeonisX/master
Browse files Browse the repository at this point in the history
Avoid StackOverflowError in XeroExceptionHandler
  • Loading branch information
SidneyAllen authored Apr 30, 2018
2 parents 8677946 + 6e39dae commit 6c519b2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public XeroApiException handleBadRequest(HttpResponseException httpResponseExcep
return convertException(httpResponseException);
}
} else {
return convertException(httpResponseException);
return newApiException(httpResponseException);
}
}

Expand Down
15 changes: 12 additions & 3 deletions src/test/java/com/xero/api/exception/XeroExceptionHandlerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
Expand Down Expand Up @@ -67,6 +65,17 @@ public void handleOAuthErrorRequest() throws Exception {
assertNotNull(xeroApiException.getMessage());
}

@Test
public void handleOtherErrorRequest() throws Exception {
when(httpResponseException.getContent()).thenReturn("dummy");
when(httpResponseException.getStatusCode()).thenReturn(400);
XeroApiException xeroApiException = xeroExceptionHandler.handleBadRequest(httpResponseException);
assertNotNull(xeroApiException);
assertNotNull(xeroApiException.getMessages());
assertNotNull(xeroApiException.getMessage());
assertEquals(xeroApiException.getResponseCode(), 400);
}

/**
* sample oauth exception
* @return oauth exception
Expand Down

0 comments on commit 6c519b2

Please sign in to comment.