Permalink
Browse files

Added activity api

  • Loading branch information...
1 parent 15edd7f commit def6f100e83b180c5416e4601481c5b61dbd4a76 @hemant24 hemant24 committed Oct 1, 2012
@@ -0,0 +1,15 @@
+
+package org.springframework.social.flickr.api;
+
+import java.util.ArrayList;
+
+public class Activity{
+ private ArrayList<Event> event;
+
+ public ArrayList<Event> getEvent(){
+ return this.event;
+ }
+ public void setEvent(ArrayList<Event> event){
+ this.event = event;
+ }
+}
@@ -16,7 +16,7 @@
* @param page the page
* @return the items
*/
- Items userComments(String apiKey, String perPage, String page);// perPage,page,
+ UserComment userComments(String apiKey, String perPage, String page);// perPage,page,
/**
* User photos.
@@ -27,6 +27,6 @@
* @param page the page
* @return the items
*/
- Items userPhotos(String apiKey, String timeframe, String perPage,
+ UserComment userPhotos(String apiKey, String timeframe, String perPage,
String page);// timeframe,perPage,page,
}
@@ -0,0 +1,64 @@
+
+package org.springframework.social.flickr.api;
+
+import java.util.List;
+
+public class Event{
+ private String _content;
+ private String commentid;
+ private String dateadded;
+ private Number iconfarm;
+ private String iconserver;
+ private String type;
+ private String user;
+ private String username;
+
+ public String get_content(){
+ return this._content;
+ }
+ public void set_content(String _content){
+ this._content = _content;
+ }
+ public String getCommentid(){
+ return this.commentid;
+ }
+ public void setCommentid(String commentid){
+ this.commentid = commentid;
+ }
+ public String getDateadded(){
+ return this.dateadded;
+ }
+ public void setDateadded(String dateadded){
+ this.dateadded = dateadded;
+ }
+ public Number getIconfarm(){
+ return this.iconfarm;
+ }
+ public void setIconfarm(Number iconfarm){
+ this.iconfarm = iconfarm;
+ }
+ public String getIconserver(){
+ return this.iconserver;
+ }
+ public void setIconserver(String iconserver){
+ this.iconserver = iconserver;
+ }
+ public String getType(){
+ return this.type;
+ }
+ public void setType(String type){
+ this.type = type;
+ }
+ public String getUser(){
+ return this.user;
+ }
+ public void setUser(String user){
+ this.user = user;
+ }
+ public String getUsername(){
+ return this.username;
+ }
+ public void setUsername(String username){
+ this.username = username;
+ }
+}
@@ -0,0 +1,120 @@
+
+package org.springframework.social.flickr.api;
+
+import java.util.LinkedHashMap;
+
+public class Item{
+ private Activity activity;
+ private Number comments;
+ private Number farm;
+ private Number faves;
+ private Number iconfarm;
+ private String iconserver;
+ private String id;
+ private String media;
+ private Number notes;
+ private String owner;
+ private String ownername;
+ private String secret;
+ private String server;
+ private String title;
+ private String type;
+ private Number views;
+
+ public Activity getActivity(){
+ return this.activity;
+ }
+ public void setActivity(Activity activity){
+ this.activity = activity;
+ }
+ public Number getComments(){
+ return this.comments;
+ }
+ public void setComments(Number comments){
+ this.comments = comments;
+ }
+ public Number getFarm(){
+ return this.farm;
+ }
+ public void setFarm(Number farm){
+ this.farm = farm;
+ }
+ public Number getFaves(){
+ return this.faves;
+ }
+ public void setFaves(Number faves){
+ this.faves = faves;
+ }
+ public Number getIconfarm(){
+ return this.iconfarm;
+ }
+ public void setIconfarm(Number iconfarm){
+ this.iconfarm = iconfarm;
+ }
+ public String getIconserver(){
+ return this.iconserver;
+ }
+ public void setIconserver(String iconserver){
+ this.iconserver = iconserver;
+ }
+ public String getId(){
+ return this.id;
+ }
+ public void setId(String id){
+ this.id = id;
+ }
+ public String getMedia(){
+ return this.media;
+ }
+ public void setMedia(String media){
+ this.media = media;
+ }
+ public Number getNotes(){
+ return this.notes;
+ }
+ public void setNotes(Number notes){
+ this.notes = notes;
+ }
+ public String getOwner(){
+ return this.owner;
+ }
+ public void setOwner(String owner){
+ this.owner = owner;
+ }
+ public String getOwnername(){
+ return this.ownername;
+ }
+ public void setOwnername(String ownername){
+ this.ownername = ownername;
+ }
+ public String getSecret(){
+ return this.secret;
+ }
+ public void setSecret(String secret){
+ this.secret = secret;
+ }
+ public String getServer(){
+ return this.server;
+ }
+ public void setServer(String server){
+ this.server = server;
+ }
+ public String getTitle(){
+ return this.title;
+ }
+ public void setTitle(LinkedHashMap<String,String> title){
+ this.title = title.get(FlickrConstant.JSONCONTENT);
+ }
+ public String getType(){
+ return this.type;
+ }
+ public void setType(String type){
+ this.type = type;
+ }
+ public Number getViews(){
+ return this.views;
+ }
+ public void setViews(Number views){
+ this.views = views;
+ }
+}
@@ -1,5 +0,0 @@
-package org.springframework.social.flickr.api;
-
-public class Items {
-
-}
@@ -0,0 +1,43 @@
+
+package org.springframework.social.flickr.api;
+
+import java.util.ArrayList;
+
+public class UserComment{
+ private ArrayList<Item> item;
+ private Number page;
+ private Number pages;
+ private Number perpage;
+ private Number total;
+
+ public ArrayList<Item> getItem(){
+ return this.item;
+ }
+ public void setItem(ArrayList<Item> items){
+ this.item = items;
+ }
+ public Number getPage(){
+ return this.page;
+ }
+ public void setPage(Number page){
+ this.page = page;
+ }
+ public Number getPages(){
+ return this.pages;
+ }
+ public void setPages(Number pages){
+ this.pages = pages;
+ }
+ public Number getPerpage(){
+ return this.perpage;
+ }
+ public void setPerpage(Number perpage){
+ this.perpage = perpage;
+ }
+ public Number getTotal(){
+ return this.total;
+ }
+ public void setTotal(Number total){
+ this.total = total;
+ }
+}
@@ -1,7 +1,7 @@
package org.springframework.social.flickr.api.impl;
import org.springframework.social.flickr.api.ActivityOperations;
-import org.springframework.social.flickr.api.Items;
+import org.springframework.social.flickr.api.UserComment;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
@@ -21,7 +21,7 @@ public ActivityTemplate(RestTemplate restTemplate,
}
@Override
- public Items userComments(String apiKey, String perPage, String page) {
+ public UserComment userComments(String apiKey, String perPage, String page) {
requireAuthorization();
MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
if (apiKey != null)
@@ -32,11 +32,11 @@ public Items userComments(String apiKey, String perPage, String page) {
parameters.set("page", page);
return restTemplate.getForObject(
buildUri("flickr.activity.userComments", parameters),
- Items.class);
+ UserComment.class);
}
@Override
- public Items userPhotos(String apiKey, String timeframe, String perPage,
+ public UserComment userPhotos(String apiKey, String timeframe, String perPage,
String page) {
requireAuthorization();
MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
@@ -51,6 +51,6 @@ public Items userPhotos(String apiKey, String timeframe, String perPage,
return restTemplate
.getForObject(
buildUri("flickr.activity.userPhotos", parameters),
- Items.class);
+ UserComment.class);
}
}
@@ -21,6 +21,7 @@
import org.codehaus.jackson.map.DeserializationConfig;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;
+import org.springframework.social.flickr.api.ActivityOperations;
import org.springframework.social.flickr.api.FavoritesOperations;
import org.springframework.social.flickr.api.Flickr;
import org.springframework.social.flickr.api.GalleriesOperations;
@@ -45,6 +46,7 @@
private PhotosetOperations photosetOperations;
private GalleriesOperations galleriesOperations;
private FavoritesOperations favoritesOperations;
+ private ActivityOperations activityOperations;
@@ -67,6 +69,7 @@ private void initSubApis() {
this.photosetOperations = new PhotosetTemplate(getRestTemplate(), isAuthorized());
this.galleriesOperations = new GalleriesTemplate(getRestTemplate(), isAuthorized());
this.favoritesOperations = new FavoritesTemplate(getRestTemplate(), isAuthorized());
+ this.activityOperations = new ActivityTemplate(getRestTemplate(), isAuthorized());
}
@@ -118,6 +121,10 @@ public GalleriesOperations galleriesOperations() {
public FavoritesOperations favoritesOperations() {
return favoritesOperations;
}
+
+ public ActivityOperations activityOperations() {
+ return activityOperations;
+ }
@@ -4,7 +4,10 @@
import static org.springframework.social.test.client.RequestMatchers.method;
import static org.springframework.social.test.client.RequestMatchers.requestTo;
import static org.springframework.social.test.client.ResponseCreators.withResponse;
+import junit.framework.Assert;
+
import org.junit.Test;
+import org.springframework.social.flickr.api.UserComment;
/**
* @author HemantS
@@ -14,19 +17,32 @@
@Test
public void userCommentsTest() {
mockServer
- .expect(requestTo("http://api.flickr.com/services/rest/?method=flickr.activity.userComments&format=json&nojsoncallback=1"))
+ .expect(requestTo("http://api.flickr.com/services/rest/?api_key=23&method=flickr.activity.userComments&format=json&nojsoncallback=1"))
.andExpect(method(GET))
.andRespond(
- withResponse(jsonResource("testuser"), responseHeaders));
+ withResponse(jsonResource("activity"), responseHeaders));
+ UserComment comments = flickr.activityOperations().userComments("23", null, null);
+ assertUserComment(comments);
}
-
+
@Test
public void userPhotosTest() {
mockServer
- .expect(requestTo("http://api.flickr.com/services/rest/?method=flickr.activity.userPhotos&format=json&nojsoncallback=1"))
+ .expect(requestTo("http://api.flickr.com/services/rest/?api_key=23&method=flickr.activity.userPhotos&format=json&nojsoncallback=1"))
.andExpect(method(GET))
.andRespond(
- withResponse(jsonResource("testuser"), responseHeaders));
+ withResponse(jsonResource("activity2"), responseHeaders));
+ UserComment comments = flickr.activityOperations().userPhotos("23", null, null,null);
+ assertUserPhotos(comments);
+ }
+
+ private void assertUserComment(UserComment comments) {
+ Assert.assertEquals("cute", comments.getItem().get(0).getActivity().getEvent().get(0).get_content());
+ }
+ private void assertUserPhotos(UserComment comments) {
+ Assert.assertEquals("good one", comments.getItem().get(0).getActivity().getEvent().get(0).get_content());
}
+
+
}
Oops, something went wrong.

0 comments on commit def6f10

Please sign in to comment.