@Test(expected=CmdLineParserException.class) public void testTooManyPorts() { CmdLineParserForProcessRunParameters parser = new CmdLineParserForProcessRunParameters(); String[] args = new String[]{ "-Iperson=/users/joe/person_input", "-Idocument=/users/joe/doc_input", "-Omerged=/users/joe/merged_out", "-Oother=/users/joe/other_out"}; Ports ports = createStandardPorts(); CommandLine cmdLine = CmdLineParser.parse(args); parser.run(cmdLine, ports); }
public ProcessParameters run(CommandLine cmdLine, Ports ports) { Properties inputProperties = cmdLine.getOptionProperties( CmdLineParser.inputPrefix); assumePortNamesMatch(CmdLineParser.inputPrefix, inputProperties, ports.getInput().keySet()); Map<String, Path> inputBindings = getBindings( inputProperties, ports.getInput().keySet()); Properties outputProperties = cmdLine.getOptionProperties( CmdLineParser.outputPrefix); assumePortNamesMatch(CmdLineParser.outputPrefix, outputProperties, ports.getOutput().keySet()); Map<String, Path> outputBindings = getBindings( outputProperties, ports.getOutput().keySet()); PortBindings bindings = new PortBindings(inputBindings, outputBindings); Properties specialProperties = cmdLine.getOptionProperties( CmdLineParser.specialParametersPrefix); assumeContainAllMandatoryParameters( specialProperties, CmdLineParser.mandatorySpecialParameters); Properties rawProperties = cmdLine.getOptionProperties( CmdLineParser.processParametersPrefix); Map<String, String> processParameters = new HashMap<String, String>(); for(Entry<Object, Object> entry: rawProperties.entrySet()){ processParameters.put( (String)entry.getKey(), (String)entry.getValue()); } return new ProcessParameters(bindings, processParameters); }
CmdLineParserForProcessRunParameters { public ProcessParameters run(CommandLine cmdLine, Ports ports) { Properties inputProperties = cmdLine.getOptionProperties( CmdLineParser.inputPrefix); assumePortNamesMatch(CmdLineParser.inputPrefix, inputProperties, ports.getInput().keySet()); Map<String, Path> inputBindings = getBindings( inputProperties, ports.getInput().keySet()); Properties outputProperties = cmdLine.getOptionProperties( CmdLineParser.outputPrefix); assumePortNamesMatch(CmdLineParser.outputPrefix, outputProperties, ports.getOutput().keySet()); Map<String, Path> outputBindings = getBindings( outputProperties, ports.getOutput().keySet()); PortBindings bindings = new PortBindings(inputBindings, outputBindings); Properties specialProperties = cmdLine.getOptionProperties( CmdLineParser.specialParametersPrefix); assumeContainAllMandatoryParameters( specialProperties, CmdLineParser.mandatorySpecialParameters); Properties rawProperties = cmdLine.getOptionProperties( CmdLineParser.processParametersPrefix); Map<String, String> processParameters = new HashMap<String, String>(); for(Entry<Object, Object> entry: rawProperties.entrySet()){ processParameters.put( (String)entry.getKey(), (String)entry.getValue()); } return new ProcessParameters(bindings, processParameters); } }
CmdLineParserForProcessRunParameters { public ProcessParameters run(CommandLine cmdLine, Ports ports) { Properties inputProperties = cmdLine.getOptionProperties( CmdLineParser.inputPrefix); assumePortNamesMatch(CmdLineParser.inputPrefix, inputProperties, ports.getInput().keySet()); Map<String, Path> inputBindings = getBindings( inputProperties, ports.getInput().keySet()); Properties outputProperties = cmdLine.getOptionProperties( CmdLineParser.outputPrefix); assumePortNamesMatch(CmdLineParser.outputPrefix, outputProperties, ports.getOutput().keySet()); Map<String, Path> outputBindings = getBindings( outputProperties, ports.getOutput().keySet()); PortBindings bindings = new PortBindings(inputBindings, outputBindings); Properties specialProperties = cmdLine.getOptionProperties( CmdLineParser.specialParametersPrefix); assumeContainAllMandatoryParameters( specialProperties, CmdLineParser.mandatorySpecialParameters); Properties rawProperties = cmdLine.getOptionProperties( CmdLineParser.processParametersPrefix); Map<String, String> processParameters = new HashMap<String, String>(); for(Entry<Object, Object> entry: rawProperties.entrySet()){ processParameters.put( (String)entry.getKey(), (String)entry.getValue()); } return new ProcessParameters(bindings, processParameters); }  }
CmdLineParserForProcessRunParameters { public ProcessParameters run(CommandLine cmdLine, Ports ports) { Properties inputProperties = cmdLine.getOptionProperties( CmdLineParser.inputPrefix); assumePortNamesMatch(CmdLineParser.inputPrefix, inputProperties, ports.getInput().keySet()); Map<String, Path> inputBindings = getBindings( inputProperties, ports.getInput().keySet()); Properties outputProperties = cmdLine.getOptionProperties( CmdLineParser.outputPrefix); assumePortNamesMatch(CmdLineParser.outputPrefix, outputProperties, ports.getOutput().keySet()); Map<String, Path> outputBindings = getBindings( outputProperties, ports.getOutput().keySet()); PortBindings bindings = new PortBindings(inputBindings, outputBindings); Properties specialProperties = cmdLine.getOptionProperties( CmdLineParser.specialParametersPrefix); assumeContainAllMandatoryParameters( specialProperties, CmdLineParser.mandatorySpecialParameters); Properties rawProperties = cmdLine.getOptionProperties( CmdLineParser.processParametersPrefix); Map<String, String> processParameters = new HashMap<String, String>(); for(Entry<Object, Object> entry: rawProperties.entrySet()){ processParameters.put( (String)entry.getKey(), (String)entry.getValue()); } return new ProcessParameters(bindings, processParameters); }  ProcessParameters run(CommandLine cmdLine, Ports ports); }
CmdLineParserForProcessRunParameters { public ProcessParameters run(CommandLine cmdLine, Ports ports) { Properties inputProperties = cmdLine.getOptionProperties( CmdLineParser.inputPrefix); assumePortNamesMatch(CmdLineParser.inputPrefix, inputProperties, ports.getInput().keySet()); Map<String, Path> inputBindings = getBindings( inputProperties, ports.getInput().keySet()); Properties outputProperties = cmdLine.getOptionProperties( CmdLineParser.outputPrefix); assumePortNamesMatch(CmdLineParser.outputPrefix, outputProperties, ports.getOutput().keySet()); Map<String, Path> outputBindings = getBindings( outputProperties, ports.getOutput().keySet()); PortBindings bindings = new PortBindings(inputBindings, outputBindings); Properties specialProperties = cmdLine.getOptionProperties( CmdLineParser.specialParametersPrefix); assumeContainAllMandatoryParameters( specialProperties, CmdLineParser.mandatorySpecialParameters); Properties rawProperties = cmdLine.getOptionProperties( CmdLineParser.processParametersPrefix); Map<String, String> processParameters = new HashMap<String, String>(); for(Entry<Object, Object> entry: rawProperties.entrySet()){ processParameters.put( (String)entry.getKey(), (String)entry.getValue()); } return new ProcessParameters(bindings, processParameters); }  ProcessParameters run(CommandLine cmdLine, Ports ports);  }