Skip to content

Commit 36acdb9

Browse files
committed
Fix tests
1 parent 35c8d2b commit 36acdb9

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

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

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
import org.junit.Test;
7878

7979
import java.io.File;
80-
import java.io.FileInputStream;
8180
import java.io.IOException;
8281
import java.net.MalformedURLException;
8382
import java.net.URISyntaxException;
@@ -112,7 +111,7 @@ static String getProp(String key) {
112111

113112
static {
114113
try {
115-
props.load(new FileInputStream("local.properties"));
114+
props.load(Files.newInputStream(Paths.get("local.properties")));
116115
} catch (Exception ignored) {
117116
}
118117

@@ -160,8 +159,6 @@ public static TelegramBot createTestBot() {
160159
static String testInlineQuery;
161160
static String testChosenInlineResult;
162161
static String testPollAnswer;
163-
// static String testShippingQuery;
164-
// static String testPreCheckoutQuery;
165162

166163
static Path resourcePath = Paths.get("src/test/resources");
167164
static File imageFile = resourcePath.resolve("image.jpg").toFile();
@@ -1410,7 +1407,7 @@ public void setStickerSetThumb() {
14101407
PhotoSizeTest.checkPhotos(thumb);
14111408
assertEquals(Integer.valueOf(100), thumb.width());
14121409
assertEquals(Integer.valueOf(100), thumb.height());
1413-
assertEquals(Integer.valueOf(8244), thumb.fileSize());
1410+
assertEquals(Long.valueOf(8244), thumb.fileSize());
14141411

14151412
// clear thumb by not sending it
14161413
response = bot.execute(new SetStickerSetThumb(stickerSetAnim, chatId));
@@ -1523,31 +1520,31 @@ public void editMessageMedia() {
15231520
.thumb(thumbFile)
15241521
.disableContentTypeDetection(true)
15251522
));
1526-
assertEquals((Integer) 14, response.message().document().fileSize());
1523+
assertEquals((Long) 14L, response.message().document().fileSize());
15271524
assertEquals(thumbSize, response.message().document().thumb().fileSize());
15281525

15291526
response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId,
15301527
new InputMediaDocument(docBytes).thumb(thumbBytes)));
1531-
assertEquals((Integer) 14, response.message().document().fileSize());
1528+
assertEquals((Long) 14L, response.message().document().fileSize());
15321529
assertEquals(thumbSize, response.message().document().thumb().fileSize());
15331530

15341531
response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, new InputMediaDocument(docFileId)));
15351532
MessageTest.checkMessage(response.message());
15361533
DocumentTest.check(response.message().document());
15371534

15381535

1539-
// response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, new InputMediaAnimation(gifFile)));
1540-
// assertEquals(Integer.valueOf(1), response.message().animation().duration());
1536+
response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, new InputMediaAnimation(gifFile)));
1537+
assertEquals(Integer.valueOf(1), response.message().animation().duration());
15411538

1542-
// int expectedSize = 160; // idk why?
1543-
// Integer durationAnim = 17, width = 21, height = 22;
1544-
// response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId,
1545-
// new InputMediaAnimation(gifBytes).duration(durationAnim).width(width).height(height)
1546-
// ));
1547-
// Animation animation = response.message().animation();
1548-
// assertEquals(1, animation.duration().intValue());
1549-
// assertEquals(expectedSize, animation.width().intValue());
1550-
// assertEquals(expectedSize, animation.height().intValue());
1539+
int expectedSize = 160; // idk why?
1540+
Integer durationAnim = 17, width = 21, height = 22;
1541+
response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId,
1542+
new InputMediaAnimation(gifBytes).duration(durationAnim).width(width).height(height)
1543+
));
1544+
Animation animation = response.message().animation();
1545+
assertEquals(1, animation.duration().intValue());
1546+
assertEquals(expectedSize, animation.width().intValue());
1547+
assertEquals(expectedSize, animation.height().intValue());
15511548

15521549
response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, new InputMediaAnimation(gifFileId)));
15531550
assertTrue(response.isOk());
@@ -1831,7 +1828,7 @@ public void toWebhookResponse() {
18311828
@Test
18321829
public void loginButton() {
18331830
String text = "login";
1834-
String url = "http://pengrad.herokuapp.com/hello";
1831+
String url = "https://pengrad.herokuapp.com/hello";
18351832
SendResponse response = bot.execute(
18361833
new SendMessage(chatId, "Login button").replyMarkup(new InlineKeyboardMarkup(
18371834
new InlineKeyboardButton(text).loginUrl(new LoginUrl(url)

0 commit comments

Comments
 (0)