weixin4j-qy: 新增了会话API测试类

This commit is contained in:
jinyu 2015-08-10 20:42:50 +08:00
parent 4778c22827
commit 0e8f7de752
8 changed files with 88 additions and 8 deletions

View File

@ -436,3 +436,7 @@
+ **weixin4j-qy**: 重命名NotifyApi#sendNotify为sendNotifyMessage + **weixin4j-qy**: 重命名NotifyApi#sendNotify为sendNotifyMessage
+ `release`: weixin4j-[mp|qy] upgrade to 1.5.2,weixin4j-server upgrade to 1.0.4 + `release`: weixin4j-[mp|qy] upgrade to 1.5.2,weixin4j-server upgrade to 1.0.4
* 2015-08-10
+ **weixin4j-qy**: 新增了会话API测试类

View File

@ -95,3 +95,7 @@
+ 重命名NotifyApi#sendNotify为sendNotifyMessage + 重命名NotifyApi#sendNotify为sendNotifyMessage
+ version upgrade to 1.5.2 + version upgrade to 1.5.2
* 2015-08-10
+ 新增了会话API测试类

View File

@ -1,6 +1,7 @@
package com.foxinmy.weixin4j.qy.model; package com.foxinmy.weixin4j.qy.model;
import java.io.Serializable; import java.io.Serializable;
import java.util.Arrays;
import java.util.List; import java.util.List;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
@ -36,14 +37,18 @@ public class ChatInfo implements Serializable {
@JSONField(name = "userlist") @JSONField(name = "userlist")
private List<String> members; private List<String> members;
public ChatInfo() { protected ChatInfo() {
} }
public ChatInfo(String chatId, String name, String owner) { public ChatInfo(String chatId) {
this.chatId = chatId; this.chatId = chatId;
}
public ChatInfo(String name, String owner, String... members) {
this.name = name; this.name = name;
this.owner = owner; this.owner = owner;
this.members = Arrays.asList(members);
} }
public String getChatId() { public String getChatId() {
@ -66,6 +71,10 @@ public class ChatInfo implements Serializable {
this.members = members; this.members = members;
} }
public void setMembers(String... members) {
this.members = Arrays.asList(members);
}
// ---------- setter 应该全部去掉 // ---------- setter 应该全部去掉
public void setChatId(String chatId) { public void setChatId(String chatId) {

View File

@ -35,7 +35,7 @@ public class Party implements Serializable {
*/ */
private int order; private int order;
public Party() { protected Party() {
} }

View File

@ -28,7 +28,7 @@ public class Tag implements Serializable {
@JSONField(name = "tagname") @JSONField(name = "tagname")
private String name; private String name;
public Tag() { protected Tag() {
} }

View File

@ -77,7 +77,7 @@ public class User implements Serializable {
*/ */
private List<NameValue> extattr; private List<NameValue> extattr;
public User() { protected User() {
} }
public User(String userId, String name) { public User(String userId, String name) {

View File

@ -0,0 +1,63 @@
package com.foxinmy.weixin4j.qy.test;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import com.foxinmy.weixin4j.exception.WeixinException;
import com.foxinmy.weixin4j.qy.api.ChatApi;
import com.foxinmy.weixin4j.qy.message.ChatMessage;
import com.foxinmy.weixin4j.qy.model.ChatInfo;
import com.foxinmy.weixin4j.qy.type.ChatType;
import com.foxinmy.weixin4j.tuple.Text;
public class ChatTest extends TokenTest {
private ChatApi chatApi;
@Before
public void init() {
chatApi = new ChatApi(tokenHolder);
}
@Test
public void createChat() throws WeixinException {
ChatInfo chatInfo = new ChatInfo("test", "jinyu", "jinyu", "jiaolong",
"keneng");
String chatId = chatApi.createChat(chatInfo);
System.err.println(chatId);
// 55c87507d4c64543a62583f7
}
@Test
public void getChat() throws WeixinException {
ChatInfo chatInfo = chatApi.getChat("55c87507d4c64543a62583f7");
System.err.println(chatInfo);
}
@Test
public void updateChat() throws WeixinException {
ChatInfo chatInfo = new ChatInfo("55c87507d4c64543a62583f7");
chatInfo.setName("test1");
chatApi.updateChat(chatInfo, "jinyu", Arrays.asList("keneng"), null);
}
@Test
public void quitChat() throws WeixinException {
chatApi.quitChat("55c87507d4c64543a62583f7", "keneng");
}
@Test
public void clearChatNotify() throws WeixinException {
chatApi.clearChatNotify("55c87507d4c64543a62583f7", "jinyu",
ChatType.group);
}
@Test
public void sendChatMessage() throws WeixinException {
ChatMessage message = new ChatMessage("55c87507d4c64543a62583f7",
ChatType.group, "keneng", new Text("test"));
chatApi.sendChatMessage(message);
}
}

View File

@ -20,13 +20,13 @@ import com.foxinmy.weixin4j.tuple.Voice;
/** /**
* 客服消息测试 * 客服消息测试
* *
* @className MessageNotifyTest * @className NotifyTest
* @author jy.hu * @author jy.hu
* @date 2014年4月10日 * @date 2014年4月10日
* @since JDK 1.7 * @since JDK 1.7
* @see * @see
*/ */
public class NotifyMsgTest extends TokenTest { public class NotifyTest extends TokenTest {
private NotifyApi notifyApi; private NotifyApi notifyApi;