/** * Gets an IMF validation tool executable. Usually a default value is used (distributed with the utility), * but it can be overridden in config.xml. * * @return IMF validation executable */ public String getImfValidationTool() { // custom has first priority if (customValidationTool != null) { return customValidationTool; } return defaultTools.getImfValidationTool(); }
private void validateInputParameters() { logger.debug("Checking required input parameters for conversion..."); ImfUtilityInputParametersValidator.validateInputParameters(inputParameters); logger.debug("Checked required input parameters for conversion: OK\n"); }
@Test public void testDefaultCpl() throws Exception { String[] args = new String[]{}; ImfUtilityInputParameters inputParameters = new FakeInputParameters( CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args), new FakeDefaultTools()); inputParameters.setDefaultImp("defaultImp"); inputParameters.setDefaultCpl("defaultCpl"); assertEquals(new File("defaultImp", "defaultCpl"), inputParameters.getCplFile()); }
@Test public void testDefaultWorkingDir() { String[] args = new String[]{}; ImfUtilityInputParameters inputParameters = new FakeInputParameters( CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args), new FakeDefaultTools()); inputParameters.setDefaultWorkingDir("defaultWorkingDir"); assertEquals(new File("defaultWorkingDir"), inputParameters.getWorkingDirFile()); }
@Test(expected = ArgumentValidationException.class) public void testValidateWorkingDirNotSpecified() throws Exception { String[] args = new String[]{ "--imp", ImpUtils.getImpFolder().getAbsolutePath(), "--cpl", ImpUtils.getCorrectCpl().getName() }; ImfUtilityInputParameters inputParameters = new FakeInputParameters( CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args), new FakeDefaultTools()); ImfUtilityInputParametersValidator.validateInputParameters(inputParameters); }
@Test public void testDefaultImpFolder() throws Exception { String[] args = new String[]{}; ImfUtilityInputParameters inputParameters = new FakeInputParameters( CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args), new FakeDefaultTools()); inputParameters.setDefaultImp("defaultImp"); assertEquals(new File("defaultImp"), inputParameters.getImpDirectoryFile()); }
@Test(expected = ArgumentValidationException.class) public void testValidateConfigNotSpecified() throws Exception { String[] args = new String[]{}; ImfUtilityInputParameters inputParameters = new FakeInputParameters( CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args), new FakeDefaultTools()); ImfUtilityInputParametersValidator.validateCmdLineArguments(inputParameters); }
private static <T extends ImfUtilityCmdLineArgs> T parseArgs(Class<T> clazz, String[] args) { LOGGER.debug("Parsing command line arguments..."); T imfArgs = CliFactory.parseArguments(clazz, Arrays.copyOfRange(args, 1, args.length)); LogHelper.setLogLevel(imfArgs.getLogLevel().getLogLevel()); LOGGER.debug("Parsed command line arguments: OK\n"); return imfArgs; }
@Test public void testCmdLineCplReplacesDefault() throws Exception { String[] args = new String[]{ "--cpl", ImpUtils.getCorrectCpl().getName(), "--imp", ImpUtils.getImpFolder().getAbsolutePath() }; ImfUtilityInputParameters inputParameters = new FakeInputParameters( CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args), new FakeDefaultTools()); inputParameters.setDefaultCpl("defaultCpl"); assertEquals(ImpUtils.getCorrectCpl(), inputParameters.getCplFile()); }
@Test public void tesCmdLineWorkingDirReplacesDefault() { String[] args = new String[]{ "-w", TemplateParameterContextCreator.getWorkingDir().getAbsolutePath() }; ImfUtilityInputParameters inputParameters = new FakeInputParameters( CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args), new FakeDefaultTools()); inputParameters.setDefaultWorkingDir("defaultWorkingDir"); assertEquals(TemplateParameterContextCreator.getWorkingDir(), inputParameters.getWorkingDirFile()); }
@Test(expected = ArgumentValidationException.class) public void testValidateImpNotSpecified() throws Exception { String[] args = new String[]{ "--cpl", ImpUtils.getCorrectCpl().getName(), "-w", TemplateParameterContextCreator.getWorkingDir().getAbsolutePath() }; ImfUtilityInputParameters inputParameters = new FakeInputParameters( CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args), new FakeDefaultTools()); ImfUtilityInputParametersValidator.validateInputParameters(inputParameters); }
@Test public void testCmdLineImpReplacesDefault() throws Exception { String[] args = new String[]{ "--imp", ImpUtils.getImpFolder().getAbsolutePath() }; ImfUtilityInputParameters inputParameters = new FakeInputParameters( CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args), new FakeDefaultTools()); inputParameters.setDefaultImp("defaultImp"); assertEquals(ImpUtils.getImpFolder(), inputParameters.getImpDirectoryFile()); }
@Test(expected = ArgumentValidationException.class) public void testValidateConfigNotExistentFile() throws Exception { String[] args = new String[]{ "-c", "someFile" }; ImfUtilityInputParameters inputParameters = new FakeInputParameters( CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args), new FakeDefaultTools()); ImfUtilityInputParametersValidator.validateCmdLineArguments(inputParameters); }
@Test(expected = ArgumentValidationException.class) public void testValidateImpNotExistentFolder() throws Exception { String[] args = new String[]{ "--imp", "someFolder", "--cpl", ImpUtils.getCorrectCpl().getName(), "-w", TemplateParameterContextCreator.getWorkingDir().getAbsolutePath() }; ImfUtilityInputParameters inputParameters = new FakeInputParameters( CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args), new FakeDefaultTools()); ImfUtilityInputParametersValidator.validateInputParameters(inputParameters); }
@Test public void testValidateConfigCorrect() throws Exception { @SuppressWarnings("ConstantConditions") String[] args = new String[]{ "-c", ConfigUtils.getCorrectConfigXmlFile().getAbsolutePath() }; ImfUtilityInputParameters inputParameters = new FakeInputParameters( CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args), new FakeDefaultTools()); ImfUtilityInputParametersValidator.validateCmdLineArguments(inputParameters); }
@Test(expected = ArgumentValidationException.class) public void testValidateCplNotSpecified() throws Exception { String[] args = new String[]{ "--imp", ImpUtils.getImpFolder().getAbsolutePath(), "-w", TemplateParameterContextCreator.getWorkingDir().getAbsolutePath() }; ImfUtilityInputParameters inputParameters = new FakeInputParameters( CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args), new FakeDefaultTools()); ImfUtilityInputParametersValidator.validateInputParameters(inputParameters); }
@Test(expected = ArgumentValidationException.class) public void testValidateCplNotExistentFile() throws Exception { String[] args = new String[]{ "--imp", ImpUtils.getImpFolder().getAbsolutePath(), "--cpl", "someFile", "-w", TemplateParameterContextCreator.getWorkingDir().getAbsolutePath() }; ImfUtilityInputParameters inputParameters = new FakeInputParameters( CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args), new FakeDefaultTools()); ImfUtilityInputParametersValidator.validateInputParameters(inputParameters); }
@Test public void testValidateInputParamsCorrectAbsoluteCpl() throws Exception { String[] args = new String[]{ "--imp", ImpUtils.getImpFolder().getAbsolutePath(), "--cpl", ImpUtils.getCorrectCpl().getAbsolutePath(), "-w", TemplateParameterContextCreator.getWorkingDir().getAbsolutePath() }; ImfUtilityInputParameters inputParameters = new FakeInputParameters( CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args), new FakeDefaultTools()); ImfUtilityInputParametersValidator.validateInputParameters(inputParameters); }
@Test public void testValidateInputParamsCorrectRelativeCpl() throws Exception { String[] args = new String[]{ "--imp", ImpUtils.getImpFolder().getAbsolutePath(), "--cpl", ImpUtils.getCorrectCpl().getName(), "-w", TemplateParameterContextCreator.getWorkingDir().getAbsolutePath() }; ImfUtilityInputParameters inputParameters = new FakeInputParameters( CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args), new FakeDefaultTools()); ImfUtilityInputParametersValidator.validateInputParameters(inputParameters); }