Merge pull request #792 from costalfy/master
Upgrade Spring Boot dependency in telegrambots-spring-boot-starter
This commit is contained in:
commit
f83e2b3ccb
1
pom.xml
1
pom.xml
@ -190,6 +190,7 @@
|
||||
</executions>
|
||||
<configuration>
|
||||
<doclint>none</doclint>
|
||||
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
@ -70,8 +70,21 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
||||
<telegrambots.version>4.9.1</telegrambots.version>
|
||||
<spring-boot.version>2.3.3.RELEASE</spring-boot.version>
|
||||
<assertj-core.version>3.14.0</assertj-core.version>
|
||||
|
||||
<spring-boot.version>2.2.2.RELEASE</spring-boot.version>
|
||||
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
|
||||
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
|
||||
<maven-clean-plugin.version>3.1.0</maven-clean-plugin.version>
|
||||
<maven-assembly-plugin.version>3.1.1</maven-assembly-plugin.version>
|
||||
<maven-source-plugin.version>3.1.0</maven-source-plugin.version>
|
||||
<maven-javadoc-plugin.version>3.1.0</maven-javadoc-plugin.version>
|
||||
<jacoco-maven-plugin.version>0.8.4</jacoco-maven-plugin.version>
|
||||
<maven-enforcer-plugin.version>3.0.0-M2</maven-enforcer-plugin.version>
|
||||
<maven-dependency-plugin.version>3.1.1</maven-dependency-plugin.version>
|
||||
<maven-surefire-plugin.version>3.0.0-M3</maven-surefire-plugin.version>
|
||||
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -79,7 +92,7 @@
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots</artifactId>
|
||||
<version>4.9.1</version>
|
||||
<version>${telegrambots.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@ -104,7 +117,7 @@
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>3.14.0</version>
|
||||
<version>${assertj-core.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@ -118,7 +131,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.6</version>
|
||||
<version>${maven-gpg-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
@ -132,7 +145,7 @@
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.8</version>
|
||||
<version>${nexus-staging-maven-plugin.version}</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>ossrh</serverId>
|
||||
@ -142,7 +155,7 @@
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>${maven-clean-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>clean-project</id>
|
||||
@ -155,7 +168,7 @@
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<version>${maven-assembly-plugin.version}</version>
|
||||
<configuration>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
@ -174,7 +187,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>${maven-source-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@ -186,7 +199,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>${maven-javadoc-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@ -201,7 +214,7 @@
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.8.4</version>
|
||||
<version>${jacoco-maven-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@ -220,7 +233,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>3.0.0-M2</version>
|
||||
<version>${maven-enforcer-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>enforce-versions</id>
|
||||
@ -238,7 +251,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<version>${maven-dependency-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy</id>
|
||||
@ -249,7 +262,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M3</version>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<pluginManagement>
|
||||
@ -257,7 +270,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
|
@ -10,15 +10,14 @@ 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));
|
||||
.withAllowBeanDefinitionOverriding(true)
|
||||
.withConfiguration(AutoConfigurations.of(MockTelegramBotsApi.class,
|
||||
TelegramBotStarterConfiguration.class));
|
||||
|
||||
@Test
|
||||
void createMockTelegramBotsApiWithDefaultSettings() {
|
||||
@ -40,7 +39,8 @@ class TestTelegramBotStarterConfiguration {
|
||||
|
||||
TelegramBotsApi telegramBotsApi = context.getBean(TelegramBotsApi.class);
|
||||
|
||||
verify(telegramBotsApi, times(1)).registerBot( context.getBean(LongPollingBot.class) );
|
||||
verify(telegramBotsApi,
|
||||
times(1)).registerBot(context.getBean(LongPollingBot.class));
|
||||
verifyNoMoreInteractions(telegramBotsApi);
|
||||
});
|
||||
}
|
||||
@ -54,28 +54,32 @@ class TestTelegramBotStarterConfiguration {
|
||||
|
||||
TelegramBotsApi telegramBotsApi = context.getBean(TelegramBotsApi.class);
|
||||
|
||||
verify(telegramBotsApi, times(1)).registerBot( context.getBean(WebhookBot.class) );
|
||||
verify(telegramBotsApi,
|
||||
times(1)).registerBot(context.getBean(WebhookBot.class));
|
||||
verifyNoMoreInteractions(telegramBotsApi);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void createLongPoolingBotAndWebhookBot() {
|
||||
this.contextRunner.withUserConfiguration(LongPollingBotConfig.class, WebhookBotConfig.class)
|
||||
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) );
|
||||
verify(telegramBotsApi,
|
||||
times(1)).registerBot(context.getBean(LongPollingBot.class));
|
||||
verify(telegramBotsApi,
|
||||
times(1)).registerBot(context.getBean(WebhookBot.class));
|
||||
//verifyNoMoreInteractions(telegramBotsApi);
|
||||
});
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class MockTelegramBotsApi{
|
||||
static class MockTelegramBotsApi {
|
||||
|
||||
@Bean
|
||||
public TelegramBotsApi telegramBotsApi() {
|
||||
@ -84,7 +88,7 @@ class TestTelegramBotStarterConfiguration {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class LongPollingBotConfig{
|
||||
static class LongPollingBotConfig {
|
||||
@Bean
|
||||
public LongPollingBot longPollingBot() {
|
||||
return mock(LongPollingBot.class);
|
||||
@ -92,7 +96,7 @@ class TestTelegramBotStarterConfiguration {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class WebhookBotConfig{
|
||||
static class WebhookBotConfig {
|
||||
@Bean
|
||||
public WebhookBot webhookBot() {
|
||||
return mock(WebhookBot.class);
|
||||
|
@ -14,24 +14,19 @@ 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));
|
||||
|
||||
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 static final DefaultBotSession someBotSession = new DefaultBotSession();
|
||||
|
||||
private static final TelegramBotsApi mockTelegramBotsApi = mock(TelegramBotsApi.class);
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withAllowBeanDefinitionOverriding(true)
|
||||
.withConfiguration(AutoConfigurations.of(MockTelegramBotsApi.class,
|
||||
TelegramBotStarterConfiguration.class));
|
||||
|
||||
@Test
|
||||
void longPollingBotWithAnnotatedMethodshouldBeCalled() throws TelegramApiRequestException {
|
||||
@ -47,14 +42,15 @@ class TestTelegramBotStarterRegistrationHooks {
|
||||
|
||||
assertThat(hookCalled).isTrue();
|
||||
assertThat(hookCalledWithSession).isTrue();
|
||||
verify(telegramBotsApi, times(1)).registerBot(bot);
|
||||
verify(telegramBotsApi,
|
||||
times(1)).registerBot(bot);
|
||||
verifyNoMoreInteractions(telegramBotsApi);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
static class MockTelegramBotsApi{
|
||||
static class MockTelegramBotsApi {
|
||||
|
||||
@Bean
|
||||
public TelegramBotsApi telegramBotsApi() {
|
||||
@ -63,21 +59,28 @@ class TestTelegramBotStarterRegistrationHooks {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class LongPollingBotConfig{
|
||||
static class LongPollingBotConfig {
|
||||
@Bean
|
||||
public LongPollingBot longPollingBot() { return new AnnotatedLongPollingBot(); }
|
||||
public LongPollingBot longPollingBot() {
|
||||
return new AnnotatedLongPollingBot();
|
||||
}
|
||||
}
|
||||
|
||||
static class AnnotatedLongPollingBot extends TelegramLongPollingBot {
|
||||
|
||||
@Override
|
||||
public void onUpdateReceived(final Update update) {}
|
||||
public void onUpdateReceived(final Update update) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBotUsername() { return null; }
|
||||
public String getBotUsername() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBotToken() { return null; }
|
||||
public String getBotToken() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@AfterBotRegistration
|
||||
public void afterBotHook() {
|
||||
|
Loading…
Reference in New Issue
Block a user