diff --git a/src/main/java/chanjarster/weixin/bean/WxCustomMessage.java b/src/main/java/chanjarster/weixin/bean/WxCustomMessage.java
index 53e0e8a70..965db4917 100644
--- a/src/main/java/chanjarster/weixin/bean/WxCustomMessage.java
+++ b/src/main/java/chanjarster/weixin/bean/WxCustomMessage.java
@@ -6,7 +6,6 @@ import java.util.List;
import chanjarster.weixin.api.WxConsts;
import chanjarster.weixin.bean.custombuilder.ImageBuilder;
import chanjarster.weixin.bean.custombuilder.MusicBuilder;
-import chanjarster.weixin.bean.custombuilder.NewsArticleBuilder;
import chanjarster.weixin.bean.custombuilder.NewsBuilder;
import chanjarster.weixin.bean.custombuilder.TextBuilder;
import chanjarster.weixin.bean.custombuilder.VideoBuilder;
@@ -191,12 +190,4 @@ public class WxCustomMessage {
return new NewsBuilder();
}
- /**
- * 获得图文消息文章builder
- * @return
- */
- public static NewsArticleBuilder NEWS_ARTICLE() {
- return new NewsArticleBuilder();
- }
-
}
diff --git a/src/main/java/chanjarster/weixin/bean/WxXmlMessage.java b/src/main/java/chanjarster/weixin/bean/WxXmlMessage.java
index 5d681cb63..044ff645f 100644
--- a/src/main/java/chanjarster/weixin/bean/WxXmlMessage.java
+++ b/src/main/java/chanjarster/weixin/bean/WxXmlMessage.java
@@ -386,127 +386,5 @@ public class WxXmlMessage {
public void setErrorCount(Integer errorCount) {
ErrorCount = errorCount;
}
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((Content == null) ? 0 : Content.hashCode());
- result = prime * result + ((CreateTime == null) ? 0 : CreateTime.hashCode());
- result = prime * result + ((Description == null) ? 0 : Description.hashCode());
- result = prime * result + ErrorCount;
- result = prime * result + ((Event == null) ? 0 : Event.hashCode());
- result = prime * result + ((EventKey == null) ? 0 : EventKey.hashCode());
- result = prime * result + FilterCount;
- result = prime * result + ((Format == null) ? 0 : Format.hashCode());
- result = prime * result + ((FromUserName == null) ? 0 : FromUserName.hashCode());
- result = prime * result + ((Label == null) ? 0 : Label.hashCode());
- result = prime * result + ((Latitude == null) ? 0 : Latitude.hashCode());
- result = prime * result + ((Location_X == null) ? 0 : Location_X.hashCode());
- result = prime * result + ((Location_Y == null) ? 0 : Location_Y.hashCode());
- result = prime * result + ((Longitude == null) ? 0 : Longitude.hashCode());
- result = prime * result + ((MediaId == null) ? 0 : MediaId.hashCode());
- result = prime * result + ((MsgId == null) ? 0 : MsgId.hashCode());
- result = prime * result + ((MsgType == null) ? 0 : MsgType.hashCode());
- result = prime * result + ((PicUrl == null) ? 0 : PicUrl.hashCode());
- result = prime * result + ((Precision == null) ? 0 : Precision.hashCode());
- result = prime * result + ((Recognition == null) ? 0 : Recognition.hashCode());
- result = prime * result + ((Scale == null) ? 0 : Scale.hashCode());
- result = prime * result + SentCount;
- result = prime * result + ((Status == null) ? 0 : Status.hashCode());
- result = prime * result + ((ThumbMediaId == null) ? 0 : ThumbMediaId.hashCode());
- result = prime * result + ((Ticket == null) ? 0 : Ticket.hashCode());
- result = prime * result + ((Title == null) ? 0 : Title.hashCode());
- result = prime * result + ((ToUserName == null) ? 0 : ToUserName.hashCode());
- result = prime * result + TotalCount;
- result = prime * result + ((Url == null) ? 0 : Url.hashCode());
- return result;
- }
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null) return false;
- if (getClass() != obj.getClass()) return false;
- WxXmlMessage other = (WxXmlMessage) obj;
- if (Content == null) {
- if (other.Content != null) return false;
- } else if (!Content.equals(other.Content)) return false;
- if (CreateTime == null) {
- if (other.CreateTime != null) return false;
- } else if (!CreateTime.equals(other.CreateTime)) return false;
- if (Description == null) {
- if (other.Description != null) return false;
- } else if (!Description.equals(other.Description)) return false;
- if (ErrorCount != other.ErrorCount) return false;
- if (Event == null) {
- if (other.Event != null) return false;
- } else if (!Event.equals(other.Event)) return false;
- if (EventKey == null) {
- if (other.EventKey != null) return false;
- } else if (!EventKey.equals(other.EventKey)) return false;
- if (FilterCount != other.FilterCount) return false;
- if (Format == null) {
- if (other.Format != null) return false;
- } else if (!Format.equals(other.Format)) return false;
- if (FromUserName == null) {
- if (other.FromUserName != null) return false;
- } else if (!FromUserName.equals(other.FromUserName)) return false;
- if (Label == null) {
- if (other.Label != null) return false;
- } else if (!Label.equals(other.Label)) return false;
- if (Latitude == null) {
- if (other.Latitude != null) return false;
- } else if (!Latitude.equals(other.Latitude)) return false;
- if (Location_X == null) {
- if (other.Location_X != null) return false;
- } else if (!Location_X.equals(other.Location_X)) return false;
- if (Location_Y == null) {
- if (other.Location_Y != null) return false;
- } else if (!Location_Y.equals(other.Location_Y)) return false;
- if (Longitude == null) {
- if (other.Longitude != null) return false;
- } else if (!Longitude.equals(other.Longitude)) return false;
- if (MediaId == null) {
- if (other.MediaId != null) return false;
- } else if (!MediaId.equals(other.MediaId)) return false;
- if (MsgId == null) {
- if (other.MsgId != null) return false;
- } else if (!MsgId.equals(other.MsgId)) return false;
- if (MsgType == null) {
- if (other.MsgType != null) return false;
- } else if (!MsgType.equals(other.MsgType)) return false;
- if (PicUrl == null) {
- if (other.PicUrl != null) return false;
- } else if (!PicUrl.equals(other.PicUrl)) return false;
- if (Precision == null) {
- if (other.Precision != null) return false;
- } else if (!Precision.equals(other.Precision)) return false;
- if (Recognition == null) {
- if (other.Recognition != null) return false;
- } else if (!Recognition.equals(other.Recognition)) return false;
- if (Scale == null) {
- if (other.Scale != null) return false;
- } else if (!Scale.equals(other.Scale)) return false;
- if (SentCount != other.SentCount) return false;
- if (Status == null) {
- if (other.Status != null) return false;
- } else if (!Status.equals(other.Status)) return false;
- if (ThumbMediaId == null) {
- if (other.ThumbMediaId != null) return false;
- } else if (!ThumbMediaId.equals(other.ThumbMediaId)) return false;
- if (Ticket == null) {
- if (other.Ticket != null) return false;
- } else if (!Ticket.equals(other.Ticket)) return false;
- if (Title == null) {
- if (other.Title != null) return false;
- } else if (!Title.equals(other.Title)) return false;
- if (ToUserName == null) {
- if (other.ToUserName != null) return false;
- } else if (!ToUserName.equals(other.ToUserName)) return false;
- if (TotalCount != other.TotalCount) return false;
- if (Url == null) {
- if (other.Url != null) return false;
- } else if (!Url.equals(other.Url)) return false;
- return true;
- }
}
\ No newline at end of file
diff --git a/src/main/java/chanjarster/weixin/bean/WxXmlOutMessage.java b/src/main/java/chanjarster/weixin/bean/WxXmlOutMessage.java
index 7a7d2b87c..c3f82539a 100644
--- a/src/main/java/chanjarster/weixin/bean/WxXmlOutMessage.java
+++ b/src/main/java/chanjarster/weixin/bean/WxXmlOutMessage.java
@@ -7,6 +7,12 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import chanjarster.weixin.bean.outxmlbuilder.ImageBuilder;
+import chanjarster.weixin.bean.outxmlbuilder.MusicBuilder;
+import chanjarster.weixin.bean.outxmlbuilder.NewsBuilder;
+import chanjarster.weixin.bean.outxmlbuilder.TextBuilder;
+import chanjarster.weixin.bean.outxmlbuilder.VideoBuilder;
+import chanjarster.weixin.bean.outxmlbuilder.VoiceBuilder;
import chanjarster.weixin.util.xml.AdapterCDATA;
import chanjarster.weixin.util.xml.XmlTransformer;
@@ -69,4 +75,51 @@ public class WxXmlOutMessage {
return null;
}
+ /**
+ * 获得文本消息builder
+ * @return
+ */
+ public static TextBuilder TEXT() {
+ return new TextBuilder();
+ }
+
+ /**
+ * 获得图片消息builder
+ * @return
+ */
+ public static ImageBuilder IMAGE() {
+ return new ImageBuilder();
+ }
+
+ /**
+ * 获得语音消息builder
+ * @return
+ */
+ public static VoiceBuilder VOICE() {
+ return new VoiceBuilder();
+ }
+
+ /**
+ * 获得视频消息builder
+ * @return
+ */
+ public static VideoBuilder VIDEO() {
+ return new VideoBuilder();
+ }
+
+ /**
+ * 获得音乐消息builder
+ * @return
+ */
+ public static MusicBuilder MUSIC() {
+ return new MusicBuilder();
+ }
+
+ /**
+ * 获得图文消息builder
+ * @return
+ */
+ public static NewsBuilder NEWS() {
+ return new NewsBuilder();
+ }
}
diff --git a/src/main/java/chanjarster/weixin/bean/custombuilder/NewsArticleBuilder.java b/src/main/java/chanjarster/weixin/bean/custombuilder/NewsArticleBuilder.java
deleted file mode 100644
index a72dd9b76..000000000
--- a/src/main/java/chanjarster/weixin/bean/custombuilder/NewsArticleBuilder.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package chanjarster.weixin.bean.custombuilder;
-
-import chanjarster.weixin.bean.WxCustomMessage;
-
-/**
- * 图文消息文章builder
- *
- * 用法: WxCustomMessage.WxArticle m = WxCustomMessage.NEWS_ARTICLE()
- * .url(...)
- * .title(...)
- * .picurl(...)
- * .description(...)
- * .build();
- *
- * @author chanjarster
- *
- */
-public final class NewsArticleBuilder {
- private String title;
- private String description;
- private String url;
- private String picurl;
-
- public NewsArticleBuilder url(String url) {
- this.url = url;
- return this;
- }
-
- public NewsArticleBuilder title(String title) {
- this.title = title;
- return this;
- }
-
- public NewsArticleBuilder description(String description) {
- this.description = description;
- return this;
- }
-
- public NewsArticleBuilder picurl(String picurl) {
- this.picurl = picurl;
- return this;
- }
-
- public WxCustomMessage.WxArticle build() {
- WxCustomMessage.WxArticle m = new WxCustomMessage.WxArticle();
- m.setPicurl(this.picurl);
- m.setTitle(title);
- m.setDescription(description);
- m.setUrl(this.url);
- return m;
- }
-}
diff --git a/src/main/java/chanjarster/weixin/bean/custombuilder/NewsBuilder.java b/src/main/java/chanjarster/weixin/bean/custombuilder/NewsBuilder.java
index cafef264b..7a7d93005 100644
--- a/src/main/java/chanjarster/weixin/bean/custombuilder/NewsBuilder.java
+++ b/src/main/java/chanjarster/weixin/bean/custombuilder/NewsBuilder.java
@@ -11,12 +11,6 @@ import chanjarster.weixin.bean.WxCustomMessage.WxArticle;
* 图文消息builder
*
* 用法:
- * WxCustomMessage.WxArticle article = WxCustomMessage.NEWS_ARTICLE()
- * .url(...)
- * .title(...)
- * .picurl(...)
- * .description(...)
- * .build();
* WxCustomMessage m = WxCustomMessage.NEWS().addArticle(article).touser(...).build();
*
* @author chanjarster
diff --git a/src/main/java/chanjarster/weixin/bean/outxmlbuilder/BaseBuilder.java b/src/main/java/chanjarster/weixin/bean/outxmlbuilder/BaseBuilder.java
index 195976d7a..0aee6c865 100644
--- a/src/main/java/chanjarster/weixin/bean/outxmlbuilder/BaseBuilder.java
+++ b/src/main/java/chanjarster/weixin/bean/outxmlbuilder/BaseBuilder.java
@@ -9,8 +9,6 @@ public abstract class BaseBuilder {
protected String fromUserName;
- protected String msgtype;
-
public BuilderType touser(String touser) {
this.toUserName = touser;
return (BuilderType) this;
@@ -26,7 +24,6 @@ public abstract class BaseBuilder {
public void setCommon(WxXmlOutMessage m) {
m.setToUserName(this.toUserName);
m.setFromUserName(this.fromUserName);
- m.setMsgType(this.msgtype);
m.setCreateTime(System.currentTimeMillis() / 1000l);
}
diff --git a/src/main/java/chanjarster/weixin/bean/outxmlbuilder/ImageBuilder.java b/src/main/java/chanjarster/weixin/bean/outxmlbuilder/ImageBuilder.java
index 6c9d744dc..d7fcc3d3d 100644
--- a/src/main/java/chanjarster/weixin/bean/outxmlbuilder/ImageBuilder.java
+++ b/src/main/java/chanjarster/weixin/bean/outxmlbuilder/ImageBuilder.java
@@ -1,32 +1,24 @@
package chanjarster.weixin.bean.outxmlbuilder;
-import chanjarster.weixin.api.WxConsts;
import chanjarster.weixin.bean.WxXmlOutImageMessage;
/**
- * 获得消息builder
- *
- * 用法: WxXmlMessage m = WxXmlMessage.IMAGE().media_id(...).touser(...).build();
- *
+ * 图片消息builder
* @author chanjarster
- *
*/
public final class ImageBuilder extends BaseBuilder {
- private String media_id;
- public ImageBuilder() {
- this.msgtype = WxConsts.XML_MSG_IMAGE;
- }
+ private String mediaId;
- public ImageBuilder media_id(String media_id) {
- this.media_id = media_id;
+ public ImageBuilder mediaId(String media_id) {
+ this.mediaId = media_id;
return this;
}
public WxXmlOutImageMessage build() {
WxXmlOutImageMessage m = new WxXmlOutImageMessage();
setCommon(m);
- m.setMediaId(this.media_id);
+ m.setMediaId(this.mediaId);
return m;
}
diff --git a/src/main/java/chanjarster/weixin/bean/outxmlbuilder/MusicBuilder.java b/src/main/java/chanjarster/weixin/bean/outxmlbuilder/MusicBuilder.java
new file mode 100644
index 000000000..1154c73d8
--- /dev/null
+++ b/src/main/java/chanjarster/weixin/bean/outxmlbuilder/MusicBuilder.java
@@ -0,0 +1,54 @@
+package chanjarster.weixin.bean.outxmlbuilder;
+
+import chanjarster.weixin.bean.WxXmlOutMusicMessage;
+
+/**
+ * 音乐消息builder
+ *
+ * @author chanjarster
+ */
+public final class MusicBuilder extends BaseBuilder {
+
+ private String title;
+ private String description;
+ private String hQMusicUrl;
+ private String musicUrl;
+ private String thumbMediaId;
+
+ public MusicBuilder title(String title) {
+ this.title = title;
+ return this;
+ }
+
+ public MusicBuilder description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ public MusicBuilder hQMusicUrl(String hQMusicUrl) {
+ this.hQMusicUrl = hQMusicUrl;
+ return this;
+ }
+
+ public MusicBuilder musicUrl(String musicUrl) {
+ this.musicUrl = musicUrl;
+ return this;
+ }
+
+ public MusicBuilder thumbMediaId(String thumbMediaId) {
+ this.thumbMediaId = thumbMediaId;
+ return this;
+ }
+
+ public WxXmlOutMusicMessage build() {
+ WxXmlOutMusicMessage m = new WxXmlOutMusicMessage();
+ setCommon(m);
+ m.setTitle(title);
+ m.setDescription(description);
+ m.setHQMusicUrl(hQMusicUrl);
+ m.setMusicUrl(musicUrl);
+ m.setThumbMediaId(thumbMediaId);
+ return m;
+ }
+
+}
diff --git a/src/main/java/chanjarster/weixin/bean/outxmlbuilder/NewsBuilder.java b/src/main/java/chanjarster/weixin/bean/outxmlbuilder/NewsBuilder.java
new file mode 100644
index 000000000..d174c38a2
--- /dev/null
+++ b/src/main/java/chanjarster/weixin/bean/outxmlbuilder/NewsBuilder.java
@@ -0,0 +1,31 @@
+package chanjarster.weixin.bean.outxmlbuilder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import chanjarster.weixin.bean.WxXmlOutMewsMessage;
+import chanjarster.weixin.bean.WxXmlOutMewsMessage.Item;
+
+/**
+ * 图文消息builder
+ * @author chanjarster
+ */
+public final class NewsBuilder extends BaseBuilder {
+
+ protected final List- articles = new ArrayList
- ();
+
+ public NewsBuilder addArticle(Item item) {
+ this.articles.add(item);
+ return this;
+ }
+
+ public WxXmlOutMewsMessage build() {
+ WxXmlOutMewsMessage m = new WxXmlOutMewsMessage();
+ for(Item item : articles) {
+ m.addArticle(item);
+ }
+ setCommon(m);
+ return m;
+ }
+
+}
diff --git a/src/main/java/chanjarster/weixin/bean/outxmlbuilder/TextBuilder.java b/src/main/java/chanjarster/weixin/bean/outxmlbuilder/TextBuilder.java
index d4f194839..8609ca634 100644
--- a/src/main/java/chanjarster/weixin/bean/outxmlbuilder/TextBuilder.java
+++ b/src/main/java/chanjarster/weixin/bean/outxmlbuilder/TextBuilder.java
@@ -1,23 +1,15 @@
package chanjarster.weixin.bean.outxmlbuilder;
-import chanjarster.weixin.api.WxConsts;
import chanjarster.weixin.bean.WxXmlOutTextMessage;
/**
* 文本消息builder
- *
- * 用法: WxXmlMessage m = WxXmlMessage.TEXT().touser(...).fromUser(...).content(...).build();
- *
* @author chanjarster
*
*/
public final class TextBuilder extends BaseBuilder {
private String content;
- public TextBuilder() {
- this.msgtype = WxConsts.XML_MSG_TEXT;
- }
-
public TextBuilder content(String content) {
this.content = content;
return this;
diff --git a/src/main/java/chanjarster/weixin/bean/outxmlbuilder/VideoBuilder.java b/src/main/java/chanjarster/weixin/bean/outxmlbuilder/VideoBuilder.java
new file mode 100644
index 000000000..78151f1bc
--- /dev/null
+++ b/src/main/java/chanjarster/weixin/bean/outxmlbuilder/VideoBuilder.java
@@ -0,0 +1,38 @@
+package chanjarster.weixin.bean.outxmlbuilder;
+
+import chanjarster.weixin.bean.WxXmlOutVideoMessage;
+
+/**
+ * 视频消息builder
+ * @author chanjarster
+ *
+ */
+public final class VideoBuilder extends BaseBuilder {
+
+ private String mediaId;
+ private String title;
+ private String description;
+
+ public VideoBuilder title(String title) {
+ this.title = title;
+ return this;
+ }
+ public VideoBuilder description(String description) {
+ this.description = description;
+ return this;
+ }
+ public VideoBuilder mediaId(String mediaId) {
+ this.mediaId = mediaId;
+ return this;
+ }
+
+ public WxXmlOutVideoMessage build() {
+ WxXmlOutVideoMessage m = new WxXmlOutVideoMessage();
+ setCommon(m);
+ m.setTitle(title);
+ m.setDescription(description);
+ m.setMediaId(mediaId);
+ return m;
+ }
+
+}
diff --git a/src/main/java/chanjarster/weixin/bean/outxmlbuilder/VoiceBuilder.java b/src/main/java/chanjarster/weixin/bean/outxmlbuilder/VoiceBuilder.java
new file mode 100644
index 000000000..f4b470046
--- /dev/null
+++ b/src/main/java/chanjarster/weixin/bean/outxmlbuilder/VoiceBuilder.java
@@ -0,0 +1,25 @@
+package chanjarster.weixin.bean.outxmlbuilder;
+
+import chanjarster.weixin.bean.WxXmlOutVoiceMessage;
+
+/**
+ * 语音消息builder
+ * @author chanjarster
+ */
+public final class VoiceBuilder extends BaseBuilder {
+
+ private String mediaId;
+
+ public VoiceBuilder mediaId(String mediaId) {
+ this.mediaId = mediaId;
+ return this;
+ }
+
+ public WxXmlOutVoiceMessage build() {
+ WxXmlOutVoiceMessage m = new WxXmlOutVoiceMessage();
+ setCommon(m);
+ m.setMediaId(mediaId);
+ return m;
+ }
+
+}
diff --git a/src/test/java/chanjarster/weixin/bean/WxXmlOutIMusicMessageTest.java b/src/test/java/chanjarster/weixin/bean/WxXmlOutIMusicMessageTest.java
index 76cbfdb63..f13d98c37 100644
--- a/src/test/java/chanjarster/weixin/bean/WxXmlOutIMusicMessageTest.java
+++ b/src/test/java/chanjarster/weixin/bean/WxXmlOutIMusicMessageTest.java
@@ -10,12 +10,12 @@ public class WxXmlOutIMusicMessageTest {
WxXmlOutMusicMessage m = new WxXmlOutMusicMessage();
m.setTitle("title");
m.setDescription("ddfff");
- m.setCreateTime(1122l);
- m.setFromUserName("fromUser");
- m.setToUserName("toUser");
m.setHQMusicUrl("hQMusicUrl");
m.setMusicUrl("musicUrl");
m.setThumbMediaId("thumbMediaId");
+ m.setCreateTime(1122l);
+ m.setFromUserName("fromUser");
+ m.setToUserName("toUser");
String expected = ""
+ ""
@@ -35,4 +35,40 @@ public class WxXmlOutIMusicMessageTest {
Assert.assertEquals(m.toXml().replaceAll("\\s", ""), expected.replaceAll("\\s", ""));
}
+ public void testBuild() {
+ WxXmlOutMusicMessage m = WxXmlOutMessage.MUSIC()
+ .fromUser("fromUser")
+ .touser("toUser")
+ .title("title")
+ .description("ddfff")
+ .hQMusicUrl("hQMusicUrl")
+ .musicUrl("musicUrl")
+ .thumbMediaId("thumbMediaId")
+ .build();
+ String expected = ""
+ + ""
+ + ""
+ + ""
+ + "1122"
+ + ""
+ + ""
+ + " "
+ + " "
+ + " "
+ + " "
+ + " "
+ + " "
+ + "";
+ System.out.println(m.toXml());
+ Assert.assertEquals(
+ m
+ .toXml()
+ .replaceAll("\\s", "")
+ .replaceAll(".*?", ""),
+ expected
+ .replaceAll("\\s", "")
+ .replaceAll(".*?", "")
+ );
+ }
+
}
diff --git a/src/test/java/chanjarster/weixin/bean/WxXmlOutINewsMessageTest.java b/src/test/java/chanjarster/weixin/bean/WxXmlOutINewsMessageTest.java
index 22bcffd88..9aad8c5e1 100644
--- a/src/test/java/chanjarster/weixin/bean/WxXmlOutINewsMessageTest.java
+++ b/src/test/java/chanjarster/weixin/bean/WxXmlOutINewsMessageTest.java
@@ -45,4 +45,51 @@ public class WxXmlOutINewsMessageTest {
Assert.assertEquals(m.toXml().replaceAll("\\s", ""), expected.replaceAll("\\s", ""));
}
+ public void testBuild() {
+ WxXmlOutMewsMessage.Item item = new WxXmlOutMewsMessage.Item();
+ item.setDescription("description");
+ item.setPicUrl("picUrl");
+ item.setTitle("title");
+ item.setUrl("url");
+
+ WxXmlOutMewsMessage m = WxXmlOutMessage.NEWS()
+ .fromUser("fromUser")
+ .touser("toUser")
+ .addArticle(item)
+ .addArticle(item)
+ .build();
+ String expected = ""
+ + ""
+ + ""
+ + ""
+ + "1122"
+ + ""
+ + " 2"
+ + " "
+ + " - "
+ + " "
+ + " "
+ + " "
+ + " "
+ + "
"
+ + " - "
+ + " "
+ + " "
+ + " "
+ + " "
+ + "
"
+ + " "
+ + "";
+ System.out.println(m.toXml());
+ Assert.assertEquals(
+ m
+ .toXml()
+ .replaceAll("\\s", "")
+ .replaceAll(".*?", ""),
+ expected
+ .replaceAll("\\s", "")
+ .replaceAll(".*?", "")
+ );
+ }
+
}
diff --git a/src/test/java/chanjarster/weixin/bean/WxXmlOutIVideoMessageTest.java b/src/test/java/chanjarster/weixin/bean/WxXmlOutIVideoMessageTest.java
index e8bca3d44..df9792414 100644
--- a/src/test/java/chanjarster/weixin/bean/WxXmlOutIVideoMessageTest.java
+++ b/src/test/java/chanjarster/weixin/bean/WxXmlOutIVideoMessageTest.java
@@ -31,4 +31,36 @@ public class WxXmlOutIVideoMessageTest {
Assert.assertEquals(m.toXml().replaceAll("\\s", ""), expected.replaceAll("\\s", ""));
}
+ public void testBuild() {
+ WxXmlOutVideoMessage m = WxXmlOutMessage.VIDEO()
+ .mediaId("media_id")
+ .fromUser("fromUser")
+ .touser("toUser")
+ .title("title")
+ .description("ddfff")
+ .build();
+ String expected = ""
+ + ""
+ + ""
+ + ""
+ + "1122"
+ + ""
+ + " "
+ + "";
+ System.out.println(m.toXml());
+ Assert.assertEquals(
+ m
+ .toXml()
+ .replaceAll("\\s", "")
+ .replaceAll(".*?", ""),
+ expected
+ .replaceAll("\\s", "")
+ .replaceAll(".*?", "")
+ );
+ }
+
}
diff --git a/src/test/java/chanjarster/weixin/bean/WxXmlOutIVoiceMessageTest.java b/src/test/java/chanjarster/weixin/bean/WxXmlOutIVoiceMessageTest.java
index fb7161eb0..2babe03dc 100644
--- a/src/test/java/chanjarster/weixin/bean/WxXmlOutIVoiceMessageTest.java
+++ b/src/test/java/chanjarster/weixin/bean/WxXmlOutIVoiceMessageTest.java
@@ -25,4 +25,26 @@ public class WxXmlOutIVoiceMessageTest {
Assert.assertEquals(m.toXml().replaceAll("\\s", ""), expected.replaceAll("\\s", ""));
}
+ public void testBuild() {
+ WxXmlOutVoiceMessage m = WxXmlOutMessage.VOICE().mediaId("ddfefesfsdfef").fromUser("from").touser("to").build();
+ String expected = ""
+ + ""
+ + ""
+ + ""
+ + "1122"
+ + ""
+ + ""
+ + "";
+ System.out.println(m.toXml());
+ Assert.assertEquals(
+ m
+ .toXml()
+ .replaceAll("\\s", "")
+ .replaceAll(".*?", ""),
+ expected
+ .replaceAll("\\s", "")
+ .replaceAll(".*?", "")
+ );
+ }
+
}
diff --git a/src/test/java/chanjarster/weixin/bean/WxXmlOutImageMessageTest.java b/src/test/java/chanjarster/weixin/bean/WxXmlOutImageMessageTest.java
index b5ced66c5..908e707a9 100644
--- a/src/test/java/chanjarster/weixin/bean/WxXmlOutImageMessageTest.java
+++ b/src/test/java/chanjarster/weixin/bean/WxXmlOutImageMessageTest.java
@@ -25,4 +25,26 @@ public class WxXmlOutImageMessageTest {
Assert.assertEquals(m.toXml().replaceAll("\\s", ""), expected.replaceAll("\\s", ""));
}
+ public void testBuild() {
+ WxXmlOutImageMessage m = WxXmlOutMessage.IMAGE().mediaId("ddfefesfsdfef").fromUser("from").touser("to").build();
+ String expected = ""
+ + ""
+ + ""
+ + ""
+ + "1122"
+ + ""
+ + ""
+ + "";
+ System.out.println(m.toXml());
+ Assert.assertEquals(
+ m
+ .toXml()
+ .replaceAll("\\s", "")
+ .replaceAll(".*?", ""),
+ expected
+ .replaceAll("\\s", "")
+ .replaceAll(".*?", "")
+ );
+
+ }
}
diff --git a/src/test/java/chanjarster/weixin/bean/WxXmlOutTextMessageTest.java b/src/test/java/chanjarster/weixin/bean/WxXmlOutTextMessageTest.java
index 273361f59..c889df040 100644
--- a/src/test/java/chanjarster/weixin/bean/WxXmlOutTextMessageTest.java
+++ b/src/test/java/chanjarster/weixin/bean/WxXmlOutTextMessageTest.java
@@ -25,4 +25,28 @@ public class WxXmlOutTextMessageTest {
Assert.assertEquals(m.toXml().replaceAll("\\s", ""), expected.replaceAll("\\s", ""));
}
+ public void testBuild() {
+ WxXmlOutTextMessage m = WxXmlOutMessage.TEXT().content("content").fromUser("from").touser("to").build();
+ String expected = ""
+ + ""
+ + ""
+ + ""
+ + "1122"
+ + ""
+ + ""
+ + "";
+ System.out.println(m.toXml());
+ Assert.assertEquals(
+ m
+ .toXml()
+ .replaceAll("\\s", "")
+ .replaceAll(".*?", ""),
+ expected
+ .replaceAll("\\s", "")
+ .replaceAll(".*?", "")
+ );
+
+ }
+
+
}