### Question:
DirectIoListTransaction extends Configured implements Tool { @Override public int run(String[] args) { if (args.length == 0) { DirectIoTransactionEditor editor = new DirectIoTransactionEditor(repository); editor.setConf(getConf()); try { List<TransactionInfo> list = editor.list(); if (list.isEmpty() == false) { for (TransactionInfo commit : list) { System.out.println("===="); System.out.printf("Date:%n"); System.out.printf(" %s%n", new java.util.Date(commit.getTimestamp())); System.out.printf("Execution ID:%n"); System.out.printf(" %s%n", commit.getExecutionId()); System.out.printf("Status:%n"); System.out.printf(" %s%n", commit.isCommitted() ? "Committed" : "NOT Committed"); System.out.printf("Comments:%n"); for (String line : commit.getComment()) { System.out.printf(" %s%n", line); } } System.out.println("===="); } return 0; } catch (Exception e) { LOG.error("Failed to list transaction", e); return 1; } } else { LOG.error(MessageFormat.format( "Invalid arguments: {0}", Arrays.toString(args))); System.err.println(MessageFormat.format( "Usage: hadoop {0} -conf <datasource-conf.xml>", getClass().getName())); return 1; } } DirectIoListTransaction();   DirectIoListTransaction(DirectDataSourceRepository repository); @Override int run(String[] args); static void main(String[] args);  }### Answer:
@Test public void run() throws Exception { Tool exec = new DirectIoListTransaction(repo); indoubt("ex1"); indoubt("ex2"); indoubt("ex3"); assertThat(ToolRunner.run(conf, exec, new String[0]), is(0)); editor.apply("ex2"); assertThat(ToolRunner.run(conf, exec, new String[0]), is(0)); editor.apply("ex1"); assertThat(ToolRunner.run(conf, exec, new String[0]), is(0)); editor.apply("ex3"); assertThat(ToolRunner.run(conf, exec, new String[0]), is(0)); }
@Test public void run_invalid() throws Exception { Tool exec = new DirectIoListTransaction(repo); assertThat(ToolRunner.run(conf, exec, new String[] { "1" }), is(not(0))); }