File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
main/java/com/xero/api/exception
test/java/com/xero/api/exception Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ public XeroApiException handleBadRequest(HttpResponseException httpResponseExcep
8080 return convertException (httpResponseException );
8181 }
8282 } else {
83- return convertException (httpResponseException );
83+ return newApiException (httpResponseException );
8484 }
8585 }
8686
Original file line number Diff line number Diff line change 1313import org .mockito .Mock ;
1414import org .mockito .junit .MockitoJUnitRunner ;
1515
16- import static org .junit .Assert .assertFalse ;
17- import static org .junit .Assert .assertNotNull ;
18- import static org .junit .Assert .assertTrue ;
16+ import static org .junit .Assert .*;
1917import static org .mockito .Mockito .when ;
2018
2119@ RunWith (MockitoJUnitRunner .class )
@@ -67,6 +65,17 @@ public void handleOAuthErrorRequest() throws Exception {
6765 assertNotNull (xeroApiException .getMessage ());
6866 }
6967
68+ @ Test
69+ public void handleOtherErrorRequest () throws Exception {
70+ when (httpResponseException .getContent ()).thenReturn ("dummy" );
71+ when (httpResponseException .getStatusCode ()).thenReturn (400 );
72+ XeroApiException xeroApiException = xeroExceptionHandler .handleBadRequest (httpResponseException );
73+ assertNotNull (xeroApiException );
74+ assertNotNull (xeroApiException .getMessages ());
75+ assertNotNull (xeroApiException .getMessage ());
76+ assertEquals (xeroApiException .getResponseCode (), 400 );
77+ }
78+
7079 /**
7180 * sample oauth exception
7281 * @return oauth exception
You can’t perform that action at this time.
0 commit comments