Search in sources :

Example 1 with WxMenuButton

use of me.chanjar.weixin.common.bean.WxMenu.WxMenuButton in project weixin-java-tools by chanjarster.

the class WxMpMenuAPITest method getMenu.

@DataProvider(name = "menu")
public Object[][] getMenu() {
    WxMenu menu = new WxMenu();
    WxMenuButton button1 = new WxMenuButton();
    button1.setType(WxConsts.BUTTON_CLICK);
    button1.setName("今日歌曲");
    button1.setKey("V1001_TODAY_MUSIC");
    WxMenuButton button2 = new WxMenuButton();
    button2.setType(WxConsts.BUTTON_CLICK);
    button2.setName("歌手简介");
    button2.setKey("V1001_TODAY_SINGER");
    WxMenuButton button3 = new WxMenuButton();
    button3.setName("菜单");
    menu.getButtons().add(button1);
    menu.getButtons().add(button2);
    menu.getButtons().add(button3);
    WxMenuButton button31 = new WxMenuButton();
    button31.setType(WxConsts.BUTTON_VIEW);
    button31.setName("搜索");
    button31.setUrl("http://www.soso.com/");
    WxMenuButton button32 = new WxMenuButton();
    button32.setType(WxConsts.BUTTON_VIEW);
    button32.setName("视频");
    button32.setUrl("http://v.qq.com/");
    WxMenuButton button33 = new WxMenuButton();
    button33.setType(WxConsts.BUTTON_CLICK);
    button33.setName("赞一下我们");
    button33.setKey("V1001_GOOD");
    button3.getSubButtons().add(button31);
    button3.getSubButtons().add(button32);
    button3.getSubButtons().add(button33);
    return new Object[][] { new Object[] { menu } };
}
Also used : WxMenu(me.chanjar.weixin.common.bean.WxMenu) WxMenuButton(me.chanjar.weixin.common.bean.WxMenu.WxMenuButton) DataProvider(org.testng.annotations.DataProvider)

Example 2 with WxMenuButton

use of me.chanjar.weixin.common.bean.WxMenu.WxMenuButton in project weixin-java-tools by chanjarster.

the class WxMenuTest method testToJson.

@Test(dataProvider = "wxPushMenu")
public void testToJson(String json) {
    WxMenu menu = new WxMenu();
    WxMenuButton button1 = new WxMenuButton();
    button1.setType("click");
    button1.setName("今日歌曲");
    button1.setKey("V1001_TODAY_MUSIC");
    WxMenuButton button2 = new WxMenuButton();
    button2.setType("click");
    button2.setName("歌手简介");
    button2.setKey("V1001_TODAY_SINGER");
    WxMenuButton button3 = new WxMenuButton();
    button3.setName("菜单");
    menu.getButtons().add(button1);
    menu.getButtons().add(button2);
    menu.getButtons().add(button3);
    WxMenuButton button31 = new WxMenuButton();
    button31.setType("view");
    button31.setName("搜索");
    button31.setUrl("http://www.soso.com/");
    WxMenuButton button32 = new WxMenuButton();
    button32.setType("view");
    button32.setName("视频");
    button32.setUrl("http://v.qq.com/");
    WxMenuButton button33 = new WxMenuButton();
    button33.setType("click");
    button33.setName("赞一下我们");
    button33.setKey("V1001_GOOD");
    button3.getSubButtons().add(button31);
    button3.getSubButtons().add(button32);
    button3.getSubButtons().add(button33);
    Assert.assertEquals(menu.toJson(), json);
}
Also used : WxMenuButton(me.chanjar.weixin.common.bean.WxMenu.WxMenuButton) Test(org.testng.annotations.Test)

Example 3 with WxMenuButton

use of me.chanjar.weixin.common.bean.WxMenu.WxMenuButton in project weixin-java-tools by chanjarster.

the class WxMenuAPITest method getMenu.

@DataProvider(name = "menu")
public Object[][] getMenu() {
    WxMenu menu = new WxMenu();
    WxMenuButton button1 = new WxMenuButton();
    button1.setType(WxConsts.BUTTON_CLICK);
    button1.setName("今日歌曲");
    button1.setKey("V1001_TODAY_MUSIC");
    WxMenuButton button2 = new WxMenuButton();
    button2.setType(WxConsts.BUTTON_CLICK);
    button2.setName("歌手简介");
    button2.setKey("V1001_TODAY_SINGER");
    WxMenuButton button3 = new WxMenuButton();
    button3.setName("菜单");
    menu.getButtons().add(button1);
    menu.getButtons().add(button2);
    menu.getButtons().add(button3);
    WxMenuButton button31 = new WxMenuButton();
    button31.setType(WxConsts.BUTTON_VIEW);
    button31.setName("搜索");
    button31.setUrl("http://www.soso.com/");
    WxMenuButton button32 = new WxMenuButton();
    button32.setType(WxConsts.BUTTON_VIEW);
    button32.setName("视频");
    button32.setUrl("http://v.qq.com/");
    WxMenuButton button33 = new WxMenuButton();
    button33.setType(WxConsts.BUTTON_CLICK);
    button33.setName("赞一下我们");
    button33.setKey("V1001_GOOD");
    button3.getSubButtons().add(button31);
    button3.getSubButtons().add(button32);
    button3.getSubButtons().add(button33);
    return new Object[][] { new Object[] { menu } };
}
Also used : WxMenu(me.chanjar.weixin.common.bean.WxMenu) WxMenuButton(me.chanjar.weixin.common.bean.WxMenu.WxMenuButton) DataProvider(org.testng.annotations.DataProvider)

Aggregations

WxMenuButton (me.chanjar.weixin.common.bean.WxMenu.WxMenuButton)3 WxMenu (me.chanjar.weixin.common.bean.WxMenu)2 DataProvider (org.testng.annotations.DataProvider)2 Test (org.testng.annotations.Test)1