1 package com.foxinmy.weixin4j.qy.test;
2
3 import java.util.List;
4
5 import org.junit.Assert;
6 import org.junit.Before;
7 import org.junit.Test;
8
9 import com.foxinmy.weixin4j.exception.WeixinException;
10 import com.foxinmy.weixin4j.http.weixin.ApiResult;
11 import com.foxinmy.weixin4j.qy.api.PartyApi;
12 import com.foxinmy.weixin4j.qy.model.Party;
13
14
15
16
17
18
19
20
21
22
23 public class PartyTest extends TokenTest {
24 public PartyApi partyApi;
25
26 @Before
27 public void init() {
28 this.partyApi = new PartyApi(tokenManager);
29 }
30
31 @Test
32 public void create() throws WeixinException {
33 Party Party = new Party(1, "苦逼组", 1);
34 int id = partyApi.createParty(Party);
35 Assert.assertTrue(id > 0);
36 }
37
38 @Test
39 public void update() throws WeixinException {
40 Party Party = new Party(2, "苦逼组111", 1);
41 ApiResult result = partyApi.updateParty(Party);
42 Assert.assertEquals("updated", result.getReturnMsg());
43 }
44
45 @Test
46 public void list() throws WeixinException {
47 List<Party> list = partyApi.listParty(0);
48 Assert.assertFalse(list.isEmpty());
49 System.out.println(list);
50 }
51
52 @Test
53 public void delete() throws WeixinException {
54 ApiResult result = partyApi.deleteParty(2);
55 Assert.assertEquals("deleted", result.getReturnMsg());
56 }
57 }