RemoteGitHelper { public boolean isGitInstalled(SshConnection connection) throws IOException { ExecutionResult result = connection.tryExecute("which", "git"); if (result.getExitCode() == 0) { return true; } if (result.getExitCode() == 1) { return false; } throw new ProgramExecutionException(new String[] {"which", "git"}, result); } protected  RemoteGitHelper(); void installGit(SshConnection connection, SystemSpecification os); boolean isGitInstalled(SshConnection connection); void checkoutHard(SshConnection connection, String remotePath, String revision); void initEmptyRepository(SshConnection connection, String remotePath);  }
@Test public void testIsGitInstalled() throws IOException { when(connection.tryExecute("which", "git")).thenReturn( new ExecutionResult(0, "", "")); assertThat(remoteGitHelper.isGitInstalled(connection), is(true)); }
@Test public void testIsGitInstalledReturnsFalse() throws IOException { when(connection.tryExecute("which", "git")).thenReturn( new ExecutionResult(1, "", "")); assertThat(remoteGitHelper.isGitInstalled(connection), is(false)); }
@Test(expected = IOException.class) public void testIsGitInstalledThrows() throws IOException { when(connection.tryExecute("which", "git")).thenReturn( new ExecutionResult(3, "", "unexpected result")); remoteGitHelper.isGitInstalled(connection); }