X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fde%2Fjuplo%2Ffacebook%2Ferrors%2FGraphApiErrorHandlerTest.java;h=c1719560dea9d31f65a94208d2d806e8c2b57cb2;hb=e3b130e04e4e89a08e203185ba9ae7e6c1f350d8;hp=dde664e39b7e070a2b56056d12a196edfbffbb16;hpb=874954203f56e8880e9bfc9d9df98a5d985baea7;p=facebook-errors diff --git a/src/test/java/de/juplo/facebook/errors/GraphApiErrorHandlerTest.java b/src/test/java/de/juplo/facebook/errors/GraphApiErrorHandlerTest.java index dde664e..c171956 100644 --- a/src/test/java/de/juplo/facebook/errors/GraphApiErrorHandlerTest.java +++ b/src/test/java/de/juplo/facebook/errors/GraphApiErrorHandlerTest.java @@ -254,6 +254,56 @@ public class GraphApiErrorHandlerTest } } + @Test + public void testError190() + { + log.info("testError190"); + + requestFactory.setBody("{\"error\":{\"message\":\"Bad signature\",\"type\":\"OAuthException\",\"code\":190,\"fbtrace_id\":\"Ay2OYQrINbXOCfQpBvoxDIw\"}}"); + + try + { + clientTemplate.getForObject("ANY", SOME.class); + fail("The expected exception was not thrown"); + } + catch(AccessTokenExpiredException e) + { + log.debug("{}", e.toString()); + assertEquals(new Integer(190), e.getCode()); + assertEquals("Bad signature", e.getMessage()); + assertEquals(Type.OAuthException, e.getType()); + assertEquals("Ay2OYQrINbXOCfQpBvoxDIw", e.getTraceId()); + } + } + + @Test + public void testError200() + { + log.info("testError200"); + + requestFactory.setBody("{\n" + + " \"error\": {\n" + + " \"message\": \"(#200) The user hasn't authorized the application to perform this action\",\n" + + " \"type\": \"OAuthException\",\n" + + " \"code\": 200\n" + + " }\n" + + "}"); + + try + { + clientTemplate.getForObject("ANY", SOME.class); + fail("The expected exception was not thrown"); + } + catch(ApplicationNotAuthorizedByUserException e) + { + log.debug("{}", e.toString()); + assertEquals(new Integer(200), e.getCode()); + assertEquals("(#200) The user hasn't authorized the application to perform this action", e.getMessage()); + assertEquals(Type.OAuthException, e.getType()); + assertNull(e.getTraceId()); + } + } + @Test public void testError613() { @@ -753,7 +803,7 @@ public class GraphApiErrorHandlerTest clientTemplate = new RestTemplate(); clientTemplate.setRequestFactory(requestFactory); clientTemplate.setErrorHandler( - new GraphApiErrorHandler(clientTemplate.getErrorHandler()) + new GraphApiErrorResponseErrorHandler(clientTemplate.getErrorHandler()) ); }