X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fde%2Fjuplo%2Ffacebook%2Ferrors%2FGraphApiErrorHandlerTest.java;h=c9a53cd232fac8588a2f644deadd5722273f7c10;hb=8079d646addc5206f64bfb213d018a2fa94444d3;hp=9a5d302c70e0c3f101e956efd869d780bac0e5c0;hpb=8b78564d39b0cef4476dfd949a21825cc5f2485c;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 9a5d302..c9a53cd 100644 --- a/src/test/java/de/juplo/facebook/errors/GraphApiErrorHandlerTest.java +++ b/src/test/java/de/juplo/facebook/errors/GraphApiErrorHandlerTest.java @@ -88,6 +88,68 @@ public class GraphApiErrorHandlerTest } } + @Test + public void testError4() + { + log.info("testError4"); + + + requestFactory.setBody( + "{\n" + + " \"error\": {\n" + + " \"code\": 4, \n" + + " \"fbtrace_id\": \"HZRM6BTMu+D\", \n" + + " \"is_transient\": true, \n" + + " \"message\": \"(#4) Application request limit reached\", \n" + + " \"type\": \"OAuthException\"\n" + + " }\n" + + "}\n"); + + try + { + clientTemplate.getForObject("ANY", SOME.class); + fail("The expected exception was not thrown"); + } + catch(ApplicationRequestLimitReachedException e) + { + log.debug("{}", e.toString()); + assertEquals(new Integer(4), e.getCode()); + assertEquals("(#4) Application request limit reached", e.getMessage()); + assertEquals(Type.OAuthException, e.getType()); + } + } + + @Test + public void testError12() + { + log.info("testError12"); + + + requestFactory.setBody( + "{\n" + + " \"error\":\n" + + " {\n" + + " \"message\": \"(#12) location field is deprecated for versions v2.5 and higher\",\n" + + " \"type\": \"OAuthException\",\n" + + " \"code\": 12\n," + + " \"fbtrace_id\":\"BoxCYne7GrL\"\n" + + " }\n" + + "}"); + + try + { + clientTemplate.getForObject("ANY", SOME.class); + fail("The expected exception was not thrown"); + } + catch(DeprecatedException e) + { + log.debug("{}", e.toString()); + assertEquals(new Integer(12), e.getCode()); + assertEquals("(#12) location field is deprecated for versions v2.5 and higher", e.getMessage()); + assertEquals(Type.OAuthException, e.getType()); + } + } + @Test public void testError21() { @@ -148,6 +210,28 @@ public class GraphApiErrorHandlerTest } } + @Test + public void testError102() + { + log.info("testError102"); + + requestFactory.setBody("{\"error\":{\"message\":\"A user access token is required to request this resource.\",\"type\":\"OAuthException\",\"code\":102,\"fbtrace_id\":\"DhdMyf23Ki7\"}}"); + + try + { + clientTemplate.getForObject("ANY", SOME.class); + fail("The expected exception was not thrown"); + } + catch(UserAccessTokenRequiredException e) + { + log.debug("{}", e.toString()); + assertEquals(new Integer(102), e.getCode()); + assertEquals("A user access token is required to request this resource.", e.getMessage()); + assertEquals(Type.OAuthException, e.getType()); + assertEquals("DhdMyf23Ki7", e.getTraceId()); + } + } + @Test public void testError104() { @@ -170,6 +254,28 @@ 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 testError613() { @@ -191,7 +297,7 @@ public class GraphApiErrorHandlerTest clientTemplate.getForObject("ANY", SOME.class); fail("The expected exception was not thrown"); } - catch(RateExceededException e) + catch(RateLimitExceededException e) { log.debug("{}", e.toString()); assertEquals(new Integer(613), e.getCode()); @@ -669,7 +775,7 @@ public class GraphApiErrorHandlerTest clientTemplate = new RestTemplate(); clientTemplate.setRequestFactory(requestFactory); clientTemplate.setErrorHandler( - new GraphApiErrorHandler(clientTemplate.getErrorHandler()) + new GraphApiErrorResponseErrorHandler(clientTemplate.getErrorHandler()) ); }