1 package com.foxinmy.weixin4j.qy.test;
2
3 import java.util.Arrays;
4
5 import org.junit.Before;
6 import org.junit.Test;
7
8 import com.foxinmy.weixin4j.exception.WeixinException;
9 import com.foxinmy.weixin4j.qy.api.ChatApi;
10 import com.foxinmy.weixin4j.qy.message.ChatMessage;
11 import com.foxinmy.weixin4j.qy.model.ChatInfo;
12 import com.foxinmy.weixin4j.qy.type.ChatType;
13 import com.foxinmy.weixin4j.tuple.Text;
14
15 public class ChatTest extends TokenTest {
16
17 private ChatApi chatApi;
18
19 @Before
20 public void init() {
21 chatApi = new ChatApi(tokenManager);
22 }
23
24 @Test
25 public void createChat() throws WeixinException {
26 ChatInfo chatInfo = new ChatInfo("test", "jinyu", "jinyu", "jiaolong",
27 "keneng");
28 String chatId = chatApi.createChat(chatInfo);
29 System.err.println(chatId);
30
31 }
32
33 @Test
34 public void getChat() throws WeixinException {
35 ChatInfo chatInfo = chatApi.getChat("55c87507d4c64543a62583f7");
36 System.err.println(chatInfo);
37 }
38
39 @Test
40 public void updateChat() throws WeixinException {
41 ChatInfo chatInfo = new ChatInfo("55c87507d4c64543a62583f7");
42 chatInfo.setName("test1");
43 chatApi.updateChat(chatInfo, "jinyu", Arrays.asList("keneng"), null);
44 }
45
46 @Test
47 public void quitChat() throws WeixinException {
48 chatApi.quitChat("55c87507d4c64543a62583f7", "keneng");
49 }
50
51 @Test
52 public void clearChatNotify() throws WeixinException {
53 chatApi.clearChatNotify("55c87507d4c64543a62583f7", "jinyu",
54 ChatType.group);
55 }
56
57 @Test
58 public void sendChatMessage() throws WeixinException {
59 ChatMessage message = new ChatMessage("55c87507d4c64543a62583f7",
60 ChatType.group, "keneng", new Text("test"));
61 chatApi.sendChatMessage(message);
62 }
63 }