CliHandler { Options createOptions() { Options options = new Options(); OptionBuilder.hasArg(); OptionBuilder.withArgName("template>=<filePath"); OptionBuilder.withDescription("The absolute path of the velocity templates (*.vm). Could be several given by key-value-pairs."); OptionBuilder.isRequired(); options.addOption(OptionBuilder.create("v")); OptionBuilder.hasArg(); OptionBuilder.withArgName("filePath"); OptionBuilder.withDescription("The absolute item path (e.g. a product), the metadata file will be placed next to the item. " + "It gets the name 'itemName-templateName.templateSuffix'. Refer to as $targetPath in velocity templates. If the targetPath is a " + "directory, the metadata file will get the name of the velocity template without the suffix *.vm"); OptionBuilder.isRequired(); options.addOption(OptionBuilder.create("t")); OptionBuilder.hasArg(); OptionBuilder.withArgName("source>=<filePath"); OptionBuilder.withDescription("Optional. The absolute path and name of the source items. Could be several given by key-value-pairs. " + "In the velocity templates the key will give you the content of the associated metadata file(s). The reference $sourcePaths " + "holds a map of the input item paths. The reference $sourceMetadata holds a map with all source-metadata, which can be " + "referenced by their key. " + "($sourceMetadata.get(\"source\").get(\"metadata_xml\").content"); options.addOption(OptionBuilder.create("S")); OptionBuilder.hasArg(); OptionBuilder.withArgName("myKey>=<filePath"); OptionBuilder.withDescription("Optional. The absolute path and name of text file(s) (e.g. global metadata, LUTs) to be included as " + "ceres-metadata - Resource. Refer to as $myKey in velocity templates. ($myKey.content; $myKey.map.get(\"key\"), if it was " + "a *.properties file or $myKey.path)"); options.addOption(OptionBuilder.create("m")); return options; } CliHandler(String[] args); void printUsage(); HashMap<String, String> fetchTemplateFiles(); HashMap<String, String> fetchSourceItemFiles(); String fetchTargetItemFile(); HashMap<String, String> fetchGlobalMetadataFiles(); String[] fetchArguments();  }
@Test public void testCreateOptions() throws Exception { Options options = cliHandler.createOptions(); Option option = options.getOption("-v"); assertNotNull(option); assertTrue(option.isRequired()); assertNull(option.getValue()); assertEquals("template>=<filePath", option.getArgName()); assertEquals("The absolute path of the velocity templates (*.vm). Could be several given by key-value-pairs.", option.getDescription()); option = options.getOption("-t"); assertNotNull(option); assertTrue(option.isRequired()); assertNull(option.getValue()); assertEquals("filePath", option.getArgName()); String desc = "The absolute item path (e.g. a product), the metadata file will be placed next to the item. It gets the name " + "'itemName-templateName.templateSuffix'. Refer to as $targetPath in velocity templates. If the targetPath is a " + "directory, the metadata file will get the name of the velocity template without the suffix *.vm"; assertEquals(desc, option.getDescription()); option = options.getOption("-S"); assertNotNull(option); assertFalse("source item paths are optional", option.isRequired()); assertNull(option.getValue()); assertEquals("source>=<filePath", option.getArgName()); desc = "Optional. The absolute path and name of the source items. Could be several given by key-value-pairs. In the velocity " + "templates the key will give you the content of the associated metadata file(s). The reference $sourcePaths holds a " + "map of the input item paths. The reference $sourceMetadata holds a map with all source-metadata, which can be referenced " + "by their key. ($sourceMetadata.get(\"source\").get(\"metadata_xml\").content"; assertEquals(desc, option.getDescription()); option = options.getOption("-m"); assertNotNull(option); assertFalse("static metadata are optional", option.isRequired()); assertNull(option.getValue()); assertEquals("myKey>=<filePath", option.getArgName()); desc = "Optional. The absolute path and name of text file(s) (e.g. global metadata, LUTs) to be included as ceres-metadata - Resource. " + "Refer to as $myKey in velocity templates. ($myKey.content; $myKey.map.get(\"key\"), if it was a *.properties file " + "or $myKey.path)"; assertEquals(desc, option.getDescription()); }