Search in sources :

Example 1 with WxMpMassSendResult

use of me.chanjar.weixin.mp.bean.result.WxMpMassSendResult in project weixin-java-tools by chanjarster.

the class WxMpMassMessageAPITest method testTextMassOpenIdsMessageSend.

@Test
public void testTextMassOpenIdsMessageSend() throws WxErrorException {
    // 发送群发消息
    ApiTestModule.WxXmlMpInMemoryConfigStorage configProvider = (ApiTestModule.WxXmlMpInMemoryConfigStorage) wxService.wxMpConfigStorage;
    WxMpMassOpenIdsMessage massMessage = new WxMpMassOpenIdsMessage();
    massMessage.setMsgType(WxConsts.MASS_MSG_TEXT);
    massMessage.setContent("测试群发消息\n欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
    massMessage.getToUsers().add(configProvider.getOpenId());
    WxMpMassSendResult massResult = wxService.massOpenIdsMessageSend(massMessage);
    Assert.assertNotNull(massResult);
    Assert.assertNotNull(massResult.getMsgId());
}
Also used : WxMpMassSendResult(me.chanjar.weixin.mp.bean.result.WxMpMassSendResult) WxMpMassOpenIdsMessage(me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage) Test(org.testng.annotations.Test)

Example 2 with WxMpMassSendResult

use of me.chanjar.weixin.mp.bean.result.WxMpMassSendResult in project weixin-java-tools by chanjarster.

the class WxMpMassMessageAPITest method testMediaMassOpenIdsMessageSend.

@Test(dataProvider = "massMessages")
public void testMediaMassOpenIdsMessageSend(String massMsgType, String mediaId) throws WxErrorException, IOException {
    // 发送群发消息
    ApiTestModule.WxXmlMpInMemoryConfigStorage configProvider = (ApiTestModule.WxXmlMpInMemoryConfigStorage) wxService.wxMpConfigStorage;
    WxMpMassOpenIdsMessage massMessage = new WxMpMassOpenIdsMessage();
    massMessage.setMsgType(massMsgType);
    massMessage.setMediaId(mediaId);
    massMessage.getToUsers().add(configProvider.getOpenId());
    WxMpMassSendResult massResult = wxService.massOpenIdsMessageSend(massMessage);
    Assert.assertNotNull(massResult);
    Assert.assertNotNull(massResult.getMsgId());
}
Also used : WxMpMassSendResult(me.chanjar.weixin.mp.bean.result.WxMpMassSendResult) WxMpMassOpenIdsMessage(me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage) Test(org.testng.annotations.Test)

Example 3 with WxMpMassSendResult

use of me.chanjar.weixin.mp.bean.result.WxMpMassSendResult in project weixin-java-tools by chanjarster.

the class WxMpMassSendResultAdapter method deserialize.

public WxMpMassSendResult deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
    WxMpMassSendResult sendResult = new WxMpMassSendResult();
    JsonObject sendResultJsonObject = json.getAsJsonObject();
    if (sendResultJsonObject.get("errcode") != null && !sendResultJsonObject.get("errcode").isJsonNull()) {
        sendResult.setErrorCode(GsonHelper.getAsString(sendResultJsonObject.get("errcode")));
    }
    if (sendResultJsonObject.get("errmsg") != null && !sendResultJsonObject.get("errmsg").isJsonNull()) {
        sendResult.setErrorMsg(GsonHelper.getAsString(sendResultJsonObject.get("errmsg")));
    }
    if (sendResultJsonObject.get("msg_id") != null && !sendResultJsonObject.get("msg_id").isJsonNull()) {
        sendResult.setMsgId(GsonHelper.getAsString(sendResultJsonObject.get("msg_id")));
    }
    return sendResult;
}
Also used : WxMpMassSendResult(me.chanjar.weixin.mp.bean.result.WxMpMassSendResult)

Example 4 with WxMpMassSendResult

use of me.chanjar.weixin.mp.bean.result.WxMpMassSendResult in project weixin-java-tools by chanjarster.

the class WxMpMassMessageAPITest method testTextMassGroupMessageSend.

@Test
public void testTextMassGroupMessageSend() throws WxErrorException {
    WxMpMassGroupMessage massMessage = new WxMpMassGroupMessage();
    massMessage.setMsgtype(WxConsts.MASS_MSG_TEXT);
    massMessage.setContent("测试群发消息\n欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
    massMessage.setGroupId(wxService.groupGet().get(0).getId());
    WxMpMassSendResult massResult = wxService.massGroupMessageSend(massMessage);
    Assert.assertNotNull(massResult);
    Assert.assertNotNull(massResult.getMsgId());
}
Also used : WxMpMassGroupMessage(me.chanjar.weixin.mp.bean.WxMpMassGroupMessage) WxMpMassSendResult(me.chanjar.weixin.mp.bean.result.WxMpMassSendResult) Test(org.testng.annotations.Test)

Example 5 with WxMpMassSendResult

use of me.chanjar.weixin.mp.bean.result.WxMpMassSendResult in project weixin-java-tools by chanjarster.

the class WxMpMassMessageAPITest method testMediaMassGroupMessageSend.

@Test(dataProvider = "massMessages")
public void testMediaMassGroupMessageSend(String massMsgType, String mediaId) throws WxErrorException, IOException {
    WxMpMassGroupMessage massMessage = new WxMpMassGroupMessage();
    massMessage.setMsgtype(massMsgType);
    massMessage.setMediaId(mediaId);
    massMessage.setGroupId(wxService.groupGet().get(0).getId());
    WxMpMassSendResult massResult = wxService.massGroupMessageSend(massMessage);
    Assert.assertNotNull(massResult);
    Assert.assertNotNull(massResult.getMsgId());
}
Also used : WxMpMassGroupMessage(me.chanjar.weixin.mp.bean.WxMpMassGroupMessage) WxMpMassSendResult(me.chanjar.weixin.mp.bean.result.WxMpMassSendResult) Test(org.testng.annotations.Test)

Aggregations

WxMpMassSendResult (me.chanjar.weixin.mp.bean.result.WxMpMassSendResult)5 Test (org.testng.annotations.Test)4 WxMpMassGroupMessage (me.chanjar.weixin.mp.bean.WxMpMassGroupMessage)2 WxMpMassOpenIdsMessage (me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage)2