package com.renren.api.client.services;
import java.util.Date;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import com.renren.api.client.AbstractServiceTest;
import com.renren.api.client.param.impl.AccessToken;
public class StatusServiceTest extends AbstractServiceTest{
@Test
public void testGetStatuses(){
int uid=0;
int page=1;
int count=1;
JSONArray statuses=this.getRenrenApiClient().getStatusService().getStatuses(uid, page, count,new AccessToken(this.getAccessToken()));
Assert.assertEquals(1,statuses.size());
}
@Test
public void testGetStatus(){
long userid=432801017L;
long statusId=2844895649L;
JSONObject status=this.getRenrenApiClient().getStatusService().getStatus(userid, statusId,new AccessToken(this.getAccessToken()));
long uid=(Long) status.get("uid");
System.out.println(status.get("status_id"));
Assert.assertEquals(uid,userid);
}
@Test
public void testSetStatus(){
String status="我在测试";
int res=this.getRenrenApiClient().getStatusService().setStatus(status,new AccessToken(this.getAccessToken()));
Assert.assertEquals(1, res);
}
@Test
public void testGetComments(){
long statusId=2844895649L;
long ownerId=432801017L;
int page=1;
int count=1;
int order=0;
JSONArray comments=this.getRenrenApiClient().getStatusService().getComments(statusId, ownerId, page, count, order,new AccessToken(this.getAccessToken()));
Assert.assertEquals(1, comments.size());
}
@Test
public void testAddComment(){
long statusId=2844895649L;
long ownerId=432801017L;
String content="测试回复状态~~";
long rid=0;
int res=this.getRenrenApiClient().getStatusService().addComment(statusId, ownerId, content, rid,new AccessToken(this.getAccessToken()));
Assert.assertEquals(1, res);
}
@Test
public void testGetEmoticons(){
JSONArray json=this.getRenrenApiClient().getStatusService().getEmoticons(new AccessToken(this.getAccessToken()));
System.out.println(json.size());
Assert.assertTrue(json.size()>-1);
}
@Test
public void testForwardStatus(){
long forward_id=2844895649L;
long forward_owner=432801017L;
String status="转发的测试HaHa!!"+new Date();
JSONObject json=this.getRenrenApiClient().getStatusService().forwardStatus(forward_id, forward_owner, status,new AccessToken(this.getAccessToken()));
System.out.println(json);
long id=Long.parseLong((String)json.get("id"));
Assert.assertTrue(id>0);
}
}