#111 的unit test code

This commit is contained in:
Daniel Qian 2015-03-20 14:59:59 +08:00
parent 913f49e470
commit b885d2a1a9
2 changed files with 65 additions and 3 deletions

View File

@ -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 +
'}';
}
}
}

View File

@ -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());