Polish
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -38,7 +38,7 @@ public class EnumValueProvider implements ValueProvider {
|
||||
public List<CompletionProposal> complete(MethodParameter parameter, CompletionContext completionContext, String[] hints) {
|
||||
List<CompletionProposal> 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 = "";
|
||||
|
||||
@@ -380,7 +380,7 @@ public class StandardParameterResolver implements ParameterResolver {
|
||||
List<CompletionProposal> 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;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class CommandValueProviderTest {
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
MockitoAnnotations.openMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.springframework.shell.MethodTarget;
|
||||
*/
|
||||
public class BaseCalculatorTest {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T> T invoke(final MethodTarget methodTarget, final Object... args) {
|
||||
return (T) invokeMethod(methodTarget.getMethod(), methodTarget.getBean(), args);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user