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

#835 小程序模块增加微信运动数据解密方法

This commit is contained in:
Binary Wang
2018-11-04 15:20:00 +08:00
parent 4b7cce8706
commit e204b0e2e4
6 changed files with 163 additions and 6 deletions

View File

@@ -0,0 +1,43 @@
package cn.binarywang.wx.miniapp.bean;
import java.util.List;
import org.testng.annotations.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.Assert.*;
/**
* <pre>
*
* Created by Binary Wang on 2018/11/4.
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
public class WxMaRunStepInfoTest {
@Test
public void testFromJson() {
// 数据来源https://developers.weixin.qq.com/miniprogram/dev/api/open-api/werun/wx.getWeRunData.html
String json = "{\n" +
" \"stepInfoList\": [\n" +
" {\n" +
" \"timestamp\": 1445866601,\n" +
" \"step\": 100\n" +
" },\n" +
" {\n" +
" \"timestamp\": 1445876601,\n" +
" \"step\": 120\n" +
" }\n" +
" ]\n" +
"}";
final List<WxMaRunStepInfo> stepInfoList = WxMaRunStepInfo.fromJson(json);
assertThat(stepInfoList).isNotEmpty();
assertThat(stepInfoList.get(0).getStep()).isEqualTo(100);
assertThat(stepInfoList.get(0).getTimestamp()).isEqualTo(1445866601);
assertThat(stepInfoList.get(1).getStep()).isEqualTo(120);
assertThat(stepInfoList.get(1).getTimestamp()).isEqualTo(1445876601);
}
}