|
@@ -94,42 +94,37 @@ public class WxMpMenuServiceImplTest { |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void testCreateMenu_by_json() throws WxErrorException { |
|
|
public void testCreateMenu_by_json() throws WxErrorException { |
|
|
String a = "{\n" |
|
|
|
|
|
+ " \"menu\": {\n" |
|
|
|
|
|
+ " \"button\": [\n" |
|
|
|
|
|
+ " {\n" |
|
|
|
|
|
+ " \"type\": \"click\",\n" |
|
|
|
|
|
+ " \"name\": \"今日歌曲\",\n" |
|
|
|
|
|
+ " \"key\": \"V1001_TODAY_MUSIC\"\n" |
|
|
|
|
|
+ " },\n" |
|
|
|
|
|
+ " {\n" |
|
|
|
|
|
+ " \"type\": \"click\",\n" |
|
|
|
|
|
+ " \"name\": \"歌手简介\",\n" |
|
|
|
|
|
+ " \"key\": \"V1001_TODAY_SINGER\"\n" |
|
|
|
|
|
+ " },\n" |
|
|
|
|
|
+ " {\n" |
|
|
|
|
|
+ " \"name\": \"菜单\",\n" |
|
|
|
|
|
+ " \"sub_button\": [\n" |
|
|
|
|
|
+ " {\n" |
|
|
|
|
|
+ " \"type\": \"view\",\n" |
|
|
|
|
|
+ " \"name\": \"搜索\",\n" |
|
|
|
|
|
+ " \"url\": \"http://www.soso.com/\"\n" |
|
|
|
|
|
+ " },\n" |
|
|
|
|
|
+ " {\n" |
|
|
|
|
|
+ " \"type\": \"view\",\n" |
|
|
|
|
|
+ " \"name\": \"视频\",\n" |
|
|
|
|
|
+ " \"url\": \"http://v.qq.com/\"\n" |
|
|
|
|
|
+ " },\n" |
|
|
|
|
|
+ " {\n" |
|
|
|
|
|
+ " \"type\": \"click\",\n" |
|
|
|
|
|
+ " \"name\": \"赞一下我们\",\n" |
|
|
|
|
|
+ " \"key\": \"V1001_GOOD\"\n" |
|
|
|
|
|
+ " }\n" |
|
|
|
|
|
+ " ]\n" |
|
|
|
|
|
+ " }\n" |
|
|
|
|
|
+ " ]\n" |
|
|
|
|
|
+ " }\n" |
|
|
|
|
|
+ "}"; |
|
|
|
|
|
|
|
|
String a = "{\n" + |
|
|
|
|
|
" \"button\": [\n" + |
|
|
|
|
|
" {\n" + |
|
|
|
|
|
" \"type\": \"click\",\n" + |
|
|
|
|
|
" \"name\": \"今日歌曲\",\n" + |
|
|
|
|
|
" \"key\": \"V1001_TODAY_MUSIC\"\n" + |
|
|
|
|
|
" },\n" + |
|
|
|
|
|
" {\n" + |
|
|
|
|
|
" \"name\": \"菜单\",\n" + |
|
|
|
|
|
" \"sub_button\": [\n" + |
|
|
|
|
|
" {\n" + |
|
|
|
|
|
" \"type\": \"view\",\n" + |
|
|
|
|
|
" \"name\": \"搜索\",\n" + |
|
|
|
|
|
" \"url\": \"http://www.soso.com/\"\n" + |
|
|
|
|
|
" },\n" + |
|
|
|
|
|
" {\n" + |
|
|
|
|
|
" \"type\": \"miniprogram\",\n" + |
|
|
|
|
|
" \"name\": \"wxa\",\n" + |
|
|
|
|
|
" \"url\": \"http://mp.weixin.qq.com\",\n" + |
|
|
|
|
|
" \"appid\": \"wx286b93c14bbf93aa\",\n" + |
|
|
|
|
|
" \"pagepath\": \"pages/lunar/index.html\"\n" + |
|
|
|
|
|
" },\n" + |
|
|
|
|
|
" {\n" + |
|
|
|
|
|
" \"type\": \"click\",\n" + |
|
|
|
|
|
" \"name\": \"赞一下我们\",\n" + |
|
|
|
|
|
" \"key\": \"V1001_GOOD\"\n" + |
|
|
|
|
|
" }\n" + |
|
|
|
|
|
" ]\n" + |
|
|
|
|
|
" }\n" + |
|
|
|
|
|
" ]\n" + |
|
|
|
|
|
"}"; |
|
|
|
|
|
|
|
|
WxMenu menu = WxMenu.fromJson(a); |
|
|
WxMenu menu = WxMenu.fromJson(a); |
|
|
System.out.println(menu.toJson()); |
|
|
System.out.println(menu.toJson()); |
|
@@ -157,9 +152,11 @@ public class WxMpMenuServiceImplTest { |
|
|
button1.setKey("V1001_TODAY_MUSIC"); |
|
|
button1.setKey("V1001_TODAY_MUSIC"); |
|
|
|
|
|
|
|
|
WxMenuButton button2 = new WxMenuButton(); |
|
|
WxMenuButton button2 = new WxMenuButton(); |
|
|
button2.setType(WxConsts.BUTTON_CLICK); |
|
|
|
|
|
button2.setName("歌手简介"); |
|
|
|
|
|
button2.setKey("V1001_TODAY_SINGER"); |
|
|
|
|
|
|
|
|
button2.setType(WxConsts.BUTTON_MINIPROGRAM); |
|
|
|
|
|
button2.setName("小程序"); |
|
|
|
|
|
button2.setAppId("wx286b93c14bbf93aa"); |
|
|
|
|
|
button2.setPagePath("pages/lunar/index.html"); |
|
|
|
|
|
button2.setUrl("http://mp.weixin.qq.com"); |
|
|
|
|
|
|
|
|
WxMenuButton button3 = new WxMenuButton(); |
|
|
WxMenuButton button3 = new WxMenuButton(); |
|
|
button3.setName("菜单"); |
|
|
button3.setName("菜单"); |
|
|