@Test public void missingStoreTypeOption() { final String[] args = new String[] { "-inputpath", "somefile.txt", "-exporttype", "h2", "-outputfile", outputPath.toString(), "-dbpass", "-dbuser" }; commandLine.execute(args); final CliResult result = commandLine.getExecutionResult(); assertThat(result).isNull(); assertThat(systemErrRule.getLog()).contains("Missing required option '-storetype <storeType>'"); }
@Override public CliResult execute(String... args) throws Exception { final StoreLoader storeLoader = storeType.getLoader(); storeLoader.load(inputpath); final DataExporter dataExporter; if (exportType == ExportType.JDBC) { if (dbconfig == null) { throw new IllegalArgumentException("dbconfig file path is required when no export type is defined."); } final Properties properties = new Properties(); try (InputStream inStream = Files.newInputStream(dbconfig)) { properties.load(inStream); } final String insertRow = Objects.requireNonNull( properties.getProperty("insertRow"), "No insertRow value defined in config file. "); final String createTable = Objects.requireNonNull( properties.getProperty("createTable"), "No createTable value defined in config file. "); final String jdbcUrl = Objects.requireNonNull( properties.getProperty("jdbcUrl"), "No jdbcUrl value defined in config file. "); dataExporter = new JdbcDataExporter(jdbcUrl, insertRow, singletonList(createTable)); } else { dataExporter = DataExporterFactory.create(exportType); } dataExporter.export(storeLoader, outputFile, username, password); System.out.printf("Exported data to %s", Objects.toString(outputFile)); System.out.println(); return new CliResult(0, true, null); }
CmdLineExecutor implements CliAdapter, Callable<CliResult> { @Override public CliResult execute(String... args) throws Exception { final StoreLoader storeLoader = storeType.getLoader(); storeLoader.load(inputpath); final DataExporter dataExporter; if (exportType == ExportType.JDBC) { if (dbconfig == null) { throw new IllegalArgumentException("dbconfig file path is required when no export type is defined."); } final Properties properties = new Properties(); try (InputStream inStream = Files.newInputStream(dbconfig)) { properties.load(inStream); } final String insertRow = Objects.requireNonNull( properties.getProperty("insertRow"), "No insertRow value defined in config file. "); final String createTable = Objects.requireNonNull( properties.getProperty("createTable"), "No createTable value defined in config file. "); final String jdbcUrl = Objects.requireNonNull( properties.getProperty("jdbcUrl"), "No jdbcUrl value defined in config file. "); dataExporter = new JdbcDataExporter(jdbcUrl, insertRow, singletonList(createTable)); } else { dataExporter = DataExporterFactory.create(exportType); } dataExporter.export(storeLoader, outputFile, username, password); System.out.printf("Exported data to %s", Objects.toString(outputFile)); System.out.println(); return new CliResult(0, true, null); } }
CmdLineExecutor implements CliAdapter, Callable<CliResult> { @Override public CliResult execute(String... args) throws Exception { final StoreLoader storeLoader = storeType.getLoader(); storeLoader.load(inputpath); final DataExporter dataExporter; if (exportType == ExportType.JDBC) { if (dbconfig == null) { throw new IllegalArgumentException("dbconfig file path is required when no export type is defined."); } final Properties properties = new Properties(); try (InputStream inStream = Files.newInputStream(dbconfig)) { properties.load(inStream); } final String insertRow = Objects.requireNonNull( properties.getProperty("insertRow"), "No insertRow value defined in config file. "); final String createTable = Objects.requireNonNull( properties.getProperty("createTable"), "No createTable value defined in config file. "); final String jdbcUrl = Objects.requireNonNull( properties.getProperty("jdbcUrl"), "No jdbcUrl value defined in config file. "); dataExporter = new JdbcDataExporter(jdbcUrl, insertRow, singletonList(createTable)); } else { dataExporter = DataExporterFactory.create(exportType); } dataExporter.export(storeLoader, outputFile, username, password); System.out.printf("Exported data to %s", Objects.toString(outputFile)); System.out.println(); return new CliResult(0, true, null); }  }
CmdLineExecutor implements CliAdapter, Callable<CliResult> { @Override public CliResult execute(String... args) throws Exception { final StoreLoader storeLoader = storeType.getLoader(); storeLoader.load(inputpath); final DataExporter dataExporter; if (exportType == ExportType.JDBC) { if (dbconfig == null) { throw new IllegalArgumentException("dbconfig file path is required when no export type is defined."); } final Properties properties = new Properties(); try (InputStream inStream = Files.newInputStream(dbconfig)) { properties.load(inStream); } final String insertRow = Objects.requireNonNull( properties.getProperty("insertRow"), "No insertRow value defined in config file. "); final String createTable = Objects.requireNonNull( properties.getProperty("createTable"), "No createTable value defined in config file. "); final String jdbcUrl = Objects.requireNonNull( properties.getProperty("jdbcUrl"), "No jdbcUrl value defined in config file. "); dataExporter = new JdbcDataExporter(jdbcUrl, insertRow, singletonList(createTable)); } else { dataExporter = DataExporterFactory.create(exportType); } dataExporter.export(storeLoader, outputFile, username, password); System.out.printf("Exported data to %s", Objects.toString(outputFile)); System.out.println(); return new CliResult(0, true, null); }  @Override CliResult call(); @Override CliType getType(); @Override CliResult execute(String... args); }
CmdLineExecutor implements CliAdapter, Callable<CliResult> { @Override public CliResult execute(String... args) throws Exception { final StoreLoader storeLoader = storeType.getLoader(); storeLoader.load(inputpath); final DataExporter dataExporter; if (exportType == ExportType.JDBC) { if (dbconfig == null) { throw new IllegalArgumentException("dbconfig file path is required when no export type is defined."); } final Properties properties = new Properties(); try (InputStream inStream = Files.newInputStream(dbconfig)) { properties.load(inStream); } final String insertRow = Objects.requireNonNull( properties.getProperty("insertRow"), "No insertRow value defined in config file. "); final String createTable = Objects.requireNonNull( properties.getProperty("createTable"), "No createTable value defined in config file. "); final String jdbcUrl = Objects.requireNonNull( properties.getProperty("jdbcUrl"), "No jdbcUrl value defined in config file. "); dataExporter = new JdbcDataExporter(jdbcUrl, insertRow, singletonList(createTable)); } else { dataExporter = DataExporterFactory.create(exportType); } dataExporter.export(storeLoader, outputFile, username, password); System.out.printf("Exported data to %s", Objects.toString(outputFile)); System.out.println(); return new CliResult(0, true, null); }  @Override CliResult call(); @Override CliType getType(); @Override CliResult execute(String... args);  }