mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-11-01 03:25:35 +08:00 
			
		
		
		
	#531 小程序WxMaMessage类增加小程序卡片消息相关的几个属性
This commit is contained in:
		| @ -42,7 +42,6 @@ public class WxMaMessage implements Serializable { | ||||
|  | ||||
|   @SerializedName("CreateTime") | ||||
|   @XStreamAlias("CreateTime") | ||||
|   @XStreamConverter(value = XStreamCDataConverter.class) | ||||
|   private Integer createTime; | ||||
|  | ||||
|   @SerializedName("MsgType") | ||||
| @ -62,7 +61,6 @@ public class WxMaMessage implements Serializable { | ||||
|  | ||||
|   @SerializedName("MsgId") | ||||
|   @XStreamAlias("MsgId") | ||||
|   @XStreamConverter(value = XStreamCDataConverter.class) | ||||
|   private Long msgId; | ||||
|  | ||||
|   @SerializedName("PicUrl") | ||||
| @ -80,6 +78,31 @@ public class WxMaMessage implements Serializable { | ||||
|   @XStreamConverter(value = XStreamCDataConverter.class) | ||||
|   private String event; | ||||
|  | ||||
|   @SerializedName("Title") | ||||
|   @XStreamAlias("Title") | ||||
|   @XStreamConverter(value = XStreamCDataConverter.class) | ||||
|   private String title; | ||||
|  | ||||
|   @SerializedName("AppId") | ||||
|   @XStreamAlias("AppId") | ||||
|   @XStreamConverter(value = XStreamCDataConverter.class) | ||||
|   private String appId; | ||||
|  | ||||
|   @SerializedName("PagePath") | ||||
|   @XStreamAlias("PagePath") | ||||
|   @XStreamConverter(value = XStreamCDataConverter.class) | ||||
|   private String pagePath; | ||||
|  | ||||
|   @SerializedName("ThumbUrl") | ||||
|   @XStreamAlias("ThumbUrl") | ||||
|   @XStreamConverter(value = XStreamCDataConverter.class) | ||||
|   private String thumbUrl; | ||||
|  | ||||
|   @SerializedName("ThumbMediaId") | ||||
|   @XStreamAlias("ThumbMediaId") | ||||
|   @XStreamConverter(value = XStreamCDataConverter.class) | ||||
|   private String thumbMediaId; | ||||
|  | ||||
|   @SerializedName("SessionFrom") | ||||
|   @XStreamAlias("SessionFrom") | ||||
|   @XStreamConverter(value = XStreamCDataConverter.class) | ||||
|  | ||||
| @ -12,118 +12,39 @@ import static org.testng.Assert.assertEquals; | ||||
| public class WxMaMessageTest { | ||||
|  | ||||
|   public void testFromXml() { | ||||
|     String xml = "<xml>" | ||||
|       + "<ToUserName><![CDATA[toUser]]></ToUserName>" | ||||
|       + "<FromUserName><![CDATA[fromUser]]></FromUserName> " | ||||
|       + "<CreateTime>1348831860</CreateTime>" | ||||
|       + "<MsgDataFormat><![CDATA[text]]></MsgDataFormat>" | ||||
|       + "<Content><![CDATA[this is a test]]></Content>" | ||||
|       + "<MsgId>1234567890123456</MsgId>" | ||||
|       + "<PicUrl><![CDATA[this is a url]]></PicUrl>" | ||||
|       + "<MediaId><![CDATA[media_id]]></MediaId>" | ||||
|       + "<Format><![CDATA[Format]]></Format>" | ||||
|       + "<ThumbMediaId><![CDATA[thumb_media_id]]></ThumbMediaId>" | ||||
|       + "<Location_X>23.134521</Location_X>" | ||||
|       + "<Location_Y>113.358803</Location_Y>" | ||||
|       + "<Scale>20</Scale>" | ||||
|       + "<Label><![CDATA[位置信息]]></Label>" | ||||
|       + "<Description><![CDATA[公众平台官网链接]]></Description>" | ||||
|       + "<Url><![CDATA[url]]></Url>" | ||||
|       + "<Title><![CDATA[公众平台官网链接]]></Title>" | ||||
|       + "<Event><![CDATA[subscribe]]></Event>" | ||||
|       + "<EventKey><![CDATA[qrscene_123123]]></EventKey>" | ||||
|       + "<Ticket><![CDATA[TICKET]]></Ticket>" | ||||
|       + "<Latitude>23.137466</Latitude>" | ||||
|       + "<Longitude>113.352425</Longitude>" | ||||
|       + "<Precision>119.385040</Precision>" | ||||
|       + "<ScanCodeInfo>" | ||||
|       + " <ScanType><![CDATA[qrcode]]></ScanType>" | ||||
|       + " <ScanResult><![CDATA[1]]></ScanResult>" | ||||
|       + "</ScanCodeInfo>" | ||||
|       + "<SendPicsInfo>" | ||||
|       + " <Count>1</Count>\n" | ||||
|       + " <PicList>" | ||||
|       + "  <item>" | ||||
|       + "   <PicMd5Sum><![CDATA[1b5f7c23b5bf75682a53e7b6d163e185]]></PicMd5Sum>" | ||||
|       + "  </item>" | ||||
|       + " </PicList>" | ||||
|       + "</SendPicsInfo>" | ||||
|       + "<SendLocationInfo>" | ||||
|       + "  <Location_X><![CDATA[23]]></Location_X>\n" | ||||
|       + "  <Location_Y><![CDATA[113]]></Location_Y>\n" | ||||
|       + "  <Scale><![CDATA[15]]></Scale>\n" | ||||
|       + "  <Label><![CDATA[ 广州市海珠区客村艺苑路 106号]]></Label>\n" | ||||
|       + "  <Poiname><![CDATA[wo de poi]]></Poiname>\n" | ||||
|       + "</SendLocationInfo>" | ||||
|       + "</xml>"; | ||||
|     String xml = "<xml>\n" + | ||||
|       "   <ToUserName><![CDATA[toUser]]></ToUserName>\n" + | ||||
|       "   <FromUserName><![CDATA[fromUser]]></FromUserName>\n" + | ||||
|       "   <CreateTime>1482048670</CreateTime>\n" + | ||||
|       "   <MsgType><![CDATA[text]]></MsgType>\n" + | ||||
|       "   <Content><![CDATA[this is a test]]></Content>\n" + | ||||
|       "   <MsgId>1234567890123456</MsgId>\n" + | ||||
|       "   <PicUrl><![CDATA[this is a url]]></PicUrl>\n" + | ||||
|       "   <MediaId><![CDATA[media_id]]></MediaId>\n" + | ||||
|       "   <Title><![CDATA[Title]]></Title>\n" + | ||||
|       "   <AppId><![CDATA[AppId]]></AppId>\n" + | ||||
|       "   <PagePath><![CDATA[PagePath]]></PagePath>\n" + | ||||
|       "   <ThumbUrl><![CDATA[ThumbUrl]]></ThumbUrl>\n" + | ||||
|       "   <ThumbMediaId><![CDATA[ThumbMediaId]]></ThumbMediaId>\n" + | ||||
|       "   <Event><![CDATA[user_enter_tempsession]]></Event>\n" + | ||||
|       "   <SessionFrom><![CDATA[sessionFrom]]></SessionFrom>\n" + | ||||
|       "</xml>"; | ||||
|     WxMaMessage wxMessage = WxMaMessage.fromXml(xml); | ||||
|     assertEquals(wxMessage.getToUser(), "toUser"); | ||||
|     assertEquals(wxMessage.getFromUser(), "fromUser"); | ||||
|     assertEquals(wxMessage.getCreateTime(), new Long(1348831860L)); | ||||
|     assertEquals(wxMessage.getCreateTime(),new Integer(1482048670)); | ||||
|     assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT); | ||||
|     assertEquals(wxMessage.getContent(), "this is a test"); | ||||
|     assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); | ||||
|     assertEquals(wxMessage.getPicUrl(), "this is a url"); | ||||
|     assertEquals(wxMessage.getMediaId(), "media_id"); | ||||
|     assertEquals(wxMessage.getEvent(), "subscribe"); | ||||
|   } | ||||
|  | ||||
|   public void testFromXml2() { | ||||
|  | ||||
|     String xml = "<xml>" | ||||
|       + "<ToUserName><![CDATA[toUser]]></ToUserName>" | ||||
|       + "<FromUserName><![CDATA[fromUser]]></FromUserName> " | ||||
|       + "<CreateTime>1348831860</CreateTime>" | ||||
|       + "<MsgDataFormat><![CDATA[text]]></MsgDataFormat>" | ||||
|       + "<Content><![CDATA[this is a test]]></Content>" | ||||
|       + "<MsgID>1234567890123456</MsgID>" | ||||
|       + "<PicUrl><![CDATA[this is a url]]></PicUrl>" | ||||
|       + "<MediaId><![CDATA[media_id]]></MediaId>" | ||||
|       + "<Format><![CDATA[Format]]></Format>" | ||||
|       + "<ThumbMediaId><![CDATA[thumb_media_id]]></ThumbMediaId>" | ||||
|       + "<Location_X>23.134521</Location_X>" | ||||
|       + "<Location_Y>113.358803</Location_Y>" | ||||
|       + "<Scale>20</Scale>" | ||||
|       + "<Label><![CDATA[位置信息]]></Label>" | ||||
|       + "<Description><![CDATA[公众平台官网链接]]></Description>" | ||||
|       + "<Url><![CDATA[url]]></Url>" | ||||
|       + "<Title><![CDATA[公众平台官网链接]]></Title>" | ||||
|       + "<Event><![CDATA[subscribe]]></Event>" | ||||
|       + "<EventKey><![CDATA[qrscene_123123]]></EventKey>" | ||||
|       + "<Ticket><![CDATA[TICKET]]></Ticket>" | ||||
|       + "<Latitude>23.137466</Latitude>" | ||||
|       + "<Longitude>113.352425</Longitude>" | ||||
|       + "<Precision>119.385040</Precision>" | ||||
|       + "<ScanCodeInfo>" | ||||
|       + " <ScanType><![CDATA[qrcode]]></ScanType>" | ||||
|       + " <ScanResult><![CDATA[1]]></ScanResult>" | ||||
|       + "</ScanCodeInfo>" | ||||
|       + "<SendPicsInfo>" | ||||
|       + " <Count>1</Count>\n" | ||||
|       + " <PicList>" | ||||
|       + "  <item>" | ||||
|       + "   <PicMd5Sum><![CDATA[1b5f7c23b5bf75682a53e7b6d163e185]]></PicMd5Sum>" | ||||
|       + "  </item>" | ||||
|       + " </PicList>" | ||||
|       + "</SendPicsInfo>" | ||||
|       + "<SendLocationInfo>" | ||||
|       + "  <Location_X><![CDATA[23]]></Location_X>\n" | ||||
|       + "  <Location_Y><![CDATA[113]]></Location_Y>\n" | ||||
|       + "  <Scale><![CDATA[15]]></Scale>\n" | ||||
|       + "  <Label><![CDATA[ 广州市海珠区客村艺苑路 106号]]></Label>\n" | ||||
|       + "  <Poiname><![CDATA[wo de poi]]></Poiname>\n" | ||||
|       + "</SendLocationInfo>" | ||||
|       + "</xml>"; | ||||
|     WxMaMessage wxMessage = WxMaMessage.fromXml(xml); | ||||
|     assertEquals(wxMessage.getToUser(), "toUser"); | ||||
|     assertEquals(wxMessage.getFromUser(), "fromUser"); | ||||
|     assertEquals(wxMessage.getCreateTime(), new Integer(1348831860)); | ||||
|     assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT); | ||||
|     assertEquals(wxMessage.getContent(), "this is a test"); | ||||
|     assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); | ||||
|     assertEquals(wxMessage.getPicUrl(), "this is a url"); | ||||
|     assertEquals(wxMessage.getMediaId(), "media_id"); | ||||
|     assertEquals(wxMessage.getEvent(), "subscribe"); | ||||
|     assertEquals(wxMessage.getTitle(), "Title"); | ||||
|     assertEquals(wxMessage.getPagePath(), "PagePath"); | ||||
|     assertEquals(wxMessage.getThumbUrl(), "ThumbUrl"); | ||||
|     assertEquals(wxMessage.getThumbMediaId(), "ThumbMediaId"); | ||||
|     assertEquals(wxMessage.getAppId(), "AppId"); | ||||
|     assertEquals(wxMessage.getEvent(), "user_enter_tempsession"); | ||||
|     assertEquals(wxMessage.getSessionFrom(), "sessionFrom"); | ||||
|   } | ||||
|  | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Binary Wang
					Binary Wang