@Test public void correctVersionMsgIsSendToClient_whenVersionsAreMatching() throws Exception { final AgentClient client = mock(AgentClient.class); final AgentServerVersionsChecker checker = new AgentServerVersionsChecker(); final List<Object> attributes = newArrayList( ImmutableMap.of("cmd_line", "cmd", "python", "", "robot", "", "protocol", getCurrentVersion())); final Map<String, Object> eventMap = ImmutableMap.of("version", attributes); checker.handleVersions(VersionsEvent.from(client, eventMap)); verify(client).send(any(ProtocolVersion.class)); }
@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);  }