| @@ -1,9 +1,9 @@ | |||
| package me.chanjar.weixin.mp.api; | |||
| package me.chanjar.weixin.common.api; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| public class WxMpConsts { | |||
| public class WxConsts { | |||
| /////////////////////// | |||
| // 微信推送过来的消息的类型,和发送给微信xml格式消息的消息类型 | |||
| @@ -20,7 +20,7 @@ public class WxMpConsts { | |||
| public static final String XML_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service"; | |||
| /////////////////////// | |||
| // 客服消息的消息类型 | |||
| // 主动发送消息的消息类型 | |||
| /////////////////////// | |||
| public static final String CUSTOM_MSG_TEXT = "text"; | |||
| public static final String CUSTOM_MSG_IMAGE = "image"; | |||
| @@ -28,6 +28,7 @@ public class WxMpConsts { | |||
| public static final String CUSTOM_MSG_VIDEO = "video"; | |||
| public static final String CUSTOM_MSG_MUSIC = "music"; | |||
| public static final String CUSTOM_MSG_NEWS = "news"; | |||
| public static final String CUSTOM_MSG_FILE = "file"; | |||
| /////////////////////// | |||
| // 群发消息的消息类型 | |||
| @@ -95,6 +96,7 @@ public class WxMpConsts { | |||
| public static final String MEDIA_VOICE = "voice"; | |||
| public static final String MEDIA_VIDEO = "video"; | |||
| public static final String MEDIA_THUMB = "thumb"; | |||
| public static final String MEDIA_FILE = "file"; | |||
| /////////////////////// | |||
| // 文件类型 | |||
| @@ -1,81 +0,0 @@ | |||
| package me.chanjar.weixin.cp.api; | |||
| public class WxCpConsts { | |||
| /////////////////////// | |||
| // 微信推送过来的消息的类型,和发送给微信xml格式消息的消息类型 | |||
| /////////////////////// | |||
| public static final String XML_MSG_TEXT = "text"; | |||
| public static final String XML_MSG_IMAGE = "image"; | |||
| public static final String XML_MSG_VOICE = "voice"; | |||
| public static final String XML_MSG_VIDEO = "video"; | |||
| public static final String XML_MSG_NEWS = "news"; | |||
| public static final String XML_MSG_LOCATION = "location"; | |||
| public static final String XML_MSG_LINK = "link"; | |||
| public static final String XML_MSG_EVENT = "event"; | |||
| /////////////////////// | |||
| // 消息的消息类型 | |||
| /////////////////////// | |||
| public static final String CUSTOM_MSG_TEXT = "text"; | |||
| public static final String CUSTOM_MSG_IMAGE = "image"; | |||
| public static final String CUSTOM_MSG_VOICE = "voice"; | |||
| public static final String CUSTOM_MSG_VIDEO = "video"; | |||
| public static final String CUSTOM_MSG_NEWS = "news"; | |||
| public static final String CUSTOM_MSG_FILE = "file"; | |||
| /////////////////////// | |||
| // 微信端推送过来的事件类型 | |||
| /////////////////////// | |||
| public static final String EVT_SUBSCRIBE = "subscribe"; | |||
| public static final String EVT_UNSUBSCRIBE = "unsubscribe"; | |||
| public static final String EVT_SCAN = "SCAN"; | |||
| public static final String EVT_LOCATION = "LOCATION"; | |||
| public static final String EVT_CLICK = "CLICK"; | |||
| public static final String EVT_VIEW = "VIEW"; | |||
| public static final String EVT_MASS_SEND_JOB_FINISH = "MASSSENDJOBFINISH"; | |||
| public static final String EVT_SCANCODE_PUSH = "scancode_push"; | |||
| public static final String EVT_SCANCODE_WAITMSG = "scancode_waitmsg"; | |||
| public static final String EVT_PIC_SYSPHOTO = "pic_sysphoto"; | |||
| public static final String EVT_PIC_PHOTO_OR_ALBUM = "pic_photo_or_album"; | |||
| public static final String EVT_PIC_WEIXIN = "pic_weixin"; | |||
| public static final String EVT_LOCATION_SELECT = "location_select"; | |||
| /////////////////////// | |||
| // 上传多媒体文件的类型 | |||
| /////////////////////// | |||
| public static final String MEDIA_IMAGE = "image"; | |||
| public static final String MEDIA_VOICE = "voice"; | |||
| public static final String MEDIA_VIDEO = "video"; | |||
| public static final String MEDIA_FILE = "file"; | |||
| /////////////////////// | |||
| // 文件类型 | |||
| /////////////////////// | |||
| public static final String FILE_JPG = "jpeg"; | |||
| public static final String FILE_MP3 = "mp3"; | |||
| public static final String FILE_ARM = "arm"; | |||
| public static final String FILE_MP4 = "mp4"; | |||
| /////////////////////// | |||
| // 自定义菜单的按钮类型 | |||
| /////////////////////// | |||
| /** 点击推事件 */ | |||
| public static final String BUTTON_CLICK = "click"; | |||
| /** 跳转URL */ | |||
| public static final String BUTTON_VIEW = "view"; | |||
| /** 扫码推事件 */ | |||
| public static final String BUTTON_SCANCODE_PUSH = "scancode_push"; | |||
| /** 扫码推事件且弹出“消息接收中”提示框 */ | |||
| public static final String BUTTON_SCANCODE_WAITMSG = "scancode_waitmsg"; | |||
| /** 弹出系统拍照发图 */ | |||
| public static final String PIC_SYSPHOTO = "pic_sysphoto"; | |||
| /** 弹出拍照或者相册发图 */ | |||
| public static final String PIC_PHOTO_OR_ALBUM = "pic_photo_or_album"; | |||
| /** 弹出微信相册发图器 */ | |||
| public static final String PIC_WEIXIN = "pic_weixin"; | |||
| /** 弹出地理位置选择器 */ | |||
| public static final String LOCATION_SELECT = "location_select"; | |||
| } | |||
| @@ -55,8 +55,8 @@ public interface WxMpService { | |||
| * | |||
| * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=上传下载多媒体文件 | |||
| * </pre> | |||
| * @param mediaType 媒体类型, 请看{@link WxMpConsts} | |||
| * @param fileType 文件类型,请看{@link WxMpConsts} | |||
| * @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} | |||
| * @param fileType 文件类型,请看{@link me.chanjar.weixin.common.api.WxConsts} | |||
| * @param inputStream 输入流 | |||
| * @throws WxErrorException | |||
| */ | |||
| @@ -37,12 +37,12 @@ public class WxMpCustomMessage { | |||
| /** | |||
| * <pre> | |||
| * 请使用 | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#CUSTOM_MSG_TEXT} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#CUSTOM_MSG_IMAGE} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#CUSTOM_MSG_VOICE} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#CUSTOM_MSG_MUSIC} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#CUSTOM_MSG_VIDEO} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#CUSTOM_MSG_NEWS} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_TEXT} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_IMAGE} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VOICE} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_MUSIC} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VIDEO} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_NEWS} | |||
| * </pre> | |||
| * @param msgType | |||
| */ | |||
| @@ -25,11 +25,11 @@ public class WxMpMassGroupMessage { | |||
| /** | |||
| * <pre> | |||
| * 请使用 | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_IMAGE} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_NEWS} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_TEXT} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_VIDEO} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_VOICE} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_IMAGE} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_NEWS} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_TEXT} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VIDEO} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VOICE} | |||
| * 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误 | |||
| * </pre> | |||
| * @param msgtype | |||
| @@ -12,13 +12,13 @@ import java.util.List; | |||
| */ | |||
| public class WxMpMassNews { | |||
| private List<WxMassNewsArticle> articles = new ArrayList<WxMassNewsArticle>(); | |||
| private List<WxMpMassNewsArticle> articles = new ArrayList<WxMpMassNewsArticle>(); | |||
| public List<WxMassNewsArticle> getArticles() { | |||
| public List<WxMpMassNewsArticle> getArticles() { | |||
| return articles; | |||
| } | |||
| public void addArticle(WxMassNewsArticle article) { | |||
| public void addArticle(WxMpMassNewsArticle article) { | |||
| this.articles.add(article); | |||
| } | |||
| @@ -40,7 +40,7 @@ public class WxMpMassNews { | |||
| * @author chanjarster | |||
| * | |||
| */ | |||
| public static class WxMassNewsArticle { | |||
| public static class WxMpMassNewsArticle { | |||
| /** | |||
| * (必填) 图文消息缩略图的media_id,可以在基础支持-上传多媒体文件接口中获得 | |||
| */ | |||
| @@ -28,11 +28,11 @@ public class WxMpMassOpenIdsMessage { | |||
| /** | |||
| * <pre> | |||
| * 请使用 | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_IMAGE} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_NEWS} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_TEXT} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_VIDEO} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_VOICE} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_IMAGE} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_NEWS} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_TEXT} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VIDEO} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VOICE} | |||
| * 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误 | |||
| * </pre> | |||
| * @param msgType | |||
| @@ -1,7 +1,7 @@ | |||
| package me.chanjar.weixin.mp.bean; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import me.chanjar.weixin.common.util.xml.MediaIdMarshaller; | |||
| import me.chanjar.weixin.mp.api.WxMpConsts; | |||
| import javax.xml.bind.annotation.XmlAccessType; | |||
| import javax.xml.bind.annotation.XmlAccessorType; | |||
| @@ -18,7 +18,7 @@ public class WxMpMpXmlOutImageMessage extends WxMpXmlOutMessage { | |||
| private String mediaId; | |||
| public WxMpMpXmlOutImageMessage() { | |||
| this.msgType = WxMpConsts.XML_MSG_IMAGE; | |||
| this.msgType = WxConsts.XML_MSG_IMAGE; | |||
| } | |||
| public String getMediaId() { | |||
| @@ -179,13 +179,13 @@ public class WxMpXmlMessage { | |||
| /** | |||
| * <pre> | |||
| * 当接受用户消息时,可能会获得以下值: | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_TEXT} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_IMAGE} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_VOICE} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_VIDEO} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_LOCATION} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_LINK} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_EVENT} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_TEXT} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_IMAGE} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VOICE} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VIDEO} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LOCATION} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LINK} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_EVENT} | |||
| * </pre> | |||
| * | |||
| * @return | |||
| @@ -197,12 +197,12 @@ public class WxMpXmlMessage { | |||
| /** | |||
| * <pre> | |||
| * 当发送消息的时候使用: | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_TEXT} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_IMAGE} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_VOICE} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_VIDEO} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_NEWS} | |||
| * {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_MUSIC} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_TEXT} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_IMAGE} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VOICE} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VIDEO} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_NEWS} | |||
| * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_MUSIC} | |||
| * </pre> | |||
| * | |||
| * @param msgType | |||
| @@ -1,7 +1,7 @@ | |||
| package me.chanjar.weixin.mp.bean; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import me.chanjar.weixin.common.util.xml.AdapterCDATA; | |||
| import me.chanjar.weixin.mp.api.WxMpConsts; | |||
| import javax.xml.bind.annotation.*; | |||
| import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; | |||
| @@ -20,7 +20,7 @@ public class WxMpXmlOutMewsMessage extends WxMpXmlOutMessage { | |||
| protected final List<Item> articles = new ArrayList<Item>(); | |||
| public WxMpXmlOutMewsMessage() { | |||
| this.msgType = WxMpConsts.XML_MSG_NEWS; | |||
| this.msgType = WxConsts.XML_MSG_NEWS; | |||
| } | |||
| public int getArticleCount() { | |||
| @@ -1,7 +1,7 @@ | |||
| package me.chanjar.weixin.mp.bean; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import me.chanjar.weixin.common.util.xml.AdapterCDATA; | |||
| import me.chanjar.weixin.mp.api.WxMpConsts; | |||
| import javax.xml.bind.annotation.XmlAccessType; | |||
| import javax.xml.bind.annotation.XmlAccessorType; | |||
| @@ -17,7 +17,7 @@ public class WxMpXmlOutMusicMessage extends WxMpXmlOutMessage { | |||
| protected final Music music = new Music(); | |||
| public WxMpXmlOutMusicMessage() { | |||
| this.msgType = WxMpConsts.XML_MSG_MUSIC; | |||
| this.msgType = WxConsts.XML_MSG_MUSIC; | |||
| } | |||
| public String getTitle() { | |||
| @@ -1,7 +1,7 @@ | |||
| package me.chanjar.weixin.mp.bean; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import me.chanjar.weixin.common.util.xml.AdapterCDATA; | |||
| import me.chanjar.weixin.mp.api.WxMpConsts; | |||
| import javax.xml.bind.annotation.XmlAccessType; | |||
| import javax.xml.bind.annotation.XmlAccessorType; | |||
| @@ -18,7 +18,7 @@ public class WxMpXmlOutTextMessage extends WxMpXmlOutMessage { | |||
| private String content; | |||
| public WxMpXmlOutTextMessage() { | |||
| this.msgType = WxMpConsts.XML_MSG_TEXT; | |||
| this.msgType = WxConsts.XML_MSG_TEXT; | |||
| } | |||
| public String getContent() { | |||
| @@ -1,7 +1,7 @@ | |||
| package me.chanjar.weixin.mp.bean; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import me.chanjar.weixin.common.util.xml.AdapterCDATA; | |||
| import me.chanjar.weixin.mp.api.WxMpConsts; | |||
| import javax.xml.bind.annotation.XmlAccessType; | |||
| import javax.xml.bind.annotation.XmlAccessorType; | |||
| @@ -17,7 +17,7 @@ public class WxMpXmlOutVideoMessage extends WxMpXmlOutMessage { | |||
| protected final Video video = new Video(); | |||
| public WxMpXmlOutVideoMessage() { | |||
| this.msgType = WxMpConsts.XML_MSG_VIDEO; | |||
| this.msgType = WxConsts.XML_MSG_VIDEO; | |||
| } | |||
| public String getMediaId() { | |||
| @@ -1,7 +1,7 @@ | |||
| package me.chanjar.weixin.mp.bean; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import me.chanjar.weixin.common.util.xml.MediaIdMarshaller; | |||
| import me.chanjar.weixin.mp.api.WxMpConsts; | |||
| import javax.xml.bind.annotation.XmlAccessType; | |||
| import javax.xml.bind.annotation.XmlAccessorType; | |||
| @@ -18,7 +18,7 @@ public class WxMpXmlOutVoiceMessage extends WxMpXmlOutMessage { | |||
| private String mediaId; | |||
| public WxMpXmlOutVoiceMessage() { | |||
| this.msgType = WxMpConsts.XML_MSG_VOICE; | |||
| this.msgType = WxConsts.XML_MSG_VOICE; | |||
| } | |||
| public String getMediaId() { | |||
| @@ -1,6 +1,6 @@ | |||
| package me.chanjar.weixin.mp.bean.custombuilder; | |||
| import me.chanjar.weixin.mp.api.WxMpConsts; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import me.chanjar.weixin.mp.bean.WxMpCustomMessage; | |||
| /** | |||
| @@ -15,7 +15,7 @@ public final class ImageBuilder extends BaseBuilder<ImageBuilder> { | |||
| private String mediaId; | |||
| public ImageBuilder() { | |||
| this.msgType = WxMpConsts.CUSTOM_MSG_IMAGE; | |||
| this.msgType = WxConsts.CUSTOM_MSG_IMAGE; | |||
| } | |||
| public ImageBuilder mediaId(String media_id) { | |||
| @@ -1,6 +1,6 @@ | |||
| package me.chanjar.weixin.mp.bean.custombuilder; | |||
| import me.chanjar.weixin.mp.api.WxMpConsts; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import me.chanjar.weixin.mp.bean.WxMpCustomMessage; | |||
| /** | |||
| @@ -24,7 +24,7 @@ public final class MusicBuilder extends BaseBuilder<MusicBuilder> { | |||
| private String hqMusicUrl; | |||
| public MusicBuilder() { | |||
| this.msgType = WxMpConsts.CUSTOM_MSG_MUSIC; | |||
| this.msgType = WxConsts.CUSTOM_MSG_MUSIC; | |||
| } | |||
| public MusicBuilder musicUrl(String musicurl) { | |||
| @@ -1,6 +1,6 @@ | |||
| package me.chanjar.weixin.mp.bean.custombuilder; | |||
| import me.chanjar.weixin.mp.api.WxMpConsts; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import me.chanjar.weixin.mp.bean.WxMpCustomMessage; | |||
| import java.util.ArrayList; | |||
| @@ -20,7 +20,7 @@ public final class NewsBuilder extends BaseBuilder<NewsBuilder> { | |||
| private List<WxMpCustomMessage.WxArticle> articles = new ArrayList<WxMpCustomMessage.WxArticle>(); | |||
| public NewsBuilder() { | |||
| this.msgType = WxMpConsts.CUSTOM_MSG_NEWS; | |||
| this.msgType = WxConsts.CUSTOM_MSG_NEWS; | |||
| } | |||
| public NewsBuilder addArticle(WxMpCustomMessage.WxArticle article) { | |||
| @@ -1,6 +1,6 @@ | |||
| package me.chanjar.weixin.mp.bean.custombuilder; | |||
| import me.chanjar.weixin.mp.api.WxMpConsts; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import me.chanjar.weixin.mp.bean.WxMpCustomMessage; | |||
| /** | |||
| @@ -15,7 +15,7 @@ public final class TextBuilder extends BaseBuilder<TextBuilder> { | |||
| private String content; | |||
| public TextBuilder() { | |||
| this.msgType = WxMpConsts.CUSTOM_MSG_TEXT; | |||
| this.msgType = WxConsts.CUSTOM_MSG_TEXT; | |||
| } | |||
| public TextBuilder content(String content) { | |||
| @@ -1,6 +1,6 @@ | |||
| package me.chanjar.weixin.mp.bean.custombuilder; | |||
| import me.chanjar.weixin.mp.api.WxMpConsts; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import me.chanjar.weixin.mp.bean.WxMpCustomMessage; | |||
| /** | |||
| @@ -24,7 +24,7 @@ public final class VideoBuilder extends BaseBuilder<VideoBuilder> { | |||
| private String thumbMediaId; | |||
| public VideoBuilder() { | |||
| this.msgType = WxMpConsts.CUSTOM_MSG_VIDEO; | |||
| this.msgType = WxConsts.CUSTOM_MSG_VIDEO; | |||
| } | |||
| public VideoBuilder mediaId(String mediaId) { | |||
| @@ -1,6 +1,6 @@ | |||
| package me.chanjar.weixin.mp.bean.custombuilder; | |||
| import me.chanjar.weixin.mp.api.WxMpConsts; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import me.chanjar.weixin.mp.bean.WxMpCustomMessage; | |||
| /** | |||
| @@ -15,7 +15,7 @@ public final class VoiceBuilder extends BaseBuilder<VoiceBuilder> { | |||
| private String mediaId; | |||
| public VoiceBuilder() { | |||
| this.msgType = WxMpConsts.CUSTOM_MSG_VOICE; | |||
| this.msgType = WxConsts.CUSTOM_MSG_VOICE; | |||
| } | |||
| public VoiceBuilder mediaId(String media_id) { | |||
| @@ -9,7 +9,7 @@ | |||
| package me.chanjar.weixin.mp.util.json; | |||
| import com.google.gson.*; | |||
| import me.chanjar.weixin.mp.api.WxMpConsts; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import me.chanjar.weixin.mp.bean.WxMpCustomMessage; | |||
| import java.lang.reflect.Type; | |||
| @@ -26,25 +26,25 @@ public class WxMpCustomMessageGsonAdapter implements JsonSerializer<WxMpCustomMe | |||
| messageJson.addProperty("touser", message.getToUser()); | |||
| messageJson.addProperty("msgtype", message.getMsgType()); | |||
| if (WxMpConsts.CUSTOM_MSG_TEXT.equals(message.getMsgType())) { | |||
| if (WxConsts.CUSTOM_MSG_TEXT.equals(message.getMsgType())) { | |||
| JsonObject text = new JsonObject(); | |||
| text.addProperty("content", message.getContent()); | |||
| messageJson.add("text", text); | |||
| } | |||
| if (WxMpConsts.CUSTOM_MSG_IMAGE.equals(message.getMsgType())) { | |||
| if (WxConsts.CUSTOM_MSG_IMAGE.equals(message.getMsgType())) { | |||
| JsonObject image = new JsonObject(); | |||
| image.addProperty("media_id", message.getMediaId()); | |||
| messageJson.add("image", image); | |||
| } | |||
| if (WxMpConsts.CUSTOM_MSG_VOICE.equals(message.getMsgType())) { | |||
| if (WxConsts.CUSTOM_MSG_VOICE.equals(message.getMsgType())) { | |||
| JsonObject voice = new JsonObject(); | |||
| voice.addProperty("media_id", message.getMediaId()); | |||
| messageJson.add("voice", voice); | |||
| } | |||
| if (WxMpConsts.CUSTOM_MSG_VIDEO.equals(message.getMsgType())) { | |||
| if (WxConsts.CUSTOM_MSG_VIDEO.equals(message.getMsgType())) { | |||
| JsonObject video = new JsonObject(); | |||
| video.addProperty("media_id", message.getMediaId()); | |||
| video.addProperty("thumb_media_id", message.getThumbMediaId()); | |||
| @@ -53,7 +53,7 @@ public class WxMpCustomMessageGsonAdapter implements JsonSerializer<WxMpCustomMe | |||
| messageJson.add("video", video); | |||
| } | |||
| if (WxMpConsts.CUSTOM_MSG_MUSIC.equals(message.getMsgType())) { | |||
| if (WxConsts.CUSTOM_MSG_MUSIC.equals(message.getMsgType())) { | |||
| JsonObject music = new JsonObject(); | |||
| music.addProperty("title", message.getTitle()); | |||
| music.addProperty("description", message.getDescription()); | |||
| @@ -63,7 +63,7 @@ public class WxMpCustomMessageGsonAdapter implements JsonSerializer<WxMpCustomMe | |||
| messageJson.add("music", music); | |||
| } | |||
| if (WxMpConsts.CUSTOM_MSG_NEWS.equals(message.getMsgType())) { | |||
| if (WxConsts.CUSTOM_MSG_NEWS.equals(message.getMsgType())) { | |||
| JsonArray articleJsonArray = new JsonArray(); | |||
| for (WxMpCustomMessage.WxArticle article : message.getArticles()) { | |||
| JsonObject articleJson = new JsonObject(); | |||
| @@ -12,7 +12,7 @@ import com.google.gson.JsonElement; | |||
| import com.google.gson.JsonObject; | |||
| import com.google.gson.JsonSerializationContext; | |||
| import com.google.gson.JsonSerializer; | |||
| import me.chanjar.weixin.mp.api.WxMpConsts; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import me.chanjar.weixin.mp.bean.WxMpMassGroupMessage; | |||
| import java.lang.reflect.Type; | |||
| @@ -31,30 +31,30 @@ public class WxMpMassMessageGsonAdapter implements JsonSerializer<WxMpMassGroupM | |||
| filter.addProperty("group_id", message.getGroupId()); | |||
| messageJson.add("filter", filter); | |||
| if (WxMpConsts.MASS_MSG_NEWS.equals(message.getMsgtype())) { | |||
| if (WxConsts.MASS_MSG_NEWS.equals(message.getMsgtype())) { | |||
| JsonObject sub = new JsonObject(); | |||
| sub.addProperty("media_id", message.getMediaId()); | |||
| messageJson.add(WxMpConsts.MASS_MSG_NEWS, sub); | |||
| messageJson.add(WxConsts.MASS_MSG_NEWS, sub); | |||
| } | |||
| if (WxMpConsts.MASS_MSG_TEXT.equals(message.getMsgtype())) { | |||
| if (WxConsts.MASS_MSG_TEXT.equals(message.getMsgtype())) { | |||
| JsonObject sub = new JsonObject(); | |||
| sub.addProperty("content", message.getContent()); | |||
| messageJson.add(WxMpConsts.MASS_MSG_TEXT, sub); | |||
| messageJson.add(WxConsts.MASS_MSG_TEXT, sub); | |||
| } | |||
| if (WxMpConsts.MASS_MSG_VOICE.equals(message.getMsgtype())) { | |||
| if (WxConsts.MASS_MSG_VOICE.equals(message.getMsgtype())) { | |||
| JsonObject sub = new JsonObject(); | |||
| sub.addProperty("media_id", message.getMediaId()); | |||
| messageJson.add(WxMpConsts.MASS_MSG_VOICE, sub); | |||
| messageJson.add(WxConsts.MASS_MSG_VOICE, sub); | |||
| } | |||
| if (WxMpConsts.MASS_MSG_IMAGE.equals(message.getMsgtype())) { | |||
| if (WxConsts.MASS_MSG_IMAGE.equals(message.getMsgtype())) { | |||
| JsonObject sub = new JsonObject(); | |||
| sub.addProperty("media_id", message.getMediaId()); | |||
| messageJson.add(WxMpConsts.MASS_MSG_IMAGE, sub); | |||
| messageJson.add(WxConsts.MASS_MSG_IMAGE, sub); | |||
| } | |||
| if (WxMpConsts.MASS_MSG_VIDEO.equals(message.getMsgtype())) { | |||
| if (WxConsts.MASS_MSG_VIDEO.equals(message.getMsgtype())) { | |||
| JsonObject sub = new JsonObject(); | |||
| sub.addProperty("media_id", message.getMediaId()); | |||
| messageJson.add(WxMpConsts.MASS_MSG_VIDEO, sub); | |||
| messageJson.add(WxConsts.MASS_MSG_VIDEO, sub); | |||
| } | |||
| messageJson.addProperty("msgtype", message.getMsgtype()); | |||
| return messageJson; | |||
| @@ -24,7 +24,7 @@ public class WxMpMassNewsGsonAdapter implements JsonSerializer<WxMpMassNews> { | |||
| JsonObject newsJson = new JsonObject(); | |||
| JsonArray articleJsonArray = new JsonArray(); | |||
| for (WxMpMassNews.WxMassNewsArticle article : message.getArticles()) { | |||
| for (WxMpMassNews.WxMpMassNewsArticle article : message.getArticles()) { | |||
| JsonObject articleJson = new JsonObject(); | |||
| articleJson.addProperty("thumb_media_id", article.getThumbMediaId()); | |||
| articleJson.addProperty("title", article.getTitle()); | |||
| @@ -9,7 +9,7 @@ | |||
| package me.chanjar.weixin.mp.util.json; | |||
| import com.google.gson.*; | |||
| import me.chanjar.weixin.mp.api.WxMpConsts; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage; | |||
| import java.lang.reflect.Type; | |||
| @@ -30,30 +30,30 @@ public class WxMpMassOpenIdsMessageGsonAdapter implements JsonSerializer<WxMpMas | |||
| } | |||
| messageJson.add("touser", toUsers); | |||
| if (WxMpConsts.MASS_MSG_NEWS.equals(message.getMsgType())) { | |||
| if (WxConsts.MASS_MSG_NEWS.equals(message.getMsgType())) { | |||
| JsonObject sub = new JsonObject(); | |||
| sub.addProperty("media_id", message.getMediaId()); | |||
| messageJson.add(WxMpConsts.MASS_MSG_NEWS, sub); | |||
| messageJson.add(WxConsts.MASS_MSG_NEWS, sub); | |||
| } | |||
| if (WxMpConsts.MASS_MSG_TEXT.equals(message.getMsgType())) { | |||
| if (WxConsts.MASS_MSG_TEXT.equals(message.getMsgType())) { | |||
| JsonObject sub = new JsonObject(); | |||
| sub.addProperty("content", message.getContent()); | |||
| messageJson.add(WxMpConsts.MASS_MSG_TEXT, sub); | |||
| messageJson.add(WxConsts.MASS_MSG_TEXT, sub); | |||
| } | |||
| if (WxMpConsts.MASS_MSG_VOICE.equals(message.getMsgType())) { | |||
| if (WxConsts.MASS_MSG_VOICE.equals(message.getMsgType())) { | |||
| JsonObject sub = new JsonObject(); | |||
| sub.addProperty("media_id", message.getMediaId()); | |||
| messageJson.add(WxMpConsts.MASS_MSG_VOICE, sub); | |||
| messageJson.add(WxConsts.MASS_MSG_VOICE, sub); | |||
| } | |||
| if (WxMpConsts.MASS_MSG_IMAGE.equals(message.getMsgType())) { | |||
| if (WxConsts.MASS_MSG_IMAGE.equals(message.getMsgType())) { | |||
| JsonObject sub = new JsonObject(); | |||
| sub.addProperty("media_id", message.getMediaId()); | |||
| messageJson.add(WxMpConsts.MASS_MSG_IMAGE, sub); | |||
| messageJson.add(WxConsts.MASS_MSG_IMAGE, sub); | |||
| } | |||
| if (WxMpConsts.MASS_MSG_VIDEO.equals(message.getMsgType())) { | |||
| if (WxConsts.MASS_MSG_VIDEO.equals(message.getMsgType())) { | |||
| JsonObject sub = new JsonObject(); | |||
| sub.addProperty("media_id", message.getMediaId()); | |||
| messageJson.add(WxMpConsts.MASS_MSG_VIDEO, sub); | |||
| messageJson.add(WxConsts.MASS_MSG_VIDEO, sub); | |||
| } | |||
| messageJson.addProperty("msgtype", message.getMsgType()); | |||
| return messageJson; | |||
| @@ -1,5 +1,6 @@ | |||
| package me.chanjar.weixin.mp.api; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import me.chanjar.weixin.mp.bean.WxMpCustomMessage; | |||
| import org.testng.annotations.Guice; | |||
| import org.testng.annotations.Test; | |||
| @@ -23,7 +24,7 @@ public class WxMpCustomMessageAPITest { | |||
| public void testSendCustomMessage() throws WxErrorException { | |||
| ApiTestModule.WxXmlMpInMemoryConfigStorage configStorage = (ApiTestModule.WxXmlMpInMemoryConfigStorage) wxService.wxMpConfigStorage; | |||
| WxMpCustomMessage message = new WxMpCustomMessage(); | |||
| message.setMsgType(WxMpConsts.CUSTOM_MSG_TEXT); | |||
| message.setMsgType(WxConsts.CUSTOM_MSG_TEXT); | |||
| message.setToUser(configStorage.getOpenId()); | |||
| message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); | |||
| @@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.api; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | |||
| import me.chanjar.weixin.mp.bean.WxMpMassGroupMessage; | |||
| import me.chanjar.weixin.mp.bean.WxMpMassNews; | |||
| @@ -15,7 +16,6 @@ import org.testng.annotations.DataProvider; | |||
| import org.testng.annotations.Guice; | |||
| import org.testng.annotations.Test; | |||
| import me.chanjar.weixin.mp.bean.WxMpMassNews.WxMassNewsArticle; | |||
| import me.chanjar.weixin.common.exception.WxErrorException; | |||
| import com.google.inject.Inject; | |||
| @@ -37,7 +37,7 @@ public class WxMpMassMessageAPITest { | |||
| // 发送群发消息 | |||
| ApiTestModule.WxXmlMpInMemoryConfigStorage configProvider = (ApiTestModule.WxXmlMpInMemoryConfigStorage) wxService.wxMpConfigStorage; | |||
| WxMpMassOpenIdsMessage massMessage = new WxMpMassOpenIdsMessage(); | |||
| massMessage.setMsgType(WxMpConsts.MASS_MSG_TEXT); | |||
| massMessage.setMsgType(WxConsts.MASS_MSG_TEXT); | |||
| massMessage.setContent("测试群发消息\n欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); | |||
| massMessage.getToUsers().add(configProvider.getOpenId()); | |||
| @@ -63,7 +63,7 @@ public class WxMpMassMessageAPITest { | |||
| @Test | |||
| public void testTextMassGroupMessageSend() throws WxErrorException { | |||
| WxMpMassGroupMessage massMessage = new WxMpMassGroupMessage(); | |||
| massMessage.setMsgtype(WxMpConsts.MASS_MSG_TEXT); | |||
| massMessage.setMsgtype(WxConsts.MASS_MSG_TEXT); | |||
| massMessage.setContent("测试群发消息\n欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); | |||
| massMessage.setGroupId(wxService.groupGet().get(0).getId()); | |||
| @@ -93,7 +93,7 @@ public class WxMpMassMessageAPITest { | |||
| { | |||
| // 上传视频到媒体库 | |||
| InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.mp4"); | |||
| WxMediaUploadResult uploadMediaRes = wxService.mediaUpload(WxMpConsts.MEDIA_VIDEO, WxMpConsts.FILE_MP4, inputStream); | |||
| WxMediaUploadResult uploadMediaRes = wxService.mediaUpload(WxConsts.MEDIA_VIDEO, WxConsts.FILE_MP4, inputStream); | |||
| Assert.assertNotNull(uploadMediaRes); | |||
| Assert.assertNotNull(uploadMediaRes.getMediaId()); | |||
| @@ -105,27 +105,27 @@ public class WxMpMassMessageAPITest { | |||
| WxMpMassUploadResult uploadResult = wxService.massVideoUpload(video); | |||
| Assert.assertNotNull(uploadResult); | |||
| Assert.assertNotNull(uploadResult.getMediaId()); | |||
| messages[0] = new Object[] { WxMpConsts.MASS_MSG_VIDEO, uploadResult.getMediaId() }; | |||
| messages[0] = new Object[] { WxConsts.MASS_MSG_VIDEO, uploadResult.getMediaId() }; | |||
| } | |||
| /** | |||
| * 图片素材 | |||
| */ | |||
| { | |||
| InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.jpeg"); | |||
| WxMediaUploadResult uploadMediaRes = wxService.mediaUpload(WxMpConsts.MEDIA_IMAGE, WxMpConsts.FILE_JPG, inputStream); | |||
| WxMediaUploadResult uploadMediaRes = wxService.mediaUpload(WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, inputStream); | |||
| Assert.assertNotNull(uploadMediaRes); | |||
| Assert.assertNotNull(uploadMediaRes.getMediaId()); | |||
| messages[1] = new Object[] { WxMpConsts.MASS_MSG_IMAGE, uploadMediaRes.getMediaId() }; | |||
| messages[1] = new Object[] { WxConsts.MASS_MSG_IMAGE, uploadMediaRes.getMediaId() }; | |||
| } | |||
| /** | |||
| * 语音素材 | |||
| */ | |||
| { | |||
| InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.mp3"); | |||
| WxMediaUploadResult uploadMediaRes = wxService.mediaUpload(WxMpConsts.MEDIA_VOICE, WxMpConsts.FILE_MP3, inputStream); | |||
| WxMediaUploadResult uploadMediaRes = wxService.mediaUpload(WxConsts.MEDIA_VOICE, WxConsts.FILE_MP3, inputStream); | |||
| Assert.assertNotNull(uploadMediaRes); | |||
| Assert.assertNotNull(uploadMediaRes.getMediaId()); | |||
| messages[2] = new Object[] { WxMpConsts.MASS_MSG_VOICE, uploadMediaRes.getMediaId() }; | |||
| messages[2] = new Object[] { WxConsts.MASS_MSG_VOICE, uploadMediaRes.getMediaId() }; | |||
| } | |||
| /** | |||
| * 图文素材 | |||
| @@ -133,19 +133,19 @@ public class WxMpMassMessageAPITest { | |||
| { | |||
| // 上传照片到媒体库 | |||
| InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.jpeg"); | |||
| WxMediaUploadResult uploadMediaRes = wxService.mediaUpload(WxMpConsts.MEDIA_IMAGE, WxMpConsts.FILE_JPG, inputStream); | |||
| WxMediaUploadResult uploadMediaRes = wxService.mediaUpload(WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, inputStream); | |||
| Assert.assertNotNull(uploadMediaRes); | |||
| Assert.assertNotNull(uploadMediaRes.getMediaId()); | |||
| // 上传图文消息 | |||
| WxMpMassNews news = new WxMpMassNews(); | |||
| WxMassNewsArticle article1 = new WxMassNewsArticle(); | |||
| WxMpMassNews.WxMpMassNewsArticle article1 = new WxMpMassNews.WxMpMassNewsArticle(); | |||
| article1.setTitle("标题1"); | |||
| article1.setContent("内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1"); | |||
| article1.setThumbMediaId(uploadMediaRes.getMediaId()); | |||
| news.addArticle(article1); | |||
| WxMassNewsArticle article2 = new WxMassNewsArticle(); | |||
| WxMpMassNews.WxMpMassNewsArticle article2 = new WxMpMassNews.WxMpMassNewsArticle(); | |||
| article2.setTitle("标题2"); | |||
| article2.setContent("内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2"); | |||
| article2.setThumbMediaId(uploadMediaRes.getMediaId()); | |||
| @@ -158,7 +158,7 @@ public class WxMpMassMessageAPITest { | |||
| WxMpMassUploadResult massUploadResult = wxService.massNewsUpload(news); | |||
| Assert.assertNotNull(massUploadResult); | |||
| Assert.assertNotNull(uploadMediaRes.getMediaId()); | |||
| messages[3] = new Object[] { WxMpConsts.MASS_MSG_NEWS, massUploadResult.getMediaId() }; | |||
| messages[3] = new Object[] { WxConsts.MASS_MSG_NEWS, massUploadResult.getMediaId() }; | |||
| } | |||
| return messages; | |||
| } | |||
| @@ -5,6 +5,7 @@ import java.io.InputStream; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | |||
| import org.testng.Assert; | |||
| import org.testng.annotations.DataProvider; | |||
| @@ -48,10 +49,10 @@ public class WxMpMediaAPITest { | |||
| @DataProvider | |||
| public Object[][] uploadMedia() { | |||
| return new Object[][] { | |||
| new Object[] { WxMpConsts.MEDIA_IMAGE, WxMpConsts.FILE_JPG, "mm.jpeg" }, | |||
| new Object[] { WxMpConsts.MEDIA_VOICE, WxMpConsts.FILE_MP3, "mm.mp3" }, | |||
| new Object[] { WxMpConsts.MEDIA_VIDEO, WxMpConsts.FILE_MP4, "mm.mp4" }, | |||
| new Object[] { WxMpConsts.MEDIA_THUMB, WxMpConsts.FILE_JPG, "mm.jpeg" } | |||
| new Object[] { WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, "mm.jpeg" }, | |||
| new Object[] { WxConsts.MEDIA_VOICE, WxConsts.FILE_MP3, "mm.mp3" }, | |||
| new Object[] { WxConsts.MEDIA_VIDEO, WxConsts.FILE_MP4, "mm.mp4" }, | |||
| new Object[] { WxConsts.MEDIA_THUMB, WxConsts.FILE_JPG, "mm.jpeg" } | |||
| }; | |||
| } | |||
| @@ -2,6 +2,7 @@ package me.chanjar.weixin.mp.api; | |||
| import javax.xml.bind.JAXBException; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import org.testng.Assert; | |||
| import org.testng.annotations.DataProvider; | |||
| import org.testng.annotations.Guice; | |||
| @@ -44,12 +45,12 @@ public class WxMpMenuAPITest { | |||
| public Object[][] getMenu() throws JAXBException { | |||
| WxMenu menu = new WxMenu(); | |||
| WxMenuButton button1 = new WxMenuButton(); | |||
| button1.setType(WxMpConsts.BUTTON_CLICK); | |||
| button1.setType(WxConsts.BUTTON_CLICK); | |||
| button1.setName("今日歌曲"); | |||
| button1.setKey("V1001_TODAY_MUSIC"); | |||
| WxMenuButton button2 = new WxMenuButton(); | |||
| button2.setType(WxMpConsts.BUTTON_CLICK); | |||
| button2.setType(WxConsts.BUTTON_CLICK); | |||
| button2.setName("歌手简介"); | |||
| button2.setKey("V1001_TODAY_SINGER"); | |||
| @@ -61,17 +62,17 @@ public class WxMpMenuAPITest { | |||
| menu.getButtons().add(button3); | |||
| WxMenuButton button31 = new WxMenuButton(); | |||
| button31.setType(WxMpConsts.BUTTON_VIEW); | |||
| button31.setType(WxConsts.BUTTON_VIEW); | |||
| button31.setName("搜索"); | |||
| button31.setUrl("http://www.soso.com/"); | |||
| WxMenuButton button32 = new WxMenuButton(); | |||
| button32.setType(WxMpConsts.BUTTON_VIEW); | |||
| button32.setType(WxConsts.BUTTON_VIEW); | |||
| button32.setName("视频"); | |||
| button32.setUrl("http://v.qq.com/"); | |||
| WxMenuButton button33 = new WxMenuButton(); | |||
| button33.setType(WxMpConsts.BUTTON_CLICK); | |||
| button33.setType(WxConsts.BUTTON_CLICK); | |||
| button33.setName("赞一下我们"); | |||
| button33.setKey("V1001_GOOD"); | |||
| @@ -2,6 +2,7 @@ package me.chanjar.weixin.mp.api; | |||
| import java.util.Map; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import me.chanjar.weixin.mp.bean.WxMpXmlMessage; | |||
| import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; | |||
| import org.testng.Assert; | |||
| @@ -21,21 +22,21 @@ public class WxMpMessageRouterTest { | |||
| router | |||
| .rule() | |||
| .async(async) | |||
| .msgType(WxMpConsts.XML_MSG_TEXT).event(WxMpConsts.EVT_CLICK).eventKey("KEY_1").content("CONTENT_1") | |||
| .msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK).eventKey("KEY_1").content("CONTENT_1") | |||
| .handler(new WxEchoMpMessageHandler(sb, "COMBINE_4")) | |||
| .end() | |||
| .rule() | |||
| .async(async) | |||
| .msgType(WxMpConsts.XML_MSG_TEXT).event(WxMpConsts.EVT_CLICK).eventKey("KEY_1") | |||
| .msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK).eventKey("KEY_1") | |||
| .handler(new WxEchoMpMessageHandler(sb, "COMBINE_3")) | |||
| .end() | |||
| .rule() | |||
| .async(async) | |||
| .msgType(WxMpConsts.XML_MSG_TEXT).event(WxMpConsts.EVT_CLICK) | |||
| .msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK) | |||
| .handler(new WxEchoMpMessageHandler(sb, "COMBINE_2")) | |||
| .end() | |||
| .rule().async(async).msgType(WxMpConsts.XML_MSG_TEXT).handler(new WxEchoMpMessageHandler(sb, WxMpConsts.XML_MSG_TEXT)).end() | |||
| .rule().async(async).event(WxMpConsts.EVT_CLICK).handler(new WxEchoMpMessageHandler(sb, WxMpConsts.EVT_CLICK)).end() | |||
| .rule().async(async).msgType(WxConsts.XML_MSG_TEXT).handler(new WxEchoMpMessageHandler(sb, WxConsts.XML_MSG_TEXT)).end() | |||
| .rule().async(async).event(WxConsts.EVT_CLICK).handler(new WxEchoMpMessageHandler(sb, WxConsts.EVT_CLICK)).end() | |||
| .rule().async(async).eventKey("KEY_1").handler(new WxEchoMpMessageHandler(sb, "KEY_1")).end() | |||
| .rule().async(async).content("CONTENT_1").handler(new WxEchoMpMessageHandler(sb, "CONTENT_1")).end() | |||
| .rule().async(async).rContent(".*bc.*").handler(new WxEchoMpMessageHandler(sb, "abcd")).end() | |||
| @@ -91,10 +92,10 @@ public class WxMpMessageRouterTest { | |||
| @DataProvider(name="messages-1") | |||
| public Object[][] messages2() { | |||
| WxMpXmlMessage message1 = new WxMpXmlMessage(); | |||
| message1.setMsgType(WxMpConsts.XML_MSG_TEXT); | |||
| message1.setMsgType(WxConsts.XML_MSG_TEXT); | |||
| WxMpXmlMessage message2 = new WxMpXmlMessage(); | |||
| message2.setEvent(WxMpConsts.EVT_CLICK); | |||
| message2.setEvent(WxConsts.EVT_CLICK); | |||
| WxMpXmlMessage message3 = new WxMpXmlMessage(); | |||
| message3.setEventKey("KEY_1"); | |||
| @@ -109,23 +110,23 @@ public class WxMpMessageRouterTest { | |||
| message6.setContent("abcd"); | |||
| WxMpXmlMessage c2 = new WxMpXmlMessage(); | |||
| c2.setMsgType(WxMpConsts.XML_MSG_TEXT); | |||
| c2.setEvent(WxMpConsts.EVT_CLICK); | |||
| c2.setMsgType(WxConsts.XML_MSG_TEXT); | |||
| c2.setEvent(WxConsts.EVT_CLICK); | |||
| WxMpXmlMessage c3 = new WxMpXmlMessage(); | |||
| c3.setMsgType(WxMpConsts.XML_MSG_TEXT); | |||
| c3.setEvent(WxMpConsts.EVT_CLICK); | |||
| c3.setMsgType(WxConsts.XML_MSG_TEXT); | |||
| c3.setEvent(WxConsts.EVT_CLICK); | |||
| c3.setEventKey("KEY_1"); | |||
| WxMpXmlMessage c4 = new WxMpXmlMessage(); | |||
| c4.setMsgType(WxMpConsts.XML_MSG_TEXT); | |||
| c4.setEvent(WxMpConsts.EVT_CLICK); | |||
| c4.setMsgType(WxConsts.XML_MSG_TEXT); | |||
| c4.setEvent(WxConsts.EVT_CLICK); | |||
| c4.setEventKey("KEY_1"); | |||
| c4.setContent("CONTENT_1"); | |||
| return new Object[][] { | |||
| new Object[] { message1, WxMpConsts.XML_MSG_TEXT + "," }, | |||
| new Object[] { message2, WxMpConsts.EVT_CLICK + "," }, | |||
| new Object[] { message1, WxConsts.XML_MSG_TEXT + "," }, | |||
| new Object[] { message2, WxConsts.EVT_CLICK + "," }, | |||
| new Object[] { message3, "KEY_1," }, | |||
| new Object[] { message4, "CONTENT_1," }, | |||
| new Object[] { message5, "ALL," }, | |||
| @@ -1,6 +1,6 @@ | |||
| package me.chanjar.weixin.mp.bean; | |||
| import me.chanjar.weixin.mp.api.WxMpConsts; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import org.testng.Assert; | |||
| import org.testng.annotations.Test; | |||
| @@ -12,7 +12,7 @@ public class WxMpCustomMessageTest { | |||
| public void testTextReply() { | |||
| WxMpCustomMessage reply = new WxMpCustomMessage(); | |||
| reply.setToUser("OPENID"); | |||
| reply.setMsgType(WxMpConsts.CUSTOM_MSG_TEXT); | |||
| reply.setMsgType(WxConsts.CUSTOM_MSG_TEXT); | |||
| reply.setContent("sfsfdsdf"); | |||
| Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}"); | |||
| } | |||
| @@ -25,7 +25,7 @@ public class WxMpCustomMessageTest { | |||
| public void testImageReply() { | |||
| WxMpCustomMessage reply = new WxMpCustomMessage(); | |||
| reply.setToUser("OPENID"); | |||
| reply.setMsgType(WxMpConsts.CUSTOM_MSG_IMAGE); | |||
| reply.setMsgType(WxConsts.CUSTOM_MSG_IMAGE); | |||
| reply.setMediaId("MEDIA_ID"); | |||
| Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}"); | |||
| } | |||
| @@ -38,7 +38,7 @@ public class WxMpCustomMessageTest { | |||
| public void testVoiceReply() { | |||
| WxMpCustomMessage reply = new WxMpCustomMessage(); | |||
| reply.setToUser("OPENID"); | |||
| reply.setMsgType(WxMpConsts.CUSTOM_MSG_VOICE); | |||
| reply.setMsgType(WxConsts.CUSTOM_MSG_VOICE); | |||
| reply.setMediaId("MEDIA_ID"); | |||
| Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"}}"); | |||
| } | |||
| @@ -51,7 +51,7 @@ public class WxMpCustomMessageTest { | |||
| public void testVideoReply() { | |||
| WxMpCustomMessage reply = new WxMpCustomMessage(); | |||
| reply.setToUser("OPENID"); | |||
| reply.setMsgType(WxMpConsts.CUSTOM_MSG_VIDEO); | |||
| reply.setMsgType(WxConsts.CUSTOM_MSG_VIDEO); | |||
| reply.setMediaId("MEDIA_ID"); | |||
| reply.setThumbMediaId("MEDIA_ID"); | |||
| reply.setTitle("TITLE"); | |||
| @@ -67,7 +67,7 @@ public class WxMpCustomMessageTest { | |||
| public void testMusicReply() { | |||
| WxMpCustomMessage reply = new WxMpCustomMessage(); | |||
| reply.setToUser("OPENID"); | |||
| reply.setMsgType(WxMpConsts.CUSTOM_MSG_MUSIC); | |||
| reply.setMsgType(WxConsts.CUSTOM_MSG_MUSIC); | |||
| reply.setThumbMediaId("MEDIA_ID"); | |||
| reply.setDescription("DESCRIPTION"); | |||
| reply.setTitle("TITLE"); | |||
| @@ -91,7 +91,7 @@ public class WxMpCustomMessageTest { | |||
| public void testNewsReply() { | |||
| WxMpCustomMessage reply = new WxMpCustomMessage(); | |||
| reply.setToUser("OPENID"); | |||
| reply.setMsgType(WxMpConsts.CUSTOM_MSG_NEWS); | |||
| reply.setMsgType(WxConsts.CUSTOM_MSG_NEWS); | |||
| WxArticle article1 = new WxArticle(); | |||
| article1.setUrl("URL"); | |||
| @@ -1,6 +1,6 @@ | |||
| package me.chanjar.weixin.mp.bean; | |||
| import me.chanjar.weixin.mp.api.WxMpConsts; | |||
| import me.chanjar.weixin.common.api.WxConsts; | |||
| import org.testng.Assert; | |||
| import org.testng.annotations.Test; | |||
| @@ -57,7 +57,7 @@ public class WxMpXmlMessageTest { | |||
| Assert.assertEquals(wxMessage.getToUserName(), "toUser"); | |||
| Assert.assertEquals(wxMessage.getFromUserName(), "fromUser"); | |||
| Assert.assertEquals(wxMessage.getCreateTime(), new Long(1348831860l)); | |||
| Assert.assertEquals(wxMessage.getMsgType(), WxMpConsts.XML_MSG_TEXT); | |||
| Assert.assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT); | |||
| Assert.assertEquals(wxMessage.getContent(), "this is a test"); | |||
| Assert.assertEquals(wxMessage.getMsgId(), new Long(1234567890123456l)); | |||
| Assert.assertEquals(wxMessage.getPicUrl(), "this is a url"); | |||