@Test public void exceptionIsThrown_whenVersionCheckerResponseToClient() { final AgentServerVersionsChecker checker = new AgentServerVersionsChecker(); final VersionsEventResponder responder = mock(VersionsEventResponder.class); doThrow(ResponseException.class).when(responder).versionsCorrect(); final VersionsEvent event = new VersionsEvent(responder, "cmd_line", "3.6", "3.0.2", getCurrentVersion(), Optional.of(42L)); assertThatExceptionOfType(RobotAgentEventsListenerException.class) .isThrownBy(() -> checker.handleVersions(event)); }
@Override public void handleVersions(final VersionsEvent event) { final Optional<String> error = Stream.of( Optional.of(event.getPythonVersion()).flatMap(this::checkPython), Optional.of(event.getRobotVersion()).flatMap(this::checkRobot), Optional.of(event.getProtocolVersion()).flatMap(this::checkProtocol)) .filter(Optional::isPresent) .map(Optional::get) .findFirst(); try { if (error.isPresent()) { event.responder().versionsError(error.get()); } else { event.responder().versionsCorrect(); } } catch (final ResponseException e) { throw new RobotAgentEventsListenerException("Unable to send response to client", e); } if (error.isPresent()) { throw new RobotAgentEventsListenerException(error.get()); } }
AgentServerVersionsChecker extends RobotDefaultAgentEventListener { @Override public void handleVersions(final VersionsEvent event) { final Optional<String> error = Stream.of( Optional.of(event.getPythonVersion()).flatMap(this::checkPython), Optional.of(event.getRobotVersion()).flatMap(this::checkRobot), Optional.of(event.getProtocolVersion()).flatMap(this::checkProtocol)) .filter(Optional::isPresent) .map(Optional::get) .findFirst(); try { if (error.isPresent()) { event.responder().versionsError(error.get()); } else { event.responder().versionsCorrect(); } } catch (final ResponseException e) { throw new RobotAgentEventsListenerException("Unable to send response to client", e); } if (error.isPresent()) { throw new RobotAgentEventsListenerException(error.get()); } } }
AgentServerVersionsChecker extends RobotDefaultAgentEventListener { @Override public void handleVersions(final VersionsEvent event) { final Optional<String> error = Stream.of( Optional.of(event.getPythonVersion()).flatMap(this::checkPython), Optional.of(event.getRobotVersion()).flatMap(this::checkRobot), Optional.of(event.getProtocolVersion()).flatMap(this::checkProtocol)) .filter(Optional::isPresent) .map(Optional::get) .findFirst(); try { if (error.isPresent()) { event.responder().versionsError(error.get()); } else { event.responder().versionsCorrect(); } } catch (final ResponseException e) { throw new RobotAgentEventsListenerException("Unable to send response to client", e); } if (error.isPresent()) { throw new RobotAgentEventsListenerException(error.get()); } }  }
AgentServerVersionsChecker extends RobotDefaultAgentEventListener { @Override public void handleVersions(final VersionsEvent event) { final Optional<String> error = Stream.of( Optional.of(event.getPythonVersion()).flatMap(this::checkPython), Optional.of(event.getRobotVersion()).flatMap(this::checkRobot), Optional.of(event.getProtocolVersion()).flatMap(this::checkProtocol)) .filter(Optional::isPresent) .map(Optional::get) .findFirst(); try { if (error.isPresent()) { event.responder().versionsError(error.get()); } else { event.responder().versionsCorrect(); } } catch (final ResponseException e) { throw new RobotAgentEventsListenerException("Unable to send response to client", e); } if (error.isPresent()) { throw new RobotAgentEventsListenerException(error.get()); } }  @Override void handleVersions(final VersionsEvent event); }
AgentServerVersionsChecker extends RobotDefaultAgentEventListener { @Override public void handleVersions(final VersionsEvent event) { final Optional<String> error = Stream.of( Optional.of(event.getPythonVersion()).flatMap(this::checkPython), Optional.of(event.getRobotVersion()).flatMap(this::checkRobot), Optional.of(event.getProtocolVersion()).flatMap(this::checkProtocol)) .filter(Optional::isPresent) .map(Optional::get) .findFirst(); try { if (error.isPresent()) { event.responder().versionsError(error.get()); } else { event.responder().versionsCorrect(); } } catch (final ResponseException e) { throw new RobotAgentEventsListenerException("Unable to send response to client", e); } if (error.isPresent()) { throw new RobotAgentEventsListenerException(error.get()); } }  @Override void handleVersions(final VersionsEvent event);  }