#253 修改企业号发送消息的messageSend方法,增加返回值,方便客户端进行自行处理
This commit is contained in:
@@ -5,38 +5,58 @@ import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
|
||||
import me.chanjar.weixin.cp.bean.WxCpMessage;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
import me.chanjar.weixin.cp.bean.WxCpMessageSendResult;
|
||||
import org.testng.annotations.*;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
/***
|
||||
* 测试发送消息
|
||||
* @author Daniel Qian
|
||||
*
|
||||
*/
|
||||
@Test(groups = "customMessageAPI", dependsOnGroups = "baseAPI")
|
||||
@Test(groups = "customMessageAPI")
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxCpMessageAPITest {
|
||||
|
||||
@Inject
|
||||
protected WxCpServiceImpl wxService;
|
||||
private ApiTestModule.WxXmlCpInMemoryConfigStorage configStorage;
|
||||
|
||||
public void testSendCustomMessage() throws WxErrorException {
|
||||
ApiTestModule.WxXmlCpInMemoryConfigStorage configStorage = (ApiTestModule.WxXmlCpInMemoryConfigStorage) this.wxService.getWxCpConfigStorage();
|
||||
WxCpMessage message1 = new WxCpMessage();
|
||||
message1.setAgentId(configStorage.getAgentId());
|
||||
message1.setMsgType(WxConsts.CUSTOM_MSG_TEXT);
|
||||
message1.setToUser(configStorage.getUserId());
|
||||
message1.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
|
||||
this.wxService.messageSend(message1);
|
||||
@BeforeTest
|
||||
public void setup() {
|
||||
configStorage = (ApiTestModule.WxXmlCpInMemoryConfigStorage) this.wxService.getWxCpConfigStorage();
|
||||
}
|
||||
|
||||
WxCpMessage message2 = WxCpMessage
|
||||
public void testSendMessage() throws WxErrorException {
|
||||
WxCpMessage message = new WxCpMessage();
|
||||
message.setAgentId(configStorage.getAgentId());
|
||||
message.setMsgType(WxConsts.CUSTOM_MSG_TEXT);
|
||||
message.setToUser(configStorage.getUserId());
|
||||
message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
|
||||
|
||||
WxCpMessageSendResult messageSendResult = this.wxService.messageSend(message);
|
||||
assertNotNull(messageSendResult);
|
||||
System.out.println(messageSendResult);
|
||||
System.out.println(messageSendResult.getInvalidPartyList());
|
||||
System.out.println(messageSendResult.getInvalidUserList());
|
||||
System.out.println(messageSendResult.getInvalidTagList());
|
||||
}
|
||||
|
||||
public void testSendMessage1() throws WxErrorException {
|
||||
WxCpMessage message = WxCpMessage
|
||||
.TEXT()
|
||||
.agentId(configStorage.getAgentId())
|
||||
.toUser(configStorage.getUserId())
|
||||
.content("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>")
|
||||
.build();
|
||||
this.wxService.messageSend(message2);
|
||||
|
||||
WxCpMessageSendResult messageSendResult = this.wxService.messageSend(message);
|
||||
assertNotNull(messageSendResult);
|
||||
System.out.println(messageSendResult);
|
||||
System.out.println(messageSendResult.getInvalidPartyList());
|
||||
System.out.println(messageSendResult.getInvalidUserList());
|
||||
System.out.println(messageSendResult.getInvalidTagList());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user