11package me .chanjar .weixin .mp .api .impl ;
22
3+ import org .testng .annotations .DataProvider ;
34import org .testng .annotations .Guice ;
45import org .testng .annotations .Test ;
56
67import com .google .inject .Inject ;
78
89import me .chanjar .weixin .common .exception .WxErrorException ;
910import me .chanjar .weixin .mp .api .ApiTestModule ;
11+ import me .chanjar .weixin .mp .api .ApiTestModule .WxXmlMpInMemoryConfigStorage ;
12+ import me .chanjar .weixin .mp .api .WxMpConfigStorage ;
1013import me .chanjar .weixin .mp .api .WxMpServiceImpl ;
1114import me .chanjar .weixin .mp .bean .customerservice .request .WxMpKfAccountRequest ;
1215import me .chanjar .weixin .mp .bean .customerservice .result .WxMpKfList ;
2427@ Test
2528@ Guice (modules = ApiTestModule .class )
2629public class WxMpKefuImplTest {
27- private static final String KF_ACCOUNT = "kf2009@youxintest" ;
28-
30+
2931 @ Inject
3032 protected WxMpServiceImpl wxService ;
3133
@@ -36,34 +38,48 @@ public void testKfList() throws WxErrorException {
3638 }
3739
3840 public void testKfOnlineList () throws WxErrorException {
39- WxMpKfOnlineList kfOnlineList = this .wxService .getKefuService ().kfOnlineList ();
41+ WxMpKfOnlineList kfOnlineList = this .wxService .getKefuService ()
42+ .kfOnlineList ();
4043 Assert .assertNotNull (kfOnlineList );
4144 System .err .println (kfOnlineList );
4245 }
4346
44- public void testKfAccountAdd () throws WxErrorException {
47+ @ DataProvider
48+ public Object [][] getKfAccount () {
49+ WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage ) this .wxService
50+ .getWxMpConfigStorage ();
51+ return new Object [][] { { configStorage .getKfAccount () } };
52+ }
53+
54+ @ Test (dataProvider = "getKfAccount" )
55+ public void testKfAccountAdd (String kfAccount ) throws WxErrorException {
4556 WxMpKfAccountRequest request = WxMpKfAccountRequest .builder ()
46- .kfAccount (KF_ACCOUNT ).nickName ("我晕" ).rawPassword ("123" ).build ();
57+ .kfAccount (kfAccount ).nickName ("我晕" ).rawPassword ("123" ).build ();
4758 Assert .assertTrue (this .wxService .getKefuService ().kfAccountAdd (request ));
4859 }
49-
50- @ Test (dependsOnMethods = { "testKfAccountAdd" })
51- public void testKfAccountUpdate () throws WxErrorException {
60+
61+ @ Test (dependsOnMethods = {
62+ "testKfAccountAdd" }, dataProvider = "getKfAccount" )
63+ public void testKfAccountUpdate (String kfAccount ) throws WxErrorException {
5264 WxMpKfAccountRequest request = WxMpKfAccountRequest .builder ()
53- .kfAccount (KF_ACCOUNT ).nickName ("我晕" ).rawPassword ("123" ).build ();
65+ .kfAccount (kfAccount ).nickName ("我晕" ).rawPassword ("123" ).build ();
5466 Assert .assertTrue (this .wxService .getKefuService ().kfAccountUpdate (request ));
5567 }
56-
57- @ Test (dependsOnMethods = { "testKfAccountUpdate" })
58- public void testKfAccountUploadHeadImg () throws WxErrorException {
68+
69+ @ Test (dependsOnMethods = {
70+ "testKfAccountUpdate" }, dataProvider = "getKfAccount" )
71+ public void testKfAccountUploadHeadImg (String kfAccount )
72+ throws WxErrorException {
5973 File imgFile = new File ("src\\ test\\ resources\\ mm.jpeg" );
60- boolean result = this .wxService .getKefuService ().kfAccountUploadHeadImg (KF_ACCOUNT , imgFile );
74+ boolean result = this .wxService .getKefuService ()
75+ .kfAccountUploadHeadImg (kfAccount , imgFile );
6176 Assert .assertTrue (result );
6277 }
63-
64- @ Test (dependsOnMethods = { "testKfAccountUploadHeadImg" })
65- public void testKfAccountDel () throws WxErrorException {
66- boolean result = this .wxService .getKefuService ().kfAccountDel (KF_ACCOUNT );
78+
79+ @ Test (dependsOnMethods = {
80+ "testKfAccountUploadHeadImg" }, dataProvider = "getKfAccount" )
81+ public void testKfAccountDel (String kfAccount ) throws WxErrorException {
82+ boolean result = this .wxService .getKefuService ().kfAccountDel (kfAccount );
6783 Assert .assertTrue (result );
6884 }
6985
0 commit comments