From adf1ee9b0db6593d6480f350a6448994e193da89 Mon Sep 17 00:00:00 2001 From: kkaravitis Date: Sun, 22 Mar 2020 22:06:44 +0200 Subject: [PATCH] [BAEL-3913] Fixed broken lines format and reduced the test method names length --- .../ApplicationRunnerTaskExecutor.java | 9 ++++---- .../execution/CommandLineTaskExecutor.java | 9 ++++---- .../LoadSpringContextIntegrationTest.java | 7 +++--- .../RunApplicationIntegrationTest.java | 2 +- ...icationWithTestProfileIntegrationTest.java | 14 ++++++------ ...tionWithTestPropertiesIntegrationTest.java | 22 +++++++++---------- 6 files changed, 31 insertions(+), 32 deletions(-) diff --git a/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/ApplicationRunnerTaskExecutor.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/ApplicationRunnerTaskExecutor.java index 98d4654d25..3bf08491bf 100644 --- a/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/ApplicationRunnerTaskExecutor.java +++ b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/ApplicationRunnerTaskExecutor.java @@ -7,10 +7,11 @@ import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; @Profile("!test") -@ConditionalOnProperty(prefix = "application.runner", - value = "enabled", - havingValue = "true", - matchIfMissing = true) +@ConditionalOnProperty( + prefix = "application.runner", + value = "enabled", + havingValue = "true", + matchIfMissing = true) @Component public class ApplicationRunnerTaskExecutor implements ApplicationRunner { private TaskService taskService; diff --git a/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/CommandLineTaskExecutor.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/CommandLineTaskExecutor.java index 4a77d78429..38fd3b9c0a 100644 --- a/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/CommandLineTaskExecutor.java +++ b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/CommandLineTaskExecutor.java @@ -6,10 +6,11 @@ import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; @Profile("!test") -@ConditionalOnProperty(prefix = "command.line.runner", - value = "enabled", - havingValue = "true", - matchIfMissing = true) +@ConditionalOnProperty( + prefix = "command.line.runner", + value = "enabled", + havingValue = "true", + matchIfMissing = true) @Component public class CommandLineTaskExecutor implements CommandLineRunner { private TaskService taskService; diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java index 911b16615d..c3922536b1 100644 --- a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java @@ -18,8 +18,8 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @ExtendWith(SpringExtension.class) -@ContextConfiguration(classes = {ApplicationCommandLineRunnerApp.class}, - initializers = ConfigFileApplicationContextInitializer.class) +@ContextConfiguration(classes = { ApplicationCommandLineRunnerApp.class }, + initializers = ConfigFileApplicationContextInitializer.class) public class LoadSpringContextIntegrationTest { @SpyBean TaskService taskService; @@ -31,8 +31,7 @@ public class LoadSpringContextIntegrationTest { ApplicationRunner applicationRunner; @Test - void whenContextLoads_thenAllBeansAreLoadedButCommandLineAndApplicationRunnerAreNotExecuted() - throws Exception { + void whenContextLoads_thenRunnersDoNotRun() throws Exception { assertNotNull(taskService); assertNotNull(commandLineRunner); assertNotNull(applicationRunner); diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationIntegrationTest.java index d732bc5260..26a7339f1d 100644 --- a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationIntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationIntegrationTest.java @@ -19,7 +19,7 @@ class RunApplicationIntegrationTest { CommandLineTaskExecutor commandLineTaskExecutor; @Test - void whenContextLoads_thenTheCommandLineAndApplicationRunnerAreExecuted() throws Exception { + void whenContextLoads_thenRunnersRun() throws Exception { verify(applicationRunnerTaskExecutor, times(1)).run(any()); verify(commandLineTaskExecutor, times(1)).run(any()); } diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestProfileIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestProfileIntegrationTest.java index b5e09077c6..333cd2ab91 100644 --- a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestProfileIntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestProfileIntegrationTest.java @@ -21,13 +21,13 @@ class RunApplicationWithTestProfileIntegrationTest { private ApplicationContext context; @Test - void whenContextLoads_thenTheCommandLineAndApplicationRunnerAreNotLoaded() { + void whenContextLoads_thenRunnersAreNotLoaded() { assertNotNull(context.getBean(TaskService.class)); - assertThrows(NoSuchBeanDefinitionException.class, - () -> context.getBean(CommandLineTaskExecutor.class), - "CommandLineRunner should not be loaded during this integration test"); - assertThrows(NoSuchBeanDefinitionException.class, - () -> context.getBean(ApplicationRunnerTaskExecutor.class), - "ApplicationRunner should not be loaded during this integration test"); + assertThrows(NoSuchBeanDefinitionException.class, + () -> context.getBean(CommandLineTaskExecutor.class), + "CommandLineRunner should not be loaded during this integration test"); + assertThrows(NoSuchBeanDefinitionException.class, + () -> context.getBean(ApplicationRunnerTaskExecutor.class), + "ApplicationRunner should not be loaded during this integration test"); } } diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestPropertiesIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestPropertiesIntegrationTest.java index 9ab8baec14..264a06a41e 100644 --- a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestPropertiesIntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestPropertiesIntegrationTest.java @@ -12,23 +12,21 @@ import com.baeldung.prevent.commandline.application.runner.execution.Application import com.baeldung.prevent.commandline.application.runner.execution.CommandLineTaskExecutor; import com.baeldung.prevent.commandline.application.runner.execution.TaskService; -@SpringBootTest( - properties = { - "command.line.runner.enabled=false", - "application.runner.enabled=false" - }) +@SpringBootTest(properties = { + "command.line.runner.enabled=false", + "application.runner.enabled=false" }) class RunApplicationWithTestPropertiesIntegrationTest { @Autowired private ApplicationContext context; @Test - void whenContextLoads_thenTheCommandLineAndApplicationRunnerAreNotLoaded() { + void whenContextLoads_thenRunnersAreNotLoaded() { assertNotNull(context.getBean(TaskService.class)); - assertThrows(NoSuchBeanDefinitionException.class, - () -> context.getBean(CommandLineTaskExecutor.class), - "CommandLineRunner should not be loaded during this integration test"); - assertThrows(NoSuchBeanDefinitionException.class, - () -> context.getBean(ApplicationRunnerTaskExecutor.class), - "ApplicationRunner should not be loaded during this integration test"); + assertThrows(NoSuchBeanDefinitionException.class, + () -> context.getBean(CommandLineTaskExecutor.class), + "CommandLineRunner should not be loaded during this integration test"); + assertThrows(NoSuchBeanDefinitionException.class, + () -> context.getBean(ApplicationRunnerTaskExecutor.class), + "ApplicationRunner should not be loaded during this integration test"); } }