@Test(groups = "cli.parse.option.regexOption.canProcess", dataProvider = "canProcess") public void testCanProcess(String regex, String argument) { regexOption.addRegex(regex, 1, NORMAL); CommandLine commandLine = OptionFactory.createCommandLineMock(); assertTrue( regexOption.canProcess(commandLine, createArguments(argument)), "Regex option is expected to be able to process the argument"); }
@Test(dependsOnGroups = "cli.parse.option.regexOption.canProcess", dataProvider = "process") public void testProcess(String regex, List<String> arguments, List<String> expected) { regexOption.setArgument(new ArgumentImpl()); regexOption.addRegex(regex, 1, NORMAL); CommandLine commandLine = OptionFactory.createCommandLineMock(); ListIterator<String> iterator = arguments.listIterator(); while (regexOption.canProcess(commandLine, iterator)) { regexOption.preProcess(commandLine, iterator); regexOption.process(commandLine, iterator); } verify(commandLine, atLeastOnce()).addOption(regexOption); for (String value : expected) { verify(commandLine).addValue(regexOption, value); } }