Package com.renren.api.client.services

Source Code of com.renren.api.client.services.FriendsServiceTest

package com.renren.api.client.services;

import java.util.List;

import junit.framework.Assert;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.junit.Test;

import com.renren.api.client.AbstractServiceTest;
import com.renren.api.client.param.impl.AccessToken;

/**
* @author 李勇(yong.li@opi-corp.com) 2011-2-17
*/
public class FriendsServiceTest extends AbstractServiceTest {

    @Test
    public void testAreFriends() {
        String users1 = "226009681,252090984";
        String users2 = "252089313,80178";
        JSONArray rets = this.getRenrenApiClient().getFriendsService().areFriends(users1, users2,new AccessToken(this.getAccessToken()));
        int i = Integer.parseInt(((JSONObject) rets.get(0)).get("are_friends").toString());
        Assert.assertEquals(1, i);
        i = Integer.parseInt(((JSONObject) rets.get(1)).get("are_friends").toString());
        Assert.assertEquals(0, i);
    }

    @Test
    public void testGetFriendIds() {
        int page = 1;
        int count = 10;
        List<Integer> friendIds = this.getRenrenApiClient().getFriendsService().getFriendIds(page,
                count,new AccessToken(this.getAccessToken()));
        Assert.assertTrue(friendIds.size() > 0);
    }

    @Test
    public void testGetFriends() {
        int page = 1;
        int count = 10;
        JSONArray friends = this.getRenrenApiClient().getFriendsService().getFriends(page, count,new AccessToken(this.getAccessToken()));
        Assert.assertTrue(friends.size() > 0);
    }

    @Test
    public void testGetAppFriends() {
        String fields = "name,tinyurl";
        JSONArray friends = this.getRenrenApiClient().getFriendsService().getAppUsers(fields,new AccessToken(this.getAccessToken()));
        Assert.assertTrue(friends.size() > 0);
    }
   
   
    @Test
    public void testGetSameFriends(){
        long uid1=328150390;
        long uid2=258707479;
        JSONObject json=this.getRenrenApiClient().getFriendsService().getSameFriends(uid1, uid2,new AccessToken(this.getAccessToken()));
        JSONArray friends=(JSONArray) json.get("friends");
        System.out.println(friends.size());
        Assert.assertTrue(friends.size()>0);
    }
   
    @Test
    public void testSearchFriends(){
        String name="宝";
        long uid=0;
        String email="";
        int page=1;
        int count=10;
        JSONObject json=this.getRenrenApiClient().getFriendsService().searchFriends(name, uid, email, page, count, "",new AccessToken(this.getAccessToken()));
        long total=(Long)json.get("total");
        System.out.println(total);
        Assert.assertTrue(total>-1);
    }
}
TOP

Related Classes of com.renren.api.client.services.FriendsServiceTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.