🆕 #3320【企业微信】增加异步上传临时素材相关接口
This commit is contained in:
@@ -7,6 +7,8 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.api.ApiTestModule;
|
||||
import me.chanjar.weixin.cp.api.TestConstants;
|
||||
import me.chanjar.weixin.cp.api.WxCpService;
|
||||
import me.chanjar.weixin.cp.bean.media.MediaUploadByUrlReq;
|
||||
import me.chanjar.weixin.cp.bean.media.MediaUploadByUrlResult;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -127,4 +129,38 @@ public class WxCpMediaServiceImplTest {
|
||||
assertThat(file).isNotNull();
|
||||
System.out.println(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test upload media by url.
|
||||
*
|
||||
* @throws WxErrorException the wx error exception
|
||||
*/
|
||||
@Test
|
||||
public void testUploadMediaByUrl() throws WxErrorException {
|
||||
MediaUploadByUrlReq req = new MediaUploadByUrlReq();
|
||||
req.setScene(1);
|
||||
req.setType("video");
|
||||
req.setFilename("mov_bbb");
|
||||
req.setUrl("https://www.w3school.com.cn/example/html5/mov_bbb.mp4");
|
||||
req.setMd5("198918f40ecc7cab0fc4231adaf67c96");
|
||||
String jobId = this.wxService.getMediaService().uploadByUrl(req);
|
||||
System.out.println(jobId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test upload media by url.
|
||||
*
|
||||
* @throws WxErrorException the wx error exception
|
||||
*/
|
||||
@Test
|
||||
public void testUploadMediaByUrlResult() throws WxErrorException, InterruptedException {
|
||||
String jobId = "job1745801375_5GIKWuFF3M7hcIkeSNMqs_W26xy5VeSWjLaLFTEdSfQ";
|
||||
MediaUploadByUrlResult result = this.wxService.getMediaService().uploadByUrl(jobId);
|
||||
System.out.println(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadMediaJobFinishEvent() throws WxErrorException {
|
||||
File file = this.wxService.getMediaService().getJssdkFile("....");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import me.chanjar.weixin.cp.util.xml.XStreamTransformer;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static me.chanjar.weixin.cp.constant.WxCpConsts.EventType.TASKCARD_CLICK;
|
||||
import static me.chanjar.weixin.cp.constant.WxCpConsts.EventType.UPLOAD_MEDIA_JOB_FINISH;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
@@ -421,4 +422,24 @@ public class WxCpXmlMessageTest {
|
||||
assertThat(wxCpXmlMessage.getApprovalInfo().getApprovalNodes().get(0).getItems().get(0).getItemName()).isNotEmpty();
|
||||
assertThat(wxCpXmlMessage.getApprovalInfo().getNotifyNodes().get(0).getItemName()).isNotEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test open approval change.
|
||||
*/
|
||||
public void testUploadMediaJobFinishEvent() {
|
||||
String xml = "<xml>\n" +
|
||||
"\t<ToUserName><![CDATA[wx28dbb14e3720FAKE]]></ToUserName>\n" +
|
||||
"\t<FromUserName><![CDATA[sys]]></FromUserName>\n" +
|
||||
"\t<CreateTime>1425284517</CreateTime>\n" +
|
||||
"\t<MsgType><![CDATA[event]]></MsgType>\n" +
|
||||
"\t<Event><![CDATA[upload_media_job_finish]]></Event>\n" +
|
||||
"\t<JobId><![CDATA[jobid_S0MrnndvRG5fadSlLwiBqiDDbM143UqTmKP3152FZk4]]></JobId>\n" +
|
||||
"</xml>";
|
||||
|
||||
WxCpXmlMessage wxCpXmlMessage = WxCpXmlMessage.fromXml(xml);
|
||||
assertThat(wxCpXmlMessage).isNotNull();
|
||||
assertThat(wxCpXmlMessage.getJobId()).isNotEmpty();
|
||||
assertThat(wxCpXmlMessage.getJobId()).isEqualTo("jobid_S0MrnndvRG5fadSlLwiBqiDDbM143UqTmKP3152FZk4");
|
||||
assertThat(wxCpXmlMessage.getEvent()).isEqualTo(UPLOAD_MEDIA_JOB_FINISH);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user