|
77 | 77 | import org.junit.Test; |
78 | 78 |
|
79 | 79 | import java.io.File; |
80 | | -import java.io.FileInputStream; |
81 | 80 | import java.io.IOException; |
82 | 81 | import java.net.MalformedURLException; |
83 | 82 | import java.net.URISyntaxException; |
@@ -112,7 +111,7 @@ static String getProp(String key) { |
112 | 111 |
|
113 | 112 | static { |
114 | 113 | try { |
115 | | - props.load(new FileInputStream("local.properties")); |
| 114 | + props.load(Files.newInputStream(Paths.get("local.properties"))); |
116 | 115 | } catch (Exception ignored) { |
117 | 116 | } |
118 | 117 |
|
@@ -160,8 +159,6 @@ public static TelegramBot createTestBot() { |
160 | 159 | static String testInlineQuery; |
161 | 160 | static String testChosenInlineResult; |
162 | 161 | static String testPollAnswer; |
163 | | -// static String testShippingQuery; |
164 | | -// static String testPreCheckoutQuery; |
165 | 162 |
|
166 | 163 | static Path resourcePath = Paths.get("src/test/resources"); |
167 | 164 | static File imageFile = resourcePath.resolve("image.jpg").toFile(); |
@@ -1410,7 +1407,7 @@ public void setStickerSetThumb() { |
1410 | 1407 | PhotoSizeTest.checkPhotos(thumb); |
1411 | 1408 | assertEquals(Integer.valueOf(100), thumb.width()); |
1412 | 1409 | assertEquals(Integer.valueOf(100), thumb.height()); |
1413 | | - assertEquals(Integer.valueOf(8244), thumb.fileSize()); |
| 1410 | + assertEquals(Long.valueOf(8244), thumb.fileSize()); |
1414 | 1411 |
|
1415 | 1412 | // clear thumb by not sending it |
1416 | 1413 | response = bot.execute(new SetStickerSetThumb(stickerSetAnim, chatId)); |
@@ -1523,31 +1520,31 @@ public void editMessageMedia() { |
1523 | 1520 | .thumb(thumbFile) |
1524 | 1521 | .disableContentTypeDetection(true) |
1525 | 1522 | )); |
1526 | | - assertEquals((Integer) 14, response.message().document().fileSize()); |
| 1523 | + assertEquals((Long) 14L, response.message().document().fileSize()); |
1527 | 1524 | assertEquals(thumbSize, response.message().document().thumb().fileSize()); |
1528 | 1525 |
|
1529 | 1526 | response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, |
1530 | 1527 | new InputMediaDocument(docBytes).thumb(thumbBytes))); |
1531 | | - assertEquals((Integer) 14, response.message().document().fileSize()); |
| 1528 | + assertEquals((Long) 14L, response.message().document().fileSize()); |
1532 | 1529 | assertEquals(thumbSize, response.message().document().thumb().fileSize()); |
1533 | 1530 |
|
1534 | 1531 | response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, new InputMediaDocument(docFileId))); |
1535 | 1532 | MessageTest.checkMessage(response.message()); |
1536 | 1533 | DocumentTest.check(response.message().document()); |
1537 | 1534 |
|
1538 | 1535 |
|
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()); |
1541 | 1538 |
|
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()); |
1551 | 1548 |
|
1552 | 1549 | response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, new InputMediaAnimation(gifFileId))); |
1553 | 1550 | assertTrue(response.isOk()); |
@@ -1831,7 +1828,7 @@ public void toWebhookResponse() { |
1831 | 1828 | @Test |
1832 | 1829 | public void loginButton() { |
1833 | 1830 | String text = "login"; |
1834 | | - String url = "http://pengrad.herokuapp.com/hello"; |
| 1831 | + String url = "https://pengrad.herokuapp.com/hello"; |
1835 | 1832 | SendResponse response = bot.execute( |
1836 | 1833 | new SendMessage(chatId, "Login button").replyMarkup(new InlineKeyboardMarkup( |
1837 | 1834 | new InlineKeyboardButton(text).loginUrl(new LoginUrl(url) |
|
0 commit comments