/** {@inheritDoc} */ public StatusStream getSampleStream() throws TwitterException { ensureAuthorizationEnabled(); try { return new StatusStreamImpl( getDispatcher(), http.get(conf.getStreamBaseURL() + "statuses/sample.json", auth), conf); } catch (IOException e) { throw new TwitterException(e); } }
public void testUserAsJSON() throws Exception { // single User HttpClientWrapper http = new HttpClientWrapper(); JSONObject json = getJSONObjectFromClassPath("/dao/user.json"); User user = new UserJSONImpl(json); Assert.assertTrue(user.isGeoEnabled()); Assert.assertFalse(user.isVerified()); Assert.assertEquals(id1.screenName, user.getName()); Assert.assertEquals(id1.screenName, user.getScreenName()); Assert.assertNotNull(user.getLocation()); Assert.assertNotNull(user.getDescription()); Assert.assertNotNull(user.getProfileImageURL()); Assert.assertNotNull(user.getURL()); Assert.assertFalse(user.isProtected()); Assert.assertTrue(0 <= user.getFavouritesCount()); Assert.assertTrue(0 <= user.getFollowersCount()); Assert.assertTrue(0 <= user.getFriendsCount()); Assert.assertNotNull(user.getCreatedAt()); Assert.assertNotNull(user.getTimeZone()); Assert.assertNotNull(user.getProfileBackgroundImageURL()); Assert.assertTrue(0 <= user.getStatusesCount()); Assert.assertNotNull(user.getProfileBackgroundColor()); Assert.assertNotNull(user.getProfileTextColor()); Assert.assertNotNull(user.getProfileLinkColor()); Assert.assertNotNull(user.getProfileSidebarBorderColor()); Assert.assertNotNull(user.getProfileSidebarFillColor()); Assert.assertNotNull(user.getProfileTextColor()); Assert.assertTrue(1 < user.getFollowersCount()); Assert.assertNotNull(user.getStatus().getCreatedAt()); Assert.assertNotNull(user.getStatus().getText()); Assert.assertNotNull(user.getStatus().getSource()); Assert.assertFalse(user.getStatus().isFavorited()); Assert.assertEquals(-1, user.getStatus().getInReplyToStatusId()); Assert.assertEquals(-1, user.getStatus().getInReplyToUserId()); Assert.assertFalse(user.getStatus().isFavorited()); Assert.assertNull(user.getStatus().getInReplyToScreenName()); assertDeserializedFormIsEqual(user); Assert.assertTrue(0 <= user.getListedCount()); List<User> users; // User list users = UserJSONImpl.createUserList( http.get("http://twitter4j.org/en/testcases/statuses/followers/T4J_hudson.json"), conf); Assert.assertTrue(users.size() > 0); assertDeserializedFormIsEqual(users); }
private JSONArray getJSONArrayFromGetURL(String url, Configuration conf) throws Exception { HttpClientWrapper http = new HttpClientWrapper(conf); return http.get(url, getOAuthOuthorization(conf)).asJSONArray(); }