Skip to content

Commit

Permalink
[#1260] add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
remkop committed Nov 15, 2020
1 parent 28f265a commit 53ab0e7
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/test/java/picocli/ArgGroupTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3900,4 +3900,38 @@ public void testArithmeticException1213() {
new CommandLine(bean).parseArgs("a", "b");
assertEquals(Arrays.asList(new File("a"), new File("b")), bean.sourceOptions.reportFiles);
}

public static class CriteriaWithEnvironment {

private static final List<String> DYNAMIC_LIST = Arrays.asList("FOO", "BAR");

private String environment;

@CommandLine.Spec CommandSpec spec;

@CommandLine.Option(names = {"-e", "--environment"})
public void setEnvironment(String environment) {
if (!DYNAMIC_LIST.contains(environment)) {
// Should throw a ParameterException
//throw new IllegalArgumentException("Should be one of...");
throw new ParameterException(spec.commandLine(), "should be one of " + DYNAMIC_LIST);
}
this.environment = environment;
}

public String getEnvironment() {
return environment;
}
}

@Ignore("#1260")
@Test
public void testIssue1260ArgGroupWithSpec() {
@Command
class App {
@ArgGroup CriteriaWithEnvironment criteria;
}
new CommandLine(new App()).parseArgs("-e", "X");
}

}

0 comments on commit 53ab0e7

Please sign in to comment.