RegisterSshStep { public void execute() throws EnvironmentManagerException, PeerException { Set<Host> hosts = Sets.newHashSet(); hosts.addAll( environment.getContainerHosts() ); Set<String> userKeys = environment.getSshKeys(); if ( !hosts.isEmpty() && topology.exchangeSshKeys() ) { exchangeSshKeys( userKeys ); } else if ( !CollectionUtil.isCollectionEmpty( userKeys ) ) { SshKeys sshKeys = new SshKeys(); sshKeys.addStringKeys( userKeys ); appendSshKeys( sshKeys ); } } RegisterSshStep( final Topology topology, final LocalEnvironment environment,
                            final TrackerOperation trackerOperation ); void execute();  }
@Test public void testExecute() throws Exception { doReturn( true ).when( topology ).exchangeSshKeys(); doReturn( TestHelper.SSH_KEYS() ).when( step ).readOrCreateSshKeys(); step.execute(); verify( step ).exchangeSshKeys( anySet() ); doReturn( true ).when( topology ).exchangeSshKeys(); step.execute(); verify( step, atLeastOnce() ).appendSshKeys( isA( SshKeys.class ) ); }