Skip to content

Commit 4453a2c

Browse files
committed
Fix tests: remove todo in editMessageMedia, update error descriptions
1 parent d235350 commit 4453a2c

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public void answerInline() {
304304

305305
if (!response.isOk()) {
306306
assertEquals(400, response.errorCode());
307-
assertEquals("Bad Request: QUERY_ID_INVALID", response.description());
307+
assertEquals("Bad Request: query is too old and response timeout expired or query ID is invalid", response.description());
308308
}
309309
}
310310

@@ -333,7 +333,7 @@ public void answerCallback() {
333333

334334
if (!response.isOk()) {
335335
assertEquals(400, response.errorCode());
336-
assertEquals("Bad Request: QUERY_ID_INVALID", response.description());
336+
assertEquals("Bad Request: query is too old and response timeout expired or query ID is invalid", response.description());
337337
}
338338
}
339339

@@ -831,7 +831,7 @@ public void answerShippingQuery() {
831831

832832
if (!response.isOk()) {
833833
assertEquals(400, response.errorCode());
834-
assertEquals("Bad Request: QUERY_ID_INVALID", response.description());
834+
assertEquals("Bad Request: query is too old and response timeout expired or query ID is invalid", response.description());
835835
}
836836
}
837837

@@ -844,7 +844,7 @@ public void answerShippingQueryError() {
844844

845845
if (!response.isOk()) {
846846
assertEquals(400, response.errorCode());
847-
assertEquals("Bad Request: QUERY_ID_INVALID", response.description());
847+
assertEquals("Bad Request: query is too old and response timeout expired or query ID is invalid", response.description());
848848
}
849849
}
850850

@@ -869,7 +869,7 @@ public void answerPreCheckoutQuery() {
869869

870870
if (!response.isOk()) {
871871
assertEquals(400, response.errorCode());
872-
assertEquals("Bad Request: QUERY_ID_INVALID", response.description());
872+
assertEquals("Bad Request: query is too old and response timeout expired or query ID is invalid", response.description());
873873
}
874874
}
875875

@@ -882,7 +882,7 @@ public void answerPreCheckoutQueryError() {
882882

883883
if (!response.isOk()) {
884884
assertEquals(400, response.errorCode());
885-
assertEquals("Bad Request: QUERY_ID_INVALID", response.description());
885+
assertEquals("Bad Request: query is too old and response timeout expired or query ID is invalid", response.description());
886886
}
887887
}
888888

@@ -1051,7 +1051,8 @@ public void stopMessageLiveLocation() {
10511051
response = bot.execute(new StopMessageLiveLocation("AgAAAPrwAQCj_Q4D2s-51_8jsuU"));
10521052
if (!response.isOk()) {
10531053
assertEquals(400, response.errorCode());
1054-
assertEquals("Bad Request: message is not modified", response.description());
1054+
assertEquals("Bad Request: message is not modified: specified new message content and reply markup are exactly the same as a current content and reply_markup of the message",
1055+
response.description());
10551056
}
10561057
}
10571058

@@ -1118,23 +1119,21 @@ public void editMessageMedia() {
11181119

11191120

11201121
response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, new InputMediaAnimation(gifFile)));
1121-
// todo why is it video?
1122-
assertEquals(new Integer(1), response.message().video().duration());
1122+
assertEquals(new Integer(1), response.message().animation().duration());
11231123

11241124
Integer durationAnim = 17, width = 21, height = 22;
11251125
response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId,
11261126
new InputMediaAnimation(gifBytes).duration(durationAnim).width(width).height(height)
11271127
));
1128-
// todo why is it video?
1129-
Video video = response.message().video();
1130-
assertEquals(new Integer(1), video.duration());
1131-
assertEquals(width, video.width());
1132-
assertEquals(height, video.height());
1128+
Animation animation = response.message().animation();
1129+
assertEquals(Integer.valueOf(1), animation.duration());
1130+
assertEquals(width, animation.width());
1131+
assertEquals(height, animation.height());
11331132

11341133
response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, new InputMediaAnimation(gifFileId)));
11351134
assertTrue(response.isOk());
1136-
// todo check animation object in message
1137-
// assertEquals(new Integer(3), response.message().animation().duration());
1135+
assertEquals(Integer.valueOf(3), response.message().animation().duration());
1136+
assertEquals(gifFileId, response.message().animation().fileId());
11381137
assertNotNull(response.message().document());
11391138
assertEquals((Integer) 57527, response.message().document().fileSize());
11401139
assertEquals("video/mp4", response.message().document().mimeType());

0 commit comments

Comments
 (0)