Skip to content

Commit 50ab177

Browse files
committed
[Change] ArgumentsRunner 优化代码;
[Add] ArgumentsRunnerInstanceMethodTest, ArgumentsRunnerStaticMethodTest 调整测试项;
1 parent c513d6b commit 50ab177

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src/main/java/net/lamgc/utils/base/runner/ArgumentsRunner.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
*/
2020
public class ArgumentsRunner {
2121

22-
2322
private final static Pattern COMMAND_NAME_CHECK_PATTERN = Pattern.compile("^[^ ]+$");
2423

2524
private final ArgumentsRunnerConfig config;
2625

2726
private final Class<?> runClass;
28-
private CommandMap commandMap;
27+
private final CommandMap commandMap;
2928

3029
/**
3130
* 无配置启动一个运行器.

src/test/java/net/lamgc/utils/base/runner/ArgumentsRunnerInstanceMethodTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,23 @@
66
import net.lamgc.utils.base.runner.exception.ParameterNoFoundException;
77
import org.junit.Assert;
88
import org.junit.Test;
9+
import org.slf4j.LoggerFactory;
910

11+
import java.util.Arrays;
1012
import java.util.Date;
13+
import java.util.Set;
1114

1215
public class ArgumentsRunnerInstanceMethodTest {
1316

1417
private static InstanceRunnerTestMain testMain = new InstanceRunnerTestMain();
1518

1619
@Test
1720
public void getCommandNamesTest() {
18-
new ArgumentsRunner(InstanceRunnerTestMain.class).getCommandNames();
21+
Set<String> commandNames = new ArgumentsRunner(InstanceRunnerTestMain.class).getCommandNames();
22+
String[] commandNamesArr = new String[commandNames.size()];
23+
commandNames.toArray(commandNamesArr);
24+
LoggerFactory.getLogger(ArgumentsRunnerInstanceMethodTest.class)
25+
.info("Commands: {}", Arrays.toString(commandNamesArr));
1926
}
2027

2128
@Test

src/test/java/net/lamgc/utils/base/runner/ArgumentsRunnerStaticMethodTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,21 @@
66
import net.lamgc.utils.base.runner.exception.ParameterNoFoundException;
77
import org.junit.Assert;
88
import org.junit.Test;
9+
import org.slf4j.LoggerFactory;
910

11+
import java.util.Arrays;
1012
import java.util.Date;
13+
import java.util.Set;
1114

1215
public class ArgumentsRunnerStaticMethodTest {
1316

1417
@Test
1518
public void getCommandNamesTest() {
16-
new ArgumentsRunner(InstanceRunnerTestMain.class).getCommandNames();
19+
Set<String> commandNames = new ArgumentsRunner(StaticRunnerTestMain.class).getCommandNames();
20+
String[] commandNamesArr = new String[commandNames.size()];
21+
commandNames.toArray(commandNamesArr);
22+
LoggerFactory.getLogger(ArgumentsRunnerStaticMethodTest.class)
23+
.info("Commands: {}", Arrays.toString(commandNamesArr));
1724
}
1825

1926
@Test

0 commit comments

Comments
 (0)