mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-30 18:19:04 +08:00 
			
		
		
		
	1.添加获取用户信息单元测试类
2.修改批量获取用户提交方式bug
This commit is contained in:
		| @ -56,7 +56,7 @@ public class WxMpUserServiceImpl implements WxMpUserService { | |||||||
|   @Override |   @Override | ||||||
|   public List<WxMpUser> userInfoList(WxMpUserQuery userQuery) throws WxErrorException { |   public List<WxMpUser> userInfoList(WxMpUserQuery userQuery) throws WxErrorException { | ||||||
|     String url = API_URL_PREFIX + "/info/batchget"; |     String url = API_URL_PREFIX + "/info/batchget"; | ||||||
|     String responseContent = this.wxMpService.execute(new SimpleGetRequestExecutor(), url, userQuery.toJsonString()); |     String responseContent = this.wxMpService.execute(new SimplePostRequestExecutor(), url, userQuery.toJsonString()); | ||||||
|     return WxMpUser.fromJsonList(responseContent); |     return WxMpUser.fromJsonList(responseContent); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | |||||||
| @ -1,5 +1,9 @@ | |||||||
|  |   | ||||||
| package me.chanjar.weixin.mp.api.impl; | package me.chanjar.weixin.mp.api.impl; | ||||||
|  |  | ||||||
|  | import java.util.ArrayList; | ||||||
|  | import java.util.List; | ||||||
|  |  | ||||||
| import org.testng.Assert; | import org.testng.Assert; | ||||||
| import org.testng.annotations.Guice; | import org.testng.annotations.Guice; | ||||||
| import org.testng.annotations.Test; | import org.testng.annotations.Test; | ||||||
| @ -9,6 +13,7 @@ import com.google.inject.Inject; | |||||||
| import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||||
| import me.chanjar.weixin.mp.api.ApiTestModule; | import me.chanjar.weixin.mp.api.ApiTestModule; | ||||||
| import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; | import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; | ||||||
|  | import me.chanjar.weixin.mp.bean.WxMpUserQuery; | ||||||
| import me.chanjar.weixin.mp.bean.result.WxMpUser; | import me.chanjar.weixin.mp.bean.result.WxMpUser; | ||||||
| import me.chanjar.weixin.mp.bean.result.WxMpUserList; | import me.chanjar.weixin.mp.bean.result.WxMpUserList; | ||||||
|  |  | ||||||
| @ -37,6 +42,24 @@ public class WxMpUserServiceImplTest { | |||||||
|     System.out.println(user); |     System.out.println(user); | ||||||
|   } |   } | ||||||
|    |    | ||||||
|  |   public void testUserInfoList() throws WxErrorException { | ||||||
|  |     WxXmlMpInMemoryConfigStorage configProvider = (WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage(); | ||||||
|  |     List<String> openIdList = new ArrayList<>(); | ||||||
|  |     openIdList.add(configProvider.getOpenid()); | ||||||
|  |     List<WxMpUser> userList =	this.wxService.getUserService().userInfoList(openIdList); | ||||||
|  |     Assert.assertEquals(userList.size(), 1); | ||||||
|  | 	System.out.println(userList); | ||||||
|  |   } | ||||||
|  |    | ||||||
|  |   public void testUserInfoListByWxMpUserQuery() throws WxErrorException { | ||||||
|  |     WxXmlMpInMemoryConfigStorage configProvider = (WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage(); | ||||||
|  |     WxMpUserQuery query = new WxMpUserQuery(); | ||||||
|  |     query.add(configProvider.getOpenid(), "zh_CN"); | ||||||
|  |     List<WxMpUser> userList =	this.wxService.getUserService().userInfoList(query); | ||||||
|  |     Assert.assertEquals(userList.size(), 1); | ||||||
|  |     System.out.println(userList); | ||||||
|  |   } | ||||||
|  |  | ||||||
|   public void testUserList() throws WxErrorException { |   public void testUserList() throws WxErrorException { | ||||||
|     WxMpUserList wxMpUserList = this.wxService.getUserService().userList(null); |     WxMpUserList wxMpUserList = this.wxService.getUserService().userList(null); | ||||||
|     Assert.assertNotNull(wxMpUserList); |     Assert.assertNotNull(wxMpUserList); | ||||||
| @ -46,4 +69,5 @@ public class WxMpUserServiceImplTest { | |||||||
|     System.out.println(wxMpUserList); |     System.out.println(wxMpUserList); | ||||||
|   } |   } | ||||||
|    |    | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 aimil
					aimil