From 180640358ace75cc02c9dd24025f0c72897bc06d Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Tue, 29 Jul 2014 14:03:51 +0200 Subject: [PATCH] Added error 613: rate exceeded --- ...GraphApiExceptionJackson1Deserializer.java | 1 + ...GraphApiExceptionJackson2Deserializer.java | 1 + .../juplo/facebook/RateExceededException.java | 14 +++++++++ .../facebook/GraphApiErrorHandlerTest.java | 31 +++++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 src/main/java/de/juplo/facebook/RateExceededException.java diff --git a/src/main/java/de/juplo/facebook/GraphApiExceptionJackson1Deserializer.java b/src/main/java/de/juplo/facebook/GraphApiExceptionJackson1Deserializer.java index 2d0c002..8a1d3bf 100644 --- a/src/main/java/de/juplo/facebook/GraphApiExceptionJackson1Deserializer.java +++ b/src/main/java/de/juplo/facebook/GraphApiExceptionJackson1Deserializer.java @@ -87,6 +87,7 @@ public class GraphApiExceptionJackson1Deserializer case 2: return new UnexpectedErrorException(); case 21: return new PageMigratedException(message); case 100: return new UnsupportedGetRequestException(); + case 613: return new RateExceededException(); default: return new GraphApiException(message, type, code); } } diff --git a/src/main/java/de/juplo/facebook/GraphApiExceptionJackson2Deserializer.java b/src/main/java/de/juplo/facebook/GraphApiExceptionJackson2Deserializer.java index ec46de3..becb51f 100644 --- a/src/main/java/de/juplo/facebook/GraphApiExceptionJackson2Deserializer.java +++ b/src/main/java/de/juplo/facebook/GraphApiExceptionJackson2Deserializer.java @@ -94,6 +94,7 @@ public class GraphApiExceptionJackson2Deserializer case 2: return new UnexpectedErrorException(); case 21: return new PageMigratedException(message); case 100: return new UnsupportedGetRequestException(); + case 613: return new RateExceededException(); default: return new GraphApiException(message, type, code); } } diff --git a/src/main/java/de/juplo/facebook/RateExceededException.java b/src/main/java/de/juplo/facebook/RateExceededException.java new file mode 100644 index 0000000..b633069 --- /dev/null +++ b/src/main/java/de/juplo/facebook/RateExceededException.java @@ -0,0 +1,14 @@ +package de.juplo.facebook; + + +/** + * + * @author kai + */ +public class RateExceededException extends OAuthException +{ + public RateExceededException() + { + super("(#613) Calls to stream have exceeded the rate of 600 calls per 600 seconds.", 613); + } +} diff --git a/src/test/java/de/juplo/facebook/GraphApiErrorHandlerTest.java b/src/test/java/de/juplo/facebook/GraphApiErrorHandlerTest.java index b9dc905..d93121b 100644 --- a/src/test/java/de/juplo/facebook/GraphApiErrorHandlerTest.java +++ b/src/test/java/de/juplo/facebook/GraphApiErrorHandlerTest.java @@ -173,6 +173,37 @@ public class GraphApiErrorHandlerTest } } + @Test + public void testError613() + { + log.info("testError613"); + + + requestFactory.setBody( + "{\n" + + " \"error\":\n" + + " {\n" + + " \"message\": \"(#613) Calls to stream have exceeded the rate of 600 calls per 600 seconds.\",\n" + + " \"type\": \"OAuthException\",\n" + + " \"code\": 613\n" + + " }\n" + + "}"); + + try + { + clientTemplate.getForObject("ANY", SOME.class); + fail("The expected exception was not thrown"); + } + catch(RateExceededException e) + { + log.debug("{}", e.toString()); + assertEquals("invalid_request", e.getOAuth2ErrorCode()); + assertEquals(613, e.getCode()); + assertEquals("(#613) Calls to stream have exceeded the rate of 600 calls per 600 seconds.", e.getMessage()); + assertEquals("OAuthException", e.getType()); + } + } + @Test public void testUnmappedError() { -- 2.20.1