View Javadoc
1   package com.foxinmy.weixin4j.mp.test;
2   
3   import java.util.List;
4   
5   import org.junit.Assert;
6   import org.junit.Before;
7   import org.junit.Test;
8   
9   import com.foxinmy.weixin4j.exception.WeixinException;
10  import com.foxinmy.weixin4j.http.weixin.ApiResult;
11  import com.foxinmy.weixin4j.mp.api.GroupApi;
12  import com.foxinmy.weixin4j.mp.model.Group;
13  
14  /**
15   * 用户分组测试
16   * 
17   * @className GroupTest
18   * @author jinyu(foxinmy@gmail.com)
19   * @date 2014年4月10日
20   * @since JDK 1.6
21   */
22  public class GroupTest extends TokenTest {
23  	private GroupApi groupApi;
24  
25  	@Before
26  	public void init() {
27  		groupApi = new GroupApi(tokenManager);
28  	}
29  
30  	@Test
31  	public void create() throws WeixinException {
32  		Group group = groupApi.createGroup("my");
33  		Assert.assertNotNull(group);
34  	}
35  
36  	@Test
37  	public void get() throws WeixinException {
38  		List<Group> groups = groupApi.getGroups();
39  		System.err.println(groups);
40  		Assert.assertTrue(groups.size() > 0);
41  	}
42  
43  	@Test
44  	public void getid() throws WeixinException {
45  		int gid = groupApi.getGroupByOpenId("owGBft_vbBbOaQOmpEUE4xDLeRSU");
46  		Assert.assertTrue(gid >= 0);
47  	}
48  
49  	@Test
50  	public void modify() throws WeixinException {
51  		ApiResult result = groupApi.modifyGroup(100, "my1");
52  		Assert.assertEquals("0", result.getReturnCode());
53  	}
54  
55  	@Test
56  	public void move() throws WeixinException {
57  		ApiResult result = groupApi.moveGroup(100,
58  				"owGBft_vbBbOaQOmpEUE4xDLeRSU");
59  		Assert.assertEquals("0", result.getReturnCode());
60  	}
61  
62  	@Test
63  	public void batchMove() throws WeixinException {
64  		ApiResult result = groupApi.moveGroup(100,
65  				"owGBft_vbBbOaQOmpEUE4xDLeRSU");
66  		Assert.assertEquals("0", result.getReturnCode());
67  	}
68  
69  	@Test
70  	public void delete() throws WeixinException {
71  		ApiResult result = groupApi.deleteGroup(100);
72  		Assert.assertEquals("0", result.getReturnCode());
73  	}
74  }