@Test public void exceptionIsThrownForWronglyConstructedJsonDictionary_3() { final Map<String, Object> eventMap = ImmutableMap.of("version", newArrayList()); assertThatExceptionOfType(RuntimeException.class) .isThrownBy(() -> VersionsEvent.from(mock(AgentClient.class), eventMap)); }
public static VersionsEvent from(final AgentClient client, final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("version"); final Map<?, ?> attributes = (Map<?, ?>) arguments.get(0); final String cmdLine = (String) attributes.get("cmd_line"); final String pythonVersion = (String) attributes.get("python"); final String robotVersion = (String) attributes.get("robot"); final Integer protocolVersion = (Integer) attributes.get("protocol"); final Optional<Long> pid; if (attributes.get("pid") instanceof Integer) { final Integer i = (Integer) attributes.get("pid"); pid = Optional.of(Long.valueOf(i.intValue())); } else { pid = Optional.ofNullable((Long) attributes.get("pid")); } if (cmdLine == null || pythonVersion == null || robotVersion == null || protocolVersion == null) { throw new IllegalArgumentException( "Versions event should have command line, versions of python, robot and protocol"); } return new VersionsEvent(new VersionsEventResponder(client), cmdLine, pythonVersion, robotVersion, protocolVersion, pid); }
VersionsEvent { public static VersionsEvent from(final AgentClient client, final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("version"); final Map<?, ?> attributes = (Map<?, ?>) arguments.get(0); final String cmdLine = (String) attributes.get("cmd_line"); final String pythonVersion = (String) attributes.get("python"); final String robotVersion = (String) attributes.get("robot"); final Integer protocolVersion = (Integer) attributes.get("protocol"); final Optional<Long> pid; if (attributes.get("pid") instanceof Integer) { final Integer i = (Integer) attributes.get("pid"); pid = Optional.of(Long.valueOf(i.intValue())); } else { pid = Optional.ofNullable((Long) attributes.get("pid")); } if (cmdLine == null || pythonVersion == null || robotVersion == null || protocolVersion == null) { throw new IllegalArgumentException( "Versions event should have command line, versions of python, robot and protocol"); } return new VersionsEvent(new VersionsEventResponder(client), cmdLine, pythonVersion, robotVersion, protocolVersion, pid); } }
VersionsEvent { public static VersionsEvent from(final AgentClient client, final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("version"); final Map<?, ?> attributes = (Map<?, ?>) arguments.get(0); final String cmdLine = (String) attributes.get("cmd_line"); final String pythonVersion = (String) attributes.get("python"); final String robotVersion = (String) attributes.get("robot"); final Integer protocolVersion = (Integer) attributes.get("protocol"); final Optional<Long> pid; if (attributes.get("pid") instanceof Integer) { final Integer i = (Integer) attributes.get("pid"); pid = Optional.of(Long.valueOf(i.intValue())); } else { pid = Optional.ofNullable((Long) attributes.get("pid")); } if (cmdLine == null || pythonVersion == null || robotVersion == null || protocolVersion == null) { throw new IllegalArgumentException( "Versions event should have command line, versions of python, robot and protocol"); } return new VersionsEvent(new VersionsEventResponder(client), cmdLine, pythonVersion, robotVersion, protocolVersion, pid); } VersionsEvent(final VersionsEventResponder responder, final String cmdLine, final String pythonVersion,
            final String robotVersion, final int protocolVersion, final Optional<Long> pid); }
VersionsEvent { public static VersionsEvent from(final AgentClient client, final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("version"); final Map<?, ?> attributes = (Map<?, ?>) arguments.get(0); final String cmdLine = (String) attributes.get("cmd_line"); final String pythonVersion = (String) attributes.get("python"); final String robotVersion = (String) attributes.get("robot"); final Integer protocolVersion = (Integer) attributes.get("protocol"); final Optional<Long> pid; if (attributes.get("pid") instanceof Integer) { final Integer i = (Integer) attributes.get("pid"); pid = Optional.of(Long.valueOf(i.intValue())); } else { pid = Optional.ofNullable((Long) attributes.get("pid")); } if (cmdLine == null || pythonVersion == null || robotVersion == null || protocolVersion == null) { throw new IllegalArgumentException( "Versions event should have command line, versions of python, robot and protocol"); } return new VersionsEvent(new VersionsEventResponder(client), cmdLine, pythonVersion, robotVersion, protocolVersion, pid); } VersionsEvent(final VersionsEventResponder responder, final String cmdLine, final String pythonVersion,
            final String robotVersion, final int protocolVersion, final Optional<Long> pid); static VersionsEvent from(final AgentClient client, final Map<String, Object> eventMap); String getCommandLine(); String getPythonVersion(); String getRobotVersion(); int getProtocolVersion(); Optional<Long> getPid(); VersionsEventResponder responder(); @Override boolean equals(final Object obj); @Override int hashCode(); }
VersionsEvent { public static VersionsEvent from(final AgentClient client, final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("version"); final Map<?, ?> attributes = (Map<?, ?>) arguments.get(0); final String cmdLine = (String) attributes.get("cmd_line"); final String pythonVersion = (String) attributes.get("python"); final String robotVersion = (String) attributes.get("robot"); final Integer protocolVersion = (Integer) attributes.get("protocol"); final Optional<Long> pid; if (attributes.get("pid") instanceof Integer) { final Integer i = (Integer) attributes.get("pid"); pid = Optional.of(Long.valueOf(i.intValue())); } else { pid = Optional.ofNullable((Long) attributes.get("pid")); } if (cmdLine == null || pythonVersion == null || robotVersion == null || protocolVersion == null) { throw new IllegalArgumentException( "Versions event should have command line, versions of python, robot and protocol"); } return new VersionsEvent(new VersionsEventResponder(client), cmdLine, pythonVersion, robotVersion, protocolVersion, pid); } VersionsEvent(final VersionsEventResponder responder, final String cmdLine, final String pythonVersion,
            final String robotVersion, final int protocolVersion, final Optional<Long> pid); static VersionsEvent from(final AgentClient client, final Map<String, Object> eventMap); String getCommandLine(); String getPythonVersion(); String getRobotVersion(); int getProtocolVersion(); Optional<Long> getPid(); VersionsEventResponder responder(); @Override boolean equals(final Object obj); @Override int hashCode();  }