weixin4j-qy: 新增了会话API测试类
This commit is contained in:
parent
4778c22827
commit
0e8f7de752
@ -436,3 +436,7 @@
|
||||
+ **weixin4j-qy**: 重命名NotifyApi#sendNotify为sendNotifyMessage
|
||||
|
||||
+ `release`: weixin4j-[mp|qy] upgrade to 1.5.2,weixin4j-server upgrade to 1.0.4
|
||||
|
||||
* 2015-08-10
|
||||
|
||||
+ **weixin4j-qy**: 新增了会话API测试类
|
||||
|
||||
@ -95,3 +95,7 @@
|
||||
+ 重命名NotifyApi#sendNotify为sendNotifyMessage
|
||||
|
||||
+ version upgrade to 1.5.2
|
||||
|
||||
* 2015-08-10
|
||||
|
||||
+ 新增了会话API测试类
|
||||
@ -1,6 +1,7 @@
|
||||
package com.foxinmy.weixin4j.qy.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
@ -36,14 +37,18 @@ public class ChatInfo implements Serializable {
|
||||
@JSONField(name = "userlist")
|
||||
private List<String> members;
|
||||
|
||||
public ChatInfo() {
|
||||
protected ChatInfo() {
|
||||
|
||||
}
|
||||
|
||||
public ChatInfo(String chatId, String name, String owner) {
|
||||
public ChatInfo(String chatId) {
|
||||
this.chatId = chatId;
|
||||
}
|
||||
|
||||
public ChatInfo(String name, String owner, String... members) {
|
||||
this.name = name;
|
||||
this.owner = owner;
|
||||
this.members = Arrays.asList(members);
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
@ -66,6 +71,10 @@ public class ChatInfo implements Serializable {
|
||||
this.members = members;
|
||||
}
|
||||
|
||||
public void setMembers(String... members) {
|
||||
this.members = Arrays.asList(members);
|
||||
}
|
||||
|
||||
// ---------- setter 应该全部去掉
|
||||
|
||||
public void setChatId(String chatId) {
|
||||
|
||||
@ -35,7 +35,7 @@ public class Party implements Serializable {
|
||||
*/
|
||||
private int order;
|
||||
|
||||
public Party() {
|
||||
protected Party() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ public class Tag implements Serializable {
|
||||
@JSONField(name = "tagname")
|
||||
private String name;
|
||||
|
||||
public Tag() {
|
||||
protected Tag() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@ public class User implements Serializable {
|
||||
*/
|
||||
private List<NameValue> extattr;
|
||||
|
||||
public User() {
|
||||
protected User() {
|
||||
}
|
||||
|
||||
public User(String userId, String name) {
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -20,13 +20,13 @@ import com.foxinmy.weixin4j.tuple.Voice;
|
||||
/**
|
||||
* 客服消息测试
|
||||
*
|
||||
* @className MessageNotifyTest
|
||||
* @className NotifyTest
|
||||
* @author jy.hu
|
||||
* @date 2014年4月10日
|
||||
* @since JDK 1.7
|
||||
* @see
|
||||
*/
|
||||
public class NotifyMsgTest extends TokenTest {
|
||||
public class NotifyTest extends TokenTest {
|
||||
|
||||
private NotifyApi notifyApi;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user