mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 10:38:42 +08:00 
			
		
		
		
	#246 修复企业号用户信息相关属性,对比实际接口返回内容,移除已失效属性(weixinid、tel),添加缺失的属性(telephone, english_name, hide_mobile)
This commit is contained in:
		| @ -34,6 +34,10 @@ | |||||||
|       <groupId>redis.clients</groupId> |       <groupId>redis.clients</groupId> | ||||||
|       <artifactId>jedis</artifactId> |       <artifactId>jedis</artifactId> | ||||||
|     </dependency> |     </dependency> | ||||||
|  |     <dependency> | ||||||
|  |       <groupId>org.slf4j</groupId> | ||||||
|  |       <artifactId>slf4j-api</artifactId> | ||||||
|  |     </dependency> | ||||||
|  |  | ||||||
|     <dependency> |     <dependency> | ||||||
|       <groupId>org.testng</groupId> |       <groupId>org.testng</groupId> | ||||||
| @ -60,6 +64,11 @@ | |||||||
|       <artifactId>jetty-servlet</artifactId> |       <artifactId>jetty-servlet</artifactId> | ||||||
|       <scope>test</scope> |       <scope>test</scope> | ||||||
|     </dependency> |     </dependency> | ||||||
|  |     <dependency> | ||||||
|  |       <groupId>ch.qos.logback</groupId> | ||||||
|  |       <artifactId>logback-classic</artifactId> | ||||||
|  |       <scope>test</scope> | ||||||
|  |     </dependency> | ||||||
|   </dependencies> |   </dependencies> | ||||||
|  |  | ||||||
|   <build> |   <build> | ||||||
|  | |||||||
| @ -34,7 +34,7 @@ import java.util.UUID; | |||||||
|  |  | ||||||
| public abstract class AbstractWxCpServiceImpl<H, P> implements WxCpService, RequestHttp<H, P> { | public abstract class AbstractWxCpServiceImpl<H, P> implements WxCpService, RequestHttp<H, P> { | ||||||
|  |  | ||||||
|   protected final Logger log = LoggerFactory.getLogger(AbstractWxCpServiceImpl.class); |   protected final Logger log = LoggerFactory.getLogger(this.getClass()); | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * 全局的是否正在刷新access token的锁 |    * 全局的是否正在刷新access token的锁 | ||||||
| @ -293,8 +293,7 @@ public abstract class AbstractWxCpServiceImpl<H, P> implements WxCpService, Requ | |||||||
|     String responseContent = get(url, params); |     String responseContent = get(url, params); | ||||||
|     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); |     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | ||||||
|     return WxCpGsonBuilder.INSTANCE.create() |     return WxCpGsonBuilder.INSTANCE.create() | ||||||
|       .fromJson( |       .fromJson(        tmpJsonElement.getAsJsonObject().get("userlist"), | ||||||
|         tmpJsonElement.getAsJsonObject().get("userlist"), |  | ||||||
|         new TypeToken<List<WxCpUser>>() { |         new TypeToken<List<WxCpUser>>() { | ||||||
|         }.getType() |         }.getType() | ||||||
|       ); |       ); | ||||||
|  | |||||||
| @ -14,19 +14,21 @@ import java.util.List; | |||||||
| public class WxCpUser implements Serializable { | public class WxCpUser implements Serializable { | ||||||
|  |  | ||||||
|   private static final long serialVersionUID = -5696099236344075582L; |   private static final long serialVersionUID = -5696099236344075582L; | ||||||
|   private final List<Attr> extAttrs = new ArrayList<>(); |  | ||||||
|   private String userId; |   private String userId; | ||||||
|   private String name; |   private String name; | ||||||
|   private Integer[] departIds; |   private Integer[] departIds; | ||||||
|   private String position; |   private String position; | ||||||
|   private String mobile; |   private String mobile; | ||||||
|   private String gender; |   private String gender; | ||||||
|   private String tel; |  | ||||||
|   private String email; |   private String email; | ||||||
|   private String weiXinId; |  | ||||||
|   private String avatar; |   private String avatar; | ||||||
|   private Integer status; |   private Integer status; | ||||||
|   private Integer enable; |   private Integer enable; | ||||||
|  |   private Integer isLeader; | ||||||
|  |   private final List<Attr> extAttrs = new ArrayList<>(); | ||||||
|  |   private Integer hideMobile; | ||||||
|  |   private String englishName; | ||||||
|  |   private String telephone; | ||||||
|  |  | ||||||
|   public static WxCpUser fromJson(String json) { |   public static WxCpUser fromJson(String json) { | ||||||
|     return WxCpGsonBuilder.INSTANCE.create().fromJson(json, WxCpUser.class); |     return WxCpGsonBuilder.INSTANCE.create().fromJson(json, WxCpUser.class); | ||||||
| @ -80,12 +82,12 @@ public class WxCpUser implements Serializable { | |||||||
|     this.mobile = mobile; |     this.mobile = mobile; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   public String getTel() { |   public String getTelephone() { | ||||||
|     return this.tel; |     return this.telephone; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   public void setTel(String tel) { |   public void setTelephone(String telephone) { | ||||||
|     this.tel = tel; |     this.telephone = telephone; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   public String getEmail() { |   public String getEmail() { | ||||||
| @ -96,14 +98,6 @@ public class WxCpUser implements Serializable { | |||||||
|     this.email = email; |     this.email = email; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   public String getWeiXinId() { |  | ||||||
|     return this.weiXinId; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   public void setWeiXinId(String weiXinId) { |  | ||||||
|     this.weiXinId = weiXinId; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   public String getAvatar() { |   public String getAvatar() { | ||||||
|     return this.avatar; |     return this.avatar; | ||||||
|   } |   } | ||||||
| @ -136,6 +130,30 @@ public class WxCpUser implements Serializable { | |||||||
|     return this.extAttrs; |     return this.extAttrs; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   public Integer getIsLeader() { | ||||||
|  |     return isLeader; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   public void setIsLeader(Integer isLeader) { | ||||||
|  |     this.isLeader = isLeader; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   public Integer getHideMobile() { | ||||||
|  |     return hideMobile; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   public void setHideMobile(Integer hideMobile) { | ||||||
|  |     this.hideMobile = hideMobile; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   public String getEnglishName() { | ||||||
|  |     return englishName; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   public void setEnglishName(String englishName) { | ||||||
|  |     this.englishName = englishName; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   public String toJson() { |   public String toJson() { | ||||||
|     return WxCpGsonBuilder.INSTANCE.create().toJson(this); |     return WxCpGsonBuilder.INSTANCE.create().toJson(this); | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -24,8 +24,6 @@ public class WxCpUserGsonAdapter implements JsonDeserializer<WxCpUser>, JsonSeri | |||||||
|     throws JsonParseException { |     throws JsonParseException { | ||||||
|     JsonObject o = json.getAsJsonObject(); |     JsonObject o = json.getAsJsonObject(); | ||||||
|     WxCpUser user = new WxCpUser(); |     WxCpUser user = new WxCpUser(); | ||||||
|     user.setUserId(GsonHelper.getString(o, "userid")); |  | ||||||
|     user.setName(GsonHelper.getString(o, "name")); |  | ||||||
|  |  | ||||||
|     if (o.get("department") != null) { |     if (o.get("department") != null) { | ||||||
|       JsonArray departJsonArray = o.get("department").getAsJsonArray(); |       JsonArray departJsonArray = o.get("department").getAsJsonArray(); | ||||||
| @ -37,14 +35,19 @@ public class WxCpUserGsonAdapter implements JsonDeserializer<WxCpUser>, JsonSeri | |||||||
|       user.setDepartIds(departIds); |       user.setDepartIds(departIds); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     user.setUserId(GsonHelper.getString(o, "userid")); | ||||||
|  |     user.setName(GsonHelper.getString(o, "name")); | ||||||
|     user.setPosition(GsonHelper.getString(o, "position")); |     user.setPosition(GsonHelper.getString(o, "position")); | ||||||
|     user.setMobile(GsonHelper.getString(o, "mobile")); |     user.setMobile(GsonHelper.getString(o, "mobile")); | ||||||
|     user.setGender(GsonHelper.getString(o, "gender")); |     user.setGender(GsonHelper.getString(o, "gender")); | ||||||
|     user.setTel(GsonHelper.getString(o, "tel")); |  | ||||||
|     user.setEmail(GsonHelper.getString(o, "email")); |     user.setEmail(GsonHelper.getString(o, "email")); | ||||||
|     user.setWeiXinId(GsonHelper.getString(o, "weixinid")); |  | ||||||
|     user.setAvatar(GsonHelper.getString(o, "avatar")); |     user.setAvatar(GsonHelper.getString(o, "avatar")); | ||||||
|     user.setStatus(GsonHelper.getInteger(o, "status")); |     user.setStatus(GsonHelper.getInteger(o, "status")); | ||||||
|  |     user.setEnable(GsonHelper.getInteger(o, "enable")); | ||||||
|  |     user.setIsLeader(GsonHelper.getInteger(o, "isleader")); | ||||||
|  |     user.setHideMobile(GsonHelper.getInteger(o, "hide_mobile")); | ||||||
|  |     user.setEnglishName(GsonHelper.getString(o, "english_name")); | ||||||
|  |     user.setTelephone(GsonHelper.getString(o, "telephone")); | ||||||
|  |  | ||||||
|     if (GsonHelper.isNotNull(o.get("extattr"))) { |     if (GsonHelper.isNotNull(o.get("extattr"))) { | ||||||
|       JsonArray attrJsonElements = o.get("extattr").getAsJsonObject().get("attrs").getAsJsonArray(); |       JsonArray attrJsonElements = o.get("extattr").getAsJsonObject().get("attrs").getAsJsonArray(); | ||||||
| @ -84,15 +87,9 @@ public class WxCpUserGsonAdapter implements JsonDeserializer<WxCpUser>, JsonSeri | |||||||
|     if (user.getGender() != null) { |     if (user.getGender() != null) { | ||||||
|       o.addProperty("gender", user.getGender()); |       o.addProperty("gender", user.getGender()); | ||||||
|     } |     } | ||||||
|     if (user.getTel() != null) { |  | ||||||
|       o.addProperty("tel", user.getTel()); |  | ||||||
|     } |  | ||||||
|     if (user.getEmail() != null) { |     if (user.getEmail() != null) { | ||||||
|       o.addProperty("email", user.getEmail()); |       o.addProperty("email", user.getEmail()); | ||||||
|     } |     } | ||||||
|     if (user.getWeiXinId() != null) { |  | ||||||
|       o.addProperty("weixinid", user.getWeiXinId()); |  | ||||||
|     } |  | ||||||
|     if (user.getAvatar() != null) { |     if (user.getAvatar() != null) { | ||||||
|       o.addProperty("avatar", user.getAvatar()); |       o.addProperty("avatar", user.getAvatar()); | ||||||
|     } |     } | ||||||
| @ -102,6 +99,18 @@ public class WxCpUserGsonAdapter implements JsonDeserializer<WxCpUser>, JsonSeri | |||||||
|     if (user.getEnable() != null) { |     if (user.getEnable() != null) { | ||||||
|       o.addProperty("enable", user.getEnable()); |       o.addProperty("enable", user.getEnable()); | ||||||
|     } |     } | ||||||
|  |     if (user.getIsLeader() != null) { | ||||||
|  |       o.addProperty("isleader", user.getIsLeader()); | ||||||
|  |     } | ||||||
|  |     if (user.getHideMobile() != null) { | ||||||
|  |       o.addProperty("hide_mobile", user.getHideMobile()); | ||||||
|  |     } | ||||||
|  |     if (user.getEnglishName() != null) { | ||||||
|  |       o.addProperty("english_name", user.getEnglishName()); | ||||||
|  |     } | ||||||
|  |     if (user.getTelephone() != null) { | ||||||
|  |       o.addProperty("telephone", user.getTelephone()); | ||||||
|  |     } | ||||||
|     if (user.getExtAttrs().size() > 0) { |     if (user.getExtAttrs().size() > 0) { | ||||||
|       JsonArray attrsJsonArray = new JsonArray(); |       JsonArray attrsJsonArray = new JsonArray(); | ||||||
|       for (WxCpUser.Attr attr : user.getExtAttrs()) { |       for (WxCpUser.Attr attr : user.getExtAttrs()) { | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ import com.google.inject.Module; | |||||||
| import com.thoughtworks.xstream.XStream; | import com.thoughtworks.xstream.XStream; | ||||||
| import com.thoughtworks.xstream.annotations.XStreamAlias; | import com.thoughtworks.xstream.annotations.XStreamAlias; | ||||||
| import me.chanjar.weixin.common.util.xml.XStreamInitializer; | import me.chanjar.weixin.common.util.xml.XStreamInitializer; | ||||||
| import me.chanjar.weixin.cp.api.impl.apache.WxCpServiceImpl; | import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; | ||||||
|  |  | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.io.InputStream; | import java.io.InputStream; | ||||||
|  | |||||||
| @ -1,12 +1,12 @@ | |||||||
| package me.chanjar.weixin.cp.api.impl.apache; | package me.chanjar.weixin.cp.api; | ||||||
| 
 | 
 | ||||||
| import com.google.inject.Inject; | import com.google.inject.Inject; | ||||||
| import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||||
| import me.chanjar.weixin.cp.api.ApiTestModule; | import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; | ||||||
| import me.chanjar.weixin.cp.api.WxCpConfigStorage; |  | ||||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||||
| import org.testng.*; | import org.testng.Assert; | ||||||
| import org.testng.annotations.*; | import org.testng.annotations.Guice; | ||||||
|  | import org.testng.annotations.Test; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * 基础API测试 |  * 基础API测试 | ||||||
| @ -1,10 +1,11 @@ | |||||||
| package me.chanjar.weixin.cp.api.impl.apache; | package me.chanjar.weixin.cp.api; | ||||||
| 
 | 
 | ||||||
| import me.chanjar.weixin.common.bean.result.WxError; | import me.chanjar.weixin.common.bean.result.WxError; | ||||||
| import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||||
| import me.chanjar.weixin.common.util.http.RequestExecutor; | import me.chanjar.weixin.common.util.http.RequestExecutor; | ||||||
| import me.chanjar.weixin.cp.api.WxCpService; | import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; | ||||||
| import org.testng.annotations.*; | import org.testng.annotations.DataProvider; | ||||||
|  | import org.testng.annotations.Test; | ||||||
| 
 | 
 | ||||||
| import java.util.concurrent.ExecutionException; | import java.util.concurrent.ExecutionException; | ||||||
| import java.util.concurrent.ExecutorService; | import java.util.concurrent.ExecutorService; | ||||||
| @ -2,19 +2,23 @@ package me.chanjar.weixin.cp.api; | |||||||
|  |  | ||||||
| import com.google.inject.Inject; | import com.google.inject.Inject; | ||||||
| import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||||
| import me.chanjar.weixin.cp.api.impl.apache.WxCpServiceImpl; | import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; | ||||||
| import me.chanjar.weixin.cp.bean.WxCpDepart; | import me.chanjar.weixin.cp.bean.WxCpDepart; | ||||||
| import org.testng.*; | import org.testng.Assert; | ||||||
| import org.testng.annotations.*; | import org.testng.annotations.Guice; | ||||||
|  | import org.testng.annotations.Test; | ||||||
|  |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
|  | import static org.testng.Assert.assertNotNull; | ||||||
|  | import static org.testng.Assert.assertTrue; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 测试部门接口 |  * 测试部门接口 | ||||||
|  * |  * | ||||||
|  * @author Daniel Qian |  * @author Daniel Qian | ||||||
|  */ |  */ | ||||||
| @Test(groups = "departAPI", dependsOnGroups = "baseAPI") | @Test(groups = "departAPI") | ||||||
| @Guice(modules = ApiTestModule.class) | @Guice(modules = ApiTestModule.class) | ||||||
| public class WxCpDepartAPITest { | public class WxCpDepartAPITest { | ||||||
|  |  | ||||||
| @ -23,6 +27,7 @@ public class WxCpDepartAPITest { | |||||||
|  |  | ||||||
|   protected WxCpDepart depart; |   protected WxCpDepart depart; | ||||||
|  |  | ||||||
|  |   @Test | ||||||
|   public void testDepartCreate() throws WxErrorException { |   public void testDepartCreate() throws WxErrorException { | ||||||
|     WxCpDepart cpDepart = new WxCpDepart(); |     WxCpDepart cpDepart = new WxCpDepart(); | ||||||
|     cpDepart.setName("子部门" + System.currentTimeMillis()); |     cpDepart.setName("子部门" + System.currentTimeMillis()); | ||||||
| @ -32,16 +37,16 @@ public class WxCpDepartAPITest { | |||||||
|     System.out.println(departId); |     System.out.println(departId); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Test(dependsOnMethods = "testDepartCreate") |   @Test//(dependsOnMethods = "testDepartCreate") | ||||||
|   public void testDepartGet() throws WxErrorException { |   public void testDepartGet() throws WxErrorException { | ||||||
|     System.out.println("=================获取部门"); |     System.out.println("=================获取部门"); | ||||||
|     List<WxCpDepart> departList = this.wxCpService.departGet(); |     List<WxCpDepart> departList = this.wxCpService.departGet(); | ||||||
|     Assert.assertNotNull(departList); |     assertNotNull(departList); | ||||||
|     Assert.assertTrue(departList.size() > 0); |     assertTrue(departList.size() > 0); | ||||||
|     for (WxCpDepart g : departList) { |     for (WxCpDepart g : departList) { | ||||||
|       this.depart = g; |       this.depart = g; | ||||||
|       System.out.println(this.depart.getId() + ":" + this.depart.getName()); |       System.out.println(this.depart.getId() + ":" + this.depart.getName()); | ||||||
|       Assert.assertNotNull(g.getName()); |       assertNotNull(g.getName()); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | |||||||
| @ -4,9 +4,11 @@ import com.google.inject.Inject; | |||||||
| import me.chanjar.weixin.common.api.WxConsts; | import me.chanjar.weixin.common.api.WxConsts; | ||||||
| import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | ||||||
| import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||||
| import me.chanjar.weixin.cp.api.impl.apache.WxCpServiceImpl; | import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; | ||||||
| import org.testng.*; | import org.testng.Assert; | ||||||
| import org.testng.annotations.*; | import org.testng.annotations.DataProvider; | ||||||
|  | import org.testng.annotations.Guice; | ||||||
|  | import org.testng.annotations.Test; | ||||||
|  |  | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.io.InputStream; | import java.io.InputStream; | ||||||
|  | |||||||
| @ -1,11 +1,12 @@ | |||||||
| package me.chanjar.weixin.cp.api.impl.apache; | package me.chanjar.weixin.cp.api; | ||||||
| 
 | 
 | ||||||
| import com.google.inject.Inject; | import com.google.inject.Inject; | ||||||
| import me.chanjar.weixin.common.api.WxConsts; | import me.chanjar.weixin.common.api.WxConsts; | ||||||
| import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||||
| import me.chanjar.weixin.cp.api.ApiTestModule; | import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; | ||||||
| import me.chanjar.weixin.cp.bean.WxCpMessage; | import me.chanjar.weixin.cp.bean.WxCpMessage; | ||||||
| import org.testng.annotations.*; | import org.testng.annotations.Guice; | ||||||
|  | import org.testng.annotations.Test; | ||||||
| 
 | 
 | ||||||
| /*** | /*** | ||||||
|  * 测试发送消息 |  * 测试发送消息 | ||||||
| @ -5,8 +5,9 @@ import me.chanjar.weixin.common.session.StandardSessionManager; | |||||||
| import me.chanjar.weixin.common.session.WxSessionManager; | import me.chanjar.weixin.common.session.WxSessionManager; | ||||||
| import me.chanjar.weixin.cp.bean.WxCpXmlMessage; | import me.chanjar.weixin.cp.bean.WxCpXmlMessage; | ||||||
| import me.chanjar.weixin.cp.bean.WxCpXmlOutMessage; | import me.chanjar.weixin.cp.bean.WxCpXmlOutMessage; | ||||||
| import org.testng.*; | import org.testng.Assert; | ||||||
| import org.testng.annotations.*; | import org.testng.annotations.DataProvider; | ||||||
|  | import org.testng.annotations.Test; | ||||||
|  |  | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  |  | ||||||
|  | |||||||
| @ -1,11 +1,12 @@ | |||||||
| package me.chanjar.weixin.cp.api; | package me.chanjar.weixin.cp.api; | ||||||
|  |  | ||||||
| import com.google.inject.Inject; | import com.google.inject.Inject; | ||||||
| import me.chanjar.weixin.cp.api.impl.apache.WxCpServiceImpl; | import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; | ||||||
| import me.chanjar.weixin.cp.bean.WxCpTag; | import me.chanjar.weixin.cp.bean.WxCpTag; | ||||||
| import me.chanjar.weixin.cp.bean.WxCpUser; | import me.chanjar.weixin.cp.bean.WxCpUser; | ||||||
| import org.testng.*; | import org.testng.Assert; | ||||||
| import org.testng.annotations.*; | import org.testng.annotations.Guice; | ||||||
|  | import org.testng.annotations.Test; | ||||||
|  |  | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  | |||||||
| @ -2,28 +2,30 @@ package me.chanjar.weixin.cp.api; | |||||||
|  |  | ||||||
| import com.google.inject.Inject; | import com.google.inject.Inject; | ||||||
| import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||||
| import me.chanjar.weixin.cp.api.impl.apache.WxCpServiceImpl; | import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; | ||||||
| import me.chanjar.weixin.cp.bean.WxCpDepart; |  | ||||||
| import me.chanjar.weixin.cp.bean.WxCpUser; | import me.chanjar.weixin.cp.bean.WxCpUser; | ||||||
| import org.testng.*; | import org.apache.commons.lang3.builder.ToStringBuilder; | ||||||
| import org.testng.annotations.*; | import org.apache.commons.lang3.builder.ToStringStyle; | ||||||
|  | import org.testng.Assert; | ||||||
|  | import org.testng.annotations.Guice; | ||||||
|  | import org.testng.annotations.Test; | ||||||
|  |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
|  | import static org.testng.Assert.assertNotEquals; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 测试用户接口 |  * 测试用户接口 | ||||||
|  * |  * | ||||||
|  * @author Daniel Qian |  * @author Daniel Qian | ||||||
|  */ |  */ | ||||||
| @Test(groups = "userAPI", dependsOnGroups = "baseAPI") | @Test(groups = "userAPI") | ||||||
| @Guice(modules = ApiTestModule.class) | @Guice(modules = ApiTestModule.class) | ||||||
| public class WxCpUserAPITest { | public class WxCpUserAPITest { | ||||||
|  |  | ||||||
|   @Inject |   @Inject | ||||||
|   protected WxCpServiceImpl wxCpService; |   protected WxCpServiceImpl wxCpService; | ||||||
|  |  | ||||||
|   protected WxCpDepart depart; |  | ||||||
|  |  | ||||||
|   public void testUserCreate() throws WxErrorException { |   public void testUserCreate() throws WxErrorException { | ||||||
|     WxCpUser user = new WxCpUser(); |     WxCpUser user = new WxCpUser(); | ||||||
|     user.setUserId("some.woman"); |     user.setUserId("some.woman"); | ||||||
| @ -33,7 +35,7 @@ public class WxCpUserAPITest { | |||||||
|     user.setGender("女"); |     user.setGender("女"); | ||||||
|     user.setMobile("13560084979"); |     user.setMobile("13560084979"); | ||||||
|     user.setPosition("woman"); |     user.setPosition("woman"); | ||||||
|     user.setTel("3300393"); |     user.setTelephone("3300393"); | ||||||
|     user.addExtAttr("爱好", "table"); |     user.addExtAttr("爱好", "table"); | ||||||
|     this.wxCpService.userCreate(user); |     this.wxCpService.userCreate(user); | ||||||
|   } |   } | ||||||
| @ -56,11 +58,19 @@ public class WxCpUserAPITest { | |||||||
|   @Test(dependsOnMethods = "testUserGet") |   @Test(dependsOnMethods = "testUserGet") | ||||||
|   public void testDepartGetUsers() throws WxErrorException { |   public void testDepartGetUsers() throws WxErrorException { | ||||||
|     List<WxCpUser> users = this.wxCpService.departGetUsers(1, true, 0); |     List<WxCpUser> users = this.wxCpService.departGetUsers(1, true, 0); | ||||||
|     Assert.assertNotEquals(users.size(), 0); |     assertNotEquals(users.size(), 0); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Test(dependsOnMethods = "testDepartGetUsers") |   @Test(dependsOnMethods = "testDepartGetUsers") | ||||||
|   public void testUserDelete() throws WxErrorException { |   public void testUserDelete() throws WxErrorException { | ||||||
|     this.wxCpService.userDelete("some.woman"); |     this.wxCpService.userDelete("some.woman"); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   public void testUserList() throws WxErrorException { | ||||||
|  |     List<WxCpUser> users = this.wxCpService.userList(1, true, 0); | ||||||
|  |     assertNotEquals(users.size(), 0); | ||||||
|  |     for (WxCpUser user : users) { | ||||||
|  |       System.out.println(ToStringBuilder.reflectionToString(user, ToStringStyle.MULTI_LINE_STYLE)); | ||||||
|  |     } | ||||||
|  |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -5,9 +5,11 @@ import me.chanjar.weixin.common.api.WxConsts; | |||||||
| import me.chanjar.weixin.common.bean.menu.WxMenu; | import me.chanjar.weixin.common.bean.menu.WxMenu; | ||||||
| import me.chanjar.weixin.common.bean.menu.WxMenuButton; | import me.chanjar.weixin.common.bean.menu.WxMenuButton; | ||||||
| import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||||
| import me.chanjar.weixin.cp.api.impl.apache.WxCpServiceImpl; | import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; | ||||||
| import org.testng.*; | import org.testng.Assert; | ||||||
| import org.testng.annotations.*; | import org.testng.annotations.DataProvider; | ||||||
|  | import org.testng.annotations.Guice; | ||||||
|  | import org.testng.annotations.Test; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 测试菜单 |  * 测试菜单 | ||||||
|  | |||||||
| @ -3,9 +3,9 @@ package me.chanjar.weixin.cp.bean; | |||||||
| import me.chanjar.weixin.common.api.WxConsts; | import me.chanjar.weixin.common.api.WxConsts; | ||||||
| import me.chanjar.weixin.cp.bean.article.MpnewsArticle; | import me.chanjar.weixin.cp.bean.article.MpnewsArticle; | ||||||
| import me.chanjar.weixin.cp.bean.article.NewArticle; | import me.chanjar.weixin.cp.bean.article.NewArticle; | ||||||
| import org.testng.annotations.*; | import org.testng.annotations.Test; | ||||||
|  |  | ||||||
| import static org.testng.Assert.*; | import static org.testng.Assert.assertEquals; | ||||||
|  |  | ||||||
| @Test | @Test | ||||||
| public class WxCpMessageTest { | public class WxCpMessageTest { | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| package me.chanjar.weixin.cp.bean; | package me.chanjar.weixin.cp.bean; | ||||||
|  |  | ||||||
| import me.chanjar.weixin.common.api.WxConsts; | import me.chanjar.weixin.common.api.WxConsts; | ||||||
| import org.testng.*; | import org.testng.Assert; | ||||||
| import org.testng.annotations.*; | import org.testng.annotations.Test; | ||||||
|  |  | ||||||
| @Test | @Test | ||||||
| public class WxCpXmlMessageTest { | public class WxCpXmlMessageTest { | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| package me.chanjar.weixin.cp.bean; | package me.chanjar.weixin.cp.bean; | ||||||
|  |  | ||||||
| import org.testng.*; | import org.testng.Assert; | ||||||
| import org.testng.annotations.*; | import org.testng.annotations.Test; | ||||||
|  |  | ||||||
| @Test | @Test | ||||||
| public class WxCpXmlOutImageMessageTest { | public class WxCpXmlOutImageMessageTest { | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| package me.chanjar.weixin.cp.bean; | package me.chanjar.weixin.cp.bean; | ||||||
|  |  | ||||||
| import org.testng.*; | import org.testng.Assert; | ||||||
| import org.testng.annotations.*; | import org.testng.annotations.Test; | ||||||
|  |  | ||||||
| @Test | @Test | ||||||
| public class WxCpXmlOutNewsMessageTest { | public class WxCpXmlOutNewsMessageTest { | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| package me.chanjar.weixin.cp.bean; | package me.chanjar.weixin.cp.bean; | ||||||
|  |  | ||||||
| import org.testng.*; | import org.testng.Assert; | ||||||
| import org.testng.annotations.*; | import org.testng.annotations.Test; | ||||||
|  |  | ||||||
| @Test | @Test | ||||||
| public class WxCpXmlOutTextMessageTest { | public class WxCpXmlOutTextMessageTest { | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| package me.chanjar.weixin.cp.bean; | package me.chanjar.weixin.cp.bean; | ||||||
|  |  | ||||||
| import org.testng.*; | import org.testng.Assert; | ||||||
| import org.testng.annotations.*; | import org.testng.annotations.Test; | ||||||
|  |  | ||||||
| @Test | @Test | ||||||
| public class WxCpXmlOutVideoMessageTest { | public class WxCpXmlOutVideoMessageTest { | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| package me.chanjar.weixin.cp.bean; | package me.chanjar.weixin.cp.bean; | ||||||
|  |  | ||||||
| import org.testng.*; | import org.testng.Assert; | ||||||
| import org.testng.annotations.*; | import org.testng.annotations.Test; | ||||||
|  |  | ||||||
| @Test | @Test | ||||||
| public class WxCpXmlOutVoiceMessageTest { | public class WxCpXmlOutVoiceMessageTest { | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ import me.chanjar.weixin.cp.api.WxCpConfigStorage; | |||||||
| import me.chanjar.weixin.cp.api.WxCpMessageHandler; | import me.chanjar.weixin.cp.api.WxCpMessageHandler; | ||||||
| import me.chanjar.weixin.cp.api.WxCpMessageRouter; | import me.chanjar.weixin.cp.api.WxCpMessageRouter; | ||||||
| import me.chanjar.weixin.cp.api.WxCpService; | import me.chanjar.weixin.cp.api.WxCpService; | ||||||
| import me.chanjar.weixin.cp.api.impl.apache.WxCpServiceImpl; | import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; | ||||||
| import me.chanjar.weixin.cp.bean.WxCpXmlMessage; | import me.chanjar.weixin.cp.bean.WxCpXmlMessage; | ||||||
| import me.chanjar.weixin.cp.bean.WxCpXmlOutMessage; | import me.chanjar.weixin.cp.bean.WxCpXmlOutMessage; | ||||||
| import me.chanjar.weixin.cp.bean.WxCpXmlOutTextMessage; | import me.chanjar.weixin.cp.bean.WxCpXmlOutTextMessage; | ||||||
|  | |||||||
| @ -3,9 +3,9 @@ | |||||||
| <suite name="Weixin-java-tool-suite" verbose="1"> | <suite name="Weixin-java-tool-suite" verbose="1"> | ||||||
|   <test name="API_Test"> |   <test name="API_Test"> | ||||||
|     <classes> |     <classes> | ||||||
|       <class name="me.chanjar.weixin.cp.api.impl.apache.WxCpBusyRetryTest"/> |       <class name="me.chanjar.weixin.cp.api.WxCpBusyRetryTest"/> | ||||||
|       <class name="me.chanjar.weixin.cp.api.impl.apache.WxCpBaseAPITest"/> |       <class name="me.chanjar.weixin.cp.api.WxCpBaseAPITest"/> | ||||||
|       <class name="me.chanjar.weixin.cp.api.impl.apache.WxCpMessageAPITest"/> |       <class name="me.chanjar.weixin.cp.api.WxCpMessageAPITest"/> | ||||||
|       <class name="me.chanjar.weixin.cp.api.WxMenuAPITest"/> |       <class name="me.chanjar.weixin.cp.api.WxMenuAPITest"/> | ||||||
|       <class name="me.chanjar.weixin.cp.api.WxCpDepartAPITest"/> |       <class name="me.chanjar.weixin.cp.api.WxCpDepartAPITest"/> | ||||||
|       <class name="me.chanjar.weixin.cp.api.WxCpMediaAPITest"/> |       <class name="me.chanjar.weixin.cp.api.WxCpMediaAPITest"/> | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Binary Wang
					Binary Wang