mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 10:38:42 +08:00 
			
		
		
		
	#111 的unit test code
This commit is contained in:
		| @ -37,6 +37,13 @@ public class WxMenu implements Serializable { | ||||
|     return WxGsonBuilder.create().fromJson(new InputStreamReader(is), WxMenu.class); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public String toString() { | ||||
|     return "WxMenu{" + | ||||
|         "buttons=" + buttons + | ||||
|         '}'; | ||||
|   } | ||||
|  | ||||
|   public static class WxMenuButton { | ||||
|  | ||||
|     private String type; | ||||
| @ -86,6 +93,16 @@ public class WxMenu implements Serializable { | ||||
|       this.subButtons = subButtons; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String toString() { | ||||
|       return "WxMenuButton{" + | ||||
|           "type='" + type + '\'' + | ||||
|           ", name='" + name + '\'' + | ||||
|           ", key='" + key + '\'' + | ||||
|           ", url='" + url + '\'' + | ||||
|           ", subButtons=" + subButtons + | ||||
|           '}'; | ||||
|     } | ||||
|   } | ||||
|  | ||||
| } | ||||
|  | ||||
| @ -24,9 +24,54 @@ public class WxMpMenuAPITest { | ||||
|    | ||||
|   @Test(dataProvider = "menu") | ||||
|   public void testCreateMenu(WxMenu wxMenu) throws WxErrorException { | ||||
|     System.out.println(wxMenu.toJson()); | ||||
|     wxService.menuCreate(wxMenu); | ||||
|   } | ||||
|  | ||||
|   @Test | ||||
|   public void testCreateMenu2() 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" | ||||
|         + "}"; | ||||
|  | ||||
|     WxMenu menu = WxMenu.fromJson(a); | ||||
|     System.out.println(menu.toJson()); | ||||
|     wxService.menuCreate(menu); | ||||
|   } | ||||
|  | ||||
|   @Test(dependsOnMethods = { "testCreateMenu"}) | ||||
|   public void testGetMenu() throws WxErrorException { | ||||
|     Assert.assertNotNull(wxService.menuGet()); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Daniel Qian
					Daniel Qian