From 08bcf2bdacbebd7643642b088ea4f3afc4d389ef Mon Sep 17 00:00:00 2001 From: rubenlagus Date: Tue, 9 Jul 2019 20:50:50 +0100 Subject: [PATCH] Fix remaining tests --- Bots.ipr | 39 +++++++++++++++++-- .../TestTelegramBotStarterConfiguration.java | 22 ++++++----- ...stTelegramBotStarterRegistrationHooks.java | 14 ++++--- 3 files changed, 57 insertions(+), 18 deletions(-) diff --git a/Bots.ipr b/Bots.ipr index 06f47553..091115a0 100644 --- a/Bots.ipr +++ b/Bots.ipr @@ -22,10 +22,10 @@ - - - + + + @@ -1041,6 +1041,17 @@ + + + + + + + + + + + @@ -1096,6 +1107,17 @@ + + + + + + + + + + + @@ -1129,6 +1151,17 @@ + + + + + + + + + + + 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 938c22ee..42a2d1cc 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 @@ -1,10 +1,6 @@ package org.telegram.telegrambots.starter; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.Test; -import static org.mockito.Mockito.*; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; @@ -13,13 +9,19 @@ import org.telegram.telegrambots.meta.TelegramBotsApi; import org.telegram.telegrambots.meta.generics.LongPollingBot; import org.telegram.telegrambots.meta.generics.WebhookBot; -public class TestTelegramBotStarterConfiguration { +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; + +class TestTelegramBotStarterConfiguration { private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withConfiguration(AutoConfigurations.of(MockTelegramBotsApi.class, TelegramBotStarterConfiguration.class)); @Test - public void createMockTelegramBotsApiWithDefaultSettings() { + void createMockTelegramBotsApiWithDefaultSettings() { this.contextRunner.run((context) -> { assertThat(context).hasSingleBean(TelegramBotsApi.class); assertThat(context).hasSingleBean(TelegramBotInitializer.class); @@ -30,7 +32,7 @@ public class TestTelegramBotStarterConfiguration { } @Test - public void createOnlyLongPollingBot() { + void createOnlyLongPollingBot() { this.contextRunner.withUserConfiguration(LongPollingBotConfig.class) .run((context) -> { assertThat(context).hasSingleBean(LongPollingBot.class); @@ -44,7 +46,7 @@ public class TestTelegramBotStarterConfiguration { } @Test - public void createOnlyWebhookBot() { + void createOnlyWebhookBot() { this.contextRunner.withUserConfiguration(WebhookBotConfig.class) .run((context) -> { assertThat(context).hasSingleBean(WebhookBot.class); @@ -58,7 +60,7 @@ public class TestTelegramBotStarterConfiguration { } @Test - public void createLongPoolingBotAndWebhookBot() { + void createLongPoolingBotAndWebhookBot() { this.contextRunner.withUserConfiguration(LongPollingBotConfig.class, WebhookBotConfig.class) .run((context) -> { assertThat(context).hasSingleBean(LongPollingBot.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 aba90dad..2f108d81 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 @@ -1,7 +1,6 @@ package org.telegram.telegrambots.starter; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; @@ -15,9 +14,14 @@ 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.*; +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; -public class TestTelegramBotStarterRegistrationHooks { +class TestTelegramBotStarterRegistrationHooks { private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withConfiguration(AutoConfigurations.of(MockTelegramBotsApi.class, TelegramBotStarterConfiguration.class)); @@ -30,7 +34,7 @@ public class TestTelegramBotStarterRegistrationHooks { private static final TelegramBotsApi mockTelegramBotsApi = mock(TelegramBotsApi.class); @Test - public void longPollingBotWithAnnotatedMethodshouldBeCalled() throws TelegramApiRequestException { + void longPollingBotWithAnnotatedMethodshouldBeCalled() throws TelegramApiRequestException { when(mockTelegramBotsApi.registerBot(any(LongPollingBot.class))).thenReturn(someBotSession);