Search in sources :

Example 16 with Test

use of org.testng.annotations.Test in project weixin-java-tools by chanjarster.

the class WxMpMassMessageAPITest method testMediaMassOpenIdsMessageSend.

@Test(dataProvider = "massMessages")
public void testMediaMassOpenIdsMessageSend(String massMsgType, String mediaId) throws WxErrorException, IOException {
    // 发送群发消息
    ApiTestModule.WxXmlMpInMemoryConfigStorage configProvider = (ApiTestModule.WxXmlMpInMemoryConfigStorage) wxService.wxMpConfigStorage;
    WxMpMassOpenIdsMessage massMessage = new WxMpMassOpenIdsMessage();
    massMessage.setMsgType(massMsgType);
    massMessage.setMediaId(mediaId);
    massMessage.getToUsers().add(configProvider.getOpenId());
    WxMpMassSendResult massResult = wxService.massOpenIdsMessageSend(massMessage);
    Assert.assertNotNull(massResult);
    Assert.assertNotNull(massResult.getMsgId());
}
Also used : WxMpMassSendResult(me.chanjar.weixin.mp.bean.result.WxMpMassSendResult) WxMpMassOpenIdsMessage(me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage) Test(org.testng.annotations.Test)

Example 17 with Test

use of org.testng.annotations.Test in project weixin-java-tools by chanjarster.

the class WxMpMiscAPITest method testGetUserCumulate.

@Test
public void testGetUserCumulate() throws WxErrorException, ParseException {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    Date beginDate = simpleDateFormat.parse("2015-01-01");
    Date endDate = simpleDateFormat.parse("2015-01-02");
    List<WxMpUserCumulate> cumulates = wxService.getUserCumulate(beginDate, endDate);
    System.out.println(cumulates);
    Assert.assertNotNull(cumulates);
}
Also used : WxMpUserCumulate(me.chanjar.weixin.mp.bean.result.WxMpUserCumulate) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 18 with Test

use of org.testng.annotations.Test in project weixin-java-tools by chanjarster.

the class WxMpMaterialAPITest method testDownloadMaterial.

@Test(dependsOnMethods = { "testMaterialCount" }, dataProvider = "downloadMaterial")
public void testDownloadMaterial(String media_id) throws WxErrorException, IOException {
    Map<String, Object> materialInfo = media_ids.get(media_id);
    Assert.assertNotNull(materialInfo);
    String filename = materialInfo.get("filename").toString();
    if (filename.endsWith(".mp3") || filename.endsWith(".jpeg")) {
        InputStream inputStream = wxService.materialImageOrVoiceDownload(media_id);
        Assert.assertNotNull(inputStream);
        IOUtils.closeQuietly(inputStream);
    }
    if (filename.endsWith("mp4")) {
        WxMpMaterialVideoInfoResult wxMaterialVideoInfoResult = wxService.materialVideoInfo(media_id);
        Assert.assertNotNull(wxMaterialVideoInfoResult);
        Assert.assertNotNull(wxMaterialVideoInfoResult.getDownUrl());
    }
}
Also used : InputStream(java.io.InputStream) Test(org.testng.annotations.Test)

Example 19 with Test

use of org.testng.annotations.Test in project weixin-java-tools by chanjarster.

the class WxMpMaterialAPITest method testGetNewsInfo.

@Test(dependsOnMethods = { "testAddNews" })
public void testGetNewsInfo() throws WxErrorException {
    WxMpMaterialNews wxMpMaterialNewsSingle = wxService.materialNewsInfo(singleNewsMediaId);
    WxMpMaterialNews wxMpMaterialNewsMultiple = wxService.materialNewsInfo(multiNewsMediaId);
    Assert.assertNotNull(wxMpMaterialNewsSingle);
    Assert.assertNotNull(wxMpMaterialNewsMultiple);
}
Also used : WxMpMaterialNews(me.chanjar.weixin.mp.bean.WxMpMaterialNews) Test(org.testng.annotations.Test)

Example 20 with Test

use of org.testng.annotations.Test in project weixin-java-tools by chanjarster.

the class WxMpMaterialAPITest method testAddNews.

@Test(dependsOnMethods = { "testUploadMaterial" })
public void testAddNews() throws WxErrorException {
    // 单图文消息
    WxMpMaterialNews wxMpMaterialNewsSingle = new WxMpMaterialNews();
    WxMpMaterialNews.WxMpMaterialNewsArticle mpMaterialNewsArticleSingle = new WxMpMaterialNews.WxMpMaterialNewsArticle();
    mpMaterialNewsArticleSingle.setAuthor("author");
    mpMaterialNewsArticleSingle.setThumbMediaId(thumbMediaId);
    mpMaterialNewsArticleSingle.setTitle("single title");
    mpMaterialNewsArticleSingle.setContent("single content");
    mpMaterialNewsArticleSingle.setContentSourceUrl("content url");
    mpMaterialNewsArticleSingle.setShowCoverPic(true);
    mpMaterialNewsArticleSingle.setDigest("single news");
    wxMpMaterialNewsSingle.addArticle(mpMaterialNewsArticleSingle);
    // 多图文消息
    WxMpMaterialNews wxMpMaterialNewsMultiple = new WxMpMaterialNews();
    WxMpMaterialNews.WxMpMaterialNewsArticle wxMpMaterialNewsArticleMutiple1 = new WxMpMaterialNews.WxMpMaterialNewsArticle();
    wxMpMaterialNewsArticleMutiple1.setAuthor("author1");
    wxMpMaterialNewsArticleMutiple1.setThumbMediaId(thumbMediaId);
    wxMpMaterialNewsArticleMutiple1.setTitle("multi title1");
    wxMpMaterialNewsArticleMutiple1.setContent("content 1");
    wxMpMaterialNewsArticleMutiple1.setContentSourceUrl("content url");
    wxMpMaterialNewsArticleMutiple1.setShowCoverPic(true);
    wxMpMaterialNewsArticleMutiple1.setDigest("");
    WxMpMaterialNews.WxMpMaterialNewsArticle wxMpMaterialNewsArticleMultiple2 = new WxMpMaterialNews.WxMpMaterialNewsArticle();
    wxMpMaterialNewsArticleMultiple2.setAuthor("author2");
    wxMpMaterialNewsArticleMultiple2.setThumbMediaId(thumbMediaId);
    wxMpMaterialNewsArticleMultiple2.setTitle("multi title2");
    wxMpMaterialNewsArticleMultiple2.setContent("content 2");
    wxMpMaterialNewsArticleMultiple2.setContentSourceUrl("content url");
    wxMpMaterialNewsArticleMultiple2.setShowCoverPic(true);
    wxMpMaterialNewsArticleMultiple2.setDigest("");
    wxMpMaterialNewsMultiple.addArticle(wxMpMaterialNewsArticleMutiple1);
    wxMpMaterialNewsMultiple.addArticle(wxMpMaterialNewsArticleMultiple2);
    WxMpMaterialUploadResult resSingle = wxService.materialNewsUpload(wxMpMaterialNewsSingle);
    singleNewsMediaId = resSingle.getMediaId();
    WxMpMaterialUploadResult resMulti = wxService.materialNewsUpload(wxMpMaterialNewsMultiple);
    multiNewsMediaId = resMulti.getMediaId();
}
Also used : WxMpMaterialNews(me.chanjar.weixin.mp.bean.WxMpMaterialNews) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)24007 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2438 Task (com.evolveum.midpoint.task.api.Task)2069 File (java.io.File)1433 ArrayList (java.util.ArrayList)1237 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)1188 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)1078 HashMap (java.util.HashMap)965 CommandLineProgramTest (org.broadinstitute.hellbender.CommandLineProgramTest)814 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)692 BeforeTest (org.testng.annotations.BeforeTest)692 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)690 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)651 Parameters (org.testng.annotations.Parameters)610 BaseTest (org.xdi.oxauth.BaseTest)582 BigDecimal (java.math.BigDecimal)574 List (java.util.List)558 LocalDate (org.joda.time.LocalDate)553 HashSet (java.util.HashSet)548 BaseTest (util.BaseTest)537