[BAEL-3913] Fixed broken lines format and reduced the test method names length
This commit is contained in:
parent
f1f9e87468
commit
adf1ee9b0d
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue