@Test public void unknownPath() { try { mockServer .expect(requestTo("https://graph.facebook.com/me/boguspath")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond( withBadRequest() .body(jsonResource("testdata/error-unknown-path")) .contentType(MediaType.APPLICATION_JSON)); facebook.fetchConnections("me", "boguspath", String.class); fail(); } catch (ResourceNotFoundException e) { assertEquals("Unknown path components: /boguspath", e.getMessage()); } }
@Test @Ignore("This doesn't seem to be true anymore...It looks like FB fixed their status code.") public void unknownAlias_HTTP200() { // yes, Facebook really does return this error as HTTP 200 (probably should be 404) try { mockServer .expect(requestTo("https://graph.facebook.com/dummyalias")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond( withSuccess( jsonResource("testdata/error-unknown-alias"), MediaType.APPLICATION_JSON)); facebook.fetchObject("dummyalias", FacebookProfile.class); fail("Expected GraphAPIException when fetching an unknown object alias"); } catch (ResourceNotFoundException e) { assertEquals( "(#803) Some of the aliases you requested do not exist: dummyalias", e.getMessage()); } }