Skip to content

Commit 36710fc

Browse files
piotrooofmbenhassine
authored andcommitted
Cleanup tests
Signed-off-by: Piotr Olaszewski <[email protected]>
1 parent e32ccd0 commit 36710fc

File tree

140 files changed

+1476
-1963
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+1476
-1963
lines changed

spring-shell-autoconfigure/src/test/java/org/springframework/shell/boot/ApplicationRunnerAutoConfigurationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 the original author or authors.
2+
* Copyright 2023-present the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
2222

2323
import static org.assertj.core.api.Assertions.assertThat;
2424

25-
public class ApplicationRunnerAutoConfigurationTests {
25+
class ApplicationRunnerAutoConfigurationTests {
2626

2727
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
2828
.withConfiguration(AutoConfigurations.of(ApplicationRunnerAutoConfiguration.class));

spring-shell-autoconfigure/src/test/java/org/springframework/shell/boot/CommandCatalogAutoConfigurationTests.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022-2024 the original author or authors.
2+
* Copyright 2022-present the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@
3333

3434
import static org.assertj.core.api.Assertions.assertThat;
3535

36-
public class CommandCatalogAutoConfigurationTests {
36+
class CommandCatalogAutoConfigurationTests {
3737

3838
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
3939
.withConfiguration(AutoConfigurations.of(CommandCatalogAutoConfiguration.class,
@@ -66,7 +66,7 @@ void customCommandCatalog() {
6666
@Test
6767
void registerCommandRegistration() {
6868
this.contextRunner.withUserConfiguration(CustomCommandRegistrationConfiguration.class)
69-
.run((context) -> {
69+
.run(context -> {
7070
CommandCatalog commandCatalog = context.getBean(CommandCatalog.class);
7171
assertThat(commandCatalog.getRegistrations().get("customcommand")).isNotNull();
7272
});
@@ -153,7 +153,7 @@ static class CustomCommandResolverConfiguration {
153153

154154
@Bean
155155
CommandResolver customCommandResolver() {
156-
return () -> Collections.emptyList();
156+
return Collections::emptyList;
157157
}
158158
}
159159

@@ -176,9 +176,7 @@ CommandRegistration commandRegistration() {
176176
return CommandRegistration.builder()
177177
.command("customcommand")
178178
.withTarget()
179-
.function(ctx -> {
180-
return null;
181-
})
179+
.function(ctx -> null)
182180
.and()
183181
.build();
184182
}

spring-shell-autoconfigure/src/test/java/org/springframework/shell/boot/JLineShellAutoConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 the original author or authors.
2+
* Copyright 2022-present the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-shell-autoconfigure/src/test/java/org/springframework/shell/boot/LineReaderAutoConfigurationTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 the original author or authors.
2+
* Copyright 2022-present the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,13 +36,13 @@
3636
import static org.mockito.Mockito.mock;
3737
import static org.mockito.Mockito.when;
3838

39-
public class LineReaderAutoConfigurationTests {
39+
class LineReaderAutoConfigurationTests {
4040

4141
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
4242
.withConfiguration(AutoConfigurations.of(LineReaderAutoConfiguration.class));
4343

4444
@Test
45-
public void testLineReaderCreated() {
45+
void testLineReaderCreated() {
4646
this.contextRunner
4747
.withUserConfiguration(MockConfiguration.class)
4848
.run(context -> {
@@ -53,7 +53,7 @@ public void testLineReaderCreated() {
5353
}
5454

5555
@Test
56-
public void testLineReaderCreatedNoHistoryFile() {
56+
void testLineReaderCreatedNoHistoryFile() {
5757
this.contextRunner
5858
.withUserConfiguration(MockConfiguration.class)
5959
.withPropertyValues("spring.shell.history.enabled=false")
@@ -65,7 +65,7 @@ public void testLineReaderCreatedNoHistoryFile() {
6565
}
6666

6767
@Test
68-
public void testLineReaderCreatedCustomHistoryFile() {
68+
void testLineReaderCreatedCustomHistoryFile() {
6969
this.contextRunner
7070
.withUserConfiguration(MockConfiguration.class)
7171
.withPropertyValues("spring.shell.history.name=fakehistory.txt")

spring-shell-autoconfigure/src/test/java/org/springframework/shell/boot/ParameterResolverAutoConfigurationTests.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 the original author or authors.
2+
* Copyright 2022-present the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,33 +28,32 @@
2828

2929
import static org.assertj.core.api.Assertions.assertThat;
3030

31-
public class ParameterResolverAutoConfigurationTests {
31+
class ParameterResolverAutoConfigurationTests {
3232

3333
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
3434
.withConfiguration(AutoConfigurations.of(ParameterResolverAutoConfiguration.class));
3535

3636
@Test
3737
void defaultCompletionResolverExists() {
3838
this.contextRunner.withUserConfiguration(CustomShellConversionServiceConfiguration.class)
39-
.run((context) -> {
39+
.run(context -> {
4040
assertThat(context).hasSingleBean(CompletionResolver.class);
4141
});
4242
}
4343

4444
@Test
4545
void defaultCommandExecutionHandlerMethodArgumentResolversExists() {
4646
this.contextRunner.withUserConfiguration(CustomShellConversionServiceConfiguration.class)
47-
.run((context) -> {
48-
assertThat(context).hasSingleBean(CommandExecutionHandlerMethodArgumentResolvers.class);
49-
});
47+
.run(context -> assertThat(context)
48+
.hasSingleBean(CommandExecutionHandlerMethodArgumentResolvers.class));
5049
}
5150

5251
@Configuration
5352
static class CustomShellConversionServiceConfiguration {
5453

5554
@Bean
5655
ShellConversionServiceSupplier shellConversionServiceSupplier() {
57-
return () -> new DefaultConversionService();
56+
return DefaultConversionService::new;
5857
}
5958
}
6059
}

spring-shell-autoconfigure/src/test/java/org/springframework/shell/boot/ShellRunnerAutoConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022-2024 the original author or authors.
2+
* Copyright 2022-present the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-shell-autoconfigure/src/test/java/org/springframework/shell/boot/SpringShellPropertiesTests.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021-2024 the original author or authors.
2+
* Copyright 2021-present the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,15 +24,15 @@
2424

2525
import static org.assertj.core.api.Assertions.assertThat;
2626

27-
public class SpringShellPropertiesTests {
27+
class SpringShellPropertiesTests {
2828

2929
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner();
3030

3131
@Test
32-
public void defaultNoPropertiesSet() {
32+
void defaultNoPropertiesSet() {
3333
this.contextRunner
3434
.withUserConfiguration(Config1.class)
35-
.run((context) -> {
35+
.run(context -> {
3636
SpringShellProperties properties = context.getBean(SpringShellProperties.class);
3737
assertThat(properties.getHistory().isEnabled()).isTrue();
3838
assertThat(properties.getHistory().getName()).isNull();
@@ -75,7 +75,7 @@ public void defaultNoPropertiesSet() {
7575
}
7676

7777
@Test
78-
public void setProperties() {
78+
void setProperties() {
7979
this.contextRunner
8080
.withPropertyValues("spring.shell.history.enabled=false")
8181
.withPropertyValues("spring.shell.history.name=fakename")
@@ -115,7 +115,7 @@ public void setProperties() {
115115
.withPropertyValues("spring.shell.option.naming.case-type=camel")
116116
.withPropertyValues("spring.shell.context.close=true")
117117
.withUserConfiguration(Config1.class)
118-
.run((context) -> {
118+
.run(context -> {
119119
SpringShellProperties properties = context.getBean(SpringShellProperties.class);
120120
assertThat(properties.getHistory().isEnabled()).isFalse();
121121
assertThat(properties.getHistory().getName()).isEqualTo("fakename");
@@ -159,12 +159,12 @@ public void setProperties() {
159159

160160

161161
@Test
162-
public void essentiallyUnset() {
162+
void essentiallyUnset() {
163163
this.contextRunner
164164
.withPropertyValues("spring.shell.help.long-names=")
165165
.withPropertyValues("spring.shell.help.short-names=")
166166
.withUserConfiguration(Config1.class)
167-
.run((context) -> {
167+
.run(context -> {
168168
SpringShellProperties properties = context.getBean(SpringShellProperties.class);
169169
assertThat(properties.getHelp().getLongNames()).isEmpty();
170170
assertThat(properties.getHelp().getShortNames()).isEmpty();

spring-shell-autoconfigure/src/test/java/org/springframework/shell/boot/StandardCommandsAutoConfigurationTests.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 the original author or authors.
2+
* Copyright 2022-present the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,31 +28,28 @@
2828

2929
import static org.assertj.core.api.Assertions.assertThat;
3030

31-
public class StandardCommandsAutoConfigurationTests {
31+
class StandardCommandsAutoConfigurationTests {
3232

3333
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
3434
.withConfiguration(AutoConfigurations.of(StandardCommandsAutoConfiguration.class));
3535

3636
@Test
37-
public void testCompletionCommand() {
37+
void testCompletionCommand() {
3838
this.contextRunner
3939
.with(disableCommands("help", "clear", "quit", "stacktrace", "script", "history"))
40-
.run((context) -> {assertThat(context).doesNotHaveBean(Completion.class);
41-
});
40+
.run(context -> assertThat(context).doesNotHaveBean(Completion.class));
4241
this.contextRunner
4342
.with(disableCommands("help", "clear", "quit", "stacktrace", "script", "history", "completion"))
4443
.withPropertyValues("spring.shell.command.completion.root-command=fake")
45-
.run((context) -> {assertThat(context).doesNotHaveBean(Completion.class);
46-
});
44+
.run(context -> assertThat(context).doesNotHaveBean(Completion.class));
4745
this.contextRunner
4846
.with(disableCommands("help", "clear", "quit", "stacktrace", "script", "history"))
4947
.withPropertyValues("spring.shell.command.completion.root-command=fake")
50-
.run((context) -> {assertThat(context).hasSingleBean(Completion.class);
51-
});
48+
.run(context -> assertThat(context).hasSingleBean(Completion.class));
5249
}
5350

5451
@Test
55-
public void testHelpCommand() {
52+
void testHelpCommand() {
5653
this.contextRunner
5754
.with(disableCommands("clear", "quit", "stacktrace", "script", "history", "completion"))
5855
.withPropertyValues("spring.shell.command.help.grouping-mode=flat")
@@ -67,7 +64,7 @@ public void testHelpCommand() {
6764
}
6865

6966
private static Function<ApplicationContextRunner, ApplicationContextRunner> disableCommands(String... commands) {
70-
return (cr) -> {
67+
return cr -> {
7168
for (String command : commands) {
7269
cr = cr.withPropertyValues(String.format("spring.shell.command.%s.enabled=false", command));
7370
}

spring-shell-autoconfigure/src/test/java/org/springframework/shell/boot/TerminalUIAutoConfigurationTests.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 the original author or authors.
2+
* Copyright 2023-present the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,17 +43,15 @@ class TerminalUIAutoConfigurationTests {
4343
.withConfiguration(AutoConfigurations.of(TerminalUIAutoConfiguration.class));
4444

4545
@Test
46-
public void terminalUICreated() {
46+
void terminalUICreated() {
4747
this.contextRunner
4848
.withUserConfiguration(MockConfiguration.class)
49-
.run(context -> {
50-
assertThat(context).hasSingleBean(TerminalUIBuilder.class);
51-
});
49+
.run(context -> assertThat(context).hasSingleBean(TerminalUIBuilder.class));
5250
}
5351

5452
@Test
5553
@SuppressWarnings("unchecked")
56-
public void canCustomize() {
54+
void canCustomize() {
5755
this.contextRunner
5856
.withUserConfiguration(TestConfiguration.class, MockConfiguration.class)
5957
.run(context -> {
@@ -81,9 +79,7 @@ ThemeResolver mockThemeResolver() {
8179

8280
@Bean
8381
ThemeActive themeActive() {
84-
return () -> {
85-
return "default";
86-
};
82+
return () -> "default";
8783
}
8884

8985
}

spring-shell-autoconfigure/src/test/java/org/springframework/shell/boot/ThemingAutoConfigurationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022-2024 the original author or authors.
2+
* Copyright 2022-present the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@
3737

3838
import static org.assertj.core.api.Assertions.assertThat;
3939

40-
public class ThemingAutoConfigurationTests {
40+
class ThemingAutoConfigurationTests {
4141

4242
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
4343
.withConfiguration(AutoConfigurations.of(ThemingAutoConfiguration.class));
@@ -58,7 +58,7 @@ void createsDefaultBeans() {
5858
}
5959

6060
@Test
61-
public void canRegisterCustomTheme() {
61+
void canRegisterCustomTheme() {
6262
this.contextRunner
6363
.withUserConfiguration(CustomThemeConfig.class)
6464
.run(context -> {
@@ -113,7 +113,7 @@ public ThemeAssert(Theme actual) {
113113

114114
public ThemeAssert hasName(String... names) {
115115
isNotNull();
116-
boolean match = Stream.of(names).filter(n -> actual.getName().equals(n)).findFirst().isPresent();
116+
boolean match = Stream.of(names).anyMatch(n -> actual.getName().equals(n));
117117
if (!match) {
118118
failWithMessage("Expected theme to have names %s but was %s",
119119
StringUtils.arrayToCommaDelimitedString(names), actual.getName());

0 commit comments

Comments
 (0)