@Test(dependsOnMethods = {"testUploadMaterial"}) public void testAddNews() throws WxErrorException { WxMpMaterialNews wxMpMaterialNewsSingle = new WxMpMaterialNews(); WxMpMaterialNews.WxMpMaterialNewsArticle article = new WxMpMaterialNews.WxMpMaterialNewsArticle(); article.setAuthor("author"); article.setThumbMediaId(this.thumbMediaId); article.setTitle("single title"); article.setContent("single content"); article.setContentSourceUrl("content url"); article.setShowCoverPic(true); article.setDigest("single news"); wxMpMaterialNewsSingle.addArticle(article); WxMpMaterialNews wxMpMaterialNewsMultiple = new WxMpMaterialNews(); WxMpMaterialNews.WxMpMaterialNewsArticle article1 = new WxMpMaterialNews.WxMpMaterialNewsArticle(); article1.setAuthor("author1"); article1.setThumbMediaId(this.thumbMediaId); article1.setTitle("multi title1"); article1.setContent("content 1"); article1.setContentSourceUrl("content url"); article1.setShowCoverPic(true); article1.setDigest(""); WxMpMaterialNews.WxMpMaterialNewsArticle article2 = new WxMpMaterialNews.WxMpMaterialNewsArticle(); article2.setAuthor("author2"); article2.setThumbMediaId(this.thumbMediaId); article2.setTitle("multi title2"); article2.setContent("content 2"); article2.setContentSourceUrl("content url"); article2.setShowCoverPic(true); article2.setDigest(""); wxMpMaterialNewsMultiple.addArticle(article1); wxMpMaterialNewsMultiple.addArticle(article2); WxMpMaterialUploadResult resSingle = this.wxService.getMaterialService().materialNewsUpload(wxMpMaterialNewsSingle); this.singleNewsMediaId = resSingle.getMediaId(); WxMpMaterialUploadResult resMulti = this.wxService.getMaterialService().materialNewsUpload(wxMpMaterialNewsMultiple); this.multiNewsMediaId = resMulti.getMediaId(); }
@Override public WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news) throws WxErrorException { if (news == null || news.isEmpty()) { throw new IllegalArgumentException("news is empty!"); } String responseContent = this.wxMpService.post(NEWS_ADD_URL, news.toJson()); return WxMpMaterialUploadResult.fromJson(responseContent); }
WxMpMaterialServiceImpl implements WxMpMaterialService { @Override public WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news) throws WxErrorException { if (news == null || news.isEmpty()) { throw new IllegalArgumentException("news is empty!"); } String responseContent = this.wxMpService.post(NEWS_ADD_URL, news.toJson()); return WxMpMaterialUploadResult.fromJson(responseContent); } }
WxMpMaterialServiceImpl implements WxMpMaterialService { @Override public WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news) throws WxErrorException { if (news == null || news.isEmpty()) { throw new IllegalArgumentException("news is empty!"); } String responseContent = this.wxMpService.post(NEWS_ADD_URL, news.toJson()); return WxMpMaterialUploadResult.fromJson(responseContent); } WxMpMaterialServiceImpl(WxMpService wxMpService); }
WxMpMaterialServiceImpl implements WxMpMaterialService { @Override public WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news) throws WxErrorException { if (news == null || news.isEmpty()) { throw new IllegalArgumentException("news is empty!"); } String responseContent = this.wxMpService.post(NEWS_ADD_URL, news.toJson()); return WxMpMaterialUploadResult.fromJson(responseContent); } WxMpMaterialServiceImpl(WxMpService wxMpService); @Override WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream); @Override WxMediaUploadResult mediaUpload(String mediaType, File file); @Override File mediaDownload(String mediaId); @Override WxMediaImgUploadResult mediaImgUpload(File file); @Override WxMpMaterialUploadResult materialFileUpload(String mediaType, WxMpMaterial material); @Override WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news); @Override InputStream materialImageOrVoiceDownload(String mediaId); @Override WxMpMaterialVideoInfoResult materialVideoInfo(String mediaId); @Override WxMpMaterialNews materialNewsInfo(String mediaId); @Override boolean materialNewsUpdate(WxMpMaterialArticleUpdate wxMpMaterialArticleUpdate); @Override boolean materialDelete(String mediaId); @Override WxMpMaterialCountResult materialCount(); @Override WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count); @Override WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offset, int count); }
WxMpMaterialServiceImpl implements WxMpMaterialService { @Override public WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news) throws WxErrorException { if (news == null || news.isEmpty()) { throw new IllegalArgumentException("news is empty!"); } String responseContent = this.wxMpService.post(NEWS_ADD_URL, news.toJson()); return WxMpMaterialUploadResult.fromJson(responseContent); } WxMpMaterialServiceImpl(WxMpService wxMpService); @Override WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream); @Override WxMediaUploadResult mediaUpload(String mediaType, File file); @Override File mediaDownload(String mediaId); @Override WxMediaImgUploadResult mediaImgUpload(File file); @Override WxMpMaterialUploadResult materialFileUpload(String mediaType, WxMpMaterial material); @Override WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news); @Override InputStream materialImageOrVoiceDownload(String mediaId); @Override WxMpMaterialVideoInfoResult materialVideoInfo(String mediaId); @Override WxMpMaterialNews materialNewsInfo(String mediaId); @Override boolean materialNewsUpdate(WxMpMaterialArticleUpdate wxMpMaterialArticleUpdate); @Override boolean materialDelete(String mediaId); @Override WxMpMaterialCountResult materialCount(); @Override WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count); @Override WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offset, int count);  }