GetResourceHostInfoCommand extends SubutaiShellCommandSupport { @Override protected Object doExecute() { try { ResourceHostInfo resourceHostInfo; try { resourceHostInfo = hostRegistry.getResourceHostInfoById( identifier ); } catch ( HostDisconnectedException e ) { resourceHostInfo = hostRegistry.getResourceHostInfoByHostname( identifier ); } System.out.println( resourceHostInfo ); } catch ( HostDisconnectedException e ) { System.out.println( "Host is not connected" ); log.error( "Error in GetResourceHostInfoCommand", e ); } return null; } GetResourceHostInfoCommand( final HostRegistry hostRegistry );   }
@Test public void testDoExecute() throws Exception { command.identifier = HOSTNAME; command.doExecute(); assertThat( getSysOut(), containsString( resourceHostInfo.toString() ) ); command.identifier = ID; command.doExecute(); assertThat( getSysOut(), containsString( resourceHostInfo.toString() ) ); HostDisconnectedException exception = mock( HostDisconnectedException.class ); doThrow( exception ).when( hostRegistry ).getResourceHostInfoById( ID ); doThrow( exception ).when( hostRegistry ).getResourceHostInfoByHostname( ID ); resetSysOut(); command.doExecute(); assertEquals( "Host is not connected", getSysOut() ); verify( exception ).printStackTrace( any( PrintStream.class ) ); }