Skip to content

Commit 48a377f

Browse files
committed
Fix tests
1 parent 08ecf48 commit 48a377f

File tree

3 files changed

+22
-25
lines changed

3 files changed

+22
-25
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class ForceReply extends Keyboard implements Serializable {
1010
private final static long serialVersionUID = 0L;
1111

1212
private final boolean force_reply = true;
13-
private String input_field_placeholder = "";
13+
private String input_field_placeholder;
1414
private boolean selective = false;
1515

1616
public ForceReply() {
@@ -21,12 +21,13 @@ public ForceReply(boolean selective) {
2121
this.selective = selective;
2222
}
2323

24-
// API v5.3 - added field input_field_placeholder
25-
public ForceReply(boolean selective, String input_field_placeholder) {
26-
this.selective = selective;
27-
this.input_field_placeholder = input_field_placeholder;
24+
public ForceReply inputFieldPlaceholder(String inputFieldPlaceholder) {
25+
this.input_field_placeholder = inputFieldPlaceholder;
26+
return this;
2827
}
29-
public ForceReply(String input_field_placeholder) {
30-
this.input_field_placeholder = input_field_placeholder;
28+
29+
public ForceReply selective(boolean selective) {
30+
this.selective = selective;
31+
return this;
3132
}
3233
}

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,6 @@ public class ReplyKeyboardMarkup extends Keyboard implements Serializable {
1818
private String input_field_placeholder;
1919
private boolean selective;
2020

21-
public ReplyKeyboardMarkup(String[][] keyboard, boolean resize_keyboard, boolean one_time_keyboard, boolean selective) {
22-
this.keyboard = new ArrayList<>();
23-
this.resize_keyboard = resize_keyboard;
24-
this.one_time_keyboard = one_time_keyboard;
25-
this.selective = selective;
26-
for (String[] line : keyboard) {
27-
addRow(line);
28-
}
29-
}
30-
31-
// API v5.3 - added input_field_placeholder
3221
public ReplyKeyboardMarkup(String[][] keyboard, boolean resize_keyboard, boolean one_time_keyboard, String input_field_placeholder, boolean selective) {
3322
this.keyboard = new ArrayList<>();
3423
this.resize_keyboard = resize_keyboard;
@@ -40,6 +29,10 @@ public ReplyKeyboardMarkup(String[][] keyboard, boolean resize_keyboard, boolean
4029
}
4130
}
4231

32+
public ReplyKeyboardMarkup(String[][] keyboard, boolean resize_keyboard, boolean one_time_keyboard, boolean selective) {
33+
this(keyboard, resize_keyboard, one_time_keyboard, null, selective);
34+
}
35+
4336
public ReplyKeyboardMarkup(String[]... keyboard) {
4437
this(keyboard, false, false, false);
4538
}

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ public void getChatMemberCount() {
593593

594594
@Test
595595
public void getUserProfilePhotos() {
596-
int offset = 1;
596+
int offset = 0;
597597
GetUserProfilePhotosResponse response = bot.execute(new GetUserProfilePhotos(chatId).limit(100).offset(offset));
598598
UserProfilePhotos photos = response.photos();
599599
assertEquals(photos.totalCount() - offset, photos.photos().length);
@@ -609,7 +609,9 @@ public void getUserProfilePhotos() {
609609

610610
@Test
611611
public void sendMessage() {
612-
SendResponse sendResponse = bot.execute(new SendMessage(chatId, "reply this message").replyMarkup(new ForceReply()));
612+
SendResponse sendResponse = bot.execute(new SendMessage(chatId, "reply this message").replyMarkup(
613+
new ForceReply().inputFieldPlaceholder("input-placeholder").selective(true)
614+
));
613615
MessageTest.checkTextMessage(sendResponse.message());
614616
assertNotNull(sendResponse.message().from());
615617

@@ -629,6 +631,7 @@ public void sendMessage() {
629631
new KeyboardButton("location").requestLocation(true))
630632
.oneTimeKeyboard(true)
631633
.resizeKeyboard(true)
634+
.inputFieldPlaceholder("input-placeholder")
632635
.selective(true)));
633636
MessageTest.checkTextMessage(sendResponse.message());
634637

@@ -859,8 +862,8 @@ public void sendDocument() {
859862
String caption = "caption <b>bold</b>", fileName = "my doc.zip";
860863
ParseMode parseMode = ParseMode.HTML;
861864
message = bot.execute(
862-
new SendDocument(chatId, docFile).fileName(fileName).thumb(thumbFile).caption(caption).parseMode(parseMode)
863-
.disableContentTypeDetection(true))
865+
new SendDocument(chatId, docFile).fileName(fileName).thumb(thumbFile).caption(caption).parseMode(parseMode)
866+
.disableContentTypeDetection(true))
864867
.message();
865868
MessageTest.checkMessage(message);
866869
DocumentTest.check(message.document());
@@ -932,9 +935,9 @@ public void sendVideo() {
932935
String caption = "caption <b>bold</b>";
933936
int duration = 100;
934937
message = bot.execute(
935-
new SendVideo(chatId, videoBytes).thumb(thumbBytes)
936-
.caption(caption).parseMode(ParseMode.HTML)
937-
.duration(duration).height(1).width(2).supportsStreaming(true))
938+
new SendVideo(chatId, videoBytes).thumb(thumbBytes)
939+
.caption(caption).parseMode(ParseMode.HTML)
940+
.duration(duration).height(1).width(2).supportsStreaming(true))
938941
.message();
939942
MessageTest.checkMessage(message);
940943
assertEquals(caption.replace("<b>", "").replace("</b>", ""), message.caption());

0 commit comments

Comments
 (0)