1 package com.foxinmy.weixin4j.qy.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.qy.api.AgentApi;
12 import com.foxinmy.weixin4j.qy.model.AgentInfo;
13 import com.foxinmy.weixin4j.qy.model.AgentOverview;
14 import com.foxinmy.weixin4j.qy.model.AgentSetter;
15 import com.foxinmy.weixin4j.qy.type.ReportLocationType;
16
17
18
19
20
21
22
23
24
25
26 public class AgentTest extends TokenTest {
27 public AgentApi agentApi;
28
29 @Before
30 public void init() {
31 this.agentApi = new AgentApi(tokenManager);
32 }
33
34 @Test
35 public void get() throws WeixinException {
36 AgentInfo agent = agentApi.getAgent(0);
37 Assert.assertTrue(agent != null);
38 System.err.println(agent);
39 }
40
41 @Test
42 public void set() throws WeixinException {
43 AgentSetter agentSet = new AgentSetter(1);
44 agentSet.setDescription("test");
45 agentSet.setRedirectDomain("test.com");
46 agentSet.setReportLocationType(ReportLocationType.DIALOG);
47 ApiResult result = agentApi.setAgent(agentSet);
48 Assert.assertEquals("0",result.getReturnCode());
49 }
50
51 @Test
52 public void list() throws WeixinException {
53 List<AgentOverview> list = agentApi.listAgentOverview();
54 System.err.println(list);
55 }
56 }