diff --git a/pom.xml b/pom.xml
index 91026843..523f4dfd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -190,6 +190,7 @@
none
+ ${java.home}/bin/javadoc
diff --git a/telegrambots-spring-boot-starter/pom.xml b/telegrambots-spring-boot-starter/pom.xml
index 7155c80e..90b989ab 100644
--- a/telegrambots-spring-boot-starter/pom.xml
+++ b/telegrambots-spring-boot-starter/pom.xml
@@ -70,8 +70,21 @@
UTF-8
UTF-8
+ 4.9.1
+ 2.3.3.RELEASE
+ 3.14.0
- 2.2.2.RELEASE
+ 1.6
+ 1.6.8
+ 3.1.0
+ 3.1.1
+ 3.1.0
+ 3.1.0
+ 0.8.4
+ 3.0.0-M2
+ 3.1.1
+ 3.0.0-M3
+ 3.8.1
@@ -79,7 +92,7 @@
org.telegram
telegrambots
- 4.9.1
+ ${telegrambots.version}
org.springframework.boot
@@ -104,7 +117,7 @@
org.assertj
assertj-core
test
- 3.14.0
+ ${assertj-core.version}
@@ -118,7 +131,7 @@
org.apache.maven.plugins
maven-gpg-plugin
- 1.6
+ ${maven-gpg-plugin.version}
sign-artifacts
@@ -132,7 +145,7 @@
org.sonatype.plugins
nexus-staging-maven-plugin
- 1.6.8
+ ${nexus-staging-maven-plugin.version}
true
ossrh
@@ -142,7 +155,7 @@
maven-clean-plugin
- 3.1.0
+ ${maven-clean-plugin.version}
clean-project
@@ -155,7 +168,7 @@
maven-assembly-plugin
- 3.1.1
+ ${maven-assembly-plugin.version}
jar-with-dependencies
@@ -174,7 +187,7 @@
org.apache.maven.plugins
maven-source-plugin
- 3.1.0
+ ${maven-source-plugin.version}
@@ -186,7 +199,7 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 3.1.0
+ ${maven-javadoc-plugin.version}
@@ -201,7 +214,7 @@
org.jacoco
jacoco-maven-plugin
- 0.8.4
+ ${jacoco-maven-plugin.version}
@@ -220,7 +233,7 @@
org.apache.maven.plugins
maven-enforcer-plugin
- 3.0.0-M2
+ ${maven-enforcer-plugin.version}
enforce-versions
@@ -238,7 +251,7 @@
org.apache.maven.plugins
maven-dependency-plugin
- 3.1.1
+ ${maven-dependency-plugin.version}
copy
@@ -249,7 +262,7 @@
org.apache.maven.plugins
maven-surefire-plugin
- 3.0.0-M3
+ ${maven-surefire-plugin.version}
@@ -257,7 +270,7 @@
org.apache.maven.plugins
maven-compiler-plugin
- 3.8.1
+ ${maven-compiler-plugin.version}
${java.version}
${java.version}
diff --git a/telegrambots-spring-boot-starter/src/test/java/org/telegram/telegrambots/starter/TestTelegramBotStarterConfiguration.java b/telegrambots-spring-boot-starter/src/test/java/org/telegram/telegrambots/starter/TestTelegramBotStarterConfiguration.java
index 42a2d1cc..09cbec19 100644
--- a/telegrambots-spring-boot-starter/src/test/java/org/telegram/telegrambots/starter/TestTelegramBotStarterConfiguration.java
+++ b/telegrambots-spring-boot-starter/src/test/java/org/telegram/telegrambots/starter/TestTelegramBotStarterConfiguration.java
@@ -10,92 +10,96 @@ import org.telegram.telegrambots.meta.generics.LongPollingBot;
import org.telegram.telegrambots.meta.generics.WebhookBot;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.*;
class TestTelegramBotStarterConfiguration {
- private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
- .withConfiguration(AutoConfigurations.of(MockTelegramBotsApi.class, TelegramBotStarterConfiguration.class));
+ private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
+ .withAllowBeanDefinitionOverriding(true)
+ .withConfiguration(AutoConfigurations.of(MockTelegramBotsApi.class,
+ TelegramBotStarterConfiguration.class));
- @Test
- void createMockTelegramBotsApiWithDefaultSettings() {
- this.contextRunner.run((context) -> {
- assertThat(context).hasSingleBean(TelegramBotsApi.class);
- assertThat(context).hasSingleBean(TelegramBotInitializer.class);
- assertThat(context).doesNotHaveBean(LongPollingBot.class);
- assertThat(context).doesNotHaveBean(WebhookBot.class);
- verifyNoMoreInteractions(context.getBean(TelegramBotsApi.class));
- });
- }
-
- @Test
- void createOnlyLongPollingBot() {
- this.contextRunner.withUserConfiguration(LongPollingBotConfig.class)
- .run((context) -> {
- assertThat(context).hasSingleBean(LongPollingBot.class);
- assertThat(context).doesNotHaveBean(WebhookBot.class);
-
- TelegramBotsApi telegramBotsApi = context.getBean(TelegramBotsApi.class);
-
- verify(telegramBotsApi, times(1)).registerBot( context.getBean(LongPollingBot.class) );
- verifyNoMoreInteractions(telegramBotsApi);
- });
- }
-
- @Test
- void createOnlyWebhookBot() {
- this.contextRunner.withUserConfiguration(WebhookBotConfig.class)
- .run((context) -> {
- assertThat(context).hasSingleBean(WebhookBot.class);
- assertThat(context).doesNotHaveBean(LongPollingBot.class);
-
- TelegramBotsApi telegramBotsApi = context.getBean(TelegramBotsApi.class);
-
- verify(telegramBotsApi, times(1)).registerBot( context.getBean(WebhookBot.class) );
- verifyNoMoreInteractions(telegramBotsApi);
- });
- }
-
- @Test
- void createLongPoolingBotAndWebhookBot() {
- this.contextRunner.withUserConfiguration(LongPollingBotConfig.class, WebhookBotConfig.class)
- .run((context) -> {
- assertThat(context).hasSingleBean(LongPollingBot.class);
- assertThat(context).hasSingleBean(WebhookBot.class);
+ @Test
+ void createMockTelegramBotsApiWithDefaultSettings() {
+ this.contextRunner.run((context) -> {
+ assertThat(context).hasSingleBean(TelegramBotsApi.class);
+ assertThat(context).hasSingleBean(TelegramBotInitializer.class);
+ assertThat(context).doesNotHaveBean(LongPollingBot.class);
+ assertThat(context).doesNotHaveBean(WebhookBot.class);
+ verifyNoMoreInteractions(context.getBean(TelegramBotsApi.class));
+ });
+ }
- TelegramBotsApi telegramBotsApi = context.getBean(TelegramBotsApi.class);
-
- verify(telegramBotsApi, times(1)).registerBot( context.getBean(LongPollingBot.class) );
- verify(telegramBotsApi, times(1)).registerBot( context.getBean(WebhookBot.class) );
- //verifyNoMoreInteractions(telegramBotsApi);
- });
- }
+ @Test
+ void createOnlyLongPollingBot() {
+ this.contextRunner.withUserConfiguration(LongPollingBotConfig.class)
+ .run((context) -> {
+ assertThat(context).hasSingleBean(LongPollingBot.class);
+ assertThat(context).doesNotHaveBean(WebhookBot.class);
- @Configuration
- static class MockTelegramBotsApi{
+ TelegramBotsApi telegramBotsApi = context.getBean(TelegramBotsApi.class);
- @Bean
- public TelegramBotsApi telegramBotsApi() {
- return mock(TelegramBotsApi.class);
- }
- }
-
- @Configuration
- static class LongPollingBotConfig{
- @Bean
- public LongPollingBot longPollingBot() {
- return mock(LongPollingBot.class);
- }
- }
-
- @Configuration
- static class WebhookBotConfig{
- @Bean
- public WebhookBot webhookBot() {
- return mock(WebhookBot.class);
- }
- }
+ verify(telegramBotsApi,
+ times(1)).registerBot(context.getBean(LongPollingBot.class));
+ verifyNoMoreInteractions(telegramBotsApi);
+ });
+ }
+
+ @Test
+ void createOnlyWebhookBot() {
+ this.contextRunner.withUserConfiguration(WebhookBotConfig.class)
+ .run((context) -> {
+ assertThat(context).hasSingleBean(WebhookBot.class);
+ assertThat(context).doesNotHaveBean(LongPollingBot.class);
+
+ TelegramBotsApi telegramBotsApi = context.getBean(TelegramBotsApi.class);
+
+ verify(telegramBotsApi,
+ times(1)).registerBot(context.getBean(WebhookBot.class));
+ verifyNoMoreInteractions(telegramBotsApi);
+ });
+ }
+
+ @Test
+ void createLongPoolingBotAndWebhookBot() {
+ this.contextRunner.withUserConfiguration(LongPollingBotConfig.class,
+ WebhookBotConfig.class)
+ .run((context) -> {
+ assertThat(context).hasSingleBean(LongPollingBot.class);
+ assertThat(context).hasSingleBean(WebhookBot.class);
+
+ TelegramBotsApi telegramBotsApi = context.getBean(TelegramBotsApi.class);
+
+ verify(telegramBotsApi,
+ times(1)).registerBot(context.getBean(LongPollingBot.class));
+ verify(telegramBotsApi,
+ times(1)).registerBot(context.getBean(WebhookBot.class));
+ //verifyNoMoreInteractions(telegramBotsApi);
+ });
+ }
+
+ @Configuration
+ static class MockTelegramBotsApi {
+
+ @Bean
+ public TelegramBotsApi telegramBotsApi() {
+ return mock(TelegramBotsApi.class);
+ }
+ }
+
+ @Configuration
+ static class LongPollingBotConfig {
+ @Bean
+ public LongPollingBot longPollingBot() {
+ return mock(LongPollingBot.class);
+ }
+ }
+
+ @Configuration
+ static class WebhookBotConfig {
+ @Bean
+ public WebhookBot webhookBot() {
+ return mock(WebhookBot.class);
+ }
+ }
}
diff --git a/telegrambots-spring-boot-starter/src/test/java/org/telegram/telegrambots/starter/TestTelegramBotStarterRegistrationHooks.java b/telegrambots-spring-boot-starter/src/test/java/org/telegram/telegrambots/starter/TestTelegramBotStarterRegistrationHooks.java
index 2f108d81..1764c4ad 100644
--- a/telegrambots-spring-boot-starter/src/test/java/org/telegram/telegrambots/starter/TestTelegramBotStarterRegistrationHooks.java
+++ b/telegrambots-spring-boot-starter/src/test/java/org/telegram/telegrambots/starter/TestTelegramBotStarterRegistrationHooks.java
@@ -14,27 +14,22 @@ import org.telegram.telegrambots.meta.generics.LongPollingBot;
import org.telegram.telegrambots.updatesreceivers.DefaultBotSession;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
class TestTelegramBotStarterRegistrationHooks {
- private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
- .withConfiguration(AutoConfigurations.of(MockTelegramBotsApi.class, TelegramBotStarterConfiguration.class));
-
- // Terrible workaround for mockito loosing annotations on methods
- private static boolean hookCalled = false;
- private static boolean hookCalledWithSession = false;
- private static final DefaultBotSession someBotSession = new DefaultBotSession();
-
- private static final TelegramBotsApi mockTelegramBotsApi = mock(TelegramBotsApi.class);
+ private static final DefaultBotSession someBotSession = new DefaultBotSession();
+ private static final TelegramBotsApi mockTelegramBotsApi = mock(TelegramBotsApi.class);
+ // Terrible workaround for mockito loosing annotations on methods
+ private static boolean hookCalled = false;
+ private static boolean hookCalledWithSession = false;
+ private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
+ .withAllowBeanDefinitionOverriding(true)
+ .withConfiguration(AutoConfigurations.of(MockTelegramBotsApi.class,
+ TelegramBotStarterConfiguration.class));
@Test
- void longPollingBotWithAnnotatedMethodshouldBeCalled() throws TelegramApiRequestException {
+ void longPollingBotWithAnnotatedMethodshouldBeCalled() throws TelegramApiRequestException {
when(mockTelegramBotsApi.registerBot(any(LongPollingBot.class))).thenReturn(someBotSession);
@@ -45,48 +40,56 @@ class TestTelegramBotStarterRegistrationHooks {
final LongPollingBot bot = context.getBean(LongPollingBot.class);
final TelegramBotsApi telegramBotsApi = context.getBean(TelegramBotsApi.class);
- assertThat(hookCalled).isTrue();
- assertThat(hookCalledWithSession).isTrue();
- verify(telegramBotsApi, times(1)).registerBot(bot);
- verifyNoMoreInteractions(telegramBotsApi);
+ assertThat(hookCalled).isTrue();
+ assertThat(hookCalledWithSession).isTrue();
+ verify(telegramBotsApi,
+ times(1)).registerBot(bot);
+ verifyNoMoreInteractions(telegramBotsApi);
});
}
- @Configuration
- static class MockTelegramBotsApi{
+ @Configuration
+ static class MockTelegramBotsApi {
- @Bean
- public TelegramBotsApi telegramBotsApi() {
- return mockTelegramBotsApi;
- }
- }
-
- @Configuration
- static class LongPollingBotConfig{
- @Bean
- public LongPollingBot longPollingBot() { return new AnnotatedLongPollingBot(); }
- }
+ @Bean
+ public TelegramBotsApi telegramBotsApi() {
+ return mockTelegramBotsApi;
+ }
+ }
- static class AnnotatedLongPollingBot extends TelegramLongPollingBot {
+ @Configuration
+ static class LongPollingBotConfig {
+ @Bean
+ public LongPollingBot longPollingBot() {
+ return new AnnotatedLongPollingBot();
+ }
+ }
- @Override
- public void onUpdateReceived(final Update update) {}
+ static class AnnotatedLongPollingBot extends TelegramLongPollingBot {
- @Override
- public String getBotUsername() { return null; }
+ @Override
+ public void onUpdateReceived(final Update update) {
+ }
- @Override
- public String getBotToken() { return null; }
+ @Override
+ public String getBotUsername() {
+ return null;
+ }
- @AfterBotRegistration
- public void afterBotHook() {
+ @Override
+ public String getBotToken() {
+ return null;
+ }
+
+ @AfterBotRegistration
+ public void afterBotHook() {
hookCalled = true;
}
@AfterBotRegistration
- public void afterBotHookWithSession(BotSession session) {
+ public void afterBotHookWithSession(BotSession session) {
hookCalledWithSession = session.equals(someBotSession);
}
- }
+ }
}