1
0
mirror of synced 2025-12-22 18:08:12 +08:00

🆕 #1675 企业微信增加创建日历的接口,以及相关回调事件消息通知的支持

This commit is contained in:
Binary Wang
2020-09-20 15:37:40 +08:00
parent 6713787bb9
commit 1598c61e56
11 changed files with 316 additions and 9 deletions

View File

@@ -0,0 +1,39 @@
package me.chanjar.weixin.cp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.ApiTestModule;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.oa.calendar.WxCpOaCalendar;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.util.Arrays;
/**
* 单元测试.
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
* @date 2020-09-20
*/
@Test
@Guice(modules = ApiTestModule.class)
public class WxCpOaCalendarServiceImplTest {
@Inject
protected WxCpService wxService;
@Test
public void testAdd() throws WxErrorException {
this.wxService.getOaCalendarService().add(WxCpOaCalendar.builder()
.organizer("userid1")
.readonly(1)
.setAsDefault(1)
.summary("test_summary")
.color("#FF3030")
.description("test_describe")
.shares(Arrays.asList(new WxCpOaCalendar.ShareInfo("userid2", null),
new WxCpOaCalendar.ShareInfo("userid3", 1)))
.build());
}
}

View File

@@ -37,7 +37,7 @@ public class WxCpOaServiceImplTest {
Date startTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-04-11");
Date endTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-05-10");
List<WxCpCheckinData> results = wxService.getOAService()
List<WxCpCheckinData> results = wxService.getOaService()
.getCheckinData(1, startTime, endTime, Lists.newArrayList("binary"));
assertThat(results).isNotNull();
@@ -51,7 +51,7 @@ public class WxCpOaServiceImplTest {
public void testGetCheckinOption() throws WxErrorException {
Date now = new Date();
List<WxCpCheckinOption> results = wxService.getOAService().getCheckinOption(now, Lists.newArrayList("binary"));
List<WxCpCheckinOption> results = wxService.getOaService().getCheckinOption(now, Lists.newArrayList("binary"));
assertThat(results).isNotNull();
System.out.println("results ");
System.out.println(gson.toJson(results));
@@ -61,7 +61,7 @@ public class WxCpOaServiceImplTest {
public void testGetApprovalInfo() throws WxErrorException, ParseException {
Date startTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-12-01");
Date endTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-12-31");
WxCpApprovalInfo result = wxService.getOAService().getApprovalInfo(startTime, endTime);
WxCpApprovalInfo result = wxService.getOaService().getApprovalInfo(startTime, endTime);
assertThat(result).isNotNull();
@@ -72,7 +72,7 @@ public class WxCpOaServiceImplTest {
@Test
public void testGetApprovalDetail() throws WxErrorException {
String spNo = "201912020001";
WxCpApprovalDetailResult result = wxService.getOAService().getApprovalDetail(spNo);
WxCpApprovalDetailResult result = wxService.getOaService().getApprovalDetail(spNo);
assertThat(result).isNotNull();
@@ -83,7 +83,7 @@ public class WxCpOaServiceImplTest {
@Test
public void testGetTemplateDetail() throws WxErrorException {
String templateId = "3TkZjxugodbqpEMk9j7X6h6zKqYkc7MxQrrFmT7H";
WxCpTemplateResult result = wxService.getOAService().getTemplateDetail(templateId);
WxCpTemplateResult result = wxService.getOaService().getTemplateDetail(templateId);
assertThat(result).isNotNull();
System.out.println("result ");
System.out.println(gson.toJson(result));
@@ -91,7 +91,7 @@ public class WxCpOaServiceImplTest {
@Test
public void testApply() throws WxErrorException {
this.wxService.getOAService().apply(new WxCpOaApplyEventRequest().setCreatorUserId("123"));
this.wxService.getOaService().apply(new WxCpOaApplyEventRequest().setCreatorUserId("123"));
}
@Test

View File

@@ -0,0 +1,52 @@
package me.chanjar.weixin.cp.bean.oa.calendar;
import me.chanjar.weixin.common.util.json.GsonParser;
import org.testng.annotations.Test;
import java.util.Arrays;
import static org.assertj.core.api.Assertions.assertThat;
/**
* 单元测试.
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
* @date 2020-09-20
*/
public class WxCpOaCalendarTest {
@Test
public void testToJson() {
String json = "{\n" +
" \"calendar\" : {\n" +
" \"organizer\" : \"userid1\",\n" +
" \"readonly\" : 1,\n" +
" \"set_as_default\" : 1,\n" +
" \"summary\" : \"test_summary\",\n" +
" \"color\" : \"#FF3030\",\n" +
" \"description\" : \"test_describe\",\n" +
" \"shares\" : [\n" +
" {\n" +
" \"userid\" : \"userid2\"\n" +
" },\n" +
" {\n" +
" \"userid\" : \"userid3\",\n" +
" \"readonly\" : 1\n" +
" }\n" +
" ]\n" +
" }\n" +
"}\n";
assertThat(WxCpOaCalendar.builder()
.organizer("userid1")
.readonly(1)
.setAsDefault(1)
.summary("test_summary")
.color("#FF3030")
.description("test_describe")
.shares(Arrays.asList(new WxCpOaCalendar.ShareInfo("userid2", null),
new WxCpOaCalendar.ShareInfo("userid3", 1)))
.build().toJson())
.isEqualTo(GsonParser.parse(json).toString());
}
}