1
0
mirror of synced 2026-02-17 10:47:49 +08:00

修改javadoc, readme, 单元测试代码

This commit is contained in:
Daniel Qian
2014-08-26 16:16:14 +08:00
parent db9de2a8c4
commit 464c308c46
8 changed files with 271 additions and 36 deletions

View File

@@ -210,7 +210,7 @@ public interface WxService {
* @param openid 微信用户的openid
* @throws WxErrorException
*/
public long groupQueryUserGroup(String openid) throws WxErrorException;
public long userGetGroup(String openid) throws WxErrorException;
/**
* <pre>
@@ -296,7 +296,7 @@ public interface WxService {
/**
* <pre>
* 换取二维码图片
* 换取二维码图片文件jpg格式
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=生成带参数的二维码
* </pre>
* @param ticket 二维码ticket

View File

@@ -223,7 +223,7 @@ public class WxServiceImpl implements WxService {
return WxGsonBuilder.INSTANCE.create().fromJson(tmpJsonElement.getAsJsonObject().get("groups"), new TypeToken<List<WxGroup>>(){}.getType());
}
public long groupQueryUserGroup(String openid) throws WxErrorException {
public long userGetGroup(String openid) throws WxErrorException {
String url = "https://api.weixin.qq.com/cgi-bin/groups/getid";
JsonObject o = new JsonObject();
o.addProperty("openid", openid);

View File

@@ -6,7 +6,6 @@ import org.testng.Assert;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import chanjarster.weixin.api.ApiTestModule.WxXmlConfigStorage;
import chanjarster.weixin.bean.WxGroup;
import chanjarster.weixin.exception.WxErrorException;
@@ -42,22 +41,10 @@ public class WxGroupAPITest {
}
}
@Test(dependsOnMethods="testGroupCreate")
public void testGroupQueryUserGroup() throws WxErrorException {
WxXmlConfigStorage configStorage = (WxXmlConfigStorage) wxService.wxConfigStorage;
long groupid = wxService.groupQueryUserGroup(configStorage.getOpenId());
Assert.assertTrue(groupid != -1l);
}
@Test(dependsOnMethods={"testGroupGet", "testGroupCreate"})
public void getGroupUpdate() throws WxErrorException {
group.setName("分组改名");
wxService.groupUpdate(group);
}
@Test(dependsOnMethods={"testGroupGet", "testGroupCreate"})
public void getGroupMoveUser() throws WxErrorException {
WxXmlConfigStorage configStorage = (WxXmlConfigStorage) wxService.wxConfigStorage;
wxService.userUpdateGroup(configStorage.getOpenId(), group.getId());
}
}

View File

@@ -1,5 +1,6 @@
package chanjarster.weixin.api;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@@ -57,7 +58,8 @@ public class WxMediaAPITest {
@Test(dependsOnMethods = { "testUploadMedia" }, dataProvider="downloadMedia")
public void testDownloadMedia(String media_id) throws WxErrorException {
wxService.mediaDownload(media_id);
File file = wxService.mediaDownload(media_id);
Assert.assertNotNull(file);
}
@DataProvider

View File

@@ -9,7 +9,7 @@ import chanjarster.weixin.exception.WxErrorException;
import com.google.inject.Inject;
/**
* 测试用户相关的接口
* 测试短连接
*
* @author chanjarster
*/

View File

@@ -8,7 +8,6 @@ import chanjarster.weixin.api.ApiTestModule.WxXmlConfigStorage;
import chanjarster.weixin.bean.result.WxUser;
import chanjarster.weixin.bean.result.WxUserList;
import chanjarster.weixin.exception.WxErrorException;
import chanjarster.weixin.util.json.WxGsonBuilder;
import com.google.inject.Inject;
@@ -17,7 +16,7 @@ import com.google.inject.Inject;
* @author chanjarster
*
*/
@Test(groups = "userAPI", dependsOnGroups = { "baseAPI" })
@Test(groups = "userAPI", dependsOnGroups = { "baseAPI", "groupAPI" })
@Guice(modules = ApiTestModule.class)
public class WxUserAPITest {
@@ -33,7 +32,6 @@ public class WxUserAPITest {
WxXmlConfigStorage configProvider = (WxXmlConfigStorage) wxService.wxConfigStorage;
WxUser user = wxService.userInfo(configProvider.getOpenId(), null);
Assert.assertNotNull(user);
System.out.println(WxGsonBuilder.INSTANCE.create().toJson(user));
}
public void testUserList() throws WxErrorException {
@@ -44,4 +42,15 @@ public class WxUserAPITest {
Assert.assertFalse(wxUserList.getOpenids().size() == -1);
}
public void testGroupQueryUserGroup() throws WxErrorException {
WxXmlConfigStorage configStorage = (WxXmlConfigStorage) wxService.wxConfigStorage;
long groupid = wxService.userGetGroup(configStorage.getOpenId());
Assert.assertTrue(groupid != -1l);
}
public void getGroupMoveUser() throws WxErrorException {
WxXmlConfigStorage configStorage = (WxXmlConfigStorage) wxService.wxConfigStorage;
wxService.userUpdateGroup(configStorage.getOpenId(), wxService.groupGet().get(3).getId());
}
}

View File

@@ -6,13 +6,13 @@
<class name="chanjarster.weixin.api.WxBaseAPITest" />
<class name="chanjarster.weixin.api.WxCustomMessageAPITest" />
<class name="chanjarster.weixin.api.WxMenuAPITest" />
<class name="chanjarster.weixin.api.WxMessageRouterTest" />
<class name="chanjarster.weixin.api.WxGroupAPITest" />
<class name="chanjarster.weixin.api.WxMassMessageAPITest" />
<class name="chanjarster.weixin.api.WxMediaAPITest" />
<class name="chanjarster.weixin.api.WxMassMessageAPITest" />
<class name="chanjarster.weixin.api.WxUserAPITest" />
<class name="chanjarster.weixin.api.WxQrCodeAPITest" />
<class name="chanjarster.weixin.api.WxShortUrlAPITest" />
<class name="chanjarster.weixin.api.WxMessageRouterTest" />
</classes>
</test>