X-Git-Url: https://juplo.de/gitweb/?p=facebook-utils;a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fde%2Fjuplo%2Ffacebook%2Fclient%2FGraphApiErrorHandlerTest.java;h=15dfba3b3ee60a1a6fc8f4f435ca59d81146a0c6;hp=ddd19a6bceef947634db281914d78f86d7566808;hb=5f2b31dc7f443ab9eb088d3150e2d4903cb40159;hpb=d0accf7044000e7f20e8bd586c3c48ce8c8cef7d diff --git a/src/test/java/de/juplo/facebook/client/GraphApiErrorHandlerTest.java b/src/test/java/de/juplo/facebook/client/GraphApiErrorHandlerTest.java index ddd19a6..15dfba3 100644 --- a/src/test/java/de/juplo/facebook/client/GraphApiErrorHandlerTest.java +++ b/src/test/java/de/juplo/facebook/client/GraphApiErrorHandlerTest.java @@ -6,6 +6,7 @@ import de.juplo.facebook.exceptions.RateExceededException; import de.juplo.facebook.exceptions.GraphApiException; import de.juplo.facebook.exceptions.UnknownErrorException; import de.juplo.facebook.exceptions.PageMigratedException; +import de.juplo.facebook.exceptions.UnmappedErrorException; import java.util.Date; import java.util.Map; import java.util.Set; @@ -79,7 +80,7 @@ public class GraphApiErrorHandlerTest { log.debug("{}", e.toString()); assertEquals("invalid_request", e.getOAuth2ErrorCode()); - assertEquals(1, e.getCode()); + assertEquals(new Integer(1), e.getCode()); assertEquals("An unknown error has occurred.", e.getMessage()); assertEquals("OAuthException", e.getType()); } @@ -110,7 +111,7 @@ public class GraphApiErrorHandlerTest { log.debug("{}", e.toString()); assertEquals("invalid_request", e.getOAuth2ErrorCode()); - assertEquals(2, e.getCode()); + assertEquals(new Integer(2), e.getCode()); assertEquals("An unexpected error has occurred. Please retry your request later.", e.getMessage()); assertEquals("OAuthException", e.getType()); } @@ -141,7 +142,7 @@ public class GraphApiErrorHandlerTest { log.debug("{}", e.toString()); assertEquals("invalid_request", e.getOAuth2ErrorCode()); - assertEquals(21, e.getCode()); + assertEquals(new Integer(21), e.getCode()); assertEquals("(#21) Page ID 590408587650316 was migrated to page ID 1421620791415603. Please update your API calls to the new ID", e.getMessage()); assertEquals("OAuthException", e.getType()); } @@ -172,7 +173,7 @@ public class GraphApiErrorHandlerTest { log.debug("{}", e.toString()); assertEquals("invalid_request", e.getOAuth2ErrorCode()); - assertEquals(100, e.getCode()); + assertEquals(new Integer(100), e.getCode()); assertEquals("Unsupported get request.", e.getMessage()); assertEquals("GraphMethodException", e.getType()); } @@ -203,7 +204,7 @@ public class GraphApiErrorHandlerTest { log.debug("{}", e.toString()); assertEquals("invalid_request", e.getOAuth2ErrorCode()); - assertEquals(613, e.getCode()); + assertEquals(new Integer(613), e.getCode()); assertEquals("(#613) Calls to stream have exceeded the rate of 600 calls per 600 seconds.", e.getMessage()); assertEquals("OAuthException", e.getType()); } @@ -234,16 +235,16 @@ public class GraphApiErrorHandlerTest { log.debug("{}", e.toString()); assertEquals("invalid_request", e.getOAuth2ErrorCode()); - assertEquals(999999999, e.getCode()); + assertEquals(new Integer(999999999), e.getCode()); assertEquals("This error does not exist.", e.getMessage()); assertEquals("NonexistentException", e.getType()); } } @Test - public void testInvlalidErrors() + public void testUnmappedErrors() { - log.info("testInvalidErrors"); + log.info("testUnmappedErrors"); requestFactory.setBody( @@ -261,9 +262,16 @@ public class GraphApiErrorHandlerTest clientTemplate.getForObject("ANY", SOME.class); fail("The expected exception was not thrown"); } - catch(HttpClientErrorException e) + catch(UnmappedErrorException e) { log.debug("{}", e.toString()); + assertNull(e.getMessage()); + assertEquals("Whatever", e.getType()); + assertEquals(new Integer(999999999), e.getCode()); + assertNull(e.getSubCode()); + assertNull(e.getUserTitle()); + assertNull(e.getUserMessage()); + assertNull(e.getTraceId()); } catch(Exception e) { @@ -285,9 +293,16 @@ public class GraphApiErrorHandlerTest clientTemplate.getForObject("ANY", SOME.class); fail("The expected exception was not thrown"); } - catch(HttpClientErrorException e) + catch(UnmappedErrorException e) { log.debug("{}", e.toString()); + assertNull(e.getMessage()); + assertEquals("Whatever", e.getType()); + assertEquals(new Integer(999999999), e.getCode()); + assertNull(e.getSubCode()); + assertNull(e.getUserTitle()); + assertNull(e.getUserMessage()); + assertNull(e.getTraceId()); } catch(Exception e) { @@ -299,7 +314,7 @@ public class GraphApiErrorHandlerTest "{\n" + " \"error\":\n" + " {\n" + - " \"message\": \"Not a Graph-Api-Exception.\",\n" + + " \"message\": \"An unmapped Graph-API-Exception.\",\n" + " \"type\": null,\n" + " \"code\": 999999999\n" + " }\n" + @@ -310,9 +325,16 @@ public class GraphApiErrorHandlerTest clientTemplate.getForObject("ANY", SOME.class); fail("The expected exception was not thrown"); } - catch(HttpClientErrorException e) + catch(UnmappedErrorException e) { log.debug("{}", e.toString()); + assertEquals("An unmapped Graph-API-Exception.", e.getMessage()); + assertNull(e.getType()); + assertEquals(new Integer(999999999), e.getCode()); + assertNull(e.getSubCode()); + assertNull(e.getUserTitle()); + assertNull(e.getUserMessage()); + assertNull(e.getTraceId()); } catch(Exception e) { @@ -324,7 +346,7 @@ public class GraphApiErrorHandlerTest "{\n" + " \"error\":\n" + " {\n" + - " \"message\": \"Not a Graph-Api-Exception.\",\n" + + " \"message\": \"An unmapped Graph-API-Exception.\",\n" + " \"code\": 999999999\n" + " }\n" + "}"); @@ -334,14 +356,27 @@ public class GraphApiErrorHandlerTest clientTemplate.getForObject("ANY", SOME.class); fail("The expected exception was not thrown"); } - catch(HttpClientErrorException e) + catch(UnmappedErrorException e) { log.debug("{}", e.toString()); + assertEquals("An unmapped Graph-API-Exception.", e.getMessage()); + assertNull(e.getType()); + assertEquals(new Integer(999999999), e.getCode()); + assertNull(e.getSubCode()); + assertNull(e.getUserTitle()); + assertNull(e.getUserMessage()); + assertNull(e.getTraceId()); } catch(Exception e) { fail("A wrong exception was thrown: " + e.toString()); } + } + + @Test + public void testInvlalidErrors() + { + log.info("testInvalidErrors"); requestFactory.setBody(