#698 企业微信OA数据接口单元测试代码优化

This commit is contained in:
Binary Wang 2019-05-12 12:25:50 +08:00
parent cf78cd52d2
commit 0287fb565b

View File

@ -1,5 +1,6 @@
package me.chanjar.weixin.cp.api.impl; package me.chanjar.weixin.cp.api.impl;
import com.google.common.collect.Lists;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.inject.Inject; import com.google.inject.Inject;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
@ -16,52 +17,33 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
/** /**
* @author Element * @author Element
* @Package me.chanjar.weixin.cp.api.impl
* @date 2019-04-20 13:46 * @date 2019-04-20 13:46
* @Description: TODO
*/ */
@Guice(modules = ApiTestModule.class) @Guice(modules = ApiTestModule.class)
public class WxCpOAServiceImplTest { public class WxCpOAServiceImplTest {
@Inject @Inject
protected WxCpService wxService; protected WxCpService wxService;
@Inject
protected Gson gson;
@Test @Test
public void testGetCheckinData() throws ParseException, WxErrorException { public void testGetCheckinData() throws ParseException, WxErrorException {
Date starttime,endtime; Date startTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-04-11");
List<String> userLists = new ArrayList<>(); Date endTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-05-10");
starttime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-01-01"); List<WxCpCheckinData> results = wxService.getOAService()
endtime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-01-20"); .getCheckinData(1, startTime, endTime, Lists.newArrayList("binary"));
userLists.add("1");
userLists.add("2");
userLists.add("3");
List<WxCpCheckinData> results = wxService.getOAService().getCheckinData(1, starttime,endtime,userLists);
System.out.println("results ");
System.out.println(gson.toJson(results));
assertThat(results).isNotNull();
} }
@Test @Test
public void testGetCheckinOption() throws WxErrorException { public void testGetCheckinOption() throws WxErrorException {
Date now = new Date(); Date now = new Date();
List<String> userLists = new ArrayList<>(); List<WxCpCheckinOption> results = wxService.getOAService()
.getCheckinOption(now, Lists.newArrayList("binary"));
userLists.add("user@aliyun.com"); assertThat(results).isNotNull();
List<WxCpCheckinOption> results = wxService.getOAService().getCheckinOption(now,userLists);
System.out.println("results ");
System.out.println(gson.toJson(results));
} }
} }