public void testEmptyJSON() throws Exception { HttpClientImpl http = new HttpClientImpl(); // empty User list List<User> users = UserJSONImpl.createUserList( http.get("http://twitter4j.org/en/testcases/statuses/friends/T4J_hudson.json"), conf); Assert.assertTrue(users.size() == 0); assertDeserializedFormIsEqual(users); // empty Status list List<Status> statuses = StatusJSONImpl.createStatusList( http.get("http://twitter4j.org/en/testcases/statuses/friends/T4J_hudson.json"), conf); Assert.assertTrue(statuses.size() == 0); assertDeserializedFormIsEqual(statuses); // empty DirectMessages list List<DirectMessage> directMessages = DirectMessageJSONImpl.createDirectMessageList( http.get("http://twitter4j.org/en/testcases/statuses/friends/T4J_hudson.json"), conf); Assert.assertTrue(directMessages.size() == 0); assertDeserializedFormIsEqual(directMessages); // empty Trends list List<Trends> trends = TrendsJSONImpl.createTrendsList( http.get("http://twitter4j.org/en/testcases/trends/daily-empty.json"), conf.isJSONStoreEnabled()); Assert.assertTrue(trends.size() == 0); assertDeserializedFormIsEqual(trends); }
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); }
public void testStatusJSONImplSupportsMoreThan100RetweetedStatus() throws Exception { UserJSONImpl user = new UserJSONImpl(new JSONObject(getStringFromClassPath("/dao/24696018620.json"))); Assert.assertNotNull(user.getStatus()); Assert.assertNotNull(user.getStatus().getRetweetCount()); }