|
@@ -1,17 +1,20 @@
|
|
|
package cn.binarywang.wx.miniapp.api.impl;
|
|
|
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.Date;
|
|
|
-
|
|
|
-import cn.binarywang.wx.miniapp.bean.*;
|
|
|
-import org.testng.annotations.*;
|
|
|
-
|
|
|
import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
+import cn.binarywang.wx.miniapp.bean.*;
|
|
|
import cn.binarywang.wx.miniapp.test.ApiTestModule;
|
|
|
import cn.binarywang.wx.miniapp.test.TestConfig;
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
import com.google.inject.Inject;
|
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
+import org.testng.annotations.Guice;
|
|
|
+import org.testng.annotations.Test;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
|
/**
|
|
|
* 测试消息相关接口
|
|
@@ -25,7 +28,8 @@ public class WxMaMsgServiceImplTest {
|
|
|
@Inject
|
|
|
private WxMaService wxService;
|
|
|
|
|
|
- public void testSendKefuMessage() throws WxErrorException {
|
|
|
+ @Test
|
|
|
+ public void testSendKefuMsg() throws WxErrorException {
|
|
|
TestConfig config = (TestConfig) this.wxService.getWxMaConfig();
|
|
|
WxMaKefuMessage message = WxMaKefuMessage.newTextBuilder()
|
|
|
.toUser(config.getOpenid())
|
|
@@ -74,7 +78,7 @@ public class WxMaMsgServiceImplTest {
|
|
|
@Test
|
|
|
public void testSendUniformMsg() throws WxErrorException {
|
|
|
TestConfig config = (TestConfig) this.wxService.getWxMaConfig();
|
|
|
- WxMaUniformMessage message = WxMaUniformMessage.builder()
|
|
|
+ WxMaUniformMessage message = WxMaUniformMessage.builder()
|
|
|
.isMpTemplateMsg(false)
|
|
|
.toUser(config.getOpenid())
|
|
|
.page("page/page/index")
|
|
@@ -89,4 +93,22 @@ public class WxMaMsgServiceImplTest {
|
|
|
|
|
|
this.wxService.getMsgService().sendUniformMsg(message);
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testCreateUpdatableMessageActivityId() throws WxErrorException {
|
|
|
+ final JsonObject jsonObject = this.wxService.getMsgService().createUpdatableMessageActivityId();
|
|
|
+ assertThat(jsonObject).isNotNull();
|
|
|
+ assertThat(jsonObject.get("activity_id")).isNotNull();
|
|
|
+ System.out.println(jsonObject.get("activity_id"));
|
|
|
+ assertThat(jsonObject.get("expiration_time")).isNotNull();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testSetUpdatableMsg() throws WxErrorException {
|
|
|
+ this.wxService.getMsgService().setUpdatableMsg(new WxMaUpdatableMsg()
|
|
|
+ .setActivityId("1048_4f61uDloWPZl9pAs1dGx07vDiHKZ7FwJ0suohS1iMH5z8zhFktYk4nRqqBY~")
|
|
|
+ .setTargetState(1)
|
|
|
+ .setTemplateInfo(new WxMaUpdatableMsg.TemplateInfo()
|
|
|
+ .setParameterList(Lists.newArrayList(new WxMaUpdatableMsg.Parameter().setName("member_count").setValue("1")))));
|
|
|
+ }
|
|
|
}
|