### Question:
DomainMapperCli { public void run(final String[] args) throws ClassNotFoundException, IOException { CommandLineParser parser = new BasicParser(); Options options = new Options(); options.addOption("f", "file", true, "write to file"); options.addOption("p", "package", true, "comma separated list of domain packages"); options.addOption(OptionBuilder.withArgName("package").hasArgs().isRequired().create('p')); try { CommandLine line = parser.parse(options, args); String[] packages = line.getOptionValue("p").split(",[ ]*"); log.debug("Scanning domain for packages:"); for (String packageName : packages) { log.debug(packageName); } domainMapper = DomainMapper.create(Arrays.asList(packages)); if (line.hasOption('f')) { String filename = line.getOptionValue('f'); Files.write(Paths.get(filename), domainMapper.describeDomain().getBytes()); log.info("Wrote dot to file " + filename); } else { log.info(domainMapper.describeDomain()); } } catch (ParseException exp) { log.info(exp.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar drm-core.jar", options); } }  static void main(final String[] args); void run(final String[] args);  }### Answer:
@Test public void withsinglePackage() throws Exception { cli.run(new String[]{"-p", "com.nitorcreations.testdomain.person"}); assertThat(cli.domainMapper.getClasses().size(), is(4)); }
@Test public void withMultiPackages() throws Exception { cli.run(new String[]{"-p", "\"com.nitorcreations.testdomain.person, com.nitorcreations.testdomain.another\""}); assertThat(cli.domainMapper.getClasses().size(), is(5)); }
@Test public void withNoPackages_noError() throws Exception { cli.run(new String[]{}); }
@Test public void withWriteToFile() throws Exception { cli.run(new String[]{"-p", "foo.bar", "-f", "foofile.txt"}); assertThat(Files.exists(Paths.get("foofile.txt")), is(true)); Files.delete(Paths.get("foofile.txt")); }