me.chanjar.weixin.common.api.WxConsts Java Examples
The following examples show how to use
me.chanjar.weixin.common.api.WxConsts.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WxCpMessageTest.java From weixin-java-tools with Apache License 2.0 | 6 votes |
public void testNewsReply() { WxCpMessage reply = new WxCpMessage(); reply.setToUser("OPENID"); reply.setMsgType(WxConsts.CUSTOM_MSG_NEWS); WxArticle article1 = new WxArticle(); article1.setUrl("URL"); article1.setPicUrl("PIC_URL"); article1.setDescription("Is Really A Happy Day"); article1.setTitle("Happy Day"); reply.getArticles().add(article1); WxArticle article2 = new WxArticle(); article2.setUrl("URL"); article2.setPicUrl("PIC_URL"); article2.setDescription("Is Really A Happy Day"); article2.setTitle("Happy Day"); reply.getArticles().add(article2); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"news\",\"news\":{\"articles\":[{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"},{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"}]}}"); }
Example #2
Source File: WxMpKefuMessageTest.java From weixin-java-tools with Apache License 2.0 | 6 votes |
public void testNewsReply() { WxMpKefuMessage reply = new WxMpKefuMessage(); reply.setToUser("OPENID"); reply.setMsgType(WxConsts.KefuMsgType.NEWS); WxArticle article1 = new WxArticle(); article1.setUrl("URL"); article1.setPicUrl("PIC_URL"); article1.setDescription("Is Really A Happy Day"); article1.setTitle("Happy Day"); reply.getArticles().add(article1); WxArticle article2 = new WxArticle(); article2.setUrl("URL"); article2.setPicUrl("PIC_URL"); article2.setDescription("Is Really A Happy Day"); article2.setTitle("Happy Day"); reply.getArticles().add(article2); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"news\",\"news\":{\"articles\":[{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"},{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"}]}}"); }
Example #3
Source File: WxCpMessageAPITest.java From weixin-java-tools with Apache License 2.0 | 6 votes |
public void testSendCustomMessage() throws WxErrorException { ApiTestModule.WxXmlCpInMemoryConfigStorage configStorage = (ApiTestModule.WxXmlCpInMemoryConfigStorage) wxService.wxCpConfigStorage; 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>"); wxService.messageSend(message1); WxCpMessage message2 = WxCpMessage .TEXT() .agentId(configStorage.getAgentId()) .toUser(configStorage.getUserId()) .content("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>") .build(); wxService.messageSend(message2); }
Example #4
Source File: WxMpCustomMessageTest.java From weixin-java-tools with Apache License 2.0 | 6 votes |
public void testNewsReply() { WxMpCustomMessage reply = new WxMpCustomMessage(); reply.setToUser("OPENID"); reply.setMsgType(WxConsts.CUSTOM_MSG_NEWS); WxArticle article1 = new WxArticle(); article1.setUrl("URL"); article1.setPicUrl("PIC_URL"); article1.setDescription("Is Really A Happy Day"); article1.setTitle("Happy Day"); reply.getArticles().add(article1); WxArticle article2 = new WxArticle(); article2.setUrl("URL"); article2.setPicUrl("PIC_URL"); article2.setDescription("Is Really A Happy Day"); article2.setTitle("Happy Day"); reply.getArticles().add(article2); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"news\",\"news\":{\"articles\":[{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"},{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"}]}}"); }
Example #5
Source File: WxMpCustomMessageTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
public void testTextReply() { WxMpCustomMessage reply = new WxMpCustomMessage(); reply.setToUser("OPENID"); reply.setMsgType(WxConsts.CUSTOM_MSG_TEXT); reply.setContent("sfsfdsdf"); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}"); }
Example #6
Source File: WxCpXmlMessageTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
public void testSendPicsInfo() { String xml = "<xml>" + "<ToUserName><![CDATA[wx45a0972125658be9]]></ToUserName>" + "<FromUserName><![CDATA[xiaohe]]></FromUserName>" + "<CreateTime>1502012364</CreateTime>" + "<MsgType><![CDATA[event]]></MsgType>" + "<AgentID>1000004</AgentID>" + "<Event><![CDATA[pic_weixin]]></Event>" + "<EventKey><![CDATA[faceSimilarity]]></EventKey>" + "<SendPicsInfo>" + "<PicList><item><PicMd5Sum><![CDATA[aef52ae501537e552725c5d7f99c1741]]></PicMd5Sum></item></PicList>" + "<PicList><item><PicMd5Sum><![CDATA[c4564632a4fab91378c39bea6aad6f9e]]></PicMd5Sum></item></PicList>" + "<Count>2</Count>" + "</SendPicsInfo>" + "</xml>"; WxCpXmlMessage wxMessage = WxCpXmlMessage.fromXml(xml.replace("</PicList><PicList>","")); assertEquals(wxMessage.getToUserName(), "wx45a0972125658be9"); assertEquals(wxMessage.getFromUserName(), "xiaohe"); assertEquals(wxMessage.getCreateTime(), new Long(1502012364L)); assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.EVENT); assertEquals(wxMessage.getAgentId(), Integer.valueOf(1000004)); assertEquals(wxMessage.getEvent(), "pic_weixin"); assertEquals(wxMessage.getEventKey(), "faceSimilarity"); assertNotNull(wxMessage.getSendPicsInfo()); assertEquals(wxMessage.getSendPicsInfo().getCount(), new Long(2L)); assertEquals(wxMessage.getSendPicsInfo().getPicList().get(0).getPicMd5Sum(), "aef52ae501537e552725c5d7f99c1741"); assertEquals(wxMessage.getSendPicsInfo().getPicList().get(1).getPicMd5Sum(), "c4564632a4fab91378c39bea6aad6f9e"); }
Example #7
Source File: WxCpMessageAPITest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
public void testSendMessage() throws WxErrorException { WxCpMessage message = new WxCpMessage(); // message.setAgentId(configStorage.getAgentId()); message.setMsgType(WxConsts.KefuMsgType.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()); }
Example #8
Source File: WxCpMessageRouterTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
@Test(enabled = false) public void prepare(boolean async, StringBuffer sb, WxCpMessageRouter router) { router .rule() .async(async) .msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK).eventKey("KEY_1").content("CONTENT_1") .handler(new WxEchoCpMessageHandler(sb, "COMBINE_4")) .end() .rule() .async(async) .msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK).eventKey("KEY_1") .handler(new WxEchoCpMessageHandler(sb, "COMBINE_3")) .end() .rule() .async(async) .msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK) .handler(new WxEchoCpMessageHandler(sb, "COMBINE_2")) .end() .rule().async(async).msgType(WxConsts.XML_MSG_TEXT).handler(new WxEchoCpMessageHandler(sb, WxConsts.XML_MSG_TEXT)).end() .rule().async(async).event(WxConsts.EVT_CLICK).handler(new WxEchoCpMessageHandler(sb, WxConsts.EVT_CLICK)).end() .rule().async(async).eventKey("KEY_1").handler(new WxEchoCpMessageHandler(sb, "KEY_1")).end() .rule().async(async).content("CONTENT_1").handler(new WxEchoCpMessageHandler(sb, "CONTENT_1")).end() .rule().async(async).rContent(".*bc.*").handler(new WxEchoCpMessageHandler(sb, "abcd")).end() .rule().async(async).matcher(new WxCpMessageMatcher() { @Override public boolean match(WxCpXmlMessage message) { return "strangeformat".equals(message.getFormat()); } }).handler(new WxEchoCpMessageHandler(sb, "matcher")).end() .rule().async(async).handler(new WxEchoCpMessageHandler(sb, "ALL")).end(); ; }
Example #9
Source File: WxMpMessageRouterTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
@Test(enabled = false) public void prepare(boolean async, StringBuffer sb, WxMpMessageRouter router) { router .rule() .async(async) .msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK).eventKey("KEY_1").content("CONTENT_1") .handler(new WxEchoMpMessageHandler(sb, "COMBINE_4")) .end() .rule() .async(async) .msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK).eventKey("KEY_1") .handler(new WxEchoMpMessageHandler(sb, "COMBINE_3")) .end() .rule() .async(async) .msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK) .handler(new WxEchoMpMessageHandler(sb, "COMBINE_2")) .end() .rule().async(async).msgType(WxConsts.XML_MSG_TEXT).handler(new WxEchoMpMessageHandler(sb, WxConsts.XML_MSG_TEXT)).end() .rule().async(async).event(WxConsts.EVT_CLICK).handler(new WxEchoMpMessageHandler(sb, WxConsts.EVT_CLICK)).end() .rule().async(async).eventKey("KEY_1").handler(new WxEchoMpMessageHandler(sb, "KEY_1")).end() .rule().async(async).content("CONTENT_1").handler(new WxEchoMpMessageHandler(sb, "CONTENT_1")).end() .rule().async(async).rContent(".*bc.*").handler(new WxEchoMpMessageHandler(sb, "abcd")).end() .rule().async(async).matcher(new WxMpMessageMatcher() { @Override public boolean match(WxMpXmlMessage message) { return "strangeformat".equals(message.getFormat()); } }).handler(new WxEchoMpMessageHandler(sb, "matcher")).end() .rule().async(async).handler(new WxEchoMpMessageHandler(sb, "ALL")).end(); ; }
Example #10
Source File: WxCpMessageRouterTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
@Test(enabled = false) public void prepare(boolean async, StringBuffer sb, WxCpMessageRouter router) { router .rule() .async(async) .msgType(WxConsts.XmlMsgType.TEXT).event(WxConsts.EventType.CLICK).eventKey("KEY_1").content("CONTENT_1") .handler(new WxEchoCpMessageHandler(sb, "COMBINE_4")) .end() .rule() .async(async) .msgType(WxConsts.XmlMsgType.TEXT).event(WxConsts.EventType.CLICK).eventKey("KEY_1") .handler(new WxEchoCpMessageHandler(sb, "COMBINE_3")) .end() .rule() .async(async) .msgType(WxConsts.XmlMsgType.TEXT).event(WxConsts.EventType.CLICK) .handler(new WxEchoCpMessageHandler(sb, "COMBINE_2")) .end() .rule().async(async).msgType(WxConsts.XmlMsgType.TEXT).handler(new WxEchoCpMessageHandler(sb, WxConsts.XmlMsgType.TEXT)).end() .rule().async(async).event(WxConsts.EventType.CLICK).handler(new WxEchoCpMessageHandler(sb, WxConsts.EventType.CLICK)).end() .rule().async(async).eventKey("KEY_1").handler(new WxEchoCpMessageHandler(sb, "KEY_1")).end() .rule().async(async).content("CONTENT_1").handler(new WxEchoCpMessageHandler(sb, "CONTENT_1")).end() .rule().async(async).rContent(".*bc.*").handler(new WxEchoCpMessageHandler(sb, "abcd")).end() .rule().async(async).matcher(new WxCpMessageMatcher() { @Override public boolean match(WxCpXmlMessage message) { return "strangeformat".equals(message.getFormat()); } }).handler(new WxEchoCpMessageHandler(sb, "matcher")).end() .rule().async(async).handler(new WxEchoCpMessageHandler(sb, "ALL")).end(); }
Example #11
Source File: WxCpMediaServiceImplTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
@DataProvider public Object[][] mediaData() { return new Object[][]{ new Object[]{WxConsts.MediaFileType.IMAGE, TestConstants.FILE_JPG, "mm.jpeg"}, new Object[]{WxConsts.MediaFileType.VOICE, TestConstants.FILE_MP3, "mm.mp3"}, new Object[]{WxConsts.MediaFileType.VOICE, TestConstants.FILE_AMR, "mm.amr"},//{"errcode":301017,"errmsg":"voice file only support amr like myvoice.amr"} new Object[]{WxConsts.MediaFileType.VIDEO, TestConstants.FILE_MP4, "mm.mp4"}, new Object[]{WxConsts.MediaFileType.FILE, TestConstants.FILE_JPG, "mm.jpeg"} }; }
Example #12
Source File: BaseBuilder.java From weixin-java-tools with Apache License 2.0 | 5 votes |
public WxCpMessage build() { WxCpMessage m = new WxCpMessage(); m.setAgentId(this.agentId); m.setMsgType(this.msgType); m.setToUser(this.toUser); m.setToParty(this.toParty); m.setToTag(this.toTag); m.setSafe(StringUtils.defaultIfBlank(this.safe, WxConsts.KefuMsgSafe.NO)); return m; }
Example #13
Source File: WxCpMessageTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
public void testVoiceReply() { WxCpMessage reply = new WxCpMessage(); reply.setToUser("OPENID"); reply.setMsgType(WxConsts.CUSTOM_MSG_VOICE); reply.setMediaId("MEDIA_ID"); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"}}"); }
Example #14
Source File: WxMpCustomMessageTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
public void testImageReply() { WxMpCustomMessage reply = new WxMpCustomMessage(); reply.setToUser("OPENID"); reply.setMsgType(WxConsts.CUSTOM_MSG_IMAGE); reply.setMediaId("MEDIA_ID"); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}"); }
Example #15
Source File: WxMpMaterialAPITest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
@DataProvider public Object[][] uploadMaterial() { return new Object[][]{ new Object[]{WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, "mm.jpeg"}, new Object[]{WxConsts.MEDIA_VOICE, WxConsts.FILE_MP3, "mm.mp3"}, new Object[]{WxConsts.MEDIA_VIDEO, WxConsts.FILE_MP4, "mm.mp4"}, new Object[]{WxConsts.MEDIA_THUMB, WxConsts.FILE_JPG, "mm.jpeg"} }; }
Example #16
Source File: DemoOAuth2Handler.java From weixin-java-tools with Apache License 2.0 | 5 votes |
@Override public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService, WxSessionManager sessionManager) { String href = "<a href=\"" + wxMpService.oauth2buildAuthorizationUrl( wxMpService.getWxMpConfigStorage().getOauth2redirectUri(), WxConsts.OAuth2Scope.SNSAPI_USERINFO, null) + "\">测试oauth2</a>"; return WxMpXmlOutMessage.TEXT().content(href) .fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) .build(); }
Example #17
Source File: WxMpMediaAPITest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
@DataProvider public Object[][] uploadMedia() { return new Object[][] { new Object[] { WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, "mm.jpeg" }, new Object[] { WxConsts.MEDIA_VOICE, WxConsts.FILE_MP3, "mm.mp3" }, new Object[] { WxConsts.MEDIA_VIDEO, WxConsts.FILE_MP4, "mm.mp4" }, new Object[] { WxConsts.MEDIA_THUMB, WxConsts.FILE_JPG, "mm.jpeg" } }; }
Example #18
Source File: DemoOAuth2Handler.java From weixin-java-tools with Apache License 2.0 | 5 votes |
@Override public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService, WxSessionManager sessionManager) { String href = "<a href=\"" + wxMpService.oauth2buildAuthorizationUrl(WxConsts.OAUTH2_SCOPE_USER_INFO, null) + "\">测试oauth2</a>"; return WxMpXmlOutMessage .TEXT() .content(href) .fromUser(wxMessage.getToUserName()) .toUser(wxMessage.getFromUserName()).build(); }
Example #19
Source File: WxMpKefuServiceImplTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
public void testSendKefuMessage() throws WxErrorException { TestConfigStorage configStorage = (TestConfigStorage) this.wxService.getWxMpConfigStorage(); WxMpKefuMessage message = new WxMpKefuMessage(); message.setMsgType(WxConsts.KefuMsgType.TEXT); message.setToUser(configStorage.getOpenid()); message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); boolean result = this.wxService.getKefuService().sendKefuMessage(message); assertThat(result).isTrue(); }
Example #20
Source File: WxMpKefuServiceImplTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
public void testSendKefuMessageWithKfAccount() throws WxErrorException { TestConfigStorage configStorage = (TestConfigStorage) this.wxService.getWxMpConfigStorage(); WxMpKefuMessage message = new WxMpKefuMessage(); message.setMsgType(WxConsts.KefuMsgType.TEXT); message.setToUser(configStorage.getOpenid()); message.setKfAccount(configStorage.getKfAccount()); message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); boolean result = this.wxService.getKefuService().sendKefuMessage(message); assertThat(result).isTrue(); }
Example #21
Source File: WxMpMassMessageServiceImplTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
@Test public void testTextMassOpenIdsMessageSend() throws WxErrorException { // 发送群发消息 TestConfigStorage configProvider = (TestConfigStorage) this.wxService .getWxMpConfigStorage(); WxMpMassOpenIdsMessage massMessage = new WxMpMassOpenIdsMessage(); massMessage.setMsgType(WxConsts.MassMsgType.TEXT); massMessage.setContent("测试群发消息\n欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); massMessage.getToUsers().add(configProvider.getOpenid()); WxMpMassSendResult massResult = this.wxService.getMassMessageService() .massOpenIdsMessageSend(massMessage); assertNotNull(massResult); assertNotNull(massResult.getMsgId()); }
Example #22
Source File: WxMpCustomMessageTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
public void testMusicReply() { WxMpCustomMessage reply = new WxMpCustomMessage(); reply.setToUser("OPENID"); reply.setMsgType(WxConsts.CUSTOM_MSG_MUSIC); reply.setThumbMediaId("MEDIA_ID"); reply.setDescription("DESCRIPTION"); reply.setTitle("TITLE"); reply.setMusicUrl("MUSIC_URL"); reply.setHqMusicUrl("HQ_MUSIC_URL"); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"music\",\"music\":{\"title\":\"TITLE\",\"description\":\"DESCRIPTION\",\"thumb_media_id\":\"MEDIA_ID\",\"musicurl\":\"MUSIC_URL\",\"hqmusicurl\":\"HQ_MUSIC_URL\"}}"); }
Example #23
Source File: WxMpServiceImplTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
@Test public void testBuildQrConnectUrl() { String qrconnectRedirectUrl = ((TestConfigStorage) this.wxService.getWxMpConfigStorage()).getQrconnectRedirectUrl(); String qrConnectUrl = this.wxService.buildQrConnectUrl(qrconnectRedirectUrl, WxConsts.QrConnectScope.SNSAPI_LOGIN, null); Assert.assertNotNull(qrConnectUrl); System.out.println(qrConnectUrl); }
Example #24
Source File: WxMpMaterialServiceImplTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
@Test//(dependsOnMethods = {"testMaterialNewsList"}) public void testMaterialFileList() throws WxErrorException { WxMpMaterialFileBatchGetResult wxMpMaterialVoiceBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MaterialType.VOICE, 0, 20); WxMpMaterialFileBatchGetResult wxMpMaterialVideoBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MaterialType.VIDEO, 0, 20); WxMpMaterialFileBatchGetResult wxMpMaterialImageBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MaterialType.IMAGE, 0, 20); assertNotNull(wxMpMaterialVoiceBatchGetResult); assertNotNull(wxMpMaterialVideoBatchGetResult); assertNotNull(wxMpMaterialImageBatchGetResult); }
Example #25
Source File: WxMpKefuMessageTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
public void testTextReply() { WxMpKefuMessage reply = new WxMpKefuMessage(); reply.setToUser("OPENID"); reply.setMsgType(WxConsts.KefuMsgType.TEXT); reply.setContent("sfsfdsdf"); Assert .assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}"); }
Example #26
Source File: WxMpKefuMessageTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
public void testImageReply() { WxMpKefuMessage reply = new WxMpKefuMessage(); reply.setToUser("OPENID"); reply.setMsgType(WxConsts.KefuMsgType.IMAGE); reply.setMediaId("MEDIA_ID"); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}"); }
Example #27
Source File: WxMpKefuMessageTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
public void testVoiceReply() { WxMpKefuMessage reply = new WxMpKefuMessage(); reply.setToUser("OPENID"); reply.setMsgType(WxConsts.KefuMsgType.VOICE); reply.setMediaId("MEDIA_ID"); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"}}"); }
Example #28
Source File: WxCpMessageTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
public void testImageReply() { WxCpMessage reply = new WxCpMessage(); reply.setToUser("OPENID"); reply.setMsgType(WxConsts.CUSTOM_MSG_IMAGE); reply.setMediaId("MEDIA_ID"); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}"); }
Example #29
Source File: WxMpKefuMessageTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
public void testMusicReply() { WxMpKefuMessage reply = new WxMpKefuMessage(); reply.setToUser("OPENID"); reply.setMsgType(WxConsts.KefuMsgType.MUSIC); reply.setThumbMediaId("MEDIA_ID"); reply.setDescription("DESCRIPTION"); reply.setTitle("TITLE"); reply.setMusicUrl("MUSIC_URL"); reply.setHqMusicUrl("HQ_MUSIC_URL"); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"music\",\"music\":{\"title\":\"TITLE\",\"description\":\"DESCRIPTION\",\"thumb_media_id\":\"MEDIA_ID\",\"musicurl\":\"MUSIC_URL\",\"hqmusicurl\":\"HQ_MUSIC_URL\"}}"); }
Example #30
Source File: WxCpMessageTest.java From weixin-java-tools with Apache License 2.0 | 5 votes |
public void testVideoReply() { WxCpMessage reply = new WxCpMessage(); reply.setToUser("OPENID"); reply.setMsgType(WxConsts.CUSTOM_MSG_VIDEO); reply.setMediaId("MEDIA_ID"); reply.setThumbMediaId("MEDIA_ID"); reply.setTitle("TITLE"); reply.setDescription("DESCRIPTION"); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"video\",\"video\":{\"media_id\":\"MEDIA_ID\",\"thumb_media_id\":\"MEDIA_ID\",\"title\":\"TITLE\",\"description\":\"DESCRIPTION\"}}"); }