CliHandler { public HashMap<String, String> fetchTemplateFiles() throws ParseException { String optionName = "v"; return parseKeyValueOption(optionName); } CliHandler(String[] args); void printUsage(); HashMap<String, String> fetchTemplateFiles(); HashMap<String, String> fetchSourceItemFiles(); String fetchTargetItemFile(); HashMap<String, String> fetchGlobalMetadataFiles(); String[] fetchArguments();  }
@Test public void testParseTemplateFiles() throws Exception { HashMap<String, String> templateFiles = cliHandler.fetchTemplateFiles(); assertEquals(2, templateFiles.size()); assertEquals("/my/template/dir/veltemp.vm.txt", templateFiles.get("template1")); assertEquals("/my/template/dir/veltemp.vm.xml", templateFiles.get("template2")); }
@Test public void testParseTemplateFilesWithIllegalArgumentFormat() throws Exception { command = new String[]{"-v", "/a/path/temp1.vm.txt", "-t", "bla/"}; cliHandler = new CliHandler(command); try { cliHandler.fetchTemplateFiles(); fail("Do not reach this statement."); } catch (ParseException e) { fail("Not this exception"); } catch (IllegalArgumentException expected) { assertEquals("Pattern for values of the option -v is: key=value", expected.getMessage()); } }