mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-23 13:06:54 +08:00
尽量使用接口引用 use interface where possible
This commit is contained in:
parent
639206ca1a
commit
1ceb4bf707
@ -18,10 +18,10 @@ public class ApiTestModule implements Module {
|
||||
.getSystemResourceAsStream("test-config.xml")) {
|
||||
WxXmlMpInMemoryConfigStorage config = this
|
||||
.fromXml(WxXmlMpInMemoryConfigStorage.class, is1);
|
||||
WxMpServiceImpl wxService = new WxMpServiceImpl();
|
||||
WxMpService wxService = new WxMpServiceImpl();
|
||||
wxService.setWxMpConfigStorage(config);
|
||||
|
||||
binder.bind(WxMpServiceImpl.class).toInstance(wxService);
|
||||
binder.bind(WxMpService.class).toInstance(wxService);
|
||||
binder.bind(WxMpConfigStorage.class).toInstance(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -2,7 +2,6 @@ package me.chanjar.weixin.mp.api;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Guice;
|
||||
@ -18,7 +17,7 @@ import org.testng.annotations.Test;
|
||||
public class WxMpBaseAPITest {
|
||||
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
protected WxMpService wxService;
|
||||
|
||||
public void testRefreshAccessToken() throws WxErrorException {
|
||||
WxMpConfigStorage configStorage = this.wxService.getWxMpConfigStorage();
|
||||
|
@ -8,7 +8,6 @@ import com.google.inject.Inject;
|
||||
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.crypto.SHA1;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||
|
||||
/**
|
||||
* 测试jsapi ticket接口
|
||||
@ -20,7 +19,7 @@ import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||
public class WxMpJsAPITest {
|
||||
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
protected WxMpService wxService;
|
||||
|
||||
|
||||
public void testJsapiTicket() throws WxErrorException {
|
||||
|
@ -13,7 +13,6 @@ import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMassNews;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMassTagMessage;
|
||||
@ -31,7 +30,7 @@ import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult;
|
||||
public class WxMpMassMessageAPITest {
|
||||
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
protected WxMpService wxService;
|
||||
|
||||
@Test
|
||||
public void testTextMassOpenIdsMessageSend() throws WxErrorException {
|
||||
|
@ -2,7 +2,6 @@ package me.chanjar.weixin.mp.api;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
@ -19,7 +18,7 @@ import java.util.Arrays;
|
||||
public class WxMpMiscAPITest {
|
||||
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
protected WxMpService wxService;
|
||||
|
||||
@Test
|
||||
public void testGetCallbackIP() throws WxErrorException {
|
||||
|
@ -2,7 +2,6 @@ package me.chanjar.weixin.mp.api;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
@ -17,7 +16,7 @@ import org.testng.annotations.Test;
|
||||
public class WxMpShortUrlAPITest {
|
||||
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
protected WxMpService wxService;
|
||||
|
||||
public void testShortUrl() throws WxErrorException {
|
||||
String shortUrl = this.wxService.shortUrl("www.baidu.com");
|
||||
|
@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.api.impl;
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.bean.WxCardApiSignature;
|
||||
import me.chanjar.weixin.mp.api.ApiTestModule;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpCardResult;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
@ -19,7 +20,7 @@ import static org.testng.AssertJUnit.assertNotNull;
|
||||
public class WxMpCardServiceImplTest {
|
||||
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
protected WxMpService wxService;
|
||||
private String cardId = "123";
|
||||
private String code = "good";
|
||||
private String openid = "abc";
|
||||
|
@ -4,6 +4,7 @@ import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import org.apache.commons.lang3.time.FastDateFormat;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
@ -32,7 +33,7 @@ public class WxMpDataCubeServiceImplTest {
|
||||
.getInstance("yyyy-MM-dd");
|
||||
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
protected WxMpService wxService;
|
||||
|
||||
@DataProvider
|
||||
public Object[][] oneDay() throws ParseException {
|
||||
|
@ -4,6 +4,7 @@ import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.ApiTestModule;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage;
|
||||
import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
|
||||
import me.chanjar.weixin.mp.bean.kefu.request.WxMpKfAccountRequest;
|
||||
@ -27,7 +28,7 @@ import java.util.Date;
|
||||
public class WxMpKefuServiceImplTest {
|
||||
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
protected WxMpService wxService;
|
||||
|
||||
public void testSendKefuMpNewsMessage() throws WxErrorException {
|
||||
WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage) this.wxService
|
||||
|
@ -6,6 +6,7 @@ import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.fs.FileUtils;
|
||||
import me.chanjar.weixin.mp.api.ApiTestModule;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.material.WxMpMaterial;
|
||||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialArticleUpdate;
|
||||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews;
|
||||
@ -32,7 +33,7 @@ import static org.junit.Assert.*;
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxMpMaterialServiceImplTest {
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
protected WxMpService wxService;
|
||||
|
||||
private Map<String, Map<String, Object>> mediaIds = new LinkedHashMap<>();
|
||||
// 缩略图的id,测试上传图文使用
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.chanjar.weixin.mp.api.impl;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Guice;
|
||||
@ -24,7 +25,7 @@ import me.chanjar.weixin.mp.api.ApiTestModule;
|
||||
public class WxMpMenuServiceImplTest {
|
||||
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
protected WxMpService wxService;
|
||||
|
||||
@Test(dataProvider = "menu")
|
||||
public void testCreateMenu(WxMenu wxMenu) throws WxErrorException {
|
||||
|
@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.api.impl;
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.ApiTestModule;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage;
|
||||
import me.chanjar.weixin.mp.bean.pay.request.WxEntPayRequest;
|
||||
import me.chanjar.weixin.mp.bean.pay.request.WxPayRefundRequest;
|
||||
@ -26,7 +27,7 @@ import java.io.File;
|
||||
public class WxMpPayServiceImplTest {
|
||||
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
protected WxMpService wxService;
|
||||
|
||||
@Test
|
||||
public void testGetPayInfo() throws Exception {
|
||||
@ -65,7 +66,6 @@ public class WxMpPayServiceImplTest {
|
||||
|
||||
/**
|
||||
* Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpPayServiceImpl#unifiedOrder(WxPayUnifiedOrderRequest)}.
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Test
|
||||
public void testUnifiedOrder() throws WxErrorException {
|
||||
@ -78,7 +78,6 @@ public class WxMpPayServiceImplTest {
|
||||
|
||||
/**
|
||||
* Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpPayServiceImpl#queryOrder(String, String)} .
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Test
|
||||
public final void testQueryOrder() throws WxErrorException {
|
||||
@ -89,7 +88,6 @@ public class WxMpPayServiceImplTest {
|
||||
|
||||
/**
|
||||
* Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpPayServiceImpl#closeOrder(String)} .
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Test
|
||||
public final void testCloseOrder() throws WxErrorException {
|
||||
@ -98,7 +96,6 @@ public class WxMpPayServiceImplTest {
|
||||
|
||||
/**
|
||||
* Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpPayServiceImpl#entPay(WxEntPayRequest, File)}.
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Test
|
||||
public final void testEntPay() throws WxErrorException {
|
||||
@ -109,7 +106,6 @@ public class WxMpPayServiceImplTest {
|
||||
|
||||
/**
|
||||
* Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpPayServiceImpl#queryEntPay(String, File)}.
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Test
|
||||
public final void testQueryEntPay() throws WxErrorException {
|
||||
|
@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.api.impl;
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.ApiTestModule;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Guice;
|
||||
@ -20,7 +21,7 @@ import java.io.File;
|
||||
public class WxMpQrCodeServiceImplTest {
|
||||
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
protected WxMpService wxService;
|
||||
|
||||
public void testQrCodeCreateTmpTicket() throws WxErrorException {
|
||||
WxMpQrCodeTicket ticket = this.wxService.getQrcodeService().qrCodeCreateTmpTicket(1, null);
|
||||
|
@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.api.impl;
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.mp.api.ApiTestModule;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Guice;
|
||||
@ -13,7 +14,7 @@ import org.testng.annotations.Test;
|
||||
public class WxMpServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxMpServiceImpl wxService;
|
||||
private WxMpService wxService;
|
||||
|
||||
@Test
|
||||
public void testCheckSignature() {
|
||||
|
@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.api.impl;
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.ApiTestModule;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.store.WxMpStoreBaseInfo;
|
||||
import me.chanjar.weixin.mp.bean.store.WxMpStoreInfo;
|
||||
import me.chanjar.weixin.mp.bean.store.WxMpStoreListResult;
|
||||
@ -23,7 +24,7 @@ import static org.junit.Assert.assertNotNull;
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxMpStoreServiceImplTest {
|
||||
@Inject
|
||||
private WxMpServiceImpl wxMpService;
|
||||
private WxMpService wxMpService;
|
||||
|
||||
/**
|
||||
* Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpStoreServiceImpl#add(me.chanjar.weixin.mp.bean.store.WxMpStoreBaseInfo)}.
|
||||
|
@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.api.impl;
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.ApiTestModule;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage;
|
||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplate;
|
||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
|
||||
@ -25,7 +26,7 @@ import java.util.List;
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxMpTemplateMsgServiceImplTest {
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
protected WxMpService wxService;
|
||||
|
||||
@Test(invocationCount = 10, threadPoolSize = 10)
|
||||
public void testSendTemplateMsg() throws WxErrorException {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.chanjar.weixin.mp.api.impl;
|
||||
|
||||
import me.chanjar.weixin.mp.api.ApiTestModule;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpUserBlacklistGetResult;
|
||||
import org.testng.Assert;
|
||||
@ -18,7 +19,7 @@ import java.util.List;
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxMpUserBlacklistServiceImplTest {
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
protected WxMpService wxService;
|
||||
|
||||
@Test
|
||||
public void testGetBlacklist() throws Exception {
|
||||
|
@ -4,6 +4,7 @@ package me.chanjar.weixin.mp.api.impl;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Guice;
|
||||
@ -29,7 +30,7 @@ import me.chanjar.weixin.mp.bean.result.WxMpUserList;
|
||||
public class WxMpUserServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxMpServiceImpl wxService;
|
||||
private WxMpService wxService;
|
||||
|
||||
private WxXmlMpInMemoryConfigStorage configProvider;
|
||||
|
||||
|
@ -2,6 +2,7 @@ package me.chanjar.weixin.mp.api.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
@ -22,7 +23,7 @@ import me.chanjar.weixin.mp.bean.tag.WxUserTag;
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxMpUserTagServiceImplTest {
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
protected WxMpService wxService;
|
||||
|
||||
private Long tagId = 2L;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user