mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
发送客服消息接口转移到客服专用service中,使用时需要加入getKefuService()
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
package me.chanjar.weixin.mp.api;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/***
|
||||
* 测试发送客服消息
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
@Test(groups="customMessageAPI")
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxMpCustomMessageAPITest {
|
||||
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
|
||||
public void testSendCustomMessage() throws WxErrorException {
|
||||
ApiTestModule.WxXmlMpInMemoryConfigStorage configStorage = (ApiTestModule.WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage();
|
||||
WxMpCustomMessage message = new WxMpCustomMessage();
|
||||
message.setMsgType(WxConsts.CUSTOM_MSG_TEXT);
|
||||
message.setToUser(configStorage.getOpenId());
|
||||
message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
|
||||
|
||||
this.wxService.customMessageSend(message);
|
||||
}
|
||||
|
||||
public void testSendCustomMessageWithKfAccount() throws WxErrorException {
|
||||
ApiTestModule.WxXmlMpInMemoryConfigStorage configStorage = (ApiTestModule.WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage();
|
||||
WxMpCustomMessage message = new WxMpCustomMessage();
|
||||
message.setMsgType(WxConsts.CUSTOM_MSG_TEXT);
|
||||
message.setToUser(configStorage.getOpenId());
|
||||
message.setKfAccount(configStorage.getKfAccount());
|
||||
message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
|
||||
|
||||
this.wxService.customMessageSend(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,9 +11,11 @@ import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
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.bean.WxMpCustomMessage;
|
||||
import me.chanjar.weixin.mp.bean.kefu.request.WxMpKfAccountRequest;
|
||||
import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfInfo;
|
||||
import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfList;
|
||||
@@ -35,6 +37,31 @@ public class WxMpKefuServiceImplTest {
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
|
||||
public void testSendCustomMessage() throws WxErrorException {
|
||||
ApiTestModule.WxXmlMpInMemoryConfigStorage configStorage = (ApiTestModule.WxXmlMpInMemoryConfigStorage) this.wxService
|
||||
.getWxMpConfigStorage();
|
||||
WxMpCustomMessage message = new WxMpCustomMessage();
|
||||
message.setMsgType(WxConsts.CUSTOM_MSG_TEXT);
|
||||
message.setToUser(configStorage.getOpenId());
|
||||
message.setContent(
|
||||
"欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
|
||||
|
||||
this.wxService.getKefuService().customMessageSend(message);
|
||||
}
|
||||
|
||||
public void testSendCustomMessageWithKfAccount() throws WxErrorException {
|
||||
ApiTestModule.WxXmlMpInMemoryConfigStorage configStorage = (ApiTestModule.WxXmlMpInMemoryConfigStorage) this.wxService
|
||||
.getWxMpConfigStorage();
|
||||
WxMpCustomMessage message = new WxMpCustomMessage();
|
||||
message.setMsgType(WxConsts.CUSTOM_MSG_TEXT);
|
||||
message.setToUser(configStorage.getOpenId());
|
||||
message.setKfAccount(configStorage.getKfAccount());
|
||||
message.setContent(
|
||||
"欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
|
||||
|
||||
this.wxService.getKefuService().customMessageSend(message);
|
||||
}
|
||||
|
||||
public void testKfList() throws WxErrorException {
|
||||
WxMpKfList kfList = this.wxService.getKefuService().kfList();
|
||||
Assert.assertNotNull(kfList);
|
||||
@@ -123,7 +150,7 @@ public class WxMpKefuServiceImplTest {
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getKfAccountAndOpenid")
|
||||
public void testKfSessionGet(String kfAccount,
|
||||
public void testKfSessionGet(@SuppressWarnings("unused") String kfAccount,
|
||||
String openid) throws WxErrorException {
|
||||
WxMpKfSessionGetResult result = this.wxService.getKefuService()
|
||||
.kfSessionGet(openid);
|
||||
|
||||
Reference in New Issue
Block a user