Package com.renren.api.client.services

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

package com.renren.api.client.services;

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;
import com.renren.api.client.utils.JsonUtils;

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

    @Test
    public void testGetInfo() {
        String userIds = "226009681,252090984,252089313";
        String fields = "name,email_hash, sex,star,birthday,tinyurl,headurl,mainurl,hometown_location,hs_history,university_history,work_history,contact_info";
        JSONArray users = this.getRenrenApiClient().getUserService().getInfo(userIds, fields,new AccessToken(this.getAccessToken()));
        JSONObject u = JsonUtils.getIndexJSONObject(users, 0);
        String name = JsonUtils.getValue(u, "name", String.class);
        Assert.assertNotNull(name);
        Assert.assertEquals(3, users.size());
    }

    @Test
    public void testHasAppPermission() {
        String extPerm = "emial";
        boolean b = this.getRenrenApiClient().getUserService().hasAppPermission(extPerm, 0,new AccessToken(this.getAccessToken()));
        Assert.assertFalse(b);
    }

    @Test
    public void testGetLoggedInUser() {
        int userId = this.getRenrenApiClient().getUserService().getLoggedInUser(new AccessToken(this.getAccessToken()));
        Assert.assertTrue(userId > 0);
    }

    @Test
    public void testIsAppUser() {
        boolean b = this.getRenrenApiClient().getUserService().isAppUser(700034618);
        Assert.assertTrue(b);
    }

}
TOP

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

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.