Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #16 from habuma/master

SOCIALTW-29: Added retweeted property to Tweet object.
  • Loading branch information...
commit 7b0500e444cb9085a12c2034dbcef50fc0336c5c 2 parents ae83851 + 71cb7d9
Craig Walls habuma authored
9 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/Tweet.java
@@ -33,6 +33,7 @@
33 33 private String languageCode;
34 34 private String source;
35 35 private Integer retweetCount;
  36 + private boolean retweeted;
36 37
37 38 public Tweet(long id, String text, Date createdAt, String fromUser, String profileImageUrl, Long toUserId, long fromUserId, String languageCode, String source) {
38 39 this.id = id;
@@ -138,4 +139,12 @@ public void setRetweetCount(Integer retweetCount) {
138 139 public Integer getRetweetCount() {
139 140 return retweetCount;
140 141 }
  142 +
  143 + public void setRetweeted(boolean retweeted) {
  144 + this.retweeted = retweeted;
  145 + }
  146 +
  147 + public boolean isRetweeted() {
  148 + return retweeted;
  149 + }
141 150 }
3  spring-social-twitter/src/main/java/org/springframework/social/twitter/api/impl/TweetDeserializer.java
@@ -69,6 +69,9 @@ public Tweet deserialize(JsonParser jp, DeserializationContext ctxt) throws IOEx
69 69 JsonNode retweetCountNode = tree.get("retweet_count");
70 70 Integer retweetCount = retweetCountNode != null && !retweetCountNode.isNull() ? retweetCountNode.getIntValue() : null;
71 71 tweet.setRetweetCount(retweetCount);
  72 + JsonNode retweetedNode = tree.get("retweeted");
  73 + boolean retweeted = retweetedNode != null && !retweetedNode.isNull() ? retweetedNode.getBooleanValue() : false;
  74 + tweet.setRetweeted(retweeted);
72 75 jp.skipChildren();
73 76 return tweet;
74 77 }
3  spring-social-twitter/src/test/java/org/springframework/social/twitter/api/impl/AbstractTwitterApiTest.java
@@ -64,9 +64,10 @@ protected void assertSingleTweet(Tweet tweet, boolean isSearchResult) {
64 64 assertEquals("http://a3.twimg.com/profile_images/1205746571/me2_300.jpg", tweet.getProfileImageUrl());
65 65 assertEquals("Spring Social Showcase", tweet.getSource());
66 66 assertEquals(1279042701000L, tweet.getCreatedAt().getTime());
67   - assertEquals(Long.valueOf(123123123123L), tweet.getInReplyToStatusId());
  67 + assertEquals(Long.valueOf(123123123123L), tweet.getInReplyToStatusId());
68 68 if (!isSearchResult) {
69 69 assertEquals(12, tweet.getRetweetCount().intValue());
  70 + assertTrue(tweet.isRetweeted());
70 71 } else {
71 72 assertNull(tweet.getRetweetCount());
72 73 }
3  spring-social-twitter/src/test/java/org/springframework/social/twitter/api/impl/favorite.json
@@ -11,7 +11,8 @@
11 11 "source" : "Spring Social Showcase",
12 12 "in_reply_to_user_id" : "332211",
13 13 "retweet_count" : 12,
14   - "created_at" : "Tue Jul 13 17:38:21 +0000 2010"
  14 + "created_at" : "Tue Jul 13 17:38:21 +0000 2010",
  15 + "retweeted" : true
15 16 },
16 17 {
17 18 "id" : "54321",
3  spring-social-twitter/src/test/java/org/springframework/social/twitter/api/impl/status.json
@@ -10,5 +10,6 @@
10 10 "source" : "Spring Social Showcase",
11 11 "in_reply_to_user_id" : "332211",
12 12 "retweet_count" : 12,
13   - "created_at" : "Tue Jul 13 17:38:21 +0000 2010"
  13 + "created_at" : "Tue Jul 13 17:38:21 +0000 2010",
  14 + "retweeted" : true
14 15 }
3  spring-social-twitter/src/test/java/org/springframework/social/twitter/api/impl/timeline.json
@@ -11,7 +11,8 @@
11 11 "in_reply_to_user_id" : "332211",
12 12 "retweet_count" : 12,
13 13 "in_reply_to_status_id" : 123123123123,
14   - "created_at" : "Tue Jul 13 17:38:21 +0000 2010"
  14 + "created_at" : "Tue Jul 13 17:38:21 +0000 2010",
  15 + "retweeted" : true
15 16 },
16 17 {
17 18 "id" : 54321,

0 comments on commit 7b0500e

Please sign in to comment.
Something went wrong with that request. Please try again.