Added an exception for error 12: X field is deprecated vor version vY.Z and higher
[facebook-errors] / src / test / java / de / juplo / facebook / errors / GraphApiErrorHandlerTest.java
index 9a5d302..65149d5 100644 (file)
@@ -88,6 +88,37 @@ public class GraphApiErrorHandlerTest
     }
   }
 
+  @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 +179,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()
   {
@@ -191,7 +244,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());