### Question:
Main { static Configuration configure(String[] args) throws ParseException { assert args != null; CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(OPTIONS, args); String output = cmd.getOptionValue(OPT_OUTPUT.getOpt()); String packageName = cmd.getOptionValue(OPT_PACKAGE.getOpt()); Charset sourceEnc = parseCharset(cmd.getOptionValue(OPT_SOURCE_ENCODING.getOpt())); Charset targetEnc = parseCharset(cmd.getOptionValue(OPT_TARGET_ENCODING.getOpt())); String sourcePaths = cmd.getOptionValue(OPT_SOURCE_PATH.getOpt()); String plugin = cmd.getOptionValue(OPT_PLUGIN.getOpt()); File outputDirectory = new File(output); DmdlSourceRepository source = buildRepository(parseFileList(sourcePaths), sourceEnc); ClassLoader serviceLoader = buildPluginLoader(Main.class.getClassLoader(), parseFileList(plugin)); ModelFactory factory = Models.getModelFactory(); return new Configuration( factory, source, Models.toName(factory, packageName), new Filer(outputDirectory, targetEnc), serviceLoader, Locale.getDefault()); } private  Main(); static void main(String... args);  }### Answer:
@Test public void minimum() throws Exception { File output = folder.newFolder("output"); File source = folder.newFile("example.dmdl"); List<String> arguments = new ArrayList<>(); Collections.addAll(arguments, "-output", output.getPath()); Collections.addAll(arguments, "-source", source.getPath()); Collections.addAll(arguments, "-package", "com.example.testing"); Configuration config = Main.configure(arguments.toArray(new String[arguments.size()])); assertThat(config.getSource(), is(source("example.dmdl"))); assertThat(config.getOutput(), is(target(output))); assertThat(config.getBasePackage().toNameString(), is("com.example.testing")); }
@Test public void source_directory() throws Exception { File output = folder.newFolder("output"); File source = folder.newFolder("dmdl"); new File(source, "a.dmdl").createNewFile(); new File(source, "b.dmdl").createNewFile(); List<String> arguments = new ArrayList<>(); Collections.addAll(arguments, "-output", output.getPath()); Collections.addAll(arguments, "-source", source.getPath()); Collections.addAll(arguments, "-package", "com.example.testing"); Configuration config = Main.configure(arguments.toArray(new String[arguments.size()])); assertThat(config.getSource(), is(source("a.dmdl", "b.dmdl"))); }
@Test public void multi_source() throws Exception { File output = folder.newFolder("output"); File source1 = folder.newFolder("dmdl"); new File(source1, "a.dmdl").createNewFile(); new File(source1, "b.dmdl").createNewFile(); File source2 = folder.newFile("file.dmdl"); List<String> arguments = new ArrayList<>(); Collections.addAll(arguments, "-output", output.getPath()); Collections.addAll(arguments, "-source", source1.getPath() + File.pathSeparatorChar + source2.getPath()); Collections.addAll(arguments, "-package", "com.example.testing"); Configuration config = Main.configure(arguments.toArray(new String[arguments.size()])); assertThat(config.getSource(), is(source("a.dmdl", "b.dmdl", "file.dmdl"))); }