1
0
mirror of synced 2026-02-18 03:07:48 +08:00

合并 Develop,发布3.1.0正式版 (#640)

* #519 修复小程序客服消息 URL 被转义的问题

* 优化单元测试提示信息

* 网页授权url增加&connect_redirect=1参数解决两次重定向跳转问题: https://blog.csdn.net/jiangguilong2000/article/details/79416615

* 修复错误的feeToYuan方法名为fenToYuan

* #529 EntPayBankRequest增加默认构造函数

* #529 EntPayBankResult中cmmsAmount的数据类型改为Integer

* #528 WxMpUser类增加三个属性:subscribe_scene、 qr_scene 和qr_scene_str

* 修复代码

* 发布3.0.1.BETA测试版本

* #533 微信刷卡支付请求类增加缺少的三个参数

* #536 企业号模块增加获取企业号应用相关接口

* 定义《企业号应用》的bean

* 增加《获取企业号应用》接口实现

* 增加获取测试企业号应用信息测试类

* #535 修复Tomcat 不能正常关闭的问题,增加线程池shutdown相关的操作

* #541 企业号增加实现管理标签的(获取标签成员)接口 

* 定义《企业号应用》的bean

* 增加《获取企业号应用》接口实现

* 增加获取测试企业号应用信息测试类

* tag service增加获取标签成员方法
http://qydev.weixin.qq.com/wiki/index.php?title=管理标签

* #534 公众号发送模版消息中的小程序path改回pagepath

* 发布3.0.2.BETA测试版本

* #547 开放平台模块 componentAccessToken 增加过期自动刷新

* createOrder方法增加H5支付的支持

* #551 文本卡片消息增加btntext字段

* #550 企业微信删除标签成员接口增加部门列表参数

* 清理无用代码

* #530 微信支付申请退款接口结果类增加单个代金券相关参数 ,并根据官方文档整理其他参数

* #531 小程序WxMaMessage类增加小程序卡片消息相关的几个属性

* #520 企业微信网页授权增加使用user_ticket获取成员详情的接口

* 发布3.0.3.BETA测试版本

* 优化代码

* 完善测试

* #559 微信开放平台:1. WxOpenInRedisConfigStorage 支持 JedisPool/JedisSentinelPool 等 Pool<Jedis> 的子类;2. WxOpenInRedisConfigStorage 增加 keyPrefix 以支持可配置的前缀;

* #560 微信开放平台:增加小程序代码模板库管理 

* 微信开放平台:1. WxOpenInRedisConfigStorage 支持 JedisPool/JedisSentinelPool 等 Pool<Jedis> 的子类;2. WxOpenInRedisConfigStorage 增加 keyPrefix 以支持可配置的前缀;

* 微信开放平台:增加小程序代码模板库管理

* #562 小程序增加代码管理相关 API

* 微信开放平台:1. WxOpenInRedisConfigStorage 支持 JedisPool/JedisSentinelPool 等 Pool<Jedis> 的子类;2. WxOpenInRedisConfigStorage 增加 keyPrefix 以支持可配置的前缀;

* 微信开放平台:增加小程序代码模板库管理

* 小程序:增加代码管理相关 API

* #563 小程序增加修改服务器地址、成员管理 API 

* 微信开放平台:1. WxOpenInRedisConfigStorage 支持 JedisPool/JedisSentinelPool 等 Pool<Jedis> 的子类;2. WxOpenInRedisConfigStorage 增加 keyPrefix 以支持可配置的前缀;

* 微信开放平台:增加小程序代码模板库管理

* 小程序:增加代码管理相关 API

* 小程序:增加修改服务器地址、成员管理 API

* #565 小程序增加数据分析相关 API 

* 微信开放平台:1. WxOpenInRedisConfigStorage 支持 JedisPool/JedisSentinelPool 等 Pool<Jedis> 的子类;2. WxOpenInRedisConfigStorage 增加 keyPrefix 以支持可配置的前缀;

* 微信开放平台:增加小程序代码模板库管理

* 小程序:增加代码管理相关 API

* 小程序:增加修改服务器地址、成员管理 API

* 小程序:增加数据分析相关 API

* #567 微信开放平台增加 HTTP proxy 机制

* 微信开放平台:1. WxOpenInRedisConfigStorage 支持 JedisPool/JedisSentinelPool 等 Pool<Jedis> 的子类;2. WxOpenInRedisConfigStorage 增加 keyPrefix 以支持可配置的前缀;

* 微信开放平台:增加小程序代码模板库管理

* 小程序:增加代码管理相关 API

* 小程序:增加修改服务器地址、成员管理 API

* 小程序:增加数据分析相关 API

* 微信开放平台:增加 HTTP proxy 机制

* #568 修复三方平台多次授权时,RefreshToken 没有刷新的问题

* fix 多次授权时,RefreshToken 没有刷新

* null 判断

* 发布3.0.4.BETA测试版本

* fix code

* #569 微信支付几个查询关闭对账下载相关接口增加重载方法,以方便客户端指定更多参数

* #578 微信开放平台增加 WxMaUserService 的实现

* 微信开放平台:1. WxOpenInRedisConfigStorage 支持 JedisPool/JedisSentinelPool 等 Pool<Jedis> 的子类;2. WxOpenInRedisConfigStorage 增加 keyPrefix 以支持可配置的前缀;

* 微信开放平台:增加小程序代码模板库管理

* 小程序:增加代码管理相关 API

* 小程序:增加修改服务器地址、成员管理 API

* 小程序:增加数据分析相关 API

* 微信开放平台:增加 HTTP proxy 机制

* 微信开放平台:增加 WxMaUserService 的实现

* 修复小程序码的相关方法命名:WxCode->WxaCode, WxCodeLimit -> WxaCodeUnlimit

* #556 日志信息中如果含有secret值的,将其值隐藏掉

* #585 小程序二维码支持is_hyaline参数生成透明背景二维码

* 发布3.0.5.BETA测试版本

* #584 修复企业付款到银行卡接口签名失败的问题

* 简化代码

* #586 微信支付 WxPayConfig增加支持byte数组方式设置证书

* #581 增加微信公众号错误信息枚举类WxMpErrorMsg,并提供方法,方便根据错误代码查询错误信息内容

* #555 修复微信支付服务商模式支付验证签名失败的问题

* #521 微信支付回调通知类WxPayOrderNotifyResult增加version参数

* #583 企业微信新增人员接口新增字段to_invite

* #583 企业微信通讯录管理增加邀请成员接口

* #587 企业微信几个接口增加个人二维码字段

* 修复字符

* 修复单元测试

* 发布3.0.6.BETA测试版本

* 重构WxError相关代码,自动根据代码补充错误中文说明

* 优化微信支付代码

* #584 修复企业付款queryEntPay签名失败问题

* #591 文件上传接口不自动关闭inputStream,由调用方自己控制

* #595 优化WxPayException

* 发布3.0.7.BETA测试版本

* 更新pom

* 优化代码

* #615 公众号客服消息添加 "发送小程序卡片" 类型

* 优化XStreamTransformer

* 微信支付模块jodd-http修改scope

* 发布3.0.8.BETA测试版本

* #623 群发接口增加clientmsgid

* add author for some files

* clean code

* 重构规范RequestExecuter代码

* #532 实现微信AI开放接口的三个接口:语音上传、查询识别结果和微信翻译功能

* 发布3.0.9.BETA测试版本

* #516 增加获取Wi-Fi门店列表接口

* #629 修复WxPayOrderNotifyResult解析xml报错问题

* #639 修复小程序代码模版库管理 access_token key 错误

* 发布3.1.0正式版本
This commit is contained in:
Binary Wang
2018-06-22 23:29:17 +08:00
committed by GitHub
parent 2d84939be0
commit 9d66d582db
304 changed files with 6960 additions and 1452 deletions

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.api;
import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import org.apache.commons.lang3.StringUtils;
import org.testng.*;

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.api;
import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.mp.api.impl.WxMpServiceHttpClientImpl;
import org.testng.annotations.*;

View File

@@ -1,7 +1,6 @@
package me.chanjar.weixin.mp.api;
import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.crypto.SHA1;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import org.testng.*;

View File

@@ -8,6 +8,8 @@ import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.testng.*;
import org.testng.annotations.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.Map;
/**
@@ -67,9 +69,23 @@ public class WxMpMessageRouterTest {
prepare(true, sb, router);
router.route(message);
Thread.sleep(500);
router.shutDownExecutorService();
Assert.assertEquals(sb.toString(), expected);
}
@Test(dataProvider = "messages-1")
public void testExternalExcutorService(WxMpXmlMessage message, String expected) throws InterruptedException {
StringBuffer sb = new StringBuffer();
ExecutorService executorService = Executors.newFixedThreadPool(100);
WxMpMessageRouter router = new WxMpMessageRouter(null, executorService);
prepare(true, sb, router);
router.route(message);
Thread.sleep(500);
executorService.shutdown();
Assert.assertEquals(sb.toString(), expected);
}
public void testConcurrency() throws InterruptedException {
final WxMpMessageRouter router = new WxMpMessageRouter(null);
router.rule().handler(new WxMpMessageHandler() {

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.api;
import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import org.testng.*;
import org.testng.annotations.*;

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.api;
import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import org.testng.*;
import org.testng.annotations.*;

View File

@@ -0,0 +1,47 @@
package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.AiLangType;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.io.File;
/**
* <pre>
* Created by BinaryWang on 2018/6/10.
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
@Test
@Guice(modules = ApiTestModule.class)
public class WxMpAiOpenServiceImplTest {
@Inject
protected WxMpService wxService;
@Test
public void testUploadVoice() throws WxErrorException {
String voiceId = System.currentTimeMillis() + "a";
AiLangType lang = AiLangType.zh_CN;
this.wxService.getAiOpenService().uploadVoice(voiceId, lang, new File("d:\\t.mp3"));
}
@Test
public void testRecogniseVoice() throws WxErrorException {
String voiceId = System.currentTimeMillis() + "a";
AiLangType lang = AiLangType.zh_CN;
final String result = this.wxService.getAiOpenService().recogniseVoice(voiceId, lang, new File("d:\\t.mp3"));
System.out.println(result);
}
@Test
public void testTranslate() throws WxErrorException {
final String responseContent = this.wxService.getAiOpenService()
.translate(AiLangType.zh_CN, AiLangType.en_US, "微信文档很坑爹");
System.out.println(responseContent);
}
}

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.bean.datacube.*;

View File

@@ -2,7 +2,7 @@ package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.bean.device.WxDeviceQrCodeResult;

View File

@@ -2,7 +2,7 @@ package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.test.TestConfigStorage;

View File

@@ -3,7 +3,7 @@ package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.test.TestConfigStorage;

View File

@@ -3,7 +3,7 @@ package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.fs.FileUtils;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;

View File

@@ -4,7 +4,7 @@ import com.google.inject.Inject;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.bean.menu.WxMenu;
import me.chanjar.weixin.common.bean.menu.WxMenuButton;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.bean.menu.WxMpGetSelfMenuInfoResult;

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;

View File

@@ -2,7 +2,7 @@ package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.test.TestConfigStorage;

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.bean.store.WxMpStoreBaseInfo;

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.test.TestConfigStorage;

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.test.TestConfigStorage;

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.test.TestConfigStorage;

View File

@@ -0,0 +1,31 @@
package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.bean.wifi.WxMpWifiShopListResult;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
/**
* <pre>
* Created by BinaryWang on 2018/6/10.
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
@Test
@Guice(modules = ApiTestModule.class)
public class WxMpWifiServiceImplTest {
@Inject
private WxMpService wxService;
@Test
public void testListShop() throws WxErrorException {
final WxMpWifiShopListResult result = this.wxService.getWifiService().listShop(1, 2);
System.out.println(result);
}
}

View File

@@ -1,5 +1,13 @@
package me.chanjar.weixin.mp.api.test;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.locks.ReentrantLock;
import me.chanjar.weixin.mp.api.impl.WxMpServiceHttpClientImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.Binder;
import com.google.inject.Module;
import com.thoughtworks.xstream.XStream;
@@ -8,24 +16,26 @@ import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceOkHttpImpl;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.locks.ReentrantLock;
public class ApiTestModule implements Module {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private static final String TEST_CONFIG_XML = "test-config.xml";
@Override
public void configure(Binder binder) {
try (InputStream is1 = ClassLoader.getSystemResourceAsStream("test-config.xml")) {
TestConfigStorage config = this.fromXml(TestConfigStorage.class, is1);
try (InputStream inputStream = ClassLoader.getSystemResourceAsStream(TEST_CONFIG_XML)) {
if (inputStream == null) {
throw new RuntimeException("测试配置文件【" + TEST_CONFIG_XML + "】未找到请参照test-config-sample.xml文件生成");
}
TestConfigStorage config = this.fromXml(TestConfigStorage.class, inputStream);
config.setAccessTokenLock(new ReentrantLock());
WxMpService wxService = new WxMpServiceOkHttpImpl();
WxMpService wxService = new WxMpServiceHttpClientImpl();
wxService.setWxMpConfigStorage(config);
binder.bind(WxMpService.class).toInstance(wxService);
binder.bind(WxMpConfigStorage.class).toInstance(config);
} catch (IOException e) {
e.printStackTrace();
this.log.error(e.getMessage(), e);
}
}

View File

@@ -52,10 +52,12 @@ public class TestConfigStorage extends WxMpInMemoryConfigStorage {
this.qrconnectRedirectUrl = qrconnectRedirectUrl;
}
@Override
public String getTemplateId() {
return this.templateId;
}
@Override
public void setTemplateId(String templateId) {
this.templateId = templateId;
}

View File

@@ -2,8 +2,8 @@ package me.chanjar.weixin.mp.bean.kefu;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage.WxArticle;
import org.testng.*;
import org.testng.annotations.*;
import org.testng.Assert;
import org.testng.annotations.Test;
@Test
public class WxMpKefuMessageTest {
@@ -13,12 +13,14 @@ public class WxMpKefuMessageTest {
reply.setToUser("OPENID");
reply.setMsgType(WxConsts.KefuMsgType.TEXT);
reply.setContent("sfsfdsdf");
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}");
Assert
.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}");
}
public void testTextBuild() {
WxMpKefuMessage reply = WxMpKefuMessage.TEXT().toUser("OPENID").content("sfsfdsdf").build();
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}");
Assert
.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}");
}
public void testImageReply() {
@@ -26,12 +28,14 @@ public class WxMpKefuMessageTest {
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\"}}");
Assert.assertEquals(reply.toJson(),
"{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}");
}
public void testImageBuild() {
WxMpKefuMessage reply = WxMpKefuMessage.IMAGE().toUser("OPENID").mediaId("MEDIA_ID").build();
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}");
Assert.assertEquals(reply.toJson(),
"{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}");
}
public void testVoiceReply() {
@@ -39,12 +43,14 @@ public class WxMpKefuMessageTest {
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\"}}");
Assert.assertEquals(reply.toJson(),
"{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"}}");
}
public void testVoiceBuild() {
WxMpKefuMessage reply = WxMpKefuMessage.VOICE().toUser("OPENID").mediaId("MEDIA_ID").build();
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"}}");
Assert.assertEquals(reply.toJson(),
"{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"}}");
}
public void testVideoReply() {
@@ -55,12 +61,15 @@ public class WxMpKefuMessageTest {
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\"}}");
Assert.assertEquals(reply.toJson(),
"{\"touser\":\"OPENID\",\"msgtype\":\"video\",\"video\":{\"media_id\":\"MEDIA_ID\",\"thumb_media_id\":\"MEDIA_ID\",\"title\":\"TITLE\",\"description\":\"DESCRIPTION\"}}");
}
public void testVideoBuild() {
WxMpKefuMessage reply = WxMpKefuMessage.VIDEO().toUser("OPENID").title("TITLE").mediaId("MEDIA_ID").thumbMediaId("MEDIA_ID").description("DESCRIPTION").build();
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"video\",\"video\":{\"media_id\":\"MEDIA_ID\",\"thumb_media_id\":\"MEDIA_ID\",\"title\":\"TITLE\",\"description\":\"DESCRIPTION\"}}");
WxMpKefuMessage reply = WxMpKefuMessage.VIDEO().toUser("OPENID").title("TITLE").mediaId("MEDIA_ID")
.thumbMediaId("MEDIA_ID").description("DESCRIPTION").build();
Assert.assertEquals(reply.toJson(),
"{\"touser\":\"OPENID\",\"msgtype\":\"video\",\"video\":{\"media_id\":\"MEDIA_ID\",\"thumb_media_id\":\"MEDIA_ID\",\"title\":\"TITLE\",\"description\":\"DESCRIPTION\"}}");
}
public void testMusicReply() {
@@ -72,7 +81,8 @@ public class WxMpKefuMessageTest {
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\"}}");
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\"}}");
}
public void testMusicBuild() {
@@ -84,7 +94,8 @@ public class WxMpKefuMessageTest {
.musicUrl("MUSIC_URL")
.hqMusicUrl("HQ_MUSIC_URL")
.build();
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\"}}");
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\"}}");
}
public void testNewsReply() {
@@ -106,8 +117,8 @@ public class WxMpKefuMessageTest {
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\"}]}}");
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\"}]}}");
}
public void testNewsBuild() {
@@ -125,7 +136,22 @@ public class WxMpKefuMessageTest {
WxMpKefuMessage reply = WxMpKefuMessage.NEWS().toUser("OPENID").addArticle(article1).addArticle(article2).build();
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\"}]}}");
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\"}]}}");
}
public void testMiniProgramPageBuild() {
WxMpKefuMessage reply = WxMpKefuMessage.MINIPROGRAMPAGE()
.toUser("OPENID")
.title("title")
.appId("appid")
.pagePath("pagepath")
.thumbMediaId("thumb_media_id")
.build();
Assert.assertEquals(reply.toJson(),
"{\"touser\":\"OPENID\",\"msgtype\":\"miniprogrampage\",\"miniprogrampage\":{\"title\":\"title\",\"appid\":\"appid\",\"pagepath\":\"pagepath\",\"thumb_media_id\":\"thumb_media_id\"}}");
}
}

View File

@@ -1,6 +1,6 @@
package me.chanjar.weixin.mp.demo;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.session.WxSession;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpMessageHandler;

View File

@@ -2,7 +2,7 @@ package me.chanjar.weixin.mp.demo;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpMessageHandler;
import me.chanjar.weixin.mp.api.WxMpService;

View File

@@ -1,6 +1,6 @@
package me.chanjar.weixin.mp.demo;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
import me.chanjar.weixin.mp.bean.result.WxMpUser;