|
2 | 2 |
|
3 | 3 | import com.google.common.base.Splitter; |
4 | 4 | import com.google.inject.Inject; |
| 5 | +import me.chanjar.weixin.common.exception.WxErrorException; |
5 | 6 | import me.chanjar.weixin.cp.api.ApiTestModule; |
6 | 7 | import me.chanjar.weixin.cp.api.WxCpService; |
| 8 | +import me.chanjar.weixin.cp.api.WxCpTagService; |
7 | 9 | import me.chanjar.weixin.cp.bean.WxCpTag; |
8 | 10 | import me.chanjar.weixin.cp.bean.WxCpTagAddOrRemoveUsersResult; |
| 11 | +import me.chanjar.weixin.cp.bean.WxCpTagGetResult; |
9 | 12 | import me.chanjar.weixin.cp.bean.WxCpUser; |
10 | 13 | import org.testng.annotations.*; |
11 | 14 |
|
12 | 15 | import java.util.List; |
13 | 16 |
|
| 17 | +import static org.mockito.Mockito.mock; |
| 18 | +import static org.mockito.Mockito.when; |
14 | 19 | import static org.testng.Assert.*; |
15 | 20 |
|
16 | 21 | /** |
@@ -72,4 +77,24 @@ public void testDelete() throws Exception { |
72 | 77 | this.wxService.getTagService().delete(this.tagId); |
73 | 78 | } |
74 | 79 |
|
| 80 | + @Test |
| 81 | + public void testGet() throws WxErrorException { |
| 82 | + String apiResultJson = "{\"errcode\": 0,\"errmsg\": \"ok\",\"userlist\": [{\"userid\": \"0124035\",\"name\": \"王五\"},{\"userid\": \"0114035\",\"name\": \"梦雪\"}],\"partylist\": [9576,9567,9566],\"tagname\": \"测试标签-001\"}"; |
| 83 | + WxCpService wxService = mock(WxCpService.class); |
| 84 | + when(wxService.get("https://qyapi.weixin.qq.com/cgi-bin/tag/get?tagId=150", null)).thenReturn(apiResultJson); |
| 85 | + when(wxService.getTagService()).thenReturn(new WxCpTagServiceImpl(wxService)); |
| 86 | + |
| 87 | + WxCpTagService wxCpTagService = wxService.getTagService(); |
| 88 | + |
| 89 | + WxCpTagGetResult wxCpTagGetResult = wxCpTagService.get(String.valueOf(150)); |
| 90 | + |
| 91 | + assertEquals(0, wxCpTagGetResult.getErrcode().intValue()); |
| 92 | + |
| 93 | + assertEquals(2, wxCpTagGetResult.getUserlist().size()); |
| 94 | + assertEquals(3, wxCpTagGetResult.getPartylist().size()); |
| 95 | + assertEquals("测试标签-001", wxCpTagGetResult.getTagname()); |
| 96 | + |
| 97 | + |
| 98 | + } |
| 99 | + |
75 | 100 | } |
0 commit comments