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.TagApi;
12 import com.foxinmy.weixin4j.mp.model.Tag;
13 import com.foxinmy.weixin4j.mp.model.User;
14
15
16
17
18
19
20
21
22
23
24 public class TagTest extends TokenTest {
25 private TagApi tagApi;
26
27 @Before
28 public void init() {
29 tagApi = new TagApi(tokenManager);
30 }
31
32 @Test
33 public void create() throws WeixinException {
34 Tag tag = tagApi.createTag("测试三");
35 Assert.assertNotNull(tag);
36 System.out.println(tag);
37 }
38
39 @Test
40 public void list() throws WeixinException {
41 List<Tag> tags = tagApi.listTags();
42 Assert.assertFalse(tags.isEmpty());
43 }
44
45 @Test
46 public void update() throws WeixinException {
47 ApiResult result = tagApi.updateTag(new Tag(120, "测试12"));
48 System.err.println(result);
49 }
50
51 @Test
52 public void remove() throws WeixinException {
53 ApiResult result = tagApi.deleteTag(134);
54 System.err.print(result);
55 }
56
57 @Test
58 public void batchtagging() throws WeixinException {
59 ApiResult result = tagApi.taggingUsers(120,
60 "owGBft-GyGJuKXBzpkzrfl-RG8TI", "owGBfty5TYNwh-3iUTGtxAHcD310",
61 "owGBftzXEfBml_bYvbrYxE5lE5U8");
62 System.err.println(result);
63 }
64
65 @Test
66 public void batchuntagging() throws WeixinException {
67 ApiResult result = tagApi.taggingUsers(120,
68 "owGBftwS5Yr6xKH_Hb9mGv1nbd3o");
69 System.err.println(result);
70 }
71
72 @Test
73 public void getidlist() throws WeixinException {
74 Integer[] tagIds = tagApi.getUserTags("owGBft-GyGJuKXBzpkzrfl-RG8TI");
75 Assert.assertNotNull(tagIds);
76 System.out.println(tagIds[0]);
77 }
78
79 @Test
80 public void getAllTagFollowing() throws WeixinException {
81 List<User> users = tagApi.getAllTagFollowing(120);
82 Assert.assertNotNull(users);
83 System.out.println(users);
84 }
85
86 @Test
87 public void getAllTagFollowingOpenIds() throws WeixinException {
88 List<String> tags = tagApi.getAllTagFollowingOpenIds(120);
89 Assert.assertNotNull(tags);
90 System.out.println(tags);
91 }
92 }