规范化并优化代码
This commit is contained in:
@@ -6,7 +6,6 @@ import me.chanjar.weixin.cp.api.ApiTestModule;
|
||||
import me.chanjar.weixin.cp.api.WxCpAgentService;
|
||||
import me.chanjar.weixin.cp.api.WxCpService;
|
||||
import me.chanjar.weixin.cp.bean.WxCpAgent;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@@ -71,7 +70,7 @@ public class WxCpAgentServiceImplTest {
|
||||
@Test
|
||||
public void testGet() throws Exception {
|
||||
String returnJson = "{\"errcode\": 0,\"errmsg\": \"ok\",\"agentid\": 9,\"name\": \"测试应用\",\"square_logo_url\": \"http://wx.qlogo.cn/mmhead/alksjf;lasdjf;lasjfuodiuj3rj2o34j/0\",\"description\": \"这是一个企业号应用\",\"allow_userinfos\": {\"user\": [{\"userid\": \"0009854\"}, {\"userid\": \"1723\"}, {\"userid\": \"5625\"}]},\"allow_partys\": {\"partyid\": [42762742]},\"allow_tags\": {\"tagid\": [23, 22, 35, 19, 32, 125, 133, 46, 150, 38, 183, 9, 7]},\"close\": 0,\"redirect_domain\": \"weixin.com.cn\",\"report_location_flag\": 0,\"isreportenter\": 0,\"home_url\": \"\"}";
|
||||
when(wxService.get("https://qyapi.weixin.qq.com/cgi-bin/agent/get?agentid=9", null)).thenReturn(returnJson);
|
||||
when(wxService.get(String.format(WxCpAgentService.GET_AGENT, 9), null)).thenReturn(returnJson);
|
||||
when(wxService.getAgentService()).thenReturn(new WxCpAgentServiceImpl(wxService));
|
||||
|
||||
WxCpAgentService wxAgentService = this.wxService.getAgentService();
|
||||
|
||||
@@ -24,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @date 2019-04-20 13:46
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxCpOAServiceImplTest {
|
||||
public class WxCpOaServiceImplTest {
|
||||
@Inject
|
||||
protected WxCpService wxService;
|
||||
|
||||
@@ -22,10 +22,10 @@ import static org.testng.Assert.assertNotEquals;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* Created by Binary Wang on 2017-6-25.
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxCpTagServiceImplTest {
|
||||
@@ -35,7 +35,7 @@ public class WxCpTagServiceImplTest {
|
||||
@Inject
|
||||
protected ApiTestModule.WxXmlCpInMemoryConfigStorage configStorage;
|
||||
|
||||
protected String tagId;
|
||||
private String tagId;
|
||||
|
||||
@Test
|
||||
public void testCreate() throws Exception {
|
||||
@@ -83,7 +83,7 @@ public class WxCpTagServiceImplTest {
|
||||
public void testGet() throws WxErrorException {
|
||||
String apiResultJson = "{\"errcode\": 0,\"errmsg\": \"ok\",\"userlist\": [{\"userid\": \"0124035\",\"name\": \"王五\"},{\"userid\": \"0114035\",\"name\": \"梦雪\"}],\"partylist\": [9576,9567,9566],\"tagname\": \"测试标签-001\"}";
|
||||
WxCpService wxService = mock(WxCpService.class);
|
||||
when(wxService.get("https://qyapi.weixin.qq.com/cgi-bin/tag/get?tagId=150", null)).thenReturn(apiResultJson);
|
||||
when(wxService.get(String.format(WxCpTagService.TAG_GET, 150), null)).thenReturn(apiResultJson);
|
||||
when(wxService.getTagService()).thenReturn(new WxCpTagServiceImpl(wxService));
|
||||
|
||||
WxCpTagService wxCpTagService = wxService.getTagService();
|
||||
@@ -96,7 +96,6 @@ public class WxCpTagServiceImplTest {
|
||||
assertEquals(3, wxCpTagGetResult.getPartylist().size());
|
||||
assertEquals("测试标签-001", wxCpTagGetResult.getTagname());
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user