| @@ -370,5 +370,5 @@ public interface WxMpService { | |||
| * | |||
| * @return WxMpUserBlackListService | |||
| */ | |||
| WxMpUserBlackListService getBlackListService(); | |||
| WxMpUserBlacklistService getBlackListService(); | |||
| } | |||
| @@ -1,21 +1,21 @@ | |||
| package me.chanjar.weixin.mp.api; | |||
| import me.chanjar.weixin.common.exception.WxErrorException; | |||
| import me.chanjar.weixin.mp.bean.result.WxMpUserBlackListGetResult; | |||
| import me.chanjar.weixin.mp.bean.result.WxMpUserBlacklistGetResult; | |||
| import java.util.List; | |||
| /** | |||
| * @author miller | |||
| */ | |||
| public interface WxMpUserBlackListService { | |||
| public interface WxMpUserBlacklistService { | |||
| /** | |||
| * <pre> | |||
| * 获取公众号的黑名单列表 | |||
| * 详情请见http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1471422259_pJMWA&token=&lang=zh_CN | |||
| * </pre> | |||
| */ | |||
| WxMpUserBlackListGetResult blackList(String nextOpenid) throws WxErrorException; | |||
| WxMpUserBlacklistGetResult getBlacklist(String nextOpenid) throws WxErrorException; | |||
| /** | |||
| * <pre> | |||
| @@ -23,7 +23,7 @@ public interface WxMpUserBlackListService { | |||
| * 详情请见http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1471422259_pJMWA&token=&lang=zh_CN | |||
| * </pre> | |||
| */ | |||
| void pushToBlackList(List<String> openIdList) throws WxErrorException; | |||
| void pushToBlacklist(List<String> openidList) throws WxErrorException; | |||
| /** | |||
| * <pre> | |||
| @@ -31,5 +31,5 @@ public interface WxMpUserBlackListService { | |||
| * 详情请见http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1471422259_pJMWA&token=&lang=zh_CN | |||
| * </pre> | |||
| */ | |||
| void pullFromBlackList(List<String> openIdList) throws WxErrorException; | |||
| void pullFromBlacklist(List<String> openidList) throws WxErrorException; | |||
| } | |||
| @@ -28,7 +28,7 @@ import me.chanjar.weixin.mp.api.WxMpMenuService; | |||
| import me.chanjar.weixin.mp.api.WxMpPayService; | |||
| import me.chanjar.weixin.mp.api.WxMpQrcodeService; | |||
| import me.chanjar.weixin.mp.api.WxMpService; | |||
| import me.chanjar.weixin.mp.api.WxMpUserBlackListService; | |||
| import me.chanjar.weixin.mp.api.WxMpUserBlacklistService; | |||
| import me.chanjar.weixin.mp.api.WxMpUserService; | |||
| import me.chanjar.weixin.mp.api.WxMpUserTagService; | |||
| import me.chanjar.weixin.mp.bean.WxMpIndustry; | |||
| @@ -95,7 +95,7 @@ public class WxMpServiceImpl implements WxMpService { | |||
| private WxMpDataCubeService dataCubeService = new WxMpDataCubeServiceImpl(this); | |||
| private WxMpUserBlackListService blackListService = new WxMpUserBlackListServiceImpl(this); | |||
| private WxMpUserBlacklistService blackListService = new WxMpUserBlacklistServiceImpl(this); | |||
| private CloseableHttpClient httpClient; | |||
| @@ -582,7 +582,7 @@ public class WxMpServiceImpl implements WxMpService { | |||
| } | |||
| @Override | |||
| public WxMpUserBlackListService getBlackListService() { | |||
| public WxMpUserBlacklistService getBlackListService() { | |||
| return this.blackListService; | |||
| } | |||
| @@ -5,8 +5,8 @@ import com.google.gson.JsonObject; | |||
| import me.chanjar.weixin.common.exception.WxErrorException; | |||
| import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor; | |||
| import me.chanjar.weixin.mp.api.WxMpService; | |||
| import me.chanjar.weixin.mp.api.WxMpUserBlackListService; | |||
| import me.chanjar.weixin.mp.bean.result.WxMpUserBlackListGetResult; | |||
| import me.chanjar.weixin.mp.api.WxMpUserBlacklistService; | |||
| import me.chanjar.weixin.mp.bean.result.WxMpUserBlacklistGetResult; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| @@ -15,36 +15,36 @@ import java.util.Map; | |||
| /** | |||
| * @author miller | |||
| */ | |||
| public class WxMpUserBlackListServiceImpl implements WxMpUserBlackListService { | |||
| private static final String API_BLACK_LIST_PREFIX = "https://api.weixin.qq.com/cgi-bin/tags/members"; | |||
| public class WxMpUserBlacklistServiceImpl implements WxMpUserBlacklistService { | |||
| private static final String API_BLACKLIST_PREFIX = "https://api.weixin.qq.com/cgi-bin/tags/members"; | |||
| private WxMpService wxMpService; | |||
| public WxMpUserBlackListServiceImpl(WxMpService wxMpService) { | |||
| public WxMpUserBlacklistServiceImpl(WxMpService wxMpService) { | |||
| this.wxMpService = wxMpService; | |||
| } | |||
| @Override | |||
| public WxMpUserBlackListGetResult blackList(String nextOpenid) throws WxErrorException { | |||
| public WxMpUserBlacklistGetResult getBlacklist(String nextOpenid) throws WxErrorException { | |||
| JsonObject jsonObject = new JsonObject(); | |||
| jsonObject.addProperty("begin_openid", nextOpenid); | |||
| String url = API_BLACK_LIST_PREFIX + "/getblacklist"; | |||
| String url = API_BLACKLIST_PREFIX + "/getblacklist"; | |||
| String responseContent = this.wxMpService.execute(new SimplePostRequestExecutor(), url, jsonObject.toString()); | |||
| return WxMpUserBlackListGetResult.fromJson(responseContent); | |||
| return WxMpUserBlacklistGetResult.fromJson(responseContent); | |||
| } | |||
| @Override | |||
| public void pushToBlackList(List<String> openIdList) throws WxErrorException { | |||
| public void pushToBlacklist(List<String> openidList) throws WxErrorException { | |||
| Map<String, Object> map = new HashMap<>(); | |||
| map.put("openid_list", openIdList); | |||
| String url = API_BLACK_LIST_PREFIX + "/batchblacklist"; | |||
| map.put("openid_list", openidList); | |||
| String url = API_BLACKLIST_PREFIX + "/batchblacklist"; | |||
| this.wxMpService.execute(new SimplePostRequestExecutor(), url, new Gson().toJson(map)); | |||
| } | |||
| @Override | |||
| public void pullFromBlackList(List<String> openIdList) throws WxErrorException { | |||
| public void pullFromBlacklist(List<String> openidList) throws WxErrorException { | |||
| Map<String, Object> map = new HashMap<>(); | |||
| map.put("openid_list", openIdList); | |||
| String url = API_BLACK_LIST_PREFIX + "/batchunblacklist"; | |||
| map.put("openid_list", openidList); | |||
| String url = API_BLACKLIST_PREFIX + "/batchunblacklist"; | |||
| this.wxMpService.execute(new SimplePostRequestExecutor(), url, new Gson().toJson(map)); | |||
| } | |||
| } | |||
| @@ -8,14 +8,14 @@ import java.util.List; | |||
| /** | |||
| * @author miller | |||
| */ | |||
| public class WxMpUserBlackListGetResult { | |||
| public class WxMpUserBlacklistGetResult { | |||
| protected int total = -1; | |||
| protected int count = -1; | |||
| protected List<String> openIds = new ArrayList<>(); | |||
| protected String nextOpenId; | |||
| protected List<String> openidList = new ArrayList<>(); | |||
| protected String nextOpenid; | |||
| public static WxMpUserBlackListGetResult fromJson(String json) { | |||
| return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpUserBlackListGetResult.class); | |||
| public static WxMpUserBlacklistGetResult fromJson(String json) { | |||
| return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpUserBlacklistGetResult.class); | |||
| } | |||
| public int getTotal() { | |||
| @@ -34,20 +34,20 @@ public class WxMpUserBlackListGetResult { | |||
| this.count = count; | |||
| } | |||
| public List<String> getOpenIds() { | |||
| return this.openIds; | |||
| public List<String> getOpenidList() { | |||
| return this.openidList; | |||
| } | |||
| public void setOpenIds(List<String> openIds) { | |||
| this.openIds = openIds; | |||
| public void setOpenidList(List<String> openidList) { | |||
| this.openidList = openidList; | |||
| } | |||
| public String getNextOpenId() { | |||
| return this.nextOpenId; | |||
| public String getNextOpenid() { | |||
| return this.nextOpenid; | |||
| } | |||
| public void setNextOpenId(String nextOpenId) { | |||
| this.nextOpenId = nextOpenId; | |||
| public void setNextOpenid(String nextOpenid) { | |||
| this.nextOpenid = nextOpenid; | |||
| } | |||
| @Override | |||
| @@ -45,7 +45,7 @@ public class WxMpGsonBuilder { | |||
| INSTANCE.registerTypeAdapter(WxMpMassPreviewMessage.class, new WxMpMassPreviewMessageGsonAdapter()); | |||
| INSTANCE.registerTypeAdapter(WxMediaImgUploadResult.class, new WxMediaImgUploadResultGsonAdapter()); | |||
| INSTANCE.registerTypeAdapter(WxMpIndustry.class, new WxMpIndustryGsonAdapter()); | |||
| INSTANCE.registerTypeAdapter(WxMpUserBlackListGetResult.class, new WxUserBlackListGetResultGsonAdapter()); | |||
| INSTANCE.registerTypeAdapter(WxMpUserBlacklistGetResult.class, new WxUserBlacklistGetResultGsonAdapter()); | |||
| } | |||
| public static Gson create() { | |||
| @@ -1,28 +0,0 @@ | |||
| package me.chanjar.weixin.mp.util.json; | |||
| import com.google.gson.*; | |||
| import me.chanjar.weixin.common.util.json.GsonHelper; | |||
| import me.chanjar.weixin.mp.bean.result.WxMpUserBlackListGetResult; | |||
| import java.lang.reflect.Type; | |||
| /** | |||
| * @author miller | |||
| */ | |||
| public class WxUserBlackListGetResultGsonAdapter implements JsonDeserializer<WxMpUserBlackListGetResult> { | |||
| @Override | |||
| public WxMpUserBlackListGetResult deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { | |||
| JsonObject o = json.getAsJsonObject(); | |||
| WxMpUserBlackListGetResult wxMpUserBlackListGetResult = new WxMpUserBlackListGetResult(); | |||
| wxMpUserBlackListGetResult.setTotal(GsonHelper.getInteger(o, "total")); | |||
| wxMpUserBlackListGetResult.setCount(GsonHelper.getInteger(o, "count")); | |||
| wxMpUserBlackListGetResult.setNextOpenId(GsonHelper.getString(o, "next_openid")); | |||
| if (o.get("data") != null && !o.get("data").isJsonNull() && !o.get("data").getAsJsonObject().get("openid").isJsonNull()) { | |||
| JsonArray data = o.get("data").getAsJsonObject().get("openid").getAsJsonArray(); | |||
| for (int i = 0; i < data.size(); i++) { | |||
| wxMpUserBlackListGetResult.getOpenIds().add(GsonHelper.getAsString(data.get(i))); | |||
| } | |||
| } | |||
| return wxMpUserBlackListGetResult; | |||
| } | |||
| } | |||
| @@ -0,0 +1,28 @@ | |||
| package me.chanjar.weixin.mp.util.json; | |||
| import com.google.gson.*; | |||
| import me.chanjar.weixin.common.util.json.GsonHelper; | |||
| import me.chanjar.weixin.mp.bean.result.WxMpUserBlacklistGetResult; | |||
| import java.lang.reflect.Type; | |||
| /** | |||
| * @author miller | |||
| */ | |||
| public class WxUserBlacklistGetResultGsonAdapter implements JsonDeserializer<WxMpUserBlacklistGetResult> { | |||
| @Override | |||
| public WxMpUserBlacklistGetResult deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { | |||
| JsonObject o = json.getAsJsonObject(); | |||
| WxMpUserBlacklistGetResult wxMpUserBlacklistGetResult = new WxMpUserBlacklistGetResult(); | |||
| wxMpUserBlacklistGetResult.setTotal(GsonHelper.getInteger(o, "total")); | |||
| wxMpUserBlacklistGetResult.setCount(GsonHelper.getInteger(o, "count")); | |||
| wxMpUserBlacklistGetResult.setNextOpenid(GsonHelper.getString(o, "next_openid")); | |||
| if (o.get("data") != null && !o.get("data").isJsonNull() && !o.get("data").getAsJsonObject().get("openid").isJsonNull()) { | |||
| JsonArray data = o.get("data").getAsJsonObject().get("openid").getAsJsonArray(); | |||
| for (int i = 0; i < data.size(); i++) { | |||
| wxMpUserBlacklistGetResult.getOpenidList().add(GsonHelper.getAsString(data.get(i))); | |||
| } | |||
| } | |||
| return wxMpUserBlacklistGetResult; | |||
| } | |||
| } | |||
| @@ -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 | |||
| @@ -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; | |||
| } | |||
| } | |||
| @@ -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()); | |||
| } | |||
| } | |||
| @@ -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") | |||
| @@ -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); | |||
| } | |||
| } | |||
| @@ -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); | |||
| } | |||
| } | |||
| @@ -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); | |||
| } | |||
| @@ -5,7 +5,7 @@ | |||
| <aesKey>公众号EncodingAESKey</aesKey> | |||
| <accessToken>可以不填写</accessToken> | |||
| <expiresTime>可以不填写</expiresTime> | |||
| <openId>某个加你公众号的用户的openId</openId> | |||
| <openid>某个加你公众号的用户的openId</openid> | |||
| <oauth2redirectUri>网页授权获取用户信息回调地址</oauth2redirectUri> | |||
| <qrconnectRedirectUrl>网页应用授权登陆回调地址</qrconnectRedirectUrl> | |||
| <kfAccount>完整客服账号,格式为:账号前缀@公众号微信号</kfAccount> | |||