Skip to content

Commit d578f28

Browse files
committed
Polish
1 parent 05311ff commit d578f28

File tree

6 files changed

+11
-8
lines changed

6 files changed

+11
-8
lines changed

spring-shell-core/src/main/java/org/springframework/shell/Utils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static MethodParameter createMethodParameter(Executable executable, int i
7676
if (executable instanceof Method) {
7777
methodParameter = new MethodParameter((Method) executable, i);
7878
} else if (executable instanceof Constructor){
79-
methodParameter = new MethodParameter((Constructor) executable, i);
79+
methodParameter = new MethodParameter((Constructor<?>) executable, i);
8080
} else {
8181
throw new IllegalArgumentException("Unsupported Executable: " + executable);
8282
}

spring-shell-core/src/test/java/org/springframework/shell/ShellTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void setUp() {
7272
@Test
7373
public void commandMatch() throws IOException {
7474
when(parameterResolver.supports(any())).thenReturn(true);
75-
when(inputProvider.readInput()).thenReturn(() -> "hello world how are you doing ?", null);
75+
when(inputProvider.readInput()).thenReturn(() -> "hello world how are you doing ?");
7676
valueResult = new ValueResult(null, "test");
7777
when(parameterResolver.resolve(any(), any())).thenReturn(valueResult);
7878
doThrow(new Exit()).when(resultHandlerService).handle(any());
@@ -92,7 +92,7 @@ public void commandMatch() throws IOException {
9292

9393
@Test
9494
public void commandNotFound() throws IOException {
95-
when(inputProvider.readInput()).thenReturn(() -> "hello world how are you doing ?", null);
95+
when(inputProvider.readInput()).thenReturn(() -> "hello world how are you doing ?");
9696
doThrow(new Exit()).when(resultHandlerService).handle(isA(CommandNotFound.class));
9797

9898
shell.methodTargets = Collections.singletonMap("bonjour", MethodTarget.of("helloWorld", this, new Command.Help("Say hello")));
@@ -109,7 +109,7 @@ public void commandNotFound() throws IOException {
109109
@Test
110110
// See https://github.com/spring-projects/spring-shell/issues/142
111111
public void commandNotFoundPrefix() throws IOException {
112-
when(inputProvider.readInput()).thenReturn(() -> "helloworld how are you doing ?", null);
112+
when(inputProvider.readInput()).thenReturn(() -> "helloworld how are you doing ?");
113113
doThrow(new Exit()).when(resultHandlerService).handle(isA(CommandNotFound.class));
114114

115115
shell.methodTargets = Collections.singletonMap("hello", MethodTarget.of("helloWorld", this, new Command.Help("Say hello")));
@@ -146,7 +146,7 @@ public void noCommand() throws IOException {
146146

147147
@Test
148148
public void commandThrowingAnException() throws IOException {
149-
when(inputProvider.readInput()).thenReturn(() -> "fail", null);
149+
when(inputProvider.readInput()).thenReturn(() -> "fail");
150150
doThrow(new Exit()).when(resultHandlerService).handle(isA(SomeException.class));
151151

152152
shell.methodTargets = Collections.singletonMap("fail", MethodTarget.of("failing", this, new Command.Help("Will throw an exception")));
@@ -231,10 +231,12 @@ public void commandNameCompletion() throws Exception {
231231
assertThat(proposals).isEmpty();
232232
}
233233

234+
@SuppressWarnings("unused")
234235
private void helloWorld(String a) {
235236
invoked = true;
236237
}
237238

239+
@SuppressWarnings("unused")
238240
private String failing() {
239241
invoked = true;
240242
throw new SomeException();

spring-shell-standard/src/main/java/org/springframework/shell/standard/EnumValueProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public boolean supports(MethodParameter parameter, CompletionContext completionC
3838
public List<CompletionProposal> complete(MethodParameter parameter, CompletionContext completionContext, String[] hints) {
3939
List<CompletionProposal> result = new ArrayList<>();
4040
for (Object v : parameter.getParameterType().getEnumConstants()) {
41-
Enum e = (Enum) v;
41+
Enum<?> e = (Enum<?>) v;
4242
String prefix = completionContext.currentWordUpToCursor();
4343
if (prefix == null) {
4444
prefix = "";

spring-shell-standard/src/main/java/org/springframework/shell/standard/StandardParameterResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ public List<CompletionProposal> complete(MethodParameter methodParameter, Comple
380380
List<CompletionProposal> result = new ArrayList<>();
381381

382382
Object value = convertRawValue(parameterRawValue, methodParameter);
383-
if (value instanceof Collection && ((Collection) value).size() == arity
383+
if (value instanceof Collection && ((Collection<?>) value).size() == arity
384384
|| (ObjectUtils.isArray(value) && Array.getLength(value) == arity)) {
385385
// We're done already
386386
return result;

spring-shell-standard/src/test/java/org/springframework/shell/standard/CommandValueProviderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class CommandValueProviderTest {
5151

5252
@BeforeEach
5353
public void setUp() {
54-
MockitoAnnotations.initMocks(this);
54+
MockitoAnnotations.openMocks(this);
5555
}
5656

5757
@Test

spring-shell-test-samples/src/test/java/com/example/test/BaseCalculatorTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414
public class BaseCalculatorTest {
1515

16+
@SuppressWarnings("unchecked")
1617
protected <T> T invoke(final MethodTarget methodTarget, final Object... args) {
1718
return (T) invokeMethod(methodTarget.getMethod(), methodTarget.getBean(), args);
1819
}

0 commit comments

Comments
 (0)