🎨 修复单元测试

This commit is contained in:
Binary Wang 2023-04-19 22:29:32 +08:00
parent 15b2cefaf8
commit a4fc7c9a7c
5 changed files with 15 additions and 20 deletions

View File

@ -10,8 +10,8 @@ import me.chanjar.weixin.cp.bean.message.WxCpXmlMessage;
import me.chanjar.weixin.cp.config.WxCpConfigStorage; import me.chanjar.weixin.cp.config.WxCpConfigStorage;
import me.chanjar.weixin.cp.constant.WxCpConsts; import me.chanjar.weixin.cp.constant.WxCpConsts;
import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage; import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import me.chanjar.weixin.cp.util.xml.XStreamTransformer; import me.chanjar.weixin.cp.util.xml.XStreamTransformer;
import org.eclipse.jetty.util.ajax.JSON;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.io.InputStream; import java.io.InputStream;
@ -67,7 +67,7 @@ public class WxCpLivingTest {
final WxCpXmlMessage livingXmlMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, livingXml); final WxCpXmlMessage livingXmlMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, livingXml);
livingXmlMsg.setAllFieldsMap(XmlUtils.xml2Map(livingXml)); livingXmlMsg.setAllFieldsMap(XmlUtils.xml2Map(livingXml));
log.info("livingXmlMsg:{}", JSON.toString(livingXmlMsg)); log.info("livingXmlMsg:{}", WxCpGsonBuilder.create().toJson(livingXmlMsg));
/** /**
* 直播回调事件常量 * 直播回调事件常量
@ -121,7 +121,7 @@ public class WxCpLivingTest {
*/ */
String livingCode = wxCpService.getLivingService().getLivingCode("o50by5NezHciWnoexJsrI49ILNqI", String livingCode = wxCpService.getLivingService().getLivingCode("o50by5NezHciWnoexJsrI49ILNqI",
"lvOQpTDwAAD2MYuOq9y_bmLNMJfbbdGw"); "lvOQpTDwAAD2MYuOq9y_bmLNMJfbbdGw");
log.info(JSON.toString(livingCode)); log.info(WxCpGsonBuilder.create().toJson(livingCode));
// 直播详情 // 直播详情
WxCpLivingInfo livingInfo = wxCpService.getLivingService().getLivingInfo("lvOQpTDwAAcP9wNOSSxTwpbni-TMPNSg"); WxCpLivingInfo livingInfo = wxCpService.getLivingService().getLivingInfo("lvOQpTDwAAcP9wNOSSxTwpbni-TMPNSg");

View File

@ -10,8 +10,8 @@ import me.chanjar.weixin.cp.bean.msgaudit.*;
import me.chanjar.weixin.cp.config.WxCpConfigStorage; import me.chanjar.weixin.cp.config.WxCpConfigStorage;
import me.chanjar.weixin.cp.constant.WxCpConsts; import me.chanjar.weixin.cp.constant.WxCpConsts;
import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage; import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import me.chanjar.weixin.cp.util.xml.XStreamTransformer; import me.chanjar.weixin.cp.util.xml.XStreamTransformer;
import org.eclipse.jetty.util.ajax.JSON;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -73,7 +73,7 @@ public class WxCpMsgAuditTest {
final WxCpXmlMessage msgAuditApprovedXmlMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, msgAuditApprovedXml); final WxCpXmlMessage msgAuditApprovedXmlMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, msgAuditApprovedXml);
msgAuditApprovedXmlMsg.setAllFieldsMap(XmlUtils.xml2Map(msgAuditApprovedXml)); msgAuditApprovedXmlMsg.setAllFieldsMap(XmlUtils.xml2Map(msgAuditApprovedXml));
log.info("msgAuditApprovedXmlMsg:{}", JSON.toString(msgAuditApprovedXmlMsg)); log.info("msgAuditApprovedXmlMsg:{}", WxCpGsonBuilder.create().toJson(msgAuditApprovedXmlMsg));
/* /*
* 产生会话回调事件 * 产生会话回调事件
@ -93,7 +93,7 @@ public class WxCpMsgAuditTest {
final WxCpXmlMessage msgAuditNotifyXmlMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, msgAuditNotifyXml); final WxCpXmlMessage msgAuditNotifyXmlMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, msgAuditNotifyXml);
msgAuditNotifyXmlMsg.setAllFieldsMap(XmlUtils.xml2Map(msgAuditNotifyXml)); msgAuditNotifyXmlMsg.setAllFieldsMap(XmlUtils.xml2Map(msgAuditNotifyXml));
log.info("msgAuditNotifyXmlMsg:{}", JSON.toString(msgAuditNotifyXmlMsg)); log.info("msgAuditNotifyXmlMsg:{}", WxCpGsonBuilder.create().toJson(msgAuditNotifyXmlMsg));
/* /*
* 增加变更事件类型产生会话回调事件 * 增加变更事件类型产生会话回调事件

View File

@ -13,7 +13,6 @@ import me.chanjar.weixin.cp.constant.WxCpConsts;
import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage; import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import me.chanjar.weixin.cp.util.xml.XStreamTransformer; import me.chanjar.weixin.cp.util.xml.XStreamTransformer;
import org.eclipse.jetty.util.ajax.JSON;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.io.InputStream; import java.io.InputStream;
@ -98,7 +97,7 @@ public class WxCpOaAgentTest {
"</xml>\n"; "</xml>\n";
final WxCpXmlMessage mess2 = XStreamTransformer.fromXml(WxCpXmlMessage.class, testXml2); final WxCpXmlMessage mess2 = XStreamTransformer.fromXml(WxCpXmlMessage.class, testXml2);
mess2.setAllFieldsMap(XmlUtils.xml2Map(testXml2)); mess2.setAllFieldsMap(XmlUtils.xml2Map(testXml2));
log.info("xmlJson: {}", JSON.toString(mess2)); log.info("xmlJson: {}", WxCpGsonBuilder.create().toJson(mess2));
/** /**
@ -123,7 +122,7 @@ public class WxCpOaAgentTest {
final WxCpXmlMessage mess = XStreamTransformer.fromXml(WxCpXmlMessage.class, testXml); final WxCpXmlMessage mess = XStreamTransformer.fromXml(WxCpXmlMessage.class, testXml);
mess.setAllFieldsMap(XmlUtils.xml2Map(testXml)); mess.setAllFieldsMap(XmlUtils.xml2Map(testXml));
log.info("xmlJson: {}", JSON.toString(mess)); log.info("xmlJson: {}", WxCpGsonBuilder.create().toJson(mess));
/** /**
@ -181,7 +180,7 @@ public class WxCpOaAgentTest {
final WxCpXmlMessage msg = XStreamTransformer.fromXml(WxCpXmlMessage.class, approvalInfoXml); final WxCpXmlMessage msg = XStreamTransformer.fromXml(WxCpXmlMessage.class, approvalInfoXml);
msg.setAllFieldsMap(XmlUtils.xml2Map(approvalInfoXml)); msg.setAllFieldsMap(XmlUtils.xml2Map(approvalInfoXml));
log.info("xmlJson: {}", JSON.toString(msg)); log.info("xmlJson: {}", WxCpGsonBuilder.create().toJson(msg));
/** /**
* 增加 * 增加

View File

@ -13,8 +13,8 @@ import me.chanjar.weixin.cp.bean.message.WxCpXmlMessage;
import me.chanjar.weixin.cp.bean.school.user.*; import me.chanjar.weixin.cp.bean.school.user.*;
import me.chanjar.weixin.cp.config.WxCpConfigStorage; import me.chanjar.weixin.cp.config.WxCpConfigStorage;
import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage; import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import me.chanjar.weixin.cp.util.xml.XStreamTransformer; import me.chanjar.weixin.cp.util.xml.XStreamTransformer;
import org.eclipse.jetty.util.ajax.JSON;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.io.InputStream; import java.io.InputStream;
@ -530,20 +530,20 @@ public class WxCpSchoolUserTest {
final WxCpXmlMessage createStudentMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, createStudentXml); final WxCpXmlMessage createStudentMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, createStudentXml);
Map<String, Object> map1 = XmlUtils.xml2Map(createStudentXml); Map<String, Object> map1 = XmlUtils.xml2Map(createStudentXml);
createStudentMsg.setAllFieldsMap(map1); createStudentMsg.setAllFieldsMap(map1);
log.info("createStudentMsg:{}", JSON.toString(createStudentMsg)); log.info("createStudentMsg:{}", WxCpGsonBuilder.create().toJson(createStudentMsg));
final WxCpXmlMessage unSubscribeMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, unSubscribeXml); final WxCpXmlMessage unSubscribeMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, unSubscribeXml);
Map<String, Object> map2 = XmlUtils.xml2Map(unSubscribeXml); Map<String, Object> map2 = XmlUtils.xml2Map(unSubscribeXml);
unSubscribeMsg.setAllFieldsMap(map2); unSubscribeMsg.setAllFieldsMap(map2);
log.info("unSubscribeMsg:{}", JSON.toString(unSubscribeMsg)); log.info("unSubscribeMsg:{}", WxCpGsonBuilder.create().toJson(unSubscribeMsg));
final WxCpXmlMessage createDepartmentMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, createDepartmentXml); final WxCpXmlMessage createDepartmentMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, createDepartmentXml);
createDepartmentMsg.setAllFieldsMap(XmlUtils.xml2Map(createDepartmentXml)); createDepartmentMsg.setAllFieldsMap(XmlUtils.xml2Map(createDepartmentXml));
log.info("createDepartmentMsg:{}", JSON.toString(createDepartmentMsg)); log.info("createDepartmentMsg:{}", WxCpGsonBuilder.create().toJson(createDepartmentMsg));
final WxCpXmlMessage deleteDepartmentMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, deleteDepartmentXml); final WxCpXmlMessage deleteDepartmentMsg = XStreamTransformer.fromXml(WxCpXmlMessage.class, deleteDepartmentXml);
deleteDepartmentMsg.setAllFieldsMap(XmlUtils.xml2Map(deleteDepartmentXml)); deleteDepartmentMsg.setAllFieldsMap(XmlUtils.xml2Map(deleteDepartmentXml));
log.info("deleteDepartmentMsg:{}", JSON.toString(deleteDepartmentMsg)); log.info("deleteDepartmentMsg:{}", WxCpGsonBuilder.create().toJson(deleteDepartmentMsg));
/** /**

View File

@ -9,14 +9,10 @@ import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeeting; import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeeting;
import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeetingUpdateResult; import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeetingUpdateResult;
import me.chanjar.weixin.cp.bean.oa.meeting.WxCpUserMeetingIdResult; import me.chanjar.weixin.cp.bean.oa.meeting.WxCpUserMeetingIdResult;
import org.eclipse.jetty.util.ajax.JSON;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.testng.collections.Lists; import org.testng.collections.Lists;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List; import java.util.List;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -55,7 +51,7 @@ public class WxCpMeetingServiceImplTest {
测试 创建会议 测试 创建会议
*/ */
long startTime = System.currentTimeMillis() / 1000 + 30 * 60L; long startTime = System.currentTimeMillis() / 1000 + 30 * 60L;
List<String> userIds = Lists.newArrayList(this.configStorage.getUserId(), "lisi"); List<String> userIds = Lists.newArrayList(this.configStorage.getUserId(), "lisi");
WxCpMeeting wxCpMeeting = new WxCpMeeting().setAdminUserId(this.configStorage.getUserId()).setTitle("新建会议") WxCpMeeting wxCpMeeting = new WxCpMeeting().setAdminUserId(this.configStorage.getUserId()).setTitle("新建会议")
.setMeetingStart(startTime).setMeetingDuration(3600).setDescription("新建会议描述").setLocation("广州媒体港") .setMeetingStart(startTime).setMeetingDuration(3600).setDescription("新建会议描述").setLocation("广州媒体港")
.setAttendees(new WxCpMeeting.Attendees().setUserId(userIds)) .setAttendees(new WxCpMeeting.Attendees().setUserId(userIds))