Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
commit
  • Loading branch information
Alixhan committed Oct 28, 2022
commit 071e9ff966981ed254e9378f64d476f6b5871749
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage;
import me.chanjar.weixin.cp.util.xml.XStreamTransformer;
import org.eclipse.jetty.util.ajax.JSON;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import java.io.File;
Expand Down Expand Up @@ -41,7 +42,9 @@ public class WxCpMsgAuditTest {
*/
// com.binarywang.spring.starter.wxjava.cp.config.WxCpServiceAutoConfiguration
// WxCpServiceImpl.getAccessToken()
private WxCpService initCpservice() {

@BeforeTest
private void initCpservice() {
if(cpService == null) {
InputStream inputStream = ClassLoader.getSystemResourceAsStream("test-config.xml");
WxCpDemoInMemoryConfigStorage config = WxCpDemoInMemoryConfigStorage.fromXml(inputStream);
Expand All @@ -50,12 +53,10 @@ private WxCpService initCpservice() {
cpService = new WxCpServiceImpl();
cpService.setWxCpConfigStorage(config);
}
return cpService;
}

@Test
public void test() throws Exception {
this.initCpservice();
/**
* 客户同意进行聊天内容存档事件回调
* 配置了客户联系功能的成员添加外部联系人同意进行聊天内容存档时,回调该事件。
Expand Down Expand Up @@ -657,7 +658,6 @@ public void test() throws Exception {

@Test
public void testGetMediaFile() throws Exception {
this.initCpservice();
WxCpMsgAuditService msgAuditService = cpService.getMsgAuditService();
WxCpChatDatas chatDatas = msgAuditService.getChatDatas(0L, 100L, null, null, 10);
for (WxCpChatDatas.WxCpChatData chatDatum : chatDatas.getChatData()) {
Expand Down Expand Up @@ -740,6 +740,8 @@ public void testGetMediaFile() throws Exception {
File file = new File(targetPath);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}else{
file.delete();
}
cpService.getMsgAuditService().getMediaFile(chatDatas.getSdk(), sdkFileId, null, null, 1000L, data -> {
try {
Expand Down