### Question:
CatBuildCommand extends AbstractCommand<CatBuildCommand> { @Override public void run() { PrintStream pOut =null; try { BuildResult last = dao.getLast(repository, sha1); pOut = new PrintStream(out); if (last != null) { out.write(last.getLog()); } else { pOut.println("No log found for this commit."); } out.flush(); callback.onExit(0); } catch (Throwable e) { e.printStackTrace(); callback.onExit(1, e.getMessage()); } finally { if (pOut != null) { pOut.close(); } } } CatBuildCommand(Context ctx, BuildDAO dao); @Override CatBuildCommand command(String command); @Override void run();  }### Answer:
@Test public void testRun() throws Exception { buildCommand.setSha1("0000000000000000000000000000000000000000"); buildCommand.setRepository(repo); LoggerOutputStream out = new LoggerOutputStream(); buildCommand.setOutputStream(out); String logMessage = "build 12345\nexit-code: 1"; given(build.getLog()).willReturn(logMessage.getBytes()); given(dao.getLast(isA(Repository.class), anyString())) .willReturn(build); buildCommand.run(); verify(dao).getLast(repo, "0000000000000000000000000000000000000000"); assertThat(out.getData()).isEqualTo(logMessage); }