UserProcessDebugController extends UserProcessController { @Override public Optional<ServerResponse> takeCurrentResponse(final PausingPoint pausingPoint, final QualifiedKeywordName currentlyFailedKeyword) { this.lastPausingPoint = pausingPoint; return super.takeCurrentResponse(pausingPoint, currentlyFailedKeyword).map(Optional::of) .orElseGet(() -> pauseOnErrorResponse(pausingPoint)).map(Optional::of) .orElseGet(() -> breakpointHitResponse(pausingPoint, currentlyFailedKeyword)).map(Optional::of) .orElseGet(() -> userSteppingResponse(pausingPoint)); } UserProcessDebugController(final Stacktrace stacktrace, final DebuggerPreferences preferences); void whenSuspended(final PauseReasonListener listener); boolean isStepping(); @Override void conditionEvaluated(final ConditionEvaluatedEvent event); @Override void executionPaused(); @Override Optional<ServerResponse> takeCurrentResponse(final PausingPoint pausingPoint,
            final QualifiedKeywordName currentlyFailedKeyword); @Override void pause(final Runnable whenResponseIsSent); void stepInto(final Runnable whenResponseIsSent, final Runnable whenSteppingEnds); void stepOver(final StackFrame frameToStepOver, final Runnable whenResponseIsSent,
            final Runnable whenSteppingEnds); void stepReturn(final StackFrame frameToStepReturn, final Runnable whenResponseIsSent,
            final Runnable whenSteppingEnds); void changeVariable(final StackFrame frame, final StackFrameVariable variable,
            final List<String> arguments); void changeVariableInnerValue(final StackFrame frame, final StackFrameVariable variable,
            final List<Object> path, final List<String> arguments); void evaluateRobotKeywordCall(final int exprId, final String keywordName, final List<String> arguments); void evaluateRobotVariable(final int exprId, final String variable); void evaluatePythonExpression(final int exprId, final String expression);  }
@Test public void thereIsNoResponse_forNewlyCreatedController() { final Stacktrace stack = new Stacktrace(); final DebuggerPreferences prefs = new DebuggerPreferences(() -> false, true); final UserProcessDebugController controller = new UserProcessDebugController(stack, prefs); final Optional<ServerResponse> response = controller.takeCurrentResponse(PausingPoint.START_KEYWORD, null); assertThat(response).isEmpty(); }
@Test public void whenDisconnectWasOrdered_callbackRunsAndResponseIsProperlyReturned() { final Stacktrace stack = new Stacktrace(); final DebuggerPreferences prefs = new DebuggerPreferences(() -> false, true); final UserProcessDebugController controller = new UserProcessDebugController(stack, prefs); final Runnable callback = mock(Runnable.class); controller.disconnect(callback); assertThat(controller.manualUserResponse).hasSize(1); final Optional<ServerResponse> response = controller.takeCurrentResponse(PausingPoint.START_KEYWORD, null); assertThat(controller.manualUserResponse).isEmpty(); assertThat(response).containsInstanceOf(DisconnectExecution.class); verify(callback).run(); }
@Test public void whenTerminateWasOrdered_callbackRunsAndResponseIsProperlyReturned() { final Stacktrace stack = new Stacktrace(); final DebuggerPreferences prefs = new DebuggerPreferences(() -> false, true); final UserProcessDebugController controller = new UserProcessDebugController(stack, prefs); final Runnable callback = mock(Runnable.class); controller.terminate(callback); assertThat(controller.manualUserResponse).hasSize(1); final Optional<ServerResponse> response = controller.takeCurrentResponse(PausingPoint.START_KEYWORD, null); assertThat(controller.manualUserResponse).isEmpty(); assertThat(response).containsInstanceOf(TerminateExecution.class); verify(callback).run(); }
@Test public void whenResumeWasOrdered_callbackRunsAndResponseIsProperlyReturned() { final Stacktrace stack = new Stacktrace(); final DebuggerPreferences prefs = new DebuggerPreferences(() -> false, true); final UserProcessDebugController controller = new UserProcessDebugController(stack, prefs); final Runnable callback = mock(Runnable.class); controller.resume(callback); assertThat(controller.manualUserResponse).hasSize(1); final Optional<ServerResponse> response = controller.takeCurrentResponse(PausingPoint.START_KEYWORD, null); assertThat(controller.manualUserResponse).isEmpty(); assertThat(response).containsInstanceOf(ResumeExecution.class); verify(callback).run(); }