Skip to content

Commit 3753dd4

Browse files
committed
feat: add officialAccount test
1 parent ea57b1e commit 3753dd4

File tree

6 files changed

+205
-6
lines changed

6 files changed

+205
-6
lines changed

src/main/java/io/github/doocs/im/ImClient.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22

33
import io.github.doocs.im.constant.ContentType;
44
import io.github.doocs.im.constant.Domain;
5-
import io.github.doocs.im.core.*;
5+
import io.github.doocs.im.core.Account;
6+
import io.github.doocs.im.core.Audit;
7+
import io.github.doocs.im.core.Group;
8+
import io.github.doocs.im.core.Member;
9+
import io.github.doocs.im.core.Message;
10+
import io.github.doocs.im.core.OfficialAccount;
11+
import io.github.doocs.im.core.Operation;
12+
import io.github.doocs.im.core.Profile;
13+
import io.github.doocs.im.core.RecentContact;
14+
import io.github.doocs.im.core.Robot;
15+
import io.github.doocs.im.core.Sns;
616
import io.github.doocs.im.util.RandomUtil;
717
import io.github.doocs.im.util.SigUtil;
818

@@ -39,7 +49,7 @@ public class ImClient {
3949
public final RecentContact recentContact;
4050
public final Robot robot;
4151
public final Audit audit;
42-
private final Official official;
52+
public final OfficialAccount officialAccount;
4353

4454
public static ImClient getInstance(long sdkAppId, String userId, String key) {
4555
return new ImClient(sdkAppId, userId, key);
@@ -96,7 +106,7 @@ public ImClient(long sdkAppId, String userId, String key, String domain, ClientC
96106
recentContact = new RecentContact(this);
97107
robot = new Robot(this);
98108
audit = new Audit(this);
99-
official = new Official(this);
109+
officialAccount = new OfficialAccount(this);
100110
}
101111

102112
/**

src/main/java/io/github/doocs/im/core/Official.java renamed to src/main/java/io/github/doocs/im/core/OfficialAccount.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* @author hyh
1818
* @since 2024/01/09 21:50
1919
*/
20-
public class Official {
20+
public class OfficialAccount {
2121
/**
2222
* 公众号服务名
2323
*/
@@ -32,7 +32,7 @@ public class Official {
3232

3333
private final ImClient imClient;
3434

35-
public Official(ImClient imClient) {
35+
public OfficialAccount(ImClient imClient) {
3636
this.imClient = imClient;
3737
}
3838

src/main/java/io/github/doocs/im/model/request/CreateOfficialAccountRequest.java

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,70 @@ private CreateOfficialAccountRequest(Builder builder) {
9696
this.customString = builder.customString;
9797
}
9898

99+
public String getOwnerAccount() {
100+
return ownerAccount;
101+
}
102+
103+
public void setOwnerAccount(String ownerAccount) {
104+
this.ownerAccount = ownerAccount;
105+
}
106+
107+
public String getOfficialAccountUserID() {
108+
return officialAccountUserID;
109+
}
110+
111+
public void setOfficialAccountUserID(String officialAccountUserID) {
112+
this.officialAccountUserID = officialAccountUserID;
113+
}
114+
115+
public String getName() {
116+
return name;
117+
}
118+
119+
public void setName(String name) {
120+
this.name = name;
121+
}
122+
123+
public String getIntroduction() {
124+
return introduction;
125+
}
126+
127+
public void setIntroduction(String introduction) {
128+
this.introduction = introduction;
129+
}
130+
131+
public String getFaceUrl() {
132+
return faceUrl;
133+
}
134+
135+
public void setFaceUrl(String faceUrl) {
136+
this.faceUrl = faceUrl;
137+
}
138+
139+
public Integer getMaxSubscriberNum() {
140+
return maxSubscriberNum;
141+
}
142+
143+
public void setMaxSubscriberNum(Integer maxSubscriberNum) {
144+
this.maxSubscriberNum = maxSubscriberNum;
145+
}
146+
147+
public String getOrganization() {
148+
return organization;
149+
}
150+
151+
public void setOrganization(String organization) {
152+
this.organization = organization;
153+
}
154+
155+
public String getCustomString() {
156+
return customString;
157+
}
158+
159+
public void setCustomString(String customString) {
160+
this.customString = customString;
161+
}
162+
99163
public static Builder builder() {
100164
return new Builder();
101165
}

src/main/java/io/github/doocs/im/model/request/DestroyOfficialAccountRequest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,18 @@ private DestroyOfficialAccountRequest(Builder builder) {
3232
this.officialAccount = builder.officialAccount;
3333
}
3434

35+
public String getOfficialAccount() {
36+
return officialAccount;
37+
}
38+
39+
public void setOfficialAccount(String officialAccount) {
40+
this.officialAccount = officialAccount;
41+
}
42+
3543
public static Builder builder() {
3644
return new Builder();
3745
}
3846

39-
4047
public static final class Builder {
4148
private String officialAccount;
4249

src/main/java/io/github/doocs/im/model/request/ModifyOfficialAccountBaseInfoRequest.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,62 @@ private ModifyOfficialAccountBaseInfoRequest(Builder builder) {
8686
this.maxSubscriberNum = builder.maxSubscriberNum;
8787
}
8888

89+
public String getOfficialAccount() {
90+
return officialAccount;
91+
}
92+
93+
public void setOfficialAccount(String officialAccount) {
94+
this.officialAccount = officialAccount;
95+
}
96+
97+
public String getName() {
98+
return name;
99+
}
100+
101+
public void setName(String name) {
102+
this.name = name;
103+
}
104+
105+
public String getIntroduction() {
106+
return introduction;
107+
}
108+
109+
public void setIntroduction(String introduction) {
110+
this.introduction = introduction;
111+
}
112+
113+
public String getFaceUrl() {
114+
return faceUrl;
115+
}
116+
117+
public void setFaceUrl(String faceUrl) {
118+
this.faceUrl = faceUrl;
119+
}
120+
121+
public String getOrganization() {
122+
return organization;
123+
}
124+
125+
public void setOrganization(String organization) {
126+
this.organization = organization;
127+
}
128+
129+
public String getCustomString() {
130+
return customString;
131+
}
132+
133+
public void setCustomString(String customString) {
134+
this.customString = customString;
135+
}
136+
137+
public Integer getMaxSubscriberNum() {
138+
return maxSubscriberNum;
139+
}
140+
141+
public void setMaxSubscriberNum(Integer maxSubscriberNum) {
142+
this.maxSubscriberNum = maxSubscriberNum;
143+
}
144+
89145
public static Builder builder() {
90146
return new Builder();
91147
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package io.github.doocs.im.core;
2+
3+
import io.github.doocs.im.ClientFactory;
4+
import io.github.doocs.im.ImClient;
5+
import io.github.doocs.im.constant.ActionStatus;
6+
import io.github.doocs.im.model.request.CreateOfficialAccountRequest;
7+
import io.github.doocs.im.model.request.DestroyOfficialAccountRequest;
8+
import io.github.doocs.im.model.request.ModifyOfficialAccountBaseInfoRequest;
9+
import io.github.doocs.im.model.response.CreateOfficialAccountResult;
10+
import io.github.doocs.im.model.response.DestroyOfficialAccountResult;
11+
import io.github.doocs.im.model.response.ModifyOfficialAccountBaseInfoResult;
12+
import org.junit.jupiter.api.Assertions;
13+
import org.junit.jupiter.api.BeforeAll;
14+
import org.junit.jupiter.api.Test;
15+
16+
import java.io.IOException;
17+
18+
/**
19+
* 公众号测试类 {@link OfficialAccount}
20+
*
21+
* @author hyh
22+
* @since 2024/1/10 10:00
23+
*/
24+
class OfficialAccountTest {
25+
private static ImClient client;
26+
27+
@BeforeAll
28+
static void setup() {
29+
client = ClientFactory.getInstance();
30+
Assertions.assertNotNull(client, "client is null");
31+
}
32+
33+
@Test
34+
void testCreateOfficialAccount() throws IOException {
35+
CreateOfficialAccountRequest request = new CreateOfficialAccountRequest();
36+
request.setOwnerAccount("test");
37+
request.setName("test_official_account");
38+
CreateOfficialAccountResult result = client.officialAccount.createOfficialAccount(request);
39+
System.out.println(result);
40+
Assertions.assertEquals(ActionStatus.OK, result.getActionStatus());
41+
}
42+
43+
@Test
44+
void tesDestroyOfficialAccount() throws IOException {
45+
DestroyOfficialAccountRequest request = new DestroyOfficialAccountRequest();
46+
request.setOfficialAccount("test_official_account_id");
47+
DestroyOfficialAccountResult result = client.officialAccount.destroyOfficialAccount(request);
48+
System.out.println(result);
49+
Assertions.assertEquals(ActionStatus.OK, result.getActionStatus());
50+
}
51+
52+
@Test
53+
void testModifyOfficialAccountBaseInfo () throws IOException {
54+
ModifyOfficialAccountBaseInfoRequest request = new ModifyOfficialAccountBaseInfoRequest();
55+
request.setOfficialAccount("test_official_account_id");
56+
request.setName("test_official_account2");
57+
ModifyOfficialAccountBaseInfoResult result = client.officialAccount.modifyOfficialAccountBaseInfo(request);
58+
System.out.println(result);
59+
Assertions.assertEquals(ActionStatus.OK, result.getActionStatus());
60+
}
61+
62+
}

0 commit comments

Comments
 (0)