mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-23 13:06:54 +08:00
优化客服管理接口的单元测试
This commit is contained in:
parent
f9022814fd
commit
29cfa7762e
@ -825,6 +825,10 @@ public class WxMpServiceImpl implements WxMpService {
|
||||
this.httpClient = apacheHttpClientBuilder.build();
|
||||
}
|
||||
|
||||
public WxMpConfigStorage getWxMpConfigStorage() {
|
||||
return this.wxMpConfigStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRetrySleepMillis(int retrySleepMillis) {
|
||||
this.retrySleepMillis = retrySleepMillis;
|
||||
|
@ -11,7 +11,6 @@ import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
|
||||
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpKefuServiceImpl;
|
||||
|
||||
public class ApiTestModule implements Module {
|
||||
|
||||
@ -23,7 +22,7 @@ public class ApiTestModule implements Module {
|
||||
WxXmlMpInMemoryConfigStorage.class, is1);
|
||||
WxMpServiceImpl wxService = new WxMpServiceImpl();
|
||||
wxService.setWxMpConfigStorage(config);
|
||||
|
||||
|
||||
binder.bind(WxMpServiceImpl.class).toInstance(wxService);
|
||||
binder.bind(WxMpConfigStorage.class).toInstance(config);
|
||||
} catch (IOException e) {
|
||||
@ -42,7 +41,8 @@ public class ApiTestModule implements Module {
|
||||
public static class WxXmlMpInMemoryConfigStorage
|
||||
extends WxMpInMemoryConfigStorage {
|
||||
|
||||
protected String openId;
|
||||
private String openId;
|
||||
private String kfAccount;
|
||||
|
||||
public String getOpenId() {
|
||||
return this.openId;
|
||||
@ -57,6 +57,14 @@ public class ApiTestModule implements Module {
|
||||
return ToStringBuilder.reflectionToString(this);
|
||||
}
|
||||
|
||||
public String getKfAccount() {
|
||||
return this.kfAccount;
|
||||
}
|
||||
|
||||
public void setKfAccount(String kfAccount) {
|
||||
this.kfAccount = kfAccount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.chanjar.weixin.mp.api.impl;
|
||||
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -7,6 +8,8 @@ import com.google.inject.Inject;
|
||||
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.ApiTestModule;
|
||||
import me.chanjar.weixin.mp.api.ApiTestModule.WxXmlMpInMemoryConfigStorage;
|
||||
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
|
||||
import me.chanjar.weixin.mp.api.WxMpServiceImpl;
|
||||
import me.chanjar.weixin.mp.bean.customerservice.request.WxMpKfAccountRequest;
|
||||
import me.chanjar.weixin.mp.bean.customerservice.result.WxMpKfList;
|
||||
@ -24,8 +27,7 @@ import org.testng.Assert;
|
||||
@Test
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxMpKefuImplTest {
|
||||
private static final String KF_ACCOUNT = "kf2009@youxintest";
|
||||
|
||||
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
|
||||
@ -36,34 +38,48 @@ public class WxMpKefuImplTest {
|
||||
}
|
||||
|
||||
public void testKfOnlineList() throws WxErrorException {
|
||||
WxMpKfOnlineList kfOnlineList = this.wxService.getKefuService().kfOnlineList();
|
||||
WxMpKfOnlineList kfOnlineList = this.wxService.getKefuService()
|
||||
.kfOnlineList();
|
||||
Assert.assertNotNull(kfOnlineList);
|
||||
System.err.println(kfOnlineList);
|
||||
}
|
||||
|
||||
public void testKfAccountAdd() throws WxErrorException {
|
||||
@DataProvider
|
||||
public Object[][] getKfAccount() {
|
||||
WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage) this.wxService
|
||||
.getWxMpConfigStorage();
|
||||
return new Object[][] { { configStorage.getKfAccount() } };
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getKfAccount")
|
||||
public void testKfAccountAdd(String kfAccount) throws WxErrorException {
|
||||
WxMpKfAccountRequest request = WxMpKfAccountRequest.builder()
|
||||
.kfAccount(KF_ACCOUNT).nickName("我晕").rawPassword("123").build();
|
||||
.kfAccount(kfAccount).nickName("我晕").rawPassword("123").build();
|
||||
Assert.assertTrue(this.wxService.getKefuService().kfAccountAdd(request));
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = { "testKfAccountAdd" })
|
||||
public void testKfAccountUpdate() throws WxErrorException {
|
||||
|
||||
@Test(dependsOnMethods = {
|
||||
"testKfAccountAdd" }, dataProvider = "getKfAccount")
|
||||
public void testKfAccountUpdate(String kfAccount) throws WxErrorException {
|
||||
WxMpKfAccountRequest request = WxMpKfAccountRequest.builder()
|
||||
.kfAccount(KF_ACCOUNT).nickName("我晕").rawPassword("123").build();
|
||||
.kfAccount(kfAccount).nickName("我晕").rawPassword("123").build();
|
||||
Assert.assertTrue(this.wxService.getKefuService().kfAccountUpdate(request));
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = { "testKfAccountUpdate" })
|
||||
public void testKfAccountUploadHeadImg() throws WxErrorException {
|
||||
|
||||
@Test(dependsOnMethods = {
|
||||
"testKfAccountUpdate" }, dataProvider = "getKfAccount")
|
||||
public void testKfAccountUploadHeadImg(String kfAccount)
|
||||
throws WxErrorException {
|
||||
File imgFile = new File("src\\test\\resources\\mm.jpeg");
|
||||
boolean result = this.wxService.getKefuService().kfAccountUploadHeadImg(KF_ACCOUNT, imgFile);
|
||||
boolean result = this.wxService.getKefuService()
|
||||
.kfAccountUploadHeadImg(kfAccount, imgFile);
|
||||
Assert.assertTrue(result);
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = { "testKfAccountUploadHeadImg" })
|
||||
public void testKfAccountDel() throws WxErrorException {
|
||||
boolean result = this.wxService.getKefuService().kfAccountDel(KF_ACCOUNT);
|
||||
|
||||
@Test(dependsOnMethods = {
|
||||
"testKfAccountUploadHeadImg" }, dataProvider = "getKfAccount")
|
||||
public void testKfAccountDel(String kfAccount) throws WxErrorException {
|
||||
boolean result = this.wxService.getKefuService().kfAccountDel(kfAccount);
|
||||
Assert.assertTrue(result);
|
||||
}
|
||||
|
||||
|
@ -7,4 +7,5 @@
|
||||
<expiresTime>可以不填写</expiresTime>
|
||||
<openId>某个加你公众号的用户的openId</openId>
|
||||
<oauth2redirectUri>网页授权获取用户信息回调地址</oauth2redirectUri>
|
||||
<kfAccount>完整客服账号,格式为:账号前缀@公众号微信号</kfAccount>
|
||||
</xml>
|
||||
|
Loading…
Reference in New Issue
Block a user