添加图文分析数据接口

This commit is contained in:
BinaryWang
2016-08-25 18:06:33 +08:00
parent f0cd7dd63a
commit 14fb63d6de
11 changed files with 566 additions and 128 deletions

View File

@@ -1,21 +1,22 @@
package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.ApiTestModule;
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeArticleResult;
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeArticleTotal;
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate;
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.testng.Assert;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.ApiTestModule;
import me.chanjar.weixin.mp.bean.result.WxMpUserCumulate;
import me.chanjar.weixin.mp.bean.result.WxMpUserSummary;
/**
* 测试统计分析相关的接口
* Created by Binary Wang on 2016/8/23.
@@ -28,24 +29,91 @@ public class WxMpDataCubeServiceImplTest {
@Inject
protected WxMpServiceImpl wxService;
@Test
public void testGetUserSummary() throws WxErrorException, ParseException {
Date beginDate = simpleDateFormat.parse("2016-08-20");
Date endDate = simpleDateFormat.parse("2016-08-22");
List<WxMpUserSummary> summaries = this.wxService.getDataCubeService()
@DataProvider
public Object[][] oneDay() throws ParseException {
return new Object[][]{{simpleDateFormat.parse("2016-08-22")}};
}
@DataProvider
public Object[][] threeDays() throws ParseException {
return new Object[][]{{simpleDateFormat.parse("2016-08-20"),
simpleDateFormat.parse("2016-08-22")}};
}
@DataProvider
public Object[][] sevenDays() throws ParseException {
return new Object[][]{{simpleDateFormat.parse("2016-08-16"),
simpleDateFormat.parse("2016-08-22")}};
}
@Test(dataProvider = "sevenDays")
public void testGetUserSummary(Date beginDate, Date endDate)
throws WxErrorException {
List<WxDataCubeUserSummary> summaries = this.wxService.getDataCubeService()
.getUserSummary(beginDate, endDate);
Assert.assertNotNull(summaries);
System.out.println(summaries);
}
@Test
public void testGetUserCumulate() throws WxErrorException, ParseException {
Date beginDate = simpleDateFormat.parse("2016-08-21");
Date endDate = simpleDateFormat.parse("2016-08-22");
List<WxMpUserCumulate> cumulates = this.wxService.getDataCubeService()
@Test(dataProvider = "sevenDays")
public void testGetUserCumulate(Date beginDate, Date endDate)
throws WxErrorException {
List<WxDataCubeUserCumulate> result = this.wxService.getDataCubeService()
.getUserCumulate(beginDate, endDate);
Assert.assertNotNull(cumulates);
System.out.println(cumulates);
Assert.assertNotNull(result);
System.out.println(result);
}
@Test(dataProvider = "oneDay")
public void testGetArticleSummary(Date date) throws WxErrorException {
List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
.getArticleSummary(date, date);
Assert.assertNotNull(results);
System.out.println(results);
}
/**
* TODO 该接口,暂时没找到有数据的日期,无法测试验证
*/
@Test(dataProvider = "oneDay")
public void testGetArticleTotal(Date date) throws WxErrorException {
List<WxDataCubeArticleTotal> results = this.wxService.getDataCubeService()
.getArticleTotal(date, date);
Assert.assertNotNull(results);
System.out.println(results);
}
@Test(dataProvider = "threeDays")
public void testGetUserRead(Date beginDate, Date endDate)
throws WxErrorException {
List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
.getUserRead(beginDate, endDate);
Assert.assertNotNull(results);
System.out.println(results);
}
@Test(dataProvider = "oneDay")
public void testGetUserReadHour(Date date) throws WxErrorException {
List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
.getUserReadHour(date, date);
Assert.assertNotNull(results);
System.out.println(results);
}
@Test(dataProvider = "sevenDays")
public void testGetUserShare(Date beginDate, Date endDate)
throws WxErrorException {
List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
.getUserShare(beginDate, endDate);
Assert.assertNotNull(results);
System.out.println(results);
}
@Test(dataProvider = "oneDay")
public void testGetUserShareHour(Date date) throws WxErrorException {
List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
.getUserShareHour(date, date);
Assert.assertNotNull(results);
System.out.println(results);
}
}

View File

@@ -4,8 +4,6 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import org.testng.Assert;
import org.testng.annotations.Test;
import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfList;
@Test
public class WxMpKfListTest {