@Test public void properMessageIsConstructed_forProtocolVersionMessage() { assertThat(new ProtocolVersion(null).toMessage()) .isEqualTo("{\"protocol_version\":{\"error\":\"\",\"is_correct\":true}}"); assertThat(new ProtocolVersion("oops").toMessage()) .isEqualTo("{\"protocol_version\":{\"error\":\"oops\",\"is_correct\":false}}"); }
@Override public String toMessage() { try { final Map<String, Object> arguments = new HashMap<>(); arguments.put("is_correct", error == null); arguments.put("error", Strings.nullToEmpty(error)); final Map<String, Object> value = ImmutableMap.of("protocol_version", arguments); return mapper.writeValueAsString(value); } catch (final IOException e) { throw new ResponseException("Unable to serialize protocol version response arguments to json", e); } }
ProtocolVersion implements ServerResponse { @Override public String toMessage() { try { final Map<String, Object> arguments = new HashMap<>(); arguments.put("is_correct", error == null); arguments.put("error", Strings.nullToEmpty(error)); final Map<String, Object> value = ImmutableMap.of("protocol_version", arguments); return mapper.writeValueAsString(value); } catch (final IOException e) { throw new ResponseException("Unable to serialize protocol version response arguments to json", e); } } }
ProtocolVersion implements ServerResponse { @Override public String toMessage() { try { final Map<String, Object> arguments = new HashMap<>(); arguments.put("is_correct", error == null); arguments.put("error", Strings.nullToEmpty(error)); final Map<String, Object> value = ImmutableMap.of("protocol_version", arguments); return mapper.writeValueAsString(value); } catch (final IOException e) { throw new ResponseException("Unable to serialize protocol version response arguments to json", e); } } ProtocolVersion();  ProtocolVersion(final String error); @VisibleForTesting  ProtocolVersion(final ObjectMapper mapper, final String error); }
ProtocolVersion implements ServerResponse { @Override public String toMessage() { try { final Map<String, Object> arguments = new HashMap<>(); arguments.put("is_correct", error == null); arguments.put("error", Strings.nullToEmpty(error)); final Map<String, Object> value = ImmutableMap.of("protocol_version", arguments); return mapper.writeValueAsString(value); } catch (final IOException e) { throw new ResponseException("Unable to serialize protocol version response arguments to json", e); } } ProtocolVersion();  ProtocolVersion(final String error); @VisibleForTesting  ProtocolVersion(final ObjectMapper mapper, final String error); @Override String toMessage(); }
ProtocolVersion implements ServerResponse { @Override public String toMessage() { try { final Map<String, Object> arguments = new HashMap<>(); arguments.put("is_correct", error == null); arguments.put("error", Strings.nullToEmpty(error)); final Map<String, Object> value = ImmutableMap.of("protocol_version", arguments); return mapper.writeValueAsString(value); } catch (final IOException e) { throw new ResponseException("Unable to serialize protocol version response arguments to json", e); } } ProtocolVersion();  ProtocolVersion(final String error); @VisibleForTesting  ProtocolVersion(final ObjectMapper mapper, final String error); @Override String toMessage();  }