@@ -0,0 +1,92 @@
|
||||
package cn.binarywang.wx.miniapp.api.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaLiveInfo;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaLiveResult;
|
||||
import cn.binarywang.wx.miniapp.test.ApiTestModule;
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* 测试直播商品管理相关的接口
|
||||
*
|
||||
* @author <a href="https://github.com/lipengjun92">lipengjun (939961241@qq.com)</a>
|
||||
*/
|
||||
@Test
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxMaLiveGoodsServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxMaService wxService;
|
||||
|
||||
@Test
|
||||
public void addGoods() throws Exception {
|
||||
//上传临时素材
|
||||
WxMediaUploadResult mediaUpload = this.wxService.getMaterialService().mediaUpload("image", new File("E:\\1.png"));
|
||||
|
||||
WxMaLiveInfo.Goods goods = new WxMaLiveInfo.Goods();
|
||||
goods.setCoverImgUrl(mediaUpload.getMediaId());
|
||||
goods.setName("宫廷奢华真丝四件套");
|
||||
goods.setPrice("1599");
|
||||
goods.setPrice2("0");
|
||||
goods.setPriceType(1);
|
||||
goods.setUrl("pages/goods/goods?id=b7c4fbf95493bd294054fe4296d0d9ad");
|
||||
WxMaLiveResult liveResult = this.wxService.getLiveGoodsService().addGoods(goods);
|
||||
assertNotNull(liveResult);
|
||||
System.out.println(liveResult.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resetAudit() throws Exception {
|
||||
boolean result = this.wxService.getLiveGoodsService().resetAudit(715138516, 9);
|
||||
System.out.println(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void auditGoods() throws Exception {
|
||||
String result = this.wxService.getLiveGoodsService().auditGoods(9);
|
||||
System.out.println(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteGoods() throws Exception {
|
||||
boolean result = this.wxService.getLiveGoodsService().deleteGoods(9);
|
||||
System.out.println(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateGoods() throws Exception {
|
||||
|
||||
WxMaLiveInfo.Goods goods = new WxMaLiveInfo.Goods();
|
||||
goods.setGoodsId(8);
|
||||
goods.setName("宫廷奢华真丝四件套");
|
||||
goods.setCoverImgUrl("http://mmbiz.qpic.cn/mmbiz_png/omYktZNGamuUQE0WPVfqdnLV61JDhluXOac7PiaoZeticFpcR7wvicC0aXUC2VXkl7r1gN0QSKosv2satn6oCFeiaQ/0");
|
||||
goods.setPrice("2299");
|
||||
goods.setPrice2("0");
|
||||
goods.setPriceType(1);
|
||||
goods.setUrl("pages/goods/goods?id=b7c4fbf95493bd294054fe4296d0d9ad");
|
||||
boolean maLiveInfo = this.wxService.getLiveGoodsService().updateGoods(goods);
|
||||
System.out.println(maLiveInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getGoodsWareHouse() throws Exception {
|
||||
WxMaLiveResult liveResult = this.wxService.getLiveGoodsService().getGoodsWareHouse(Arrays.asList(1, 2));
|
||||
assertNotNull(liveResult);
|
||||
System.out.println(liveResult.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getApprovedGoods() throws Exception {
|
||||
WxMaLiveResult liveResult = this.wxService.getLiveGoodsService().getApprovedGoods(0, 4, 2);
|
||||
assertNotNull(liveResult);
|
||||
System.out.println(liveResult.toString());
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,20 @@
|
||||
package cn.binarywang.wx.miniapp.api.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaGetLiveInfo;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaLiveInfo;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaLiveResult;
|
||||
import cn.binarywang.wx.miniapp.test.ApiTestModule;
|
||||
import cn.binarywang.wx.miniapp.test.TestConfig;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* 测试直播相关的接口
|
||||
@@ -31,9 +28,34 @@ public class WxMaLiveServiceImplTest {
|
||||
@Inject
|
||||
private WxMaService wxService;
|
||||
|
||||
@Test
|
||||
public void createRoom() throws Exception {
|
||||
//上传临时素材
|
||||
WxMediaUploadResult mediaUpload = this.wxService.getMaterialService().mediaUpload("image", new File("E:\\1.png"));
|
||||
|
||||
WxMaLiveInfo.RoomInfo roomInfo = new WxMaLiveInfo.RoomInfo();
|
||||
roomInfo.setName("订阅通知直播间");
|
||||
roomInfo.setCoverImg(mediaUpload.getMediaId());
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.set(2020, Calendar.SEPTEMBER, 10, 8, 0);
|
||||
roomInfo.setStartTime(c.getTimeInMillis() / 1000);
|
||||
c.set(2020, Calendar.SEPTEMBER, 10, 12, 0);
|
||||
roomInfo.setEndTime(c.getTimeInMillis() / 1000);
|
||||
roomInfo.setAnchorName("鹏军_专业小程序开发");
|
||||
roomInfo.setAnchorWechat("pengjun939961241");
|
||||
roomInfo.setShareImg(mediaUpload.getMediaId());
|
||||
roomInfo.setType(1);
|
||||
roomInfo.setScreenType(1);
|
||||
roomInfo.setCloseLike(0);
|
||||
roomInfo.setCloseGoods(0);
|
||||
roomInfo.setCloseComment(0);
|
||||
Integer roomId = this.wxService.getLiveService().createRoom(roomInfo);
|
||||
System.out.println(roomId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLiveInfo() throws Exception {
|
||||
WxMaGetLiveInfo list = this.wxService.getLiveService().getLiveInfo(0,10);
|
||||
WxMaLiveResult list = this.wxService.getLiveService().getLiveInfo(0, 10);
|
||||
assertNotNull(list);
|
||||
System.out.println(list.toString());
|
||||
}
|
||||
@@ -41,15 +63,21 @@ public class WxMaLiveServiceImplTest {
|
||||
@Test
|
||||
public void getLiveReplay() throws Exception {
|
||||
// [12, 11, 10, 9, 8, 7, 6, 5, 3, 2]
|
||||
WxMaGetLiveInfo list = this.wxService.getLiveService().getLiveReplay(11,0,10);
|
||||
WxMaLiveResult list = this.wxService.getLiveService().getLiveReplay(3, 0, 10);
|
||||
assertNotNull(list);
|
||||
System.out.println(list.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLiveinfos() throws Exception {
|
||||
List<WxMaGetLiveInfo.RoomInfo> list = this.wxService.getLiveService().getLiveinfos();
|
||||
List<WxMaLiveResult.RoomInfo> list = this.wxService.getLiveService().getLiveinfos();
|
||||
assertNotNull(list);
|
||||
System.out.println(list.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addGoodsToRoom() throws Exception {
|
||||
boolean result = this.wxService.getLiveService().addGoodsToRoom(5, Arrays.asList(8, 7, 5, 4, 10));
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user