I like the implementation, but I think that you're mocking too much. Why can't we just implement the `CommandFactory` with a nested class and make sure it returns something meaningful. Now you're sending command `ls` to the SSH server, but you never check what it returned. And we have a lot of mocking, which is difficult to understand. I can't find Javadocs of this library online, but I suspect that this `createCommand()` is the only method in `CommandFactory`, and it would much more elegant to use nested classes instead of mocks. Correct me if I'm wrong.