@Test public void test_noCommands() { assertEquals(Arrays.asList(), new ArgumentParser<Commands>(Commands.class, new String[] {}).getParsedArguments()); }
@Test(expected = IllegalArgumentException.class) public void test_missingDash() { new ArgumentParser<Commands>(Commands.class, new String[]{"-orderCoffee=f"}); }
@Test(expected = IllegalArgumentException.class) public void test_missingArgument() { new ArgumentParser<Commands>(Commands.class, new String[]{"--compileOnFirstTry=f"}); }
private void assertParsedArgument(String commandLineArg, Commands key, String value) { ArgumentParser<Commands>.ParsedArgument parsed = new ArgumentParser<>(Commands.class, new String[] { commandLineArg}).getParsedArguments().get(0); assertEquals(key, parsed.getKey()); assertEquals(value, parsed.getValue()); } }
@Test(expected = IllegalArgumentException.class) public void test_missingValue() { new ArgumentParser<Commands>(Commands.class, new String[]{"--orderCoffee"}); }
@Test public void test_validCommands() { assertEquals(3, new ArgumentParser<Commands>(Commands.class, new String[] { "--orderCoffee=first", "--drinkCoffee=next", "--writeArgumentParserClass=yay"}).getParsedArguments().size()); assertParsedArgument("--orderCoffee=fi.rst", Commands.orderCoffee, "fi.rst"); assertParsedArgument("--drinkCoffee=ne/x--t", Commands.drinkCoffee, "ne/x--t"); assertParsedArgument("--writeArgumentParserClass=compl_ete", Commands.writeArgumentParserClass, "compl_ete"); }
String pathToGeneratedFiles = null; HollowObjectMapper mapper = new HollowObjectMapper(engine); ArgumentParser<GeneratorArguments> argumentParser = new ArgumentParser(GeneratorArguments.class, args); for (ArgumentParser<GeneratorArguments>.ParsedArgument arg : argumentParser.getParsedArguments()) { switch (arg.getKey()) { case addToDataModel:
HollowAPIGenerator.Builder builder = new HollowAPIGenerator.Builder(); HollowObjectMapper mapper = new HollowObjectMapper(engine); ArgumentParser<GeneratorArguments> argumentParser = new ArgumentParser(GeneratorArguments.class, args); for (ArgumentParser<GeneratorArguments>.ParsedArgument arg : argumentParser.getParsedArguments()) { switch (arg.getKey()) { case addToDataModel: