CommandProcess { void appendResponse( Response response ) { if ( response != null ) { if ( !StringUtils.isBlank( response.getStdOut() ) ) { stdOut.append( response.getStdOut() ); } if ( !StringUtils.isBlank( response.getStdErr() ) ) { stdErr.append( response.getStdErr() ); } exitCode = response.getExitCode(); if ( response.getType() == ResponseType.EXECUTE_TIMEOUT ) { status = CommandStatus.KILLED; } else if ( exitCode != null ) { status = exitCode == 0 ? CommandStatus.SUCCEEDED : CommandStatus.FAILED; } } } CommandProcess( final CommandProcessor commandProcessor, final CommandCallback callback, final Request request,
                    final String rhId, final Session userSession ); void stop();  }
@Test public void testAppendResponse() throws Exception { when( response.getStdOut() ).thenReturn( OUTPUT ); when( response.getStdErr() ).thenReturn( OUTPUT ); when( response.getExitCode() ).thenReturn( EXIT_CODE ); commandProcess.appendResponse( response ); verify( response, times( 2 ) ).getStdOut(); verify( response, times( 2 ) ).getStdErr(); verify( response ).getExitCode(); assertEquals( CommandStatus.SUCCEEDED, commandProcess.status ); reset( response ); when( response.getStdOut() ).thenReturn( OUTPUT ); when( response.getStdErr() ).thenReturn( OUTPUT ); when( response.getExitCode() ).thenReturn( null ); when( response.getType() ).thenReturn( ResponseType.EXECUTE_TIMEOUT ); commandProcess.appendResponse( response ); verify( response, times( 2 ) ).getStdOut(); verify( response, times( 2 ) ).getStdErr(); verify( response ).getExitCode(); assertEquals( CommandStatus.KILLED, commandProcess.status ); }