Better e2e tests coverage
- Add integration tests for e2e samples. - Add some missing commands for new annotation system. - Fixes #654
This commit is contained in:
@@ -20,6 +20,8 @@ import java.util.Arrays;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.shell.command.CommandRegistration;
|
||||
import org.springframework.shell.command.CommandRegistration.OptionArity;
|
||||
import org.springframework.shell.command.annotation.Command;
|
||||
import org.springframework.shell.command.annotation.Option;
|
||||
import org.springframework.shell.standard.ShellComponent;
|
||||
import org.springframework.shell.standard.ShellMethod;
|
||||
import org.springframework.shell.standard.ShellOption;
|
||||
@@ -58,6 +60,34 @@ public class ArityCommands {
|
||||
|
||||
}
|
||||
|
||||
@Command(command = BaseE2ECommands.ANNO, group = BaseE2ECommands.GROUP)
|
||||
public static class Annotation extends BaseE2ECommands {
|
||||
|
||||
@Command(command = "arity-boolean-default-true")
|
||||
public String testArityBooleanDefaultTrueAnnotation(
|
||||
@Option(longNames = "overwrite", defaultValue = "true", arity = OptionArity.ZERO_OR_ONE)
|
||||
Boolean overwrite
|
||||
) {
|
||||
return "Hello " + overwrite;
|
||||
}
|
||||
|
||||
@Command(command = "arity-string-array")
|
||||
public String testArityStringArrayAnnotation(
|
||||
@Option(longNames = "arg1", defaultValue = "true", arity = OptionArity.ZERO_OR_MORE)
|
||||
String[] arg1
|
||||
) {
|
||||
return "Hello " + Arrays.asList(arg1);
|
||||
}
|
||||
|
||||
@Command(command = "arity-float-array")
|
||||
public String testArityFloatArrayAnnotation(
|
||||
@Option(longNames = "arg1", defaultValue = "true", arity = OptionArity.ZERO_OR_MORE)
|
||||
float[] arg1
|
||||
) {
|
||||
return "Hello " + stringOfFloats(arg1);
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
public static class Registration extends BaseE2ECommands {
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ package org.springframework.shell.samples.e2e;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.shell.command.CommandRegistration;
|
||||
import org.springframework.shell.command.annotation.Command;
|
||||
import org.springframework.shell.command.annotation.Option;
|
||||
import org.springframework.shell.standard.ShellComponent;
|
||||
import org.springframework.shell.standard.ShellMethod;
|
||||
import org.springframework.shell.standard.ShellOption;
|
||||
@@ -62,6 +64,42 @@ public class DefaultValueCommands {
|
||||
}
|
||||
}
|
||||
|
||||
@Command(command = BaseE2ECommands.ANNO, group = BaseE2ECommands.GROUP)
|
||||
public static class Annotation extends BaseE2ECommands {
|
||||
|
||||
@Command(command = "default-value")
|
||||
public String testDefaultValueAnnotation(
|
||||
@Option(longNames = "arg1", defaultValue = "hi")
|
||||
String arg1
|
||||
) {
|
||||
return "Hello " + arg1;
|
||||
}
|
||||
|
||||
@Command(command = "default-value-boolean1")
|
||||
public String testDefaultValueBoolean1Annotation(
|
||||
@Option(longNames = "arg1", defaultValue = "false")
|
||||
boolean arg1
|
||||
) {
|
||||
return "Hello " + arg1;
|
||||
}
|
||||
|
||||
@Command(command = "default-value-boolean2")
|
||||
public String testDefaultValueBoolean2Annotation(
|
||||
@Option(longNames = "arg1", defaultValue = "true")
|
||||
boolean arg1
|
||||
) {
|
||||
return "Hello " + arg1;
|
||||
}
|
||||
|
||||
@Command(command = "default-value-boolean3")
|
||||
public String testDefaultValueBoolean3Annotation(
|
||||
@Option(longNames = "arg1")
|
||||
boolean arg1
|
||||
) {
|
||||
return "Hello " + arg1;
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
public static class Registration extends BaseE2ECommands {
|
||||
|
||||
|
||||
@@ -167,7 +167,8 @@ public class ErrorHandlingCommands {
|
||||
return CommandHandlingResult.of("Hi, handled custom exception 3\n", 3);
|
||||
}
|
||||
if (e instanceof CustomException4) {
|
||||
return CommandHandlingResult.of("Hi, handled custom exception\n", 42);
|
||||
String msg = String.format("Hi, handled custom exception %s\n", e);
|
||||
return CommandHandlingResult.of(msg, 42);
|
||||
}
|
||||
if (e instanceof IllegalArgumentException) {
|
||||
return CommandHandlingResult.of("Hi, handled illegal exception\n", 42);
|
||||
|
||||
@@ -17,10 +17,21 @@ package org.springframework.shell.samples.e2e;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.shell.command.CommandRegistration;
|
||||
import org.springframework.shell.command.annotation.Command;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
public class HiddenCommands {
|
||||
|
||||
@Command(command = BaseE2ECommands.ANNO, group = BaseE2ECommands.GROUP)
|
||||
public static class Annotation extends BaseE2ECommands {
|
||||
|
||||
@Command(command = "hidden-1", hidden = true)
|
||||
public String testHidden1Annotation(
|
||||
) {
|
||||
return "Hello from hidden command";
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
public static class Registration extends BaseE2ECommands {
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ package org.springframework.shell.samples.e2e;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.shell.command.CommandRegistration;
|
||||
import org.springframework.shell.command.annotation.Command;
|
||||
import org.springframework.shell.command.annotation.Option;
|
||||
import org.springframework.shell.standard.ShellComponent;
|
||||
import org.springframework.shell.standard.ShellMethod;
|
||||
import org.springframework.shell.standard.ShellOption;
|
||||
@@ -40,6 +42,18 @@ public class OptionalValueCommands {
|
||||
}
|
||||
}
|
||||
|
||||
@Command(command = BaseE2ECommands.ANNO, group = BaseE2ECommands.GROUP)
|
||||
public static class Annotation extends BaseE2ECommands {
|
||||
|
||||
@Command(command = "optional-value")
|
||||
public String testOptionalValueAnnotation(
|
||||
@Option(longNames = "arg1")
|
||||
String arg1
|
||||
) {
|
||||
return "Hello " + arg1;
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
public static class Registration extends BaseE2ECommands {
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ public class RequiredValueCommands {
|
||||
return "Hello " + arg1;
|
||||
}
|
||||
}
|
||||
|
||||
@Command(command = BaseE2ECommands.ANNO, group = BaseE2ECommands.GROUP)
|
||||
public static class Annotation extends BaseE2ECommands {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user