forked from binarywang/WxJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2de4ac
commit b693c5f
Showing
1 changed file
with
152 additions
and
0 deletions.
There are no files selected for viewing
152 changes: 152 additions & 0 deletions
152
weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/menu/WxMpMenuTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
package me.chanjar.weixin.mp.bean.menu; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* 单元测试. | ||
* | ||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | ||
* @date 2020-11-05 | ||
*/ | ||
public class WxMpMenuTest { | ||
|
||
@Test | ||
public void testFromJson() { | ||
String json = "{\n" + | ||
" \"menu\": {\n" + | ||
" \"button\": [\n" + | ||
" {\n" + | ||
" \"type\": \"view\",\n" + | ||
" \"name\": \"阅读记录\",\n" + | ||
" \"sub_button\": []\n" + | ||
" },\n" + | ||
" {\n" + | ||
" \"type\": \"view\",\n" + | ||
" \"name\": \"\uD83D\uDC95秦枫\uD83D\uDC95\",\n" + | ||
" \"sub_button\": []\n" + | ||
" },\n" + | ||
" {\n" + | ||
" \"name\": \"签到送礼\",\n" + | ||
" \"sub_button\": [\n" + | ||
" {\n" + | ||
" \"type\": \"view\",\n" + | ||
" \"name\": \"书城首页\",\n" + | ||
" \"sub_button\": []\n" + | ||
" },\n" + | ||
" {\n" + | ||
" \"type\": \"view\",\n" + | ||
" \"name\": \"我要充值\",\n" + | ||
" \"sub_button\": []\n" + | ||
" },\n" + | ||
" {\n" + | ||
" \"type\": \"view\",\n" + | ||
" \"name\": \"个人中心\",\n" + | ||
" \"sub_button\": []\n" + | ||
" },\n" + | ||
" {\n" + | ||
" \"type\": \"view\",\n" + | ||
" \"name\": \"签到送礼\",\n" + | ||
" \"sub_button\": []\n" + | ||
" }\n" + | ||
" ]\n" + | ||
" }\n" + | ||
" ],\n" + | ||
" \"menuid\": 449778320\n" + | ||
" },\n" + | ||
" \"conditionalmenu\": [\n" + | ||
" {\n" + | ||
" \"button\": [\n" + | ||
" {\n" + | ||
" \"type\": \"view\",\n" + | ||
" \"name\": \"阅读记录\",\n" + | ||
" \"sub_button\": []\n" + | ||
" },\n" + | ||
" {\n" + | ||
" \"type\": \"view\",\n" + | ||
" \"name\": \"\uD83D\uDC95秦枫\uD83D\uDC95\",\n" + | ||
" \"sub_button\": []\n" + | ||
" },\n" + | ||
" {\n" + | ||
" \"name\": \"签到送礼\",\n" + | ||
" \"sub_button\": [\n" + | ||
" {\n" + | ||
" \"type\": \"view\",\n" + | ||
" \"name\": \"书城首页\",\n" + | ||
" \"sub_button\": []\n" + | ||
" },\n" + | ||
" {\n" + | ||
" \"type\": \"view\",\n" + | ||
" \"name\": \"我要看书\",\n" + | ||
" \"sub_button\": []\n" + | ||
" },\n" + | ||
" {\n" + | ||
" \"type\": \"view\",\n" + | ||
" \"name\": \"个人中心\",\n" + | ||
" \"sub_button\": []\n" + | ||
" },\n" + | ||
" {\n" + | ||
" \"type\": \"view\",\n" + | ||
" \"name\": \"签到送礼\",\n" + | ||
" \"sub_button\": []\n" + | ||
" }\n" + | ||
" ]\n" + | ||
" }\n" + | ||
" ],\n" + | ||
" \"matchrule\": {\n" + | ||
" \"client_platform_type\": \"1\"\n" + | ||
" },\n" + | ||
" \"menuid\": 449778326\n" + | ||
" },\n" + | ||
" {\n" + | ||
" \"button\": [\n" + | ||
" {\n" + | ||
" \"type\": \"view\",\n" + | ||
" \"name\": \"阅读记录\",\n" + | ||
" \"sub_button\": []\n" + | ||
" },\n" + | ||
" {\n" + | ||
" \"type\": \"view\",\n" + | ||
" \"name\": \"\uD83D\uDC95秦枫\uD83D\uDC95\",\n" + | ||
" \"sub_button\": []\n" + | ||
" },\n" + | ||
" {\n" + | ||
" \"name\": \"签到送礼\",\n" + | ||
" \"sub_button\": [\n" + | ||
" {\n" + | ||
" \"type\": \"view\",\n" + | ||
" \"name\": \"书城首页\",\n" + | ||
" \"sub_button\": []\n" + | ||
" },\n" + | ||
" {\n" + | ||
" \"type\": \"view\",\n" + | ||
" \"name\": \"我要充值\",\n" + | ||
" \"sub_button\": []\n" + | ||
" },\n" + | ||
" {\n" + | ||
" \"type\": \"view\",\n" + | ||
" \"name\": \"个人中心\",\n" + | ||
" \"sub_button\": []\n" + | ||
" },\n" + | ||
" {\n" + | ||
" \"type\": \"view\",\n" + | ||
" \"name\": \"签到送礼\",\n" + | ||
" \"sub_button\": []\n" + | ||
" }\n" + | ||
" ]\n" + | ||
" }\n" + | ||
" ],\n" + | ||
" \"matchrule\": {\n" + | ||
" \"client_platform_type\": \"2\"\n" + | ||
" },\n" + | ||
" \"menuid\": 449778324\n" + | ||
" }\n" + | ||
" ]\n" + | ||
"}"; | ||
|
||
final WxMpMenu menu = WxMpMenu.fromJson(json); | ||
assertThat(menu).isNotNull(); | ||
assertThat(menu.getConditionalMenu().get(0).getRule().getClientPlatformType()).isEqualTo("1"); | ||
} | ||
} |