Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 the original author or authors.
* Copyright 2023-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,7 +22,7 @@

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

public class ApplicationRunnerAutoConfigurationTests {
class ApplicationRunnerAutoConfigurationTests {

private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(ApplicationRunnerAutoConfiguration.class));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2024 the original author or authors.
* Copyright 2022-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,7 +33,7 @@

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

public class CommandCatalogAutoConfigurationTests {
class CommandCatalogAutoConfigurationTests {

private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(CommandCatalogAutoConfiguration.class,
Expand Down Expand Up @@ -66,7 +66,7 @@ void customCommandCatalog() {
@Test
void registerCommandRegistration() {
this.contextRunner.withUserConfiguration(CustomCommandRegistrationConfiguration.class)
.run((context) -> {
.run(context -> {
CommandCatalog commandCatalog = context.getBean(CommandCatalog.class);
assertThat(commandCatalog.getRegistrations().get("customcommand")).isNotNull();
});
Expand Down Expand Up @@ -153,7 +153,7 @@ static class CustomCommandResolverConfiguration {

@Bean
CommandResolver customCommandResolver() {
return () -> Collections.emptyList();
return Collections::emptyList;
}
}

Expand All @@ -176,9 +176,7 @@ CommandRegistration commandRegistration() {
return CommandRegistration.builder()
.command("customcommand")
.withTarget()
.function(ctx -> {
return null;
})
.function(ctx -> null)
.and()
.build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 the original author or authors.
* Copyright 2022-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 the original author or authors.
* Copyright 2022-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,13 +36,13 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class LineReaderAutoConfigurationTests {
class LineReaderAutoConfigurationTests {

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

@Test
public void testLineReaderCreated() {
void testLineReaderCreated() {
this.contextRunner
.withUserConfiguration(MockConfiguration.class)
.run(context -> {
Expand All @@ -53,7 +53,7 @@ public void testLineReaderCreated() {
}

@Test
public void testLineReaderCreatedNoHistoryFile() {
void testLineReaderCreatedNoHistoryFile() {
this.contextRunner
.withUserConfiguration(MockConfiguration.class)
.withPropertyValues("spring.shell.history.enabled=false")
Expand All @@ -65,7 +65,7 @@ public void testLineReaderCreatedNoHistoryFile() {
}

@Test
public void testLineReaderCreatedCustomHistoryFile() {
void testLineReaderCreatedCustomHistoryFile() {
this.contextRunner
.withUserConfiguration(MockConfiguration.class)
.withPropertyValues("spring.shell.history.name=fakehistory.txt")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 the original author or authors.
* Copyright 2022-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,33 +28,32 @@

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

public class ParameterResolverAutoConfigurationTests {
class ParameterResolverAutoConfigurationTests {

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

@Test
void defaultCompletionResolverExists() {
this.contextRunner.withUserConfiguration(CustomShellConversionServiceConfiguration.class)
.run((context) -> {
.run(context -> {
assertThat(context).hasSingleBean(CompletionResolver.class);
});
}

@Test
void defaultCommandExecutionHandlerMethodArgumentResolversExists() {
this.contextRunner.withUserConfiguration(CustomShellConversionServiceConfiguration.class)
.run((context) -> {
assertThat(context).hasSingleBean(CommandExecutionHandlerMethodArgumentResolvers.class);
});
.run(context -> assertThat(context)
.hasSingleBean(CommandExecutionHandlerMethodArgumentResolvers.class));
}

@Configuration
static class CustomShellConversionServiceConfiguration {

@Bean
ShellConversionServiceSupplier shellConversionServiceSupplier() {
return () -> new DefaultConversionService();
return DefaultConversionService::new;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2024 the original author or authors.
* Copyright 2022-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2024 the original author or authors.
* Copyright 2021-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,15 +24,15 @@

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

public class SpringShellPropertiesTests {
class SpringShellPropertiesTests {

private final ApplicationContextRunner contextRunner = new ApplicationContextRunner();

@Test
public void defaultNoPropertiesSet() {
void defaultNoPropertiesSet() {
this.contextRunner
.withUserConfiguration(Config1.class)
.run((context) -> {
.run(context -> {
SpringShellProperties properties = context.getBean(SpringShellProperties.class);
assertThat(properties.getHistory().isEnabled()).isTrue();
assertThat(properties.getHistory().getName()).isNull();
Expand Down Expand Up @@ -75,7 +75,7 @@ public void defaultNoPropertiesSet() {
}

@Test
public void setProperties() {
void setProperties() {
this.contextRunner
.withPropertyValues("spring.shell.history.enabled=false")
.withPropertyValues("spring.shell.history.name=fakename")
Expand Down Expand Up @@ -115,7 +115,7 @@ public void setProperties() {
.withPropertyValues("spring.shell.option.naming.case-type=camel")
.withPropertyValues("spring.shell.context.close=true")
.withUserConfiguration(Config1.class)
.run((context) -> {
.run(context -> {
SpringShellProperties properties = context.getBean(SpringShellProperties.class);
assertThat(properties.getHistory().isEnabled()).isFalse();
assertThat(properties.getHistory().getName()).isEqualTo("fakename");
Expand Down Expand Up @@ -159,12 +159,12 @@ public void setProperties() {


@Test
public void essentiallyUnset() {
void essentiallyUnset() {
this.contextRunner
.withPropertyValues("spring.shell.help.long-names=")
.withPropertyValues("spring.shell.help.short-names=")
.withUserConfiguration(Config1.class)
.run((context) -> {
.run(context -> {
SpringShellProperties properties = context.getBean(SpringShellProperties.class);
assertThat(properties.getHelp().getLongNames()).isEmpty();
assertThat(properties.getHelp().getShortNames()).isEmpty();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 the original author or authors.
* Copyright 2022-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,31 +28,28 @@

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

public class StandardCommandsAutoConfigurationTests {
class StandardCommandsAutoConfigurationTests {

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

@Test
public void testCompletionCommand() {
void testCompletionCommand() {
this.contextRunner
.with(disableCommands("help", "clear", "quit", "stacktrace", "script", "history"))
.run((context) -> {assertThat(context).doesNotHaveBean(Completion.class);
});
.run(context -> assertThat(context).doesNotHaveBean(Completion.class));
this.contextRunner
.with(disableCommands("help", "clear", "quit", "stacktrace", "script", "history", "completion"))
.withPropertyValues("spring.shell.command.completion.root-command=fake")
.run((context) -> {assertThat(context).doesNotHaveBean(Completion.class);
});
.run(context -> assertThat(context).doesNotHaveBean(Completion.class));
this.contextRunner
.with(disableCommands("help", "clear", "quit", "stacktrace", "script", "history"))
.withPropertyValues("spring.shell.command.completion.root-command=fake")
.run((context) -> {assertThat(context).hasSingleBean(Completion.class);
});
.run(context -> assertThat(context).hasSingleBean(Completion.class));
}

@Test
public void testHelpCommand() {
void testHelpCommand() {
this.contextRunner
.with(disableCommands("clear", "quit", "stacktrace", "script", "history", "completion"))
.withPropertyValues("spring.shell.command.help.grouping-mode=flat")
Expand All @@ -67,7 +64,7 @@ public void testHelpCommand() {
}

private static Function<ApplicationContextRunner, ApplicationContextRunner> disableCommands(String... commands) {
return (cr) -> {
return cr -> {
for (String command : commands) {
cr = cr.withPropertyValues(String.format("spring.shell.command.%s.enabled=false", command));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 the original author or authors.
* Copyright 2023-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -43,17 +43,15 @@ class TerminalUIAutoConfigurationTests {
.withConfiguration(AutoConfigurations.of(TerminalUIAutoConfiguration.class));

@Test
public void terminalUICreated() {
void terminalUICreated() {
this.contextRunner
.withUserConfiguration(MockConfiguration.class)
.run(context -> {
assertThat(context).hasSingleBean(TerminalUIBuilder.class);
});
.run(context -> assertThat(context).hasSingleBean(TerminalUIBuilder.class));
}

@Test
@SuppressWarnings("unchecked")
public void canCustomize() {
void canCustomize() {
this.contextRunner
.withUserConfiguration(TestConfiguration.class, MockConfiguration.class)
.run(context -> {
Expand Down Expand Up @@ -81,9 +79,7 @@ ThemeResolver mockThemeResolver() {

@Bean
ThemeActive themeActive() {
return () -> {
return "default";
};
return () -> "default";
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2024 the original author or authors.
* Copyright 2022-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,7 +37,7 @@

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

public class ThemingAutoConfigurationTests {
class ThemingAutoConfigurationTests {

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

@Test
public void canRegisterCustomTheme() {
void canRegisterCustomTheme() {
this.contextRunner
.withUserConfiguration(CustomThemeConfig.class)
.run(context -> {
Expand Down Expand Up @@ -113,7 +113,7 @@ public ThemeAssert(Theme actual) {

public ThemeAssert hasName(String... names) {
isNotNull();
boolean match = Stream.of(names).filter(n -> actual.getName().equals(n)).findFirst().isPresent();
boolean match = Stream.of(names).anyMatch(n -> actual.getName().equals(n));
if (!match) {
failWithMessage("Expected theme to have names %s but was %s",
StringUtils.arrayToCommaDelimitedString(names), actual.getName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 the original author or authors.
* Copyright 2022-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,15 +27,15 @@

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

public class UserConfigAutoConfigurationTests {
class UserConfigAutoConfigurationTests {

private final static Logger log = LoggerFactory.getLogger(UserConfigAutoConfigurationTests.class);
private static final Logger log = LoggerFactory.getLogger(UserConfigAutoConfigurationTests.class);

private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(UserConfigAutoConfiguration.class));

@Test
public void testDefaults() {
void testDefaults() {
this.contextRunner
.run(context -> {
assertThat(context).hasSingleBean(UserConfigPathProvider.class);
Expand All @@ -47,7 +47,7 @@ public void testDefaults() {
}

@Test
public void testUserConfig() {
void testUserConfig() {
this.contextRunner
.withPropertyValues("spring.shell.config.location={userconfig}/test")
.run(context -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 the original author or authors.
* Copyright 2023-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,7 +31,7 @@ class AvailabilityReflectiveProcessorTests {
private final ReflectionHints hints = new ReflectionHints();

@Test
void registerReflectiveHintsForMethod() throws NoSuchMethodException {
void registerReflectiveHintsForMethod() {
processor.registerReflectionHints(hints, SampleBean.class);
assertThat(hints.typeHints()).singleElement().satisfies(typeHint -> {
assertThat(typeHint.getType()).isEqualTo(TypeReference.of(SampleBean.class));
Expand Down
Loading