Skip to content

Commit a4fc7c9

Browse files
committed
🎨 修复单元测试
1 parent 15b2cef commit a4fc7c9

File tree

5 files changed

+15
-20
lines changed

5 files changed

+15
-20
lines changed

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpLivingTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import me.chanjar.weixin.cp.config.WxCpConfigStorage;
1111
import me.chanjar.weixin.cp.constant.WxCpConsts;
1212
import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage;
13+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
1314
import me.chanjar.weixin.cp.util.xml.XStreamTransformer;
14-
import org.eclipse.jetty.util.ajax.JSON;
1515
import org.testng.annotations.Test;
1616

1717
import java.io.InputStream;
@@ -67,7 +67,7 @@ public void test() throws WxErrorException {
6767

6868
final WxCpXmlMessage livingXmlMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, livingXml);
6969
livingXmlMsg.setAllFieldsMap(XmlUtils.xml2Map(livingXml));
70-
log.info("livingXmlMsg:{}", JSON.toString(livingXmlMsg));
70+
log.info("livingXmlMsg:{}", WxCpGsonBuilder.create().toJson(livingXmlMsg));
7171

7272
/**
7373
* 直播回调事件常量
@@ -121,7 +121,7 @@ public void test() throws WxErrorException {
121121
*/
122122
String livingCode = wxCpService.getLivingService().getLivingCode("o50by5NezHciWnoexJsrI49ILNqI",
123123
"lvOQpTDwAAD2MYuOq9y_bmLNMJfbbdGw");
124-
log.info(JSON.toString(livingCode));
124+
log.info(WxCpGsonBuilder.create().toJson(livingCode));
125125

126126
// 直播详情
127127
WxCpLivingInfo livingInfo = wxCpService.getLivingService().getLivingInfo("lvOQpTDwAAcP9wNOSSxTwpbni-TMPNSg");

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMsgAuditTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import me.chanjar.weixin.cp.config.WxCpConfigStorage;
1111
import me.chanjar.weixin.cp.constant.WxCpConsts;
1212
import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage;
13+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
1314
import me.chanjar.weixin.cp.util.xml.XStreamTransformer;
14-
import org.eclipse.jetty.util.ajax.JSON;
1515
import org.testng.annotations.BeforeTest;
1616
import org.testng.annotations.Test;
1717

@@ -73,7 +73,7 @@ public void test() throws Exception {
7373

7474
final WxCpXmlMessage msgAuditApprovedXmlMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, msgAuditApprovedXml);
7575
msgAuditApprovedXmlMsg.setAllFieldsMap(XmlUtils.xml2Map(msgAuditApprovedXml));
76-
log.info("msgAuditApprovedXmlMsg:{}", JSON.toString(msgAuditApprovedXmlMsg));
76+
log.info("msgAuditApprovedXmlMsg:{}", WxCpGsonBuilder.create().toJson(msgAuditApprovedXmlMsg));
7777

7878
/*
7979
* 产生会话回调事件
@@ -93,7 +93,7 @@ public void test() throws Exception {
9393

9494
final WxCpXmlMessage msgAuditNotifyXmlMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, msgAuditNotifyXml);
9595
msgAuditNotifyXmlMsg.setAllFieldsMap(XmlUtils.xml2Map(msgAuditNotifyXml));
96-
log.info("msgAuditNotifyXmlMsg:{}", JSON.toString(msgAuditNotifyXmlMsg));
96+
log.info("msgAuditNotifyXmlMsg:{}", WxCpGsonBuilder.create().toJson(msgAuditNotifyXmlMsg));
9797

9898
/*
9999
* 增加变更事件类型:产生会话回调事件

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaAgentTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage;
1414
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
1515
import me.chanjar.weixin.cp.util.xml.XStreamTransformer;
16-
import org.eclipse.jetty.util.ajax.JSON;
1716
import org.testng.annotations.Test;
1817

1918
import java.io.InputStream;
@@ -98,7 +97,7 @@ public void test() throws WxErrorException {
9897
"</xml>\n";
9998
final WxCpXmlMessage mess2 = XStreamTransformer.fromXml(WxCpXmlMessage.class, testXml2);
10099
mess2.setAllFieldsMap(XmlUtils.xml2Map(testXml2));
101-
log.info("xmlJson: {}", JSON.toString(mess2));
100+
log.info("xmlJson: {}", WxCpGsonBuilder.create().toJson(mess2));
102101

103102

104103
/**
@@ -123,7 +122,7 @@ public void test() throws WxErrorException {
123122

124123
final WxCpXmlMessage mess = XStreamTransformer.fromXml(WxCpXmlMessage.class, testXml);
125124
mess.setAllFieldsMap(XmlUtils.xml2Map(testXml));
126-
log.info("xmlJson: {}", JSON.toString(mess));
125+
log.info("xmlJson: {}", WxCpGsonBuilder.create().toJson(mess));
127126

128127

129128
/**
@@ -181,7 +180,7 @@ public void test() throws WxErrorException {
181180

182181
final WxCpXmlMessage msg = XStreamTransformer.fromXml(WxCpXmlMessage.class, approvalInfoXml);
183182
msg.setAllFieldsMap(XmlUtils.xml2Map(approvalInfoXml));
184-
log.info("xmlJson: {}", JSON.toString(msg));
183+
log.info("xmlJson: {}", WxCpGsonBuilder.create().toJson(msg));
185184

186185
/**
187186
* 增加

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpSchoolUserTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
import me.chanjar.weixin.cp.bean.school.user.*;
1414
import me.chanjar.weixin.cp.config.WxCpConfigStorage;
1515
import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage;
16+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
1617
import me.chanjar.weixin.cp.util.xml.XStreamTransformer;
17-
import org.eclipse.jetty.util.ajax.JSON;
1818
import org.testng.annotations.Test;
1919

2020
import java.io.InputStream;
@@ -530,20 +530,20 @@ public void test() throws WxErrorException {
530530
final WxCpXmlMessage createStudentMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, createStudentXml);
531531
Map<String, Object> map1 = XmlUtils.xml2Map(createStudentXml);
532532
createStudentMsg.setAllFieldsMap(map1);
533-
log.info("createStudentMsg:{}", JSON.toString(createStudentMsg));
533+
log.info("createStudentMsg:{}", WxCpGsonBuilder.create().toJson(createStudentMsg));
534534

535535
final WxCpXmlMessage unSubscribeMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, unSubscribeXml);
536536
Map<String, Object> map2 = XmlUtils.xml2Map(unSubscribeXml);
537537
unSubscribeMsg.setAllFieldsMap(map2);
538-
log.info("unSubscribeMsg:{}", JSON.toString(unSubscribeMsg));
538+
log.info("unSubscribeMsg:{}", WxCpGsonBuilder.create().toJson(unSubscribeMsg));
539539

540540
final WxCpXmlMessage createDepartmentMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, createDepartmentXml);
541541
createDepartmentMsg.setAllFieldsMap(XmlUtils.xml2Map(createDepartmentXml));
542-
log.info("createDepartmentMsg:{}", JSON.toString(createDepartmentMsg));
542+
log.info("createDepartmentMsg:{}", WxCpGsonBuilder.create().toJson(createDepartmentMsg));
543543

544544
final WxCpXmlMessage deleteDepartmentMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, deleteDepartmentXml);
545545
deleteDepartmentMsg.setAllFieldsMap(XmlUtils.xml2Map(deleteDepartmentXml));
546-
log.info("deleteDepartmentMsg:{}", JSON.toString(deleteDepartmentMsg));
546+
log.info("deleteDepartmentMsg:{}", WxCpGsonBuilder.create().toJson(deleteDepartmentMsg));
547547

548548

549549
/**

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMeetingServiceImplTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,10 @@
99
import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeeting;
1010
import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeetingUpdateResult;
1111
import me.chanjar.weixin.cp.bean.oa.meeting.WxCpUserMeetingIdResult;
12-
import org.eclipse.jetty.util.ajax.JSON;
1312
import org.testng.annotations.Guice;
1413
import org.testng.annotations.Test;
1514
import org.testng.collections.Lists;
1615

17-
import java.util.ArrayList;
18-
import java.util.Arrays;
19-
import java.util.Date;
2016
import java.util.List;
2117

2218
import static org.assertj.core.api.Assertions.assertThat;
@@ -55,7 +51,7 @@ public void testAdd() throws WxErrorException {
5551
测试 创建会议
5652
*/
5753
long startTime = System.currentTimeMillis() / 1000 + 30 * 60L;
58-
List<String> userIds = Lists.newArrayList(this.configStorage.getUserId(), "lisi");
54+
List<String> userIds = Lists.newArrayList(this.configStorage.getUserId(), "lisi");
5955
WxCpMeeting wxCpMeeting = new WxCpMeeting().setAdminUserId(this.configStorage.getUserId()).setTitle("新建会议")
6056
.setMeetingStart(startTime).setMeetingDuration(3600).setDescription("新建会议描述").setLocation("广州媒体港")
6157
.setAttendees(new WxCpMeeting.Attendees().setUserId(userIds))

0 commit comments

Comments
 (0)