This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 4f9d3c3f7f1 CAMEL-19556: camel-telegram 4f9d3c3f7f1 is described below commit 4f9d3c3f7f18ee180a457e89507ade0b89e85450 Author: Nikita Konovalov <nkono...@redhat.com> AuthorDate: Mon Jul 17 16:39:24 2023 +0200 CAMEL-19556: camel-telegram - Added assertions where possible - Simplified assertions where possible --- .../telegram/TelegramConsumerMappingTest.java | 8 ++++---- .../telegram/integration/TelegramServiceIT.java | 22 +++++++++++----------- .../integration/TelegramServiceProxyIT.java | 7 +++++-- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConsumerMappingTest.java b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConsumerMappingTest.java index d003da1498c..41af9cc047c 100644 --- a/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConsumerMappingTest.java +++ b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConsumerMappingTest.java @@ -88,19 +88,19 @@ public class TelegramConsumerMappingTest extends TelegramTestSupport { public void testMessageResultMapping() { MessageResult messageResult = getJSONResource("messages/updates-sendLocation.json", MessageResult.class); - assertEquals(true, messageResult.isOk()); - assertEquals(true, messageResult.isOk()); + assertTrue(messageResult.isOk()); + assertTrue(messageResult.isOk()); assertEquals((Long) 33L, messageResult.getMessage().getMessageId()); assertEquals(Instant.ofEpochSecond(1548091564).getEpochSecond(), messageResult.getMessage().getDate().getEpochSecond()); assertEquals((Long) 665977497L, messageResult.getMessage().getFrom().getId()); - assertEquals(true, messageResult.getMessage().getFrom().isBot()); + assertTrue(messageResult.getMessage().getFrom().isBot()); assertEquals("camelbot", messageResult.getMessage().getFrom().getFirstName()); assertEquals("camel_component_bot", messageResult.getMessage().getFrom().getUsername()); assertEquals("-182520913", messageResult.getMessage().getChat().getId()); assertEquals("testgroup", messageResult.getMessage().getChat().getTitle()); assertEquals("group", messageResult.getMessage().getChat().getType()); - assertEquals(true, messageResult.getMessage().getChat().isAllMembersAreAdministrators()); + assertTrue(messageResult.getMessage().getChat().isAllMembersAreAdministrators()); assertEquals(59.9386292, messageResult.getMessage().getLocation().getLatitude(), 1.0E-07); assertEquals(30.3141308, messageResult.getMessage().getLocation().getLongitude(), 1.0E-07); diff --git a/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/integration/TelegramServiceIT.java b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/integration/TelegramServiceIT.java index 6df830d1d69..9007871c0d4 100644 --- a/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/integration/TelegramServiceIT.java +++ b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/integration/TelegramServiceIT.java @@ -88,7 +88,7 @@ public class TelegramServiceIT extends TelegramTestSupport { OutgoingTextMessage msg = new OutgoingTextMessage(); msg.setChatId(chatId); msg.setText("This is an auto-generated message from the Bot"); - template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg); + Assertions.assertDoesNotThrow(() -> template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg)); } @Test @@ -98,7 +98,7 @@ public class TelegramServiceIT extends TelegramTestSupport { msg.setText("This is a <b>HTML</b> <i>auto-generated</i> message from the Bot"); msg.setParseMode(TelegramParseMode.HTML.getCode()); - template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg); + Assertions.assertDoesNotThrow(() -> template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg)); } @Test @@ -108,7 +108,7 @@ public class TelegramServiceIT extends TelegramTestSupport { msg.setText("This is a *Markdown* _auto-generated_ message from the Bot"); msg.setParseMode(TelegramParseMode.MARKDOWN.getCode()); - template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg); + Assertions.assertDoesNotThrow(() -> template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg)); } @Test @@ -143,7 +143,7 @@ public class TelegramServiceIT extends TelegramTestSupport { msg.setReplyMarkup(replyMarkup); - template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg); + Assertions.assertDoesNotThrow(() -> template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg)); } @Test @@ -180,7 +180,7 @@ public class TelegramServiceIT extends TelegramTestSupport { msg.setReplyMarkup(replyMarkup); - template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg); + Assertions.assertDoesNotThrow(() -> template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg)); } @Test @@ -192,7 +192,7 @@ public class TelegramServiceIT extends TelegramTestSupport { msg.setParseMode("Markdown"); msg.setDisableNotification(false); - template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg); + Assertions.assertDoesNotThrow(() -> template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg)); } @Test @@ -204,7 +204,7 @@ public class TelegramServiceIT extends TelegramTestSupport { msg.setChatId(chatId); msg.setFilenameWithExtension("file.png"); - template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg); + Assertions.assertDoesNotThrow(() -> template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg)); } @Test @@ -251,7 +251,7 @@ public class TelegramServiceIT extends TelegramTestSupport { msg.setCaption("Photo"); msg.setDisableNotification(false); - template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg); + Assertions.assertDoesNotThrow(() -> template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg)); } @Test @@ -263,7 +263,7 @@ public class TelegramServiceIT extends TelegramTestSupport { msg.setChatId(chatId); msg.setFilenameWithExtension("audio.mp3"); - template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg); + Assertions.assertDoesNotThrow(() -> template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg)); } @Test @@ -296,7 +296,7 @@ public class TelegramServiceIT extends TelegramTestSupport { msg.setChatId(chatId); msg.setFilenameWithExtension("video.mp4"); - template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg); + Assertions.assertDoesNotThrow(() -> template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg)); } @Test @@ -331,7 +331,7 @@ public class TelegramServiceIT extends TelegramTestSupport { msg.setChatId(chatId); msg.setFilenameWithExtension("file.txt"); - template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg); + Assertions.assertDoesNotThrow(() -> template.requestBody(String.format("telegram://bots?chatId=%s", chatId), msg)); } @Test diff --git a/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/integration/TelegramServiceProxyIT.java b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/integration/TelegramServiceProxyIT.java index 8d7325a6975..2ab6ba85b81 100644 --- a/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/integration/TelegramServiceProxyIT.java +++ b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/integration/TelegramServiceProxyIT.java @@ -20,6 +20,7 @@ import org.apache.camel.component.telegram.model.IncomingMessage; import org.apache.camel.component.telegram.model.OutgoingTextMessage; import org.apache.camel.component.telegram.util.TelegramApiConfig; import org.apache.camel.component.telegram.util.TelegramTestSupport; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -63,10 +64,12 @@ public class TelegramServiceProxyIT extends TelegramTestSupport { OutgoingTextMessage msg = new OutgoingTextMessage(); msg.setChatId(chatId); msg.setText("This is an auto-generated message from the Bot"); - template.requestBody( + Assertions.assertDoesNotThrow(() -> + template.requestBody( String.format("telegram://bots?chatId=%s&proxyHost=%s&proxyPort=%s&proxyType=%s", chatId, proxyHost, proxyPort, proxyType), - msg); + msg) + ); } }