Skip to content

Commit 514fab8

Browse files
committed
Tests for Approve/DeclineChatJoinRequest
1 parent 2dd9fd6 commit 514fab8

File tree

5 files changed

+34
-26
lines changed

5 files changed

+34
-26
lines changed

library/src/main/java/com/pengrad/telegrambot/model/ChatInviteLink.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public User creator() {
2929
return creator;
3030
}
3131

32-
public Boolean createsJoinReqeust() {
32+
public Boolean createsJoinRequest() {
3333
return creates_join_request;
3434
}
3535

library/src/main/java/com/pengrad/telegrambot/model/request/ChatAction.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
* 10/21/15.
66
*/
77
public enum ChatAction {
8-
typing,
9-
upload_photo,
10-
record_video,
11-
upload_video,
12-
record_audio,
13-
upload_audio,
14-
upload_document,
15-
choose_sticker,
8+
typing,
9+
upload_photo,
10+
record_video,
11+
upload_video,
12+
record_voice,
13+
upload_voice,
14+
upload_document,
15+
choose_sticker,
1616
find_location,
17-
record_video_note,
17+
record_video_note,
1818
upload_video_note
1919
}

library/src/main/java/com/pengrad/telegrambot/request/CreateChatInviteLink.java

-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public CreateChatInviteLink(Object chatId) {
1616
/**
1717
*
1818
* @param name Invite link name; 0-32 characters
19-
* @return
2019
*/
2120
public CreateChatInviteLink name(String name) {
2221
return add("name", name);
@@ -33,7 +32,6 @@ public CreateChatInviteLink memberLimit(Integer memberLimit) {
3332
/**
3433
*
3534
* @param createsJoinRequest True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can't be specified
36-
* @return
3735
*/
3836
public CreateChatInviteLink createsJoinRequest(Boolean createsJoinRequest) {
3937
return add("creates_join_request", createsJoinRequest);

library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java

+23-13
Original file line numberDiff line numberDiff line change
@@ -1931,31 +1931,41 @@ public void inviteLinks() {
19311931
assertTrue(link.creator().isBot());
19321932
assertEquals(name, link.name());
19331933

1934-
response = bot.execute(new CreateChatInviteLink(groupId)
1935-
.expireDate(expireDate)
1936-
.createsJoinRequest(true)
1937-
.name(name));
1938-
link = response.chatInviteLink();
1939-
assertEquals(expireDate, link.expireDate().intValue());
1940-
assertTrue(link.createsJoinReqeust());
1941-
assertEquals(0, link.pendingJoinRequestCount().intValue());
1942-
assertFalse(link.isRevoked());
1943-
assertTrue(link.creator().isBot());
1944-
assertEquals(name, link.name());
1945-
19461934
int editMemberLimit = 3;
19471935
int editExpireDate = (int) (System.currentTimeMillis() / 1000) + 1500;
1936+
String editName = name + "edit";
19481937
response = bot.execute(new EditChatInviteLink(groupId, link.inviteLink())
19491938
.expireDate(editExpireDate)
1950-
.memberLimit(editMemberLimit));
1939+
.memberLimit(editMemberLimit)
1940+
.name(editName));
19511941
link = response.chatInviteLink();
19521942
assertEquals(editExpireDate, link.expireDate().intValue());
19531943
assertEquals(editMemberLimit, link.memberLimit().intValue());
1944+
assertEquals(editName, link.name());
19541945
assertFalse(link.isRevoked());
19551946

19561947
response = bot.execute(new RevokeChatInviteLink(groupId, link.inviteLink()));
19571948
link = response.chatInviteLink();
19581949
assertTrue(link.isRevoked());
19591950
assertFalse(link.isPrimary());
1951+
1952+
response = bot.execute(new CreateChatInviteLink(groupId).createsJoinRequest(true));
1953+
link = response.chatInviteLink();
1954+
assertTrue(link.createsJoinRequest());
1955+
assertNull(link.pendingJoinRequestCount());
1956+
1957+
response = bot.execute(new EditChatInviteLink(groupId, link.inviteLink()).createsJoinRequest(false));
1958+
assertFalse(response.chatInviteLink().createsJoinRequest());
1959+
}
1960+
1961+
@Test
1962+
public void chatJoinRequest() {
1963+
BaseResponse response = bot.execute(new ApproveChatJoinRequest(groupId, memberBot));
1964+
assertFalse(response.isOk());
1965+
assertEquals("Bad Request: USER_ALREADY_PARTICIPANT", response.description());
1966+
1967+
response = bot.execute(new DeclineChatJoinRequest(groupId, memberBot));
1968+
assertFalse(response.isOk());
1969+
assertEquals("Bad Request: USER_ALREADY_PARTICIPANT", response.description());
19601970
}
19611971
}

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<dependency>
3131
<groupId>com.google.code.gson</groupId>
3232
<artifactId>gson</artifactId>
33-
<version>2.8.9</version>
33+
<version>2.8.6</version>
3434
<scope>compile</scope>
3535
</dependency>
3636
<dependency>

0 commit comments

Comments
 (0)