Browse Source

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

master
Binary Wang 6 years ago
parent
commit
0287fb565b
1 changed files with 12 additions and 30 deletions
  1. +12
    -30
      weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOAServiceImplTest.java

+ 12
- 30
weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOAServiceImplTest.java 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;
List<String> userLists = new ArrayList<>();

starttime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-01-01");
endtime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-01-20");
Date startTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-04-11");
Date endTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-05-10");


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));
List<WxCpCheckinData> results = wxService.getOAService()
.getCheckinData(1, startTime, endTime, Lists.newArrayList("binary"));


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<>();

userLists.add("user@aliyun.com");

List<WxCpCheckinOption> results = wxService.getOAService().getCheckinOption(now,userLists);

System.out.println("results ");
System.out.println(gson.toJson(results));
List<WxCpCheckinOption> results = wxService.getOAService()
.getCheckinOption(now, Lists.newArrayList("binary"));
assertThat(results).isNotNull();
} }
} }

Loading…
Cancel
Save