1.rename openId to openid 2.rename blackList to blacklist 3.refine blacklist test

This commit is contained in:
miller
2016-09-20 15:22:59 +08:00
parent b941a57ccd
commit 63c41d44ab
16 changed files with 143 additions and 139 deletions

View File

@@ -43,16 +43,16 @@ public class ApiTestModule implements Module {
public static class WxXmlMpInMemoryConfigStorage
extends WxMpInMemoryConfigStorage {
private String openId;
private String openid;
private String kfAccount;
private String qrconnectRedirectUrl;
public String getOpenId() {
return this.openId;
public String getOpenid() {
return this.openid;
}
public void setOpenId(String openId) {
this.openId = openId;
public void setOpenid(String openid) {
this.openid = openid;
}
@Override

View File

@@ -41,7 +41,7 @@ public class WxMpMassMessageAPITest {
WxMpMassOpenIdsMessage massMessage = new WxMpMassOpenIdsMessage();
massMessage.setMsgType(WxConsts.MASS_MSG_TEXT);
massMessage.setContent("测试群发消息\n欢迎欢迎热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
massMessage.getToUsers().add(configProvider.getOpenId());
massMessage.getToUsers().add(configProvider.getOpenid());
WxMpMassSendResult massResult = this.wxService
.massOpenIdsMessageSend(massMessage);
@@ -58,7 +58,7 @@ public class WxMpMassMessageAPITest {
WxMpMassOpenIdsMessage massMessage = new WxMpMassOpenIdsMessage();
massMessage.setMsgType(massMsgType);
massMessage.setMediaId(mediaId);
massMessage.getToUsers().add(configProvider.getOpenId());
massMessage.getToUsers().add(configProvider.getOpenid());
WxMpMassSendResult massResult = this.wxService
.massOpenIdsMessageSend(massMessage);
@@ -73,13 +73,13 @@ public class WxMpMassMessageAPITest {
massMessage.setContent("测试群发消息\n欢迎欢迎热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
massMessage
.setGroupId(this.wxService.getGroupService().groupGet().get(0).getId());
WxMpMassSendResult massResult = this.wxService
.massGroupMessageSend(massMessage);
Assert.assertNotNull(massResult);
Assert.assertNotNull(massResult.getMsgId());
}
@Test(dataProvider="massMessages")
public void testMediaMassGroupMessageSend(String massMsgType, String mediaId)
throws WxErrorException {
@@ -94,7 +94,7 @@ public class WxMpMassMessageAPITest {
Assert.assertNotNull(massResult);
Assert.assertNotNull(massResult.getMsgId());
}
@DataProvider
public Object[][] massMessages() throws WxErrorException, IOException {
Object[][] messages = new Object[4][];
@@ -109,7 +109,7 @@ public class WxMpMassMessageAPITest {
.mediaUpload(WxConsts.MEDIA_VIDEO, WxConsts.FILE_MP4, inputStream);
Assert.assertNotNull(uploadMediaRes);
Assert.assertNotNull(uploadMediaRes.getMediaId());
// 把视频变成可被群发的媒体
WxMpMassVideo video = new WxMpMassVideo();
video.setTitle("测试标题");
@@ -155,7 +155,7 @@ public class WxMpMassMessageAPITest {
.mediaUpload(WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, inputStream);
Assert.assertNotNull(uploadMediaRes);
Assert.assertNotNull(uploadMediaRes.getMediaId());
// 上传图文消息
WxMpMassNews news = new WxMpMassNews();
WxMpMassNews.WxMpMassNewsArticle article1 = new WxMpMassNews.WxMpMassNewsArticle();
@@ -163,7 +163,7 @@ public class WxMpMassMessageAPITest {
article1.setContent("内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1");
article1.setThumbMediaId(uploadMediaRes.getMediaId());
news.addArticle(article1);
WxMpMassNews.WxMpMassNewsArticle article2 = new WxMpMassNews.WxMpMassNewsArticle();
article2.setTitle("标题2");
article2.setContent("内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2");
@@ -173,7 +173,7 @@ public class WxMpMassMessageAPITest {
article2.setContentSourceUrl("www.baidu.com");
article2.setDigest("摘要2");
news.addArticle(article2);
WxMpMassUploadResult massUploadResult = this.wxService
.massNewsUpload(news);
Assert.assertNotNull(massUploadResult);
@@ -183,5 +183,5 @@ public class WxMpMassMessageAPITest {
return messages;
}
}

View File

@@ -12,7 +12,7 @@ import java.util.List;
/**
* 测试分组接口
*
*
* @author chanjarster
*/
@Deprecated
@@ -24,7 +24,7 @@ public class WxMpGroupServiceImplTest {
protected WxMpServiceImpl wxService;
protected WxMpGroup group;
public void testGroupCreate() throws WxErrorException {
WxMpGroup res = this.wxService.getGroupService().groupCreate("测试分组1");
Assert.assertEquals(res.getName(), "测试分组1");
@@ -40,7 +40,7 @@ public class WxMpGroupServiceImplTest {
Assert.assertNotNull(g.getName());
}
}
@Test(dependsOnMethods={"testGroupGet", "testGroupCreate"})
public void getGroupUpdate() throws WxErrorException {
this.group.setName("分组改名");
@@ -49,13 +49,13 @@ public class WxMpGroupServiceImplTest {
public void testGroupQueryUserGroup() throws WxErrorException {
ApiTestModule.WxXmlMpInMemoryConfigStorage configStorage = (ApiTestModule.WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage();
long groupid = this.wxService.getGroupService().userGetGroup(configStorage.getOpenId());
long groupid = this.wxService.getGroupService().userGetGroup(configStorage.getOpenid());
Assert.assertTrue(groupid != -1l);
}
public void testGroupMoveUser() throws WxErrorException {
ApiTestModule.WxXmlMpInMemoryConfigStorage configStorage = (ApiTestModule.WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage();
this.wxService.getGroupService().userUpdateGroup(configStorage.getOpenId(), this.wxService.getGroupService().groupGet().get(3).getId());
this.wxService.getGroupService().userUpdateGroup(configStorage.getOpenid(), this.wxService.getGroupService().groupGet().get(3).getId());
}
}

View File

@@ -42,7 +42,7 @@ public class WxMpKefuServiceImplTest {
.getWxMpConfigStorage();
WxMpCustomMessage message = new WxMpCustomMessage();
message.setMsgType(WxConsts.CUSTOM_MSG_TEXT);
message.setToUser(configStorage.getOpenId());
message.setToUser(configStorage.getOpenid());
message.setContent(
"欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
@@ -54,7 +54,7 @@ public class WxMpKefuServiceImplTest {
.getWxMpConfigStorage();
WxMpCustomMessage message = new WxMpCustomMessage();
message.setMsgType(WxConsts.CUSTOM_MSG_TEXT);
message.setToUser(configStorage.getOpenId());
message.setToUser(configStorage.getOpenid());
message.setKfAccount(configStorage.getKfAccount());
message.setContent(
"欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
@@ -130,7 +130,7 @@ public class WxMpKefuServiceImplTest {
WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage) this.wxService
.getWxMpConfigStorage();
return new Object[][] {
{ configStorage.getKfAccount(), configStorage.getOpenId() } };
{ configStorage.getKfAccount(), configStorage.getOpenid() } };
}
@Test(dataProvider = "getKfAccountAndOpenid")

View File

@@ -1,48 +0,0 @@
package me.chanjar.weixin.mp.api.impl;
import me.chanjar.weixin.mp.api.ApiTestModule;
import me.chanjar.weixin.mp.bean.result.WxMpUserBlackListGetResult;
import org.testng.Assert;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;
/**
* @author miller
*/
@Test(groups = "userAPI")
@Guice(modules = ApiTestModule.class)
public class WxMpUserBlackListServiceImplTest {
//此处openid只是开发的时候测试用 使用者测试的时候请替换自己公众号的openid
private final String TEST_OPENID = "o9VAswOI0KSXFUtFHgk9Kb9Rtkys";
@Inject
protected WxMpServiceImpl wxService;
@Test
public void testBlackList() throws Exception {
WxMpUserBlackListGetResult wxMpUserBlackListGetResult = this.wxService.getBlackListService().blackList(TEST_OPENID);
Assert.assertNotNull(wxMpUserBlackListGetResult);
Assert.assertFalse(wxMpUserBlackListGetResult.getCount() == -1);
Assert.assertFalse(wxMpUserBlackListGetResult.getTotal() == -1);
Assert.assertFalse(wxMpUserBlackListGetResult.getOpenIds().size() == -1);
System.out.println(wxMpUserBlackListGetResult);
}
@Test
public void testPushToBlackList() throws Exception {
List<String> openIdList = new ArrayList<>();
openIdList.add(TEST_OPENID);
this.wxService.getBlackListService().pushToBlackList(openIdList);
}
@Test
public void testPullFromBlackList() throws Exception {
List<String> openIdList = new ArrayList<>();
openIdList.add(TEST_OPENID);
this.wxService.getBlackListService().pullFromBlackList(openIdList);
}
}

View File

@@ -0,0 +1,52 @@
package me.chanjar.weixin.mp.api.impl;
import me.chanjar.weixin.mp.api.ApiTestModule;
import me.chanjar.weixin.mp.bean.result.WxMpUserBlacklistGetResult;
import org.testng.Assert;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;
/**
* @author miller
*/
@Test(groups = "userAPI")
@Guice(modules = ApiTestModule.class)
public class WxMpUserBlacklistServiceImplTest {
@Inject
protected WxMpServiceImpl wxService;
@Test
public void testGetBlacklist() throws Exception {
ApiTestModule.WxXmlMpInMemoryConfigStorage configStorage = (ApiTestModule.WxXmlMpInMemoryConfigStorage) this.wxService
.getWxMpConfigStorage();
WxMpUserBlacklistGetResult wxMpUserBlacklistGetResult = this.wxService.getBlackListService().getBlacklist(configStorage.getOpenid());
Assert.assertNotNull(wxMpUserBlacklistGetResult);
Assert.assertFalse(wxMpUserBlacklistGetResult.getCount() == -1);
Assert.assertFalse(wxMpUserBlacklistGetResult.getTotal() == -1);
Assert.assertFalse(wxMpUserBlacklistGetResult.getOpenidList().size() == -1);
System.out.println(wxMpUserBlacklistGetResult);
}
@Test
public void testPushToBlacklist() throws Exception {
ApiTestModule.WxXmlMpInMemoryConfigStorage configStorage = (ApiTestModule.WxXmlMpInMemoryConfigStorage) this.wxService
.getWxMpConfigStorage();
List<String> openidList = new ArrayList<>();
openidList.add(configStorage.getOpenid());
this.wxService.getBlackListService().pushToBlacklist(openidList);
}
@Test
public void testPullFromBlacklist() throws Exception {
ApiTestModule.WxXmlMpInMemoryConfigStorage configStorage = (ApiTestModule.WxXmlMpInMemoryConfigStorage) this.wxService
.getWxMpConfigStorage();
List<String> openidList = new ArrayList<>();
openidList.add(configStorage.getOpenid());
this.wxService.getBlackListService().pullFromBlacklist(openidList);
}
}

View File

@@ -26,12 +26,12 @@ public class WxMpUserServiceImplTest {
public void testUserUpdateRemark() throws WxErrorException {
ApiTestModule.WxXmlMpInMemoryConfigStorage configProvider = (ApiTestModule.WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage();
this.wxService.getUserService().userUpdateRemark(configProvider.getOpenId(), "测试备注名");
this.wxService.getUserService().userUpdateRemark(configProvider.getOpenid(), "测试备注名");
}
public void testUserInfo() throws WxErrorException {
ApiTestModule.WxXmlMpInMemoryConfigStorage configProvider = (ApiTestModule.WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage();
WxMpUser user = this.wxService.getUserService().userInfo(configProvider.getOpenId(), null);
WxMpUser user = this.wxService.getUserService().userInfo(configProvider.getOpenid(), null);
Assert.assertNotNull(user);
System.out.println(user);
}

View File

@@ -5,7 +5,7 @@
<aesKey>公众号EncodingAESKey</aesKey>
<accessToken>可以不填写</accessToken>
<expiresTime>可以不填写</expiresTime>
<openId>某个加你公众号的用户的openId</openId>
<openid>某个加你公众号的用户的openId</openid>
<oauth2redirectUri>网页授权获取用户信息回调地址</oauth2redirectUri>
<qrconnectRedirectUrl>网页应用授权登陆回调地址</qrconnectRedirectUrl>
<kfAccount>完整客服账号,格式为:账号前缀@公众号微信号</kfAccount>