diff --git a/spring-shell-core/src/main/java/org/springframework/shell/Utils.java b/spring-shell-core/src/main/java/org/springframework/shell/Utils.java index d991a620..28d972d0 100644 --- a/spring-shell-core/src/main/java/org/springframework/shell/Utils.java +++ b/spring-shell-core/src/main/java/org/springframework/shell/Utils.java @@ -76,7 +76,7 @@ public class Utils { if (executable instanceof Method) { methodParameter = new MethodParameter((Method) executable, i); } else if (executable instanceof Constructor){ - methodParameter = new MethodParameter((Constructor) executable, i); + methodParameter = new MethodParameter((Constructor) executable, i); } else { throw new IllegalArgumentException("Unsupported Executable: " + executable); } diff --git a/spring-shell-core/src/test/java/org/springframework/shell/ShellTest.java b/spring-shell-core/src/test/java/org/springframework/shell/ShellTest.java index 719030a6..c146a1f2 100644 --- a/spring-shell-core/src/test/java/org/springframework/shell/ShellTest.java +++ b/spring-shell-core/src/test/java/org/springframework/shell/ShellTest.java @@ -72,7 +72,7 @@ public class ShellTest { @Test public void commandMatch() throws IOException { when(parameterResolver.supports(any())).thenReturn(true); - when(inputProvider.readInput()).thenReturn(() -> "hello world how are you doing ?", null); + when(inputProvider.readInput()).thenReturn(() -> "hello world how are you doing ?"); valueResult = new ValueResult(null, "test"); when(parameterResolver.resolve(any(), any())).thenReturn(valueResult); doThrow(new Exit()).when(resultHandlerService).handle(any()); @@ -92,7 +92,7 @@ public class ShellTest { @Test public void commandNotFound() throws IOException { - when(inputProvider.readInput()).thenReturn(() -> "hello world how are you doing ?", null); + when(inputProvider.readInput()).thenReturn(() -> "hello world how are you doing ?"); doThrow(new Exit()).when(resultHandlerService).handle(isA(CommandNotFound.class)); shell.methodTargets = Collections.singletonMap("bonjour", MethodTarget.of("helloWorld", this, new Command.Help("Say hello"))); @@ -109,7 +109,7 @@ public class ShellTest { @Test // See https://github.com/spring-projects/spring-shell/issues/142 public void commandNotFoundPrefix() throws IOException { - when(inputProvider.readInput()).thenReturn(() -> "helloworld how are you doing ?", null); + when(inputProvider.readInput()).thenReturn(() -> "helloworld how are you doing ?"); doThrow(new Exit()).when(resultHandlerService).handle(isA(CommandNotFound.class)); shell.methodTargets = Collections.singletonMap("hello", MethodTarget.of("helloWorld", this, new Command.Help("Say hello"))); @@ -146,7 +146,7 @@ public class ShellTest { @Test public void commandThrowingAnException() throws IOException { - when(inputProvider.readInput()).thenReturn(() -> "fail", null); + when(inputProvider.readInput()).thenReturn(() -> "fail"); doThrow(new Exit()).when(resultHandlerService).handle(isA(SomeException.class)); shell.methodTargets = Collections.singletonMap("fail", MethodTarget.of("failing", this, new Command.Help("Will throw an exception"))); @@ -231,10 +231,12 @@ public class ShellTest { assertThat(proposals).isEmpty(); } + @SuppressWarnings("unused") private void helloWorld(String a) { invoked = true; } + @SuppressWarnings("unused") private String failing() { invoked = true; throw new SomeException(); diff --git a/spring-shell-standard/src/main/java/org/springframework/shell/standard/EnumValueProvider.java b/spring-shell-standard/src/main/java/org/springframework/shell/standard/EnumValueProvider.java index 789f3ee8..811c491a 100644 --- a/spring-shell-standard/src/main/java/org/springframework/shell/standard/EnumValueProvider.java +++ b/spring-shell-standard/src/main/java/org/springframework/shell/standard/EnumValueProvider.java @@ -38,7 +38,7 @@ public class EnumValueProvider implements ValueProvider { public List complete(MethodParameter parameter, CompletionContext completionContext, String[] hints) { List result = new ArrayList<>(); for (Object v : parameter.getParameterType().getEnumConstants()) { - Enum e = (Enum) v; + Enum e = (Enum) v; String prefix = completionContext.currentWordUpToCursor(); if (prefix == null) { prefix = ""; diff --git a/spring-shell-standard/src/main/java/org/springframework/shell/standard/StandardParameterResolver.java b/spring-shell-standard/src/main/java/org/springframework/shell/standard/StandardParameterResolver.java index 05183351..82bb7bf1 100644 --- a/spring-shell-standard/src/main/java/org/springframework/shell/standard/StandardParameterResolver.java +++ b/spring-shell-standard/src/main/java/org/springframework/shell/standard/StandardParameterResolver.java @@ -380,7 +380,7 @@ public class StandardParameterResolver implements ParameterResolver { List result = new ArrayList<>(); Object value = convertRawValue(parameterRawValue, methodParameter); - if (value instanceof Collection && ((Collection) value).size() == arity + if (value instanceof Collection && ((Collection) value).size() == arity || (ObjectUtils.isArray(value) && Array.getLength(value) == arity)) { // We're done already return result; diff --git a/spring-shell-standard/src/test/java/org/springframework/shell/standard/CommandValueProviderTest.java b/spring-shell-standard/src/test/java/org/springframework/shell/standard/CommandValueProviderTest.java index 698c81a9..1ab74e7a 100644 --- a/spring-shell-standard/src/test/java/org/springframework/shell/standard/CommandValueProviderTest.java +++ b/spring-shell-standard/src/test/java/org/springframework/shell/standard/CommandValueProviderTest.java @@ -51,7 +51,7 @@ public class CommandValueProviderTest { @BeforeEach public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); } @Test diff --git a/spring-shell-test-samples/src/test/java/com/example/test/BaseCalculatorTest.java b/spring-shell-test-samples/src/test/java/com/example/test/BaseCalculatorTest.java index ace8c039..afb05f10 100644 --- a/spring-shell-test-samples/src/test/java/com/example/test/BaseCalculatorTest.java +++ b/spring-shell-test-samples/src/test/java/com/example/test/BaseCalculatorTest.java @@ -13,6 +13,7 @@ import org.springframework.shell.MethodTarget; */ public class BaseCalculatorTest { + @SuppressWarnings("unchecked") protected T invoke(final MethodTarget methodTarget, final Object... args) { return (T) invokeMethod(methodTarget.getMethod(), methodTarget.getBean(), args); }