mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
🆕 #2991【视频号】增加视频号模块,实现视频号大部分相关接口
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.channel.api.WxChannelAddressService;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.bean.address.AddressDetail;
|
||||
import me.chanjar.weixin.channel.bean.address.AddressIdResponse;
|
||||
import me.chanjar.weixin.channel.bean.address.AddressInfoResponse;
|
||||
import me.chanjar.weixin.channel.bean.address.AddressListResponse;
|
||||
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxChannelAddressServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxChannelService channelService;
|
||||
|
||||
@Test
|
||||
public void testListAddress() throws WxErrorException {
|
||||
WxChannelAddressService addressService = channelService.getAddressService();
|
||||
AddressListResponse response = addressService.listAddress(0, 10);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAddress() throws WxErrorException {
|
||||
WxChannelAddressService addressService = channelService.getAddressService();
|
||||
String addressId = "";
|
||||
AddressInfoResponse response = addressService.getAddress(addressId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddAddress() throws WxErrorException {
|
||||
WxChannelAddressService addressService = channelService.getAddressService();
|
||||
AddressDetail addressDetail = new AddressDetail();
|
||||
// ...
|
||||
AddressIdResponse response = addressService.addAddress(addressDetail);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAddress() throws WxErrorException {
|
||||
WxChannelAddressService addressService = channelService.getAddressService();
|
||||
AddressDetail addressDetail = new AddressDetail();
|
||||
// ...
|
||||
WxChannelBaseResponse response = addressService.updateAddress(addressDetail);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteAddress() throws WxErrorException {
|
||||
WxChannelAddressService addressService = channelService.getAddressService();
|
||||
String addressId = "";
|
||||
WxChannelBaseResponse response = addressService.deleteAddress(addressId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.chanjar.weixin.channel.api.WxChannelAfterSaleService;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.bean.after.AfterSaleInfoResponse;
|
||||
import me.chanjar.weixin.channel.bean.after.AfterSaleListResponse;
|
||||
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
|
||||
import me.chanjar.weixin.channel.bean.complaint.ComplaintOrderResponse;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxChannelAfterSaleServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxChannelService channelService;
|
||||
|
||||
@Test
|
||||
public void testListIds() throws WxErrorException {
|
||||
WxChannelAfterSaleService afterSaleService = channelService.getAfterSaleService();
|
||||
Long beginCreateTime = LocalDateTime.now().minusDays(7).atZone(ZoneId.systemDefault()).toEpochSecond();
|
||||
Long endCreateTime = LocalDateTime.now().atZone(ZoneId.systemDefault()).toEpochSecond();
|
||||
String nextKey = null;
|
||||
AfterSaleListResponse response = afterSaleService.listIds(beginCreateTime, endCreateTime, nextKey);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGet() throws WxErrorException {
|
||||
WxChannelAfterSaleService afterSaleService = channelService.getAfterSaleService();
|
||||
String afterSaleOrderId = "";
|
||||
AfterSaleInfoResponse response = afterSaleService.get(afterSaleOrderId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAccept() throws WxErrorException {
|
||||
WxChannelAfterSaleService afterSaleService = channelService.getAfterSaleService();
|
||||
String afterSaleOrderId = "";
|
||||
String addressId = "123";
|
||||
WxChannelBaseResponse response = afterSaleService.accept(afterSaleOrderId, addressId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReject() throws WxErrorException {
|
||||
WxChannelAfterSaleService afterSaleService = channelService.getAfterSaleService();
|
||||
String afterSaleOrderId = "";
|
||||
String rejectReason = "123";
|
||||
WxChannelBaseResponse response = afterSaleService.reject(afterSaleOrderId, rejectReason);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadRefundEvidence() throws WxErrorException {
|
||||
WxChannelAfterSaleService afterSaleService = channelService.getAfterSaleService();
|
||||
String afterSaleOrderId = "";
|
||||
String desc = "";
|
||||
List<String> certificates = new ArrayList<>(4);
|
||||
WxChannelBaseResponse response = afterSaleService.uploadRefundEvidence(afterSaleOrderId, desc, certificates);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddComplaintMaterial() throws WxErrorException {
|
||||
WxChannelAfterSaleService afterSaleService = channelService.getAfterSaleService();
|
||||
String complaintId = "";
|
||||
String content = "";
|
||||
List<String> mediaIds = new ArrayList<>(4);
|
||||
WxChannelBaseResponse response = afterSaleService.addComplaintMaterial(complaintId, content, mediaIds);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddComplaintEvidence() throws WxErrorException {
|
||||
WxChannelAfterSaleService afterSaleService = channelService.getAfterSaleService();
|
||||
String complaintId = "";
|
||||
String content = "";
|
||||
List<String> mediaIds = new ArrayList<>(4);
|
||||
WxChannelBaseResponse response = afterSaleService.addComplaintEvidence(complaintId, content, mediaIds);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetComplaint() throws WxErrorException {
|
||||
WxChannelAfterSaleService afterSaleService = channelService.getAfterSaleService();
|
||||
String complaintId = "";
|
||||
ComplaintOrderResponse response = afterSaleService.getComplaint(complaintId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.UUID;
|
||||
import me.chanjar.weixin.channel.api.WxChannelBasicService;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.bean.address.AddressCodeResponse;
|
||||
import me.chanjar.weixin.channel.bean.image.ChannelImageInfo;
|
||||
import me.chanjar.weixin.channel.bean.image.ChannelImageResponse;
|
||||
import me.chanjar.weixin.channel.bean.image.QualificationFileResponse;
|
||||
import me.chanjar.weixin.channel.bean.shop.ShopInfo;
|
||||
import me.chanjar.weixin.channel.bean.shop.ShopInfoResponse;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
import me.chanjar.weixin.channel.util.JsonUtils;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxChannelBasicServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxChannelService channelService;
|
||||
|
||||
@Test
|
||||
public void testGetShopInfo() throws WxErrorException {
|
||||
WxChannelBasicService basicService = channelService.getBasicService();
|
||||
ShopInfoResponse response = basicService.getShopInfo();
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
ShopInfo info = response.getInfo();
|
||||
assertNotNull(info);
|
||||
System.out.println(JsonUtils.encode(response));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadImg() throws WxErrorException, IOException {
|
||||
String imgUrl = "https://github.githubassets.com/images/icons/emoji/octocat.png";
|
||||
WxChannelBasicService basicService = channelService.getBasicService();
|
||||
// 获取mediaId
|
||||
ChannelImageInfo info = basicService.uploadImg(0, imgUrl);
|
||||
assertNotNull(info);
|
||||
assertNotNull(info.getMediaId());
|
||||
System.out.println(info.getMediaId());
|
||||
// 获取临时链接
|
||||
info = basicService.uploadImg(1, imgUrl);
|
||||
assertNotNull(info);
|
||||
assertNotNull(info.getUrl());
|
||||
System.out.println(info.getUrl());
|
||||
// 本地文件的格式上传
|
||||
String fileName = "tmp.png";
|
||||
URL url = ClassLoader.getSystemResource(fileName);
|
||||
File f = File.createTempFile(UUID.randomUUID().toString(), ".png");
|
||||
FileUtils.copyURLToFile(url, f);
|
||||
info = basicService.uploadImg(1, f, 253, 253);
|
||||
assertNotNull(info);
|
||||
assertNotNull(info.getUrl());
|
||||
System.out.println(info.getUrl());
|
||||
FileUtils.forceDeleteOnExit(f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadQualificationFile() throws IOException, WxErrorException {
|
||||
WxChannelBasicService basicService = channelService.getBasicService();
|
||||
// 本地文件的格式上传
|
||||
String fileName = "tmp.png";
|
||||
URL url = ClassLoader.getSystemResource(fileName);
|
||||
File f = File.createTempFile(UUID.randomUUID().toString(), ".png");
|
||||
FileUtils.copyURLToFile(url, f);
|
||||
QualificationFileResponse response = basicService.uploadQualificationFile(f);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
assertNotNull(response.getData());
|
||||
assertNotNull(response.getData().getId());
|
||||
System.out.println(response.getData().getId());
|
||||
FileUtils.forceDeleteOnExit(f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetImg() throws WxErrorException {
|
||||
WxChannelBasicService basicService = channelService.getBasicService();
|
||||
String mediaId = "ttRiex0K2utmlhR-IWcfaWP6deE5Gzo48Hq8abLEoVtTY618jAGtEmDDRPimKpTP8vlgTMwZokXHgm4fBVw82Q";
|
||||
ChannelImageResponse response = basicService.getImg(mediaId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
System.out.println(response.getContentType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAddressCode() throws WxErrorException {
|
||||
WxChannelBasicService basicService = channelService.getBasicService();
|
||||
Integer rootCode = 0;
|
||||
AddressCodeResponse response = basicService.getAddressCode(rootCode);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
System.out.println(response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import java.util.List;
|
||||
import me.chanjar.weixin.channel.api.WxChannelBrandService;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.bean.audit.AuditApplyResponse;
|
||||
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
|
||||
import me.chanjar.weixin.channel.bean.brand.BasicBrand;
|
||||
import me.chanjar.weixin.channel.bean.brand.Brand;
|
||||
import me.chanjar.weixin.channel.bean.brand.BrandApplyListResponse;
|
||||
import me.chanjar.weixin.channel.bean.brand.BrandInfoResponse;
|
||||
import me.chanjar.weixin.channel.bean.brand.BrandListResponse;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
import me.chanjar.weixin.channel.util.JsonUtils;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.collections.CollectionUtils;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxChannelBrandServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxChannelService channelService;
|
||||
|
||||
@Test
|
||||
public void testListAllBrand() throws WxErrorException {
|
||||
WxChannelBrandService brandService = channelService.getBrandService();
|
||||
|
||||
BrandListResponse response = brandService.listAllBrand(100, null);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
List<BasicBrand> brands = response.getBrands();
|
||||
assertTrue(CollectionUtils.hasElements(brands));
|
||||
System.out.println(JsonUtils.encode(response));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddBrandApply() throws WxErrorException {
|
||||
WxChannelBrandService brandService = channelService.getBrandService();
|
||||
Brand brand = new Brand();
|
||||
// ...
|
||||
AuditApplyResponse response = brandService.addBrandApply(brand);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateBrandApply() throws WxErrorException {
|
||||
WxChannelBrandService brandService = channelService.getBrandService();
|
||||
Brand brand = new Brand();
|
||||
// ...
|
||||
AuditApplyResponse response = brandService.updateBrandApply(brand);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCancelBrandApply() throws WxErrorException {
|
||||
WxChannelBrandService brandService = channelService.getBrandService();
|
||||
String brandId = "10000000";
|
||||
String auditId = "12345566";
|
||||
WxChannelBaseResponse response = brandService.cancelBrandApply(brandId, auditId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteBrandApply() throws WxErrorException {
|
||||
WxChannelBrandService brandService = channelService.getBrandService();
|
||||
String brandId = "10000000";
|
||||
WxChannelBaseResponse response = brandService.deleteBrandApply(brandId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBrandApply() throws WxErrorException {
|
||||
WxChannelBrandService brandService = channelService.getBrandService();
|
||||
String brandId = "10000000";
|
||||
BrandInfoResponse response = brandService.getBrandApply(brandId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListBrandApply() throws WxErrorException {
|
||||
WxChannelBrandService brandService = channelService.getBrandService();
|
||||
BrandApplyListResponse response = brandService.listBrandApply(10, null, null);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListValidBrandApply() throws WxErrorException {
|
||||
WxChannelBrandService brandService = channelService.getBrandService();
|
||||
BrandApplyListResponse response = brandService.listValidBrandApply(10, null);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.chanjar.weixin.channel.api.WxChannelCategoryService;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.bean.audit.AuditApplyResponse;
|
||||
import me.chanjar.weixin.channel.bean.audit.AuditResponse;
|
||||
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
|
||||
import me.chanjar.weixin.channel.bean.category.CategoryDetailResult;
|
||||
import me.chanjar.weixin.channel.bean.category.CategoryQualificationResponse;
|
||||
import me.chanjar.weixin.channel.bean.category.PassCategoryResponse;
|
||||
import me.chanjar.weixin.channel.bean.category.ShopCategory;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.collections.CollectionUtils;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxChannelCategoryServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxChannelService channelService;
|
||||
|
||||
@Test
|
||||
public void testListAllCategory() throws WxErrorException {
|
||||
WxChannelCategoryService categoryService = channelService.getCategoryService();
|
||||
CategoryQualificationResponse response = categoryService.listAllCategory();
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
System.out.println(response);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListAvailableCategory() throws WxErrorException {
|
||||
WxChannelCategoryService categoryService = channelService.getCategoryService();
|
||||
List<ShopCategory> shopCategories = categoryService.listAvailableCategory("0");
|
||||
assertTrue(CollectionUtils.hasElements(shopCategories));
|
||||
shopCategories.forEach(System.out::println);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCategoryDetail() throws WxErrorException {
|
||||
WxChannelCategoryService categoryService = channelService.getCategoryService();
|
||||
CategoryDetailResult categoryDetail = categoryService.getCategoryDetail("1602");
|
||||
assertNotNull(categoryDetail);
|
||||
assertTrue(categoryDetail.isSuccess());
|
||||
System.out.println(categoryDetail);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddCategory() throws WxErrorException {
|
||||
WxChannelCategoryService categoryService = channelService.getCategoryService();
|
||||
List<String> certificates = new ArrayList<>();
|
||||
certificates.add(
|
||||
"hWNith8iZSrxfN7W2tXOoWSXYWi1qADRJxwImvQl2DC6wqqJrl4g8i/UEZfd59yiiEKAnqy0WETFrOcGZFcJDfpH2ccmNZddzesR1/OpAC7bbfmEiDFBK2QL7MBjhR2m");
|
||||
AuditApplyResponse response = categoryService.addCategory("1001", "1002", "1005", certificates);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
System.out.println(response);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCancelCategoryAudit() throws WxErrorException {
|
||||
WxChannelCategoryService categoryService = channelService.getCategoryService();
|
||||
String auditId = "4403159413";
|
||||
WxChannelBaseResponse response = categoryService.cancelCategoryAudit(auditId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
System.out.println(response);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAudit() throws WxErrorException {
|
||||
WxChannelCategoryService categoryService = channelService.getCategoryService();
|
||||
String auditId = "4403159413";
|
||||
AuditResponse response = categoryService.getAudit(auditId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
System.out.println(response);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListPassCategory() throws WxErrorException {
|
||||
WxChannelCategoryService categoryService = channelService.getCategoryService();
|
||||
PassCategoryResponse response = categoryService.listPassCategory();
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
System.out.println(response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.channel.api.WxChannelCouponService;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
|
||||
import me.chanjar.weixin.channel.bean.coupon.CouponIdResponse;
|
||||
import me.chanjar.weixin.channel.bean.coupon.CouponInfoResponse;
|
||||
import me.chanjar.weixin.channel.bean.coupon.CouponListParam;
|
||||
import me.chanjar.weixin.channel.bean.coupon.CouponListResponse;
|
||||
import me.chanjar.weixin.channel.bean.coupon.CouponParam;
|
||||
import me.chanjar.weixin.channel.bean.coupon.UserCouponListParam;
|
||||
import me.chanjar.weixin.channel.bean.coupon.UserCouponListResponse;
|
||||
import me.chanjar.weixin.channel.bean.coupon.UserCouponResponse;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxChannelCouponServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxChannelService channelService;
|
||||
|
||||
@Test
|
||||
public void testCreateCoupon() throws WxErrorException {
|
||||
WxChannelCouponService couponService = channelService.getCouponService();
|
||||
CouponParam param = new CouponParam();
|
||||
// ...
|
||||
CouponIdResponse response = couponService.createCoupon(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateCoupon() throws WxErrorException {
|
||||
WxChannelCouponService couponService = channelService.getCouponService();
|
||||
CouponParam param = new CouponParam();
|
||||
// ...
|
||||
CouponIdResponse response = couponService.updateCoupon(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateCouponStatus() throws WxErrorException {
|
||||
WxChannelCouponService couponService = channelService.getCouponService();
|
||||
String couponId = "";
|
||||
Integer status = 2;
|
||||
WxChannelBaseResponse response = couponService.updateCouponStatus(couponId, status);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCoupon() throws WxErrorException {
|
||||
WxChannelCouponService couponService = channelService.getCouponService();
|
||||
String couponId = "";
|
||||
CouponInfoResponse response = couponService.getCoupon(couponId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCouponList() throws WxErrorException {
|
||||
WxChannelCouponService couponService = channelService.getCouponService();
|
||||
CouponListParam param = new UserCouponListParam();
|
||||
CouponListResponse response = couponService.getCouponList(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUserCoupon() throws WxErrorException {
|
||||
WxChannelCouponService couponService = channelService.getCouponService();
|
||||
String couponId = "";
|
||||
String userCouponId = "";
|
||||
UserCouponResponse response = couponService.getUserCoupon(couponId, userCouponId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUserCouponList() throws WxErrorException {
|
||||
WxChannelCouponService couponService = channelService.getCouponService();
|
||||
UserCouponListParam param = new UserCouponListParam();
|
||||
UserCouponListResponse response = couponService.getUserCouponList(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.channel.api.WxChannelFreightTemplateService;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.bean.freight.FreightTemplate;
|
||||
import me.chanjar.weixin.channel.bean.freight.TemplateIdResponse;
|
||||
import me.chanjar.weixin.channel.bean.freight.TemplateInfoResponse;
|
||||
import me.chanjar.weixin.channel.bean.freight.TemplateListResponse;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxChannelFreightTemplateServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxChannelService channelService;
|
||||
|
||||
@Test
|
||||
public void testListTemplate() throws WxErrorException {
|
||||
WxChannelFreightTemplateService freightTemplateService = channelService.getFreightTemplateService();
|
||||
Integer offset = 0;
|
||||
Integer limit = 20;
|
||||
TemplateListResponse response = freightTemplateService.listTemplate(offset, limit);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTemplate() throws WxErrorException {
|
||||
WxChannelFreightTemplateService freightTemplateService = channelService.getFreightTemplateService();
|
||||
String templateId = "";
|
||||
TemplateInfoResponse response = freightTemplateService.getTemplate(templateId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddTemplate() throws WxErrorException {
|
||||
WxChannelFreightTemplateService freightTemplateService = channelService.getFreightTemplateService();
|
||||
FreightTemplate template = new FreightTemplate();
|
||||
// ...
|
||||
TemplateIdResponse response = freightTemplateService.addTemplate(template);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateTemplate() throws WxErrorException {
|
||||
WxChannelFreightTemplateService freightTemplateService = channelService.getFreightTemplateService();
|
||||
FreightTemplate template = new FreightTemplate();
|
||||
// ...
|
||||
TemplateIdResponse response = freightTemplateService.updateTemplate(template);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import me.chanjar.weixin.channel.api.WxChannelFundService;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
|
||||
import me.chanjar.weixin.channel.bean.fund.AccountInfo;
|
||||
import me.chanjar.weixin.channel.bean.fund.AccountInfoResponse;
|
||||
import me.chanjar.weixin.channel.bean.fund.BalanceInfoResponse;
|
||||
import me.chanjar.weixin.channel.bean.fund.FlowListResponse;
|
||||
import me.chanjar.weixin.channel.bean.fund.FundsFlowResponse;
|
||||
import me.chanjar.weixin.channel.bean.fund.FundsListParam;
|
||||
import me.chanjar.weixin.channel.bean.fund.WithdrawDetailResponse;
|
||||
import me.chanjar.weixin.channel.bean.fund.WithdrawListResponse;
|
||||
import me.chanjar.weixin.channel.bean.fund.WithdrawSubmitResponse;
|
||||
import me.chanjar.weixin.channel.bean.fund.bank.BankCityResponse;
|
||||
import me.chanjar.weixin.channel.bean.fund.bank.BankInfoResponse;
|
||||
import me.chanjar.weixin.channel.bean.fund.bank.BankListResponse;
|
||||
import me.chanjar.weixin.channel.bean.fund.bank.BankProvinceResponse;
|
||||
import me.chanjar.weixin.channel.bean.fund.bank.BranchInfoResponse;
|
||||
import me.chanjar.weixin.channel.bean.fund.qrcode.QrCheckResponse;
|
||||
import me.chanjar.weixin.channel.bean.fund.qrcode.QrCodeResponse;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxChannelFundServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxChannelService channelService;
|
||||
|
||||
@Test
|
||||
public void testGetBalance() throws WxErrorException {
|
||||
WxChannelFundService fundService = channelService.getFundService();
|
||||
BalanceInfoResponse response = fundService.getBalance();
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBankAccount() throws WxErrorException {
|
||||
WxChannelFundService fundService = channelService.getFundService();
|
||||
AccountInfoResponse response = fundService.getBankAccount();
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFundsFlowDetail() throws WxErrorException {
|
||||
WxChannelFundService fundService = channelService.getFundService();
|
||||
String flowId = "";
|
||||
FundsFlowResponse response = fundService.getFundsFlowDetail(flowId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListFundsFlow() throws WxErrorException {
|
||||
WxChannelFundService fundService = channelService.getFundService();
|
||||
FundsListParam param = new FundsListParam();
|
||||
FlowListResponse response = fundService.listFundsFlow(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetWithdrawDetail() throws WxErrorException {
|
||||
WxChannelFundService fundService = channelService.getFundService();
|
||||
String withdrawId = "";
|
||||
WithdrawDetailResponse response = fundService.getWithdrawDetail(withdrawId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListWithdraw() throws WxErrorException {
|
||||
WxChannelFundService fundService = channelService.getFundService();
|
||||
Integer pageNum = 1;
|
||||
Integer pageSize = 10;
|
||||
Long startTime = LocalDateTime.now().minusDays(7).atZone(ZoneId.systemDefault()).toEpochSecond();
|
||||
Long endTime = LocalDateTime.now().atZone(ZoneId.systemDefault()).toEpochSecond();
|
||||
WithdrawListResponse response = fundService.listWithdraw(pageNum, pageSize, startTime, endTime);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetBankAccount() throws WxErrorException {
|
||||
WxChannelFundService fundService = channelService.getFundService();
|
||||
AccountInfo accountInfo = new AccountInfo();
|
||||
// ...
|
||||
WxChannelBaseResponse response = fundService.setBankAccount(accountInfo);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubmitWithdraw() throws WxErrorException {
|
||||
WxChannelFundService fundService = channelService.getFundService();
|
||||
Integer amount = 1;
|
||||
String remark = "test";
|
||||
String bankMemo = "-";
|
||||
WithdrawSubmitResponse response = fundService.submitWithdraw(amount, remark, bankMemo);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBankInfoByCardNo() throws WxErrorException {
|
||||
WxChannelFundService fundService = channelService.getFundService();
|
||||
String accountNumber = "";
|
||||
BankInfoResponse response = fundService.getBankInfoByCardNo(accountNumber);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchBankList() throws WxErrorException {
|
||||
WxChannelFundService fundService = channelService.getFundService();
|
||||
Integer offset = 0;
|
||||
Integer limit = 20;
|
||||
String keywords = "";
|
||||
Integer bankType = 1;
|
||||
BankListResponse response = fundService.searchBankList(offset, limit, keywords, bankType);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchCityList() throws WxErrorException {
|
||||
WxChannelFundService fundService = channelService.getFundService();
|
||||
String provinceCode = "0";
|
||||
BankCityResponse response = fundService.searchCityList(provinceCode);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProvinceList() throws WxErrorException {
|
||||
WxChannelFundService fundService = channelService.getFundService();
|
||||
BankProvinceResponse response = fundService.getProvinceList();
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchBranchList() throws WxErrorException {
|
||||
WxChannelFundService fundService = channelService.getFundService();
|
||||
String bankCode = "";
|
||||
String cityCode = "";
|
||||
Integer offset = 0;
|
||||
Integer limit = 20;
|
||||
BranchInfoResponse response = fundService.searchBranchList(bankCode, cityCode, offset, limit);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetQrCode() throws WxErrorException {
|
||||
WxChannelFundService fundService = channelService.getFundService();
|
||||
String qrcodeTicket = "";
|
||||
QrCodeResponse response = fundService.getQrCode(qrcodeTicket);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckQrStatus() throws WxErrorException {
|
||||
WxChannelFundService fundService = channelService.getFundService();
|
||||
String qrcodeTicket = "";
|
||||
QrCheckResponse response = fundService.checkQrStatus(qrcodeTicket);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.chanjar.weixin.channel.api.WxChannelOrderService;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.bean.base.AddressInfo;
|
||||
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
|
||||
import me.chanjar.weixin.channel.bean.delivery.DeliveryCompanyResponse;
|
||||
import me.chanjar.weixin.channel.bean.delivery.DeliveryInfo;
|
||||
import me.chanjar.weixin.channel.bean.order.ChangeOrderInfo;
|
||||
import me.chanjar.weixin.channel.bean.order.DeliveryUpdateParam;
|
||||
import me.chanjar.weixin.channel.bean.order.OrderAddressInfo;
|
||||
import me.chanjar.weixin.channel.bean.order.OrderInfoResponse;
|
||||
import me.chanjar.weixin.channel.bean.order.OrderListParam;
|
||||
import me.chanjar.weixin.channel.bean.order.OrderListResponse;
|
||||
import me.chanjar.weixin.channel.bean.order.OrderSearchParam;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxChannelOrderServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxChannelService channelService;
|
||||
|
||||
@Test
|
||||
public void testGetOrder() throws WxErrorException {
|
||||
WxChannelOrderService orderService = channelService.getOrderService();
|
||||
String orderId = "";
|
||||
OrderInfoResponse response = orderService.getOrder(orderId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOrders() throws WxErrorException {
|
||||
WxChannelOrderService orderService = channelService.getOrderService();
|
||||
OrderListParam param = new OrderListParam();
|
||||
OrderListResponse response = orderService.getOrders(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchOrder() throws WxErrorException {
|
||||
WxChannelOrderService orderService = channelService.getOrderService();
|
||||
OrderSearchParam param = new OrderSearchParam();
|
||||
OrderListResponse response = orderService.searchOrder(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdatePrice() throws WxErrorException {
|
||||
WxChannelOrderService orderService = channelService.getOrderService();
|
||||
String orderId = "";
|
||||
Integer expressFee = 0;
|
||||
List<ChangeOrderInfo> changeOrderInfos = new ArrayList<>(4);
|
||||
ChangeOrderInfo changeOrderInfo = new ChangeOrderInfo();
|
||||
changeOrderInfos.add(changeOrderInfo);
|
||||
WxChannelBaseResponse response = orderService.updatePrice(orderId, expressFee, changeOrderInfos);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateRemark() throws WxErrorException {
|
||||
WxChannelOrderService orderService = channelService.getOrderService();
|
||||
String orderId = "";
|
||||
String merchantNotes = "";
|
||||
WxChannelBaseResponse response = orderService.updateRemark(orderId, merchantNotes);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAddress() throws WxErrorException {
|
||||
WxChannelOrderService orderService = channelService.getOrderService();
|
||||
String orderId = "";
|
||||
AddressInfo addressInfo = new OrderAddressInfo();
|
||||
WxChannelBaseResponse response = orderService.updateAddress(orderId, addressInfo);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateDelivery() throws WxErrorException {
|
||||
WxChannelOrderService orderService = channelService.getOrderService();
|
||||
DeliveryUpdateParam param = new DeliveryUpdateParam();
|
||||
WxChannelBaseResponse response = orderService.updateDelivery(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCloseOrder() {
|
||||
WxChannelOrderService orderService = channelService.getOrderService();
|
||||
String orderId = "";
|
||||
WxChannelBaseResponse response = orderService.closeOrder(orderId);
|
||||
assertNotNull(response);
|
||||
//assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListDeliveryCompany() throws WxErrorException {
|
||||
WxChannelOrderService orderService = channelService.getOrderService();
|
||||
DeliveryCompanyResponse response = orderService.listDeliveryCompany();
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeliveryOrder() throws WxErrorException {
|
||||
WxChannelOrderService orderService = channelService.getOrderService();
|
||||
String orderId = "";
|
||||
List<DeliveryInfo> deliveryList = new ArrayList<>(4);
|
||||
DeliveryInfo deliveryInfo = new DeliveryInfo();
|
||||
deliveryList.add(deliveryInfo);
|
||||
WxChannelBaseResponse response = orderService.deliveryOrder(orderId, deliveryList);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.channel.api.WxChannelProductService;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
|
||||
import me.chanjar.weixin.channel.bean.limit.LimitTaskAddResponse;
|
||||
import me.chanjar.weixin.channel.bean.limit.LimitTaskListResponse;
|
||||
import me.chanjar.weixin.channel.bean.limit.LimitTaskParam;
|
||||
import me.chanjar.weixin.channel.bean.product.SkuStockResponse;
|
||||
import me.chanjar.weixin.channel.bean.product.SpuGetResponse;
|
||||
import me.chanjar.weixin.channel.bean.product.SpuInfo;
|
||||
import me.chanjar.weixin.channel.bean.product.SpuListResponse;
|
||||
import me.chanjar.weixin.channel.bean.product.SpuUpdateResponse;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxChannelProductServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxChannelService channelService;
|
||||
|
||||
@Test
|
||||
public void testAddProduct() throws WxErrorException {
|
||||
WxChannelProductService productService = channelService.getProductService();
|
||||
SpuInfo spuInfo = new SpuInfo();
|
||||
// ...
|
||||
SpuUpdateResponse response = productService.addProduct(spuInfo);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateProduct() throws WxErrorException {
|
||||
WxChannelProductService productService = channelService.getProductService();
|
||||
SpuInfo spuInfo = new SpuInfo();
|
||||
// ...
|
||||
SpuUpdateResponse response = productService.updateProduct(spuInfo);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateStock() throws WxErrorException {
|
||||
WxChannelProductService productService = channelService.getProductService();
|
||||
String productId = "";
|
||||
String skuId = "";
|
||||
Integer diffType = 1;
|
||||
Integer num = 10;
|
||||
WxChannelBaseResponse response = productService.updateStock(productId, skuId, diffType, num);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteProduct() throws WxErrorException {
|
||||
WxChannelProductService productService = channelService.getProductService();
|
||||
String productId = "";
|
||||
WxChannelBaseResponse response = productService.deleteProduct(productId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCancelProductAudit() throws WxErrorException {
|
||||
WxChannelProductService productService = channelService.getProductService();
|
||||
String productId = "";
|
||||
WxChannelBaseResponse response = productService.cancelProductAudit(productId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProduct() throws WxErrorException {
|
||||
WxChannelProductService productService = channelService.getProductService();
|
||||
String productId = "10000029995861";
|
||||
Integer dataType = 3;
|
||||
SpuGetResponse response = productService.getProduct(productId, dataType);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListProduct() throws WxErrorException {
|
||||
WxChannelProductService productService = channelService.getProductService();
|
||||
Integer pageSize = 10;
|
||||
String nextKey = null;
|
||||
Integer status = null;
|
||||
SpuListResponse response = productService.listProduct(pageSize, nextKey, status);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpProduct() throws WxErrorException {
|
||||
WxChannelProductService productService = channelService.getProductService();
|
||||
String productId = "";
|
||||
WxChannelBaseResponse response = productService.upProduct(productId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDownProduct() throws WxErrorException {
|
||||
WxChannelProductService productService = channelService.getProductService();
|
||||
String productId = "";
|
||||
WxChannelBaseResponse response = productService.downProduct(productId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSkuStock() throws WxErrorException {
|
||||
WxChannelProductService productService = channelService.getProductService();
|
||||
String productId = "";
|
||||
String skuId = "";
|
||||
SkuStockResponse response = productService.getSkuStock(productId, skuId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddLimitTask() throws WxErrorException {
|
||||
WxChannelProductService productService = channelService.getProductService();
|
||||
LimitTaskParam param = new LimitTaskParam();
|
||||
// ...
|
||||
LimitTaskAddResponse response = productService.addLimitTask(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListLimitTask() throws WxErrorException {
|
||||
WxChannelProductService productService = channelService.getProductService();
|
||||
Integer pageSize = 1;
|
||||
String nextKey = "";
|
||||
Integer status = null;
|
||||
LimitTaskListResponse response = productService.listLimitTask(pageSize, nextKey, status);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStopLimitTask() throws WxErrorException {
|
||||
WxChannelProductService productService = channelService.getProductService();
|
||||
String taskId = "";
|
||||
WxChannelBaseResponse response = productService.stopLimitTask(taskId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteLimitTask() throws WxErrorException {
|
||||
WxChannelProductService productService = channelService.getProductService();
|
||||
String taskId = "";
|
||||
WxChannelBaseResponse response = productService.deleteLimitTask(taskId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.api.WxChannelSharerService;
|
||||
import me.chanjar.weixin.channel.bean.sharer.SharerBindResponse;
|
||||
import me.chanjar.weixin.channel.bean.sharer.SharerInfoResponse;
|
||||
import me.chanjar.weixin.channel.bean.sharer.SharerOrderParam;
|
||||
import me.chanjar.weixin.channel.bean.sharer.SharerOrderResponse;
|
||||
import me.chanjar.weixin.channel.bean.sharer.SharerSearchResponse;
|
||||
import me.chanjar.weixin.channel.bean.sharer.SharerUnbindResponse;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxChannelSharerServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxChannelService channelService;
|
||||
|
||||
@Test
|
||||
public void testBindSharer() throws WxErrorException {
|
||||
WxChannelSharerService sharerService = channelService.getSharerService();
|
||||
String username = "";
|
||||
SharerBindResponse response = sharerService.bindSharer(username);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchSharer() throws WxErrorException {
|
||||
WxChannelSharerService sharerService = channelService.getSharerService();
|
||||
String openid = "";
|
||||
String username = "";
|
||||
SharerSearchResponse response = sharerService.searchSharer(openid, username);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListSharer() throws WxErrorException {
|
||||
WxChannelSharerService sharerService = channelService.getSharerService();
|
||||
Integer page = 1;
|
||||
Integer pageSize = 10;
|
||||
Integer sharerType = 1;
|
||||
SharerInfoResponse response = sharerService.listSharer(page, pageSize, sharerType);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListSharerOrder() throws WxErrorException {
|
||||
WxChannelSharerService sharerService = channelService.getSharerService();
|
||||
SharerOrderParam param = new SharerOrderParam();
|
||||
SharerOrderResponse response = sharerService.listSharerOrder(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnbindSharer() throws WxErrorException {
|
||||
WxChannelSharerService sharerService = channelService.getSharerService();
|
||||
List<String> openIds = new ArrayList<>(4);
|
||||
openIds.add("");
|
||||
SharerUnbindResponse response = sharerService.unbindSharer(openIds);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.api.WxChannelWarehouseService;
|
||||
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
|
||||
import me.chanjar.weixin.channel.bean.warehouse.LocationPriorityResponse;
|
||||
import me.chanjar.weixin.channel.bean.warehouse.PriorityLocationParam;
|
||||
import me.chanjar.weixin.channel.bean.warehouse.WarehouseIdsResponse;
|
||||
import me.chanjar.weixin.channel.bean.warehouse.WarehouseLocation;
|
||||
import me.chanjar.weixin.channel.bean.warehouse.WarehouseParam;
|
||||
import me.chanjar.weixin.channel.bean.warehouse.WarehouseResponse;
|
||||
import me.chanjar.weixin.channel.bean.warehouse.WarehouseStockParam;
|
||||
import me.chanjar.weixin.channel.bean.warehouse.WarehouseStockResponse;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxChannelWarehouseServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxChannelService channelService;
|
||||
|
||||
@Test
|
||||
public void testCreateWarehouse() throws WxErrorException {
|
||||
WxChannelWarehouseService warehouseService = channelService.getWarehouseService();
|
||||
WarehouseParam param = new WarehouseParam();
|
||||
// ...
|
||||
WxChannelBaseResponse response = warehouseService.createWarehouse(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListWarehouse() throws WxErrorException {
|
||||
WxChannelWarehouseService warehouseService = channelService.getWarehouseService();
|
||||
Integer pageSize = 10;
|
||||
WarehouseIdsResponse response = warehouseService.listWarehouse(pageSize, null);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetWarehouse() throws WxErrorException {
|
||||
WxChannelWarehouseService warehouseService = channelService.getWarehouseService();
|
||||
String warehouseId = "123";
|
||||
WarehouseResponse response = warehouseService.getWarehouse(warehouseId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateWarehouse() throws WxErrorException {
|
||||
WxChannelWarehouseService warehouseService = channelService.getWarehouseService();
|
||||
String outWarehouseId = "";
|
||||
String name = "";
|
||||
String intro = "";
|
||||
WxChannelBaseResponse response = warehouseService.updateWarehouse(outWarehouseId, name, intro);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddWarehouseArea() throws WxErrorException {
|
||||
WxChannelWarehouseService warehouseService = channelService.getWarehouseService();
|
||||
String outWarehouseId = "";
|
||||
List<WarehouseLocation> coverLocations = new ArrayList<>(4);
|
||||
WarehouseLocation location = new WarehouseLocation();
|
||||
coverLocations.add(location);
|
||||
WxChannelBaseResponse response = warehouseService.addWarehouseArea(outWarehouseId, coverLocations);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteWarehouseArea() throws WxErrorException {
|
||||
WxChannelWarehouseService warehouseService = channelService.getWarehouseService();
|
||||
String outWarehouseId = "";
|
||||
List<WarehouseLocation> coverLocations = new ArrayList<>(4);
|
||||
WarehouseLocation location = new WarehouseLocation();
|
||||
coverLocations.add(location);
|
||||
WxChannelBaseResponse response = warehouseService.deleteWarehouseArea(outWarehouseId, coverLocations);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetWarehousePriority() throws WxErrorException {
|
||||
WxChannelWarehouseService warehouseService = channelService.getWarehouseService();
|
||||
PriorityLocationParam param = new PriorityLocationParam();
|
||||
WxChannelBaseResponse response = warehouseService.setWarehousePriority(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetWarehousePriority() throws WxErrorException {
|
||||
WxChannelWarehouseService warehouseService = channelService.getWarehouseService();
|
||||
Integer addressId1 = 1;
|
||||
Integer addressId2 = 2;
|
||||
Integer addressId3 = 3;
|
||||
Integer addressId4 = 4;
|
||||
LocationPriorityResponse response = warehouseService
|
||||
.getWarehousePriority(addressId1, addressId2, addressId3, addressId4);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateWarehouseStock() throws WxErrorException {
|
||||
WxChannelWarehouseService warehouseService = channelService.getWarehouseService();
|
||||
WarehouseStockParam param = new WarehouseStockParam();
|
||||
WxChannelBaseResponse response = warehouseService.updateWarehouseStock(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetWarehouseStock() throws WxErrorException {
|
||||
WxChannelWarehouseService warehouseService = channelService.getWarehouseService();
|
||||
String productId = "";
|
||||
String skuId = "";
|
||||
String outWarehouseId = "";
|
||||
WarehouseStockResponse response = warehouseService.getWarehouseStock(productId, skuId, outWarehouseId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.api.WxLeagueProductService;
|
||||
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
|
||||
import me.chanjar.weixin.channel.bean.league.product.BatchAddParam;
|
||||
import me.chanjar.weixin.channel.bean.league.product.BatchAddResponse;
|
||||
import me.chanjar.weixin.channel.bean.league.product.ProductDetailParam;
|
||||
import me.chanjar.weixin.channel.bean.league.product.ProductDetailResponse;
|
||||
import me.chanjar.weixin.channel.bean.league.product.ProductListParam;
|
||||
import me.chanjar.weixin.channel.bean.league.product.ProductListResponse;
|
||||
import me.chanjar.weixin.channel.bean.league.product.ProductUpdateParam;
|
||||
import me.chanjar.weixin.channel.bean.league.product.ProductUpdateResponse;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxLeagueProductServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxChannelService channelService;
|
||||
|
||||
@Test
|
||||
public void testBatchAddProduct() throws WxErrorException {
|
||||
WxLeagueProductService leagueProductService = channelService.getLeagueProductService();
|
||||
BatchAddParam param = new BatchAddParam();
|
||||
BatchAddResponse response = leagueProductService.batchAddProduct(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateProduct() throws WxErrorException {
|
||||
WxLeagueProductService leagueProductService = channelService.getLeagueProductService();
|
||||
ProductUpdateParam param = new ProductUpdateParam();
|
||||
ProductUpdateResponse response = leagueProductService.updateProduct(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteProduct() throws WxErrorException {
|
||||
WxLeagueProductService leagueProductService = channelService.getLeagueProductService();
|
||||
Integer type = 1;
|
||||
String productId = "";
|
||||
WxChannelBaseResponse response = leagueProductService.deleteProduct(type, productId, null);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProductDetail() throws WxErrorException {
|
||||
WxLeagueProductService leagueProductService = channelService.getLeagueProductService();
|
||||
ProductDetailParam param = new ProductDetailParam();
|
||||
ProductDetailResponse response = leagueProductService.getProductDetail(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListProduct() throws WxErrorException {
|
||||
WxLeagueProductService leagueProductService = channelService.getLeagueProductService();
|
||||
ProductListParam param = new ProductListParam();
|
||||
ProductListResponse response = leagueProductService.listProduct(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.api.WxLeaguePromoterService;
|
||||
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
|
||||
import me.chanjar.weixin.channel.bean.league.promoter.PromoterInfoResponse;
|
||||
import me.chanjar.weixin.channel.bean.league.promoter.PromoterListResponse;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxLeaguePromoterServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxChannelService channelService;
|
||||
|
||||
@Test
|
||||
public void testAddPromoter() throws WxErrorException {
|
||||
WxLeaguePromoterService leaguePromoterService = channelService.getLeaguePromoterService();
|
||||
String finderId = "";
|
||||
WxChannelBaseResponse response = leaguePromoterService.addPromoter(finderId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdatePromoter() throws WxErrorException {
|
||||
WxLeaguePromoterService leaguePromoterService = channelService.getLeaguePromoterService();
|
||||
String finderId = "";
|
||||
int type = 1;
|
||||
WxChannelBaseResponse response = leaguePromoterService.updatePromoter(finderId, type);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeletePromoter() throws WxErrorException {
|
||||
WxLeaguePromoterService leaguePromoterService = channelService.getLeaguePromoterService();
|
||||
String finderId = "";
|
||||
WxChannelBaseResponse response = leaguePromoterService.deletePromoter(finderId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPromoterInfo() throws WxErrorException {
|
||||
WxLeaguePromoterService leaguePromoterService = channelService.getLeaguePromoterService();
|
||||
String finderId = "";
|
||||
PromoterInfoResponse response = leaguePromoterService.getPromoterInfo(finderId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListPromoter() throws WxErrorException {
|
||||
WxLeaguePromoterService leaguePromoterService = channelService.getLeaguePromoterService();
|
||||
Integer pageIndex = 1;
|
||||
Integer pageSize = 10;
|
||||
Integer status = null;
|
||||
PromoterListResponse response = leaguePromoterService.listPromoter(pageIndex, pageSize, status);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.api.WxLeagueSupplierService;
|
||||
import me.chanjar.weixin.channel.bean.league.supplier.CommissionOrderListParam;
|
||||
import me.chanjar.weixin.channel.bean.league.supplier.CommissionOrderListResponse;
|
||||
import me.chanjar.weixin.channel.bean.league.supplier.CommissionOrderResponse;
|
||||
import me.chanjar.weixin.channel.bean.league.supplier.CoopProductListResponse;
|
||||
import me.chanjar.weixin.channel.bean.league.supplier.CoopProductResponse;
|
||||
import me.chanjar.weixin.channel.bean.league.supplier.FlowListParam;
|
||||
import me.chanjar.weixin.channel.bean.league.supplier.ShopDetailResponse;
|
||||
import me.chanjar.weixin.channel.bean.league.supplier.ShopListResponse;
|
||||
import me.chanjar.weixin.channel.bean.league.supplier.SupplierBalanceResponse;
|
||||
import me.chanjar.weixin.channel.bean.league.supplier.SupplierFlowDetailResponse;
|
||||
import me.chanjar.weixin.channel.bean.league.supplier.SupplierFlowListResponse;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxLeagueSupplierServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxChannelService channelService;
|
||||
|
||||
@Test
|
||||
public void testGetBalanceInfo() throws WxErrorException {
|
||||
WxLeagueSupplierService leagueSupplierService = channelService.getLeagueSupplierService();
|
||||
SupplierBalanceResponse response = leagueSupplierService.getBalanceInfo();
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFlowDetail() throws WxErrorException {
|
||||
WxLeagueSupplierService leagueSupplierService = channelService.getLeagueSupplierService();
|
||||
String flowId = "";
|
||||
SupplierFlowDetailResponse response = leagueSupplierService.getFlowDetail(flowId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFlowList() throws WxErrorException {
|
||||
WxLeagueSupplierService leagueSupplierService = channelService.getLeagueSupplierService();
|
||||
FlowListParam param = new FlowListParam();
|
||||
SupplierFlowListResponse response = leagueSupplierService.getFlowList(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProductDetail() throws WxErrorException {
|
||||
WxLeagueSupplierService leagueSupplierService = channelService.getLeagueSupplierService();
|
||||
String productId = "";
|
||||
String appId = "";
|
||||
CoopProductResponse response = leagueSupplierService.getProductDetail(productId, appId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProductList() throws WxErrorException {
|
||||
WxLeagueSupplierService leagueSupplierService = channelService.getLeagueSupplierService();
|
||||
String appId = "";
|
||||
Integer pageSize = 10;
|
||||
String nextKey = null;
|
||||
CoopProductListResponse response = leagueSupplierService.getProductList(appId, pageSize, nextKey);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCommissionOrder() throws WxErrorException {
|
||||
WxLeagueSupplierService leagueSupplierService = channelService.getLeagueSupplierService();
|
||||
String orderId = "";
|
||||
String skuId = "";
|
||||
CommissionOrderResponse response = leagueSupplierService.getCommissionOrder(orderId, skuId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCommissionOrderList() throws WxErrorException {
|
||||
WxLeagueSupplierService leagueSupplierService = channelService.getLeagueSupplierService();
|
||||
CommissionOrderListParam param = new CommissionOrderListParam();
|
||||
CommissionOrderListResponse response = leagueSupplierService.getCommissionOrderList(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetShopDetail() throws WxErrorException {
|
||||
WxLeagueSupplierService leagueSupplierService = channelService.getLeagueSupplierService();
|
||||
String appId = "";
|
||||
ShopDetailResponse response = leagueSupplierService.getShopDetail(appId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetShopList() throws WxErrorException {
|
||||
WxLeagueSupplierService leagueSupplierService = channelService.getLeagueSupplierService();
|
||||
Integer pageSize = 10;
|
||||
String nextKey = null;
|
||||
ShopListResponse response = leagueSupplierService.getShopList(pageSize, nextKey);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.api.WxLeagueProductService;
|
||||
import me.chanjar.weixin.channel.api.WxLeagueWindowService;
|
||||
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
|
||||
import me.chanjar.weixin.channel.bean.league.product.BatchAddParam;
|
||||
import me.chanjar.weixin.channel.bean.league.product.BatchAddResponse;
|
||||
import me.chanjar.weixin.channel.bean.league.window.AuthInfoResponse;
|
||||
import me.chanjar.weixin.channel.bean.league.window.AuthStatusResponse;
|
||||
import me.chanjar.weixin.channel.bean.league.window.ProductSearchParam;
|
||||
import me.chanjar.weixin.channel.bean.league.window.WindowProductListResponse;
|
||||
import me.chanjar.weixin.channel.bean.league.window.WindowProductResponse;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxLeagueWindowServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxChannelService channelService;
|
||||
|
||||
@Test
|
||||
public void testAddProduct() throws WxErrorException {
|
||||
WxLeagueWindowService leagueWindowService = channelService.getLeagueWindowService();
|
||||
String appid = "";
|
||||
String openfinderid = "";
|
||||
String productId = "";
|
||||
WxChannelBaseResponse response = leagueWindowService.addProduct(appid, openfinderid, productId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListProduct() throws WxErrorException {
|
||||
WxLeagueWindowService leagueWindowService = channelService.getLeagueWindowService();
|
||||
ProductSearchParam param = new ProductSearchParam();
|
||||
WindowProductListResponse response = leagueWindowService.listProduct(param);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveProduct() throws WxErrorException {
|
||||
WxLeagueWindowService leagueWindowService = channelService.getLeagueWindowService();
|
||||
String appid = "";
|
||||
String openfinderid = "";
|
||||
String productId = "";
|
||||
WxChannelBaseResponse response = leagueWindowService.removeProduct(appid, openfinderid, productId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProductDetail() throws WxErrorException {
|
||||
WxLeagueWindowService leagueWindowService = channelService.getLeagueWindowService();
|
||||
String appid = "";
|
||||
String openfinderid = "";
|
||||
String productId = "";
|
||||
WindowProductResponse response = leagueWindowService.getProductDetail(appid, openfinderid, productId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetWindowAuthInfo() throws WxErrorException {
|
||||
WxLeagueWindowService leagueWindowService = channelService.getLeagueWindowService();
|
||||
String finderId = "";
|
||||
AuthInfoResponse response = leagueWindowService.getWindowAuthInfo(finderId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetWindowAuthStatus() throws WxErrorException {
|
||||
WxLeagueWindowService leagueWindowService = channelService.getLeagueWindowService();
|
||||
String finderId = "";
|
||||
AuthStatusResponse response = leagueWindowService.getWindowAuthStatus(finderId);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package me.chanjar.weixin.channel.message;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import me.chanjar.weixin.channel.bean.message.order.OrderPayMessage;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author LiXiZe
|
||||
* @date 2023-04-20
|
||||
*/
|
||||
public class WxChannelMessageRouterRuleTest {
|
||||
|
||||
@Test
|
||||
public void testResolveMessageClass() {
|
||||
WxChannelMessageRouterRule<OrderPayMessage> rule = new WxChannelMessageRouterRule<>();
|
||||
rule.setMessageClass(OrderPayMessage.class);
|
||||
assertEquals(rule.getMessageClass(), OrderPayMessage.class);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package me.chanjar.weixin.channel.message;
|
||||
|
||||
import static me.chanjar.weixin.channel.constant.MessageEventConstants.BRAND;
|
||||
import static me.chanjar.weixin.channel.constant.MessageEventConstants.PRODUCT_SPU_AUDIT;
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Map;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.bean.message.product.BrandMessage;
|
||||
import me.chanjar.weixin.channel.bean.message.product.SpuAuditMessage;
|
||||
import me.chanjar.weixin.channel.message.rule.HandlerConsumer;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
import me.chanjar.weixin.channel.util.JsonUtils;
|
||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author LiXiZe
|
||||
* @date 2023-04-21
|
||||
*/
|
||||
@Slf4j
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxChannelMessageRouterTest {
|
||||
|
||||
@Inject
|
||||
private WxChannelService channelService;
|
||||
|
||||
@Test
|
||||
public void test1() {
|
||||
WxChannelMessageRouter router = new WxChannelMessageRouter();
|
||||
/* 品牌资质事件回调 */
|
||||
this.addRule(router, BrandMessage.class, BRAND, this::brandUpdate);
|
||||
/* 商品审核结果 */
|
||||
this.addRule(router, SpuAuditMessage.class, PRODUCT_SPU_AUDIT, this::spuAudit);
|
||||
String spuAuditJson = "{\n"
|
||||
+ " \"ToUserName\":\"gh_*\",\n"
|
||||
+ " \"FromUserName\":\"OPENID\",\n"
|
||||
+ " \"CreateTime\":1662480000,\n"
|
||||
+ " \"MsgType\":\"event\",\n"
|
||||
+ " \"Event\":\"product_spu_audit\",\n"
|
||||
+ " \"ProductSpuAudit\": {\n"
|
||||
+ " \"product_id\":\"12345678\",\n"
|
||||
+ " \"status\":3,\n"
|
||||
+ " \"reason\":\"abc\"\n"
|
||||
+ " }\n"
|
||||
+ "}";
|
||||
WxChannelMessage message = JsonUtils.decode(spuAuditJson, WxChannelMessage.class);
|
||||
Object result = router.route(message, spuAuditJson, "xxxWWQQxxx", channelService);
|
||||
if (result != null) {
|
||||
log.info("result:{}", result);
|
||||
} else {
|
||||
log.info("return null");
|
||||
}
|
||||
}
|
||||
|
||||
public void brandUpdate(BrandMessage message, String content, String appId,
|
||||
Map<String, Object> context, WxSessionManager sessionManager) {
|
||||
log.info("品牌更新:{}", JsonUtils.encode(message));
|
||||
}
|
||||
|
||||
|
||||
public void spuAudit(SpuAuditMessage message, String content, String appId,
|
||||
Map<String, Object> context, WxSessionManager sessionManager) {
|
||||
log.info("商品审核:{}", JsonUtils.encode(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加一条规则进入路由器
|
||||
*
|
||||
* @param clazz 消息类型
|
||||
* @param event 事件类型
|
||||
* @param consumer 处理器
|
||||
* @param <T> 消息类型
|
||||
*/
|
||||
protected <T extends WxChannelMessage> void addRule(WxChannelMessageRouter router, Class<T> clazz, String event,
|
||||
HandlerConsumer<T, String, String, Map<String, Object>, WxSessionManager> consumer) {
|
||||
WxChannelMessageRouterRule<T> rule = new WxChannelMessageRouterRule<>();
|
||||
rule.setMessageClass(clazz).setEvent(event).setAsync(false);
|
||||
rule.getHandlers().add((message, content, appId, context, sessionManager) -> {
|
||||
consumer.accept(message, content, appId, context, sessionManager);
|
||||
return "success";
|
||||
});
|
||||
router.getRules().add(rule);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package me.chanjar.weixin.channel.test;
|
||||
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.Module;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.api.impl.WxChannelServiceImpl;
|
||||
import me.chanjar.weixin.channel.util.XmlUtils;
|
||||
import me.chanjar.weixin.common.error.WxRuntimeException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* 测试模块
|
||||
*
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
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 inputStream = ClassLoader.getSystemResourceAsStream(TEST_CONFIG_XML)) {
|
||||
if (inputStream == null) {
|
||||
throw new WxRuntimeException(
|
||||
"测试配置文件【" + TEST_CONFIG_XML + "】未找到,请参照test-config-sample.xml文件生成");
|
||||
}
|
||||
|
||||
TestConfig config = this.fromXml(TestConfig.class, inputStream);
|
||||
WxChannelService service = new WxChannelServiceImpl();
|
||||
|
||||
service.setConfig(config);
|
||||
|
||||
binder.bind(TestConfig.class).toInstance(config);
|
||||
binder.bind(WxChannelService.class).toInstance(service);
|
||||
} catch (IOException e) {
|
||||
this.log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private <T> T fromXml(Class<T> clazz, InputStream is) {
|
||||
return XmlUtils.decode(is, clazz);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package me.chanjar.weixin.channel.test;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.chanjar.weixin.channel.config.impl.WxChannelDefaultConfigImpl;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class TestConfig extends WxChannelDefaultConfigImpl {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package me.chanjar.weixin.channel.util;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import me.chanjar.weixin.channel.bean.base.AttrInfo;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
public class JsonUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testEncode() {
|
||||
AttrInfo info = new AttrInfo("这是Key", "这是Value");
|
||||
String json = JsonUtils.encode(info);
|
||||
System.out.println(json);
|
||||
assertNotNull(json);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecode() {
|
||||
String json = "{\"attr_key\": \"这是Key\",\"attr_value\": \"这是Value\"}";
|
||||
AttrInfo info = JsonUtils.decode(json, AttrInfo.class);
|
||||
assertNotNull(info);
|
||||
assertEquals(info.getKey(), "这是Key");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package me.chanjar.weixin.channel.util;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import me.chanjar.weixin.channel.bean.shop.ShopInfoResponse;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
public class ResponseUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testDecode() {
|
||||
String json = "{\"errcode\":0,\"errmsg\":\"ok\",\"info\":{\"nickname\":\"某某视频号\","
|
||||
+ "\"headimg_url\":\"http://wx.qlogo.cn/xxx\",\"subject_type\":\"企业\"}}";
|
||||
ShopInfoResponse response = ResponseUtils.decode(json, ShopInfoResponse.class);
|
||||
assertNotNull(response);
|
||||
assertEquals(response.getErrCode(), 0);
|
||||
assertEquals(response.getErrMsg(), "ok");
|
||||
assertEquals(response.getInfo().getNickname(), "某某视频号");
|
||||
assertEquals(response.getInfo().getHeadImgUrl(), "http://wx.qlogo.cn/xxx");
|
||||
assertEquals(response.getInfo().getSubjectType(), "企业");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInternalError() {
|
||||
ShopInfoResponse response = ResponseUtils.internalError(ShopInfoResponse.class);
|
||||
assertNotNull(response);
|
||||
assertEquals(response.getErrCode(), -99);
|
||||
}
|
||||
}
|
||||
13
weixin-java-channel/src/test/resources/logback-test.xml
Normal file
13
weixin-java-channel/src/test/resources/logback-test.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<configuration>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %replace(%caller{1}){'Caller', ''} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="debug">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
@@ -0,0 +1,9 @@
|
||||
<xml>
|
||||
<msgDataFormat>JSON或者XML</msgDataFormat>
|
||||
<appid>appid</appid>
|
||||
<secret>secret</secret>
|
||||
<token>Token</token>
|
||||
<aesKey>EncodingAESKey</aesKey>
|
||||
<accessToken>可以不填写</accessToken>
|
||||
<expiresTime>可以不填写</expiresTime>
|
||||
</xml>
|
||||
11
weixin-java-channel/src/test/resources/testng.xml
Normal file
11
weixin-java-channel/src/test/resources/testng.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
||||
|
||||
<suite name="Weixin-java-tool-suite" verbose="1">
|
||||
<test name="Result_Test">
|
||||
<classes>
|
||||
<!--<class name="me.chanjar.weixin.open.bean.result.WxFastMaAccountBasicInfoResultTest"/>
|
||||
<class name="me.chanjar.weixin.open.bean.result.WxFastMaCanSetCategoryResultTest"/>
|
||||
<class name="me.chanjar.weixin.open.bean.result.WxFastMaBeenSetCategoryResultTest"/>-->
|
||||
</classes>
|
||||
</test>
|
||||
</suite>
|
||||
BIN
weixin-java-channel/src/test/resources/tmp.png
Normal file
BIN
weixin-java-channel/src/test/resources/tmp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
Reference in New Issue
Block a user