@Test public void properMessageIsConstructed_forVariableChangeMessage() { assertThat(new ChangeVariable("a", VariableScope.GLOBAL, 1, newArrayList("a")).toMessage()) .isEqualTo("{\"change_variable\":{\"name\":\"a\",\"values\":[\"a\"],\"scope\":\"global\",\"level\":1}}"); assertThat(new ChangeVariable("a", VariableScope.TEST_SUITE, 2, newArrayList("b")).toMessage()).isEqualTo( "{\"change_variable\":{\"name\":\"a\",\"values\":[\"b\"],\"scope\":\"test_suite\",\"level\":2}}"); assertThat(new ChangeVariable("a", VariableScope.TEST_CASE, 3, newArrayList("c")).toMessage()) .isEqualTo("{\"change_variable\":{\"name\":\"a\",\"values\":[\"c\"],\"scope\":\"test_case\",\"level\":3}}"); assertThat(new ChangeVariable("a", VariableScope.LOCAL, 4, newArrayList("d")).toMessage()) .isEqualTo("{\"change_variable\":{\"name\":\"a\",\"values\":[\"d\"],\"scope\":\"local\",\"level\":4}}"); }
@Override public String toMessage() throws ResponseException { try { final Builder<String, Object> argsBuilder = ImmutableMap.<String, Object> builder() .put("name", variableName) .put("values", arguments) .put("scope", scope.name().toLowerCase()) .put("level", frameLevel); if (!path.isEmpty()) { argsBuilder.put("path", path); } final Map<String, Object> value = ImmutableMap.of("change_variable", argsBuilder.build()); return mapper.writeValueAsString(value); } catch (final IOException e) { throw new ResponseException("Unable to serialize change variable response arguments to json", e); } }
ChangeVariable implements ServerResponse { @Override public String toMessage() throws ResponseException { try { final Builder<String, Object> argsBuilder = ImmutableMap.<String, Object> builder() .put("name", variableName) .put("values", arguments) .put("scope", scope.name().toLowerCase()) .put("level", frameLevel); if (!path.isEmpty()) { argsBuilder.put("path", path); } final Map<String, Object> value = ImmutableMap.of("change_variable", argsBuilder.build()); return mapper.writeValueAsString(value); } catch (final IOException e) { throw new ResponseException("Unable to serialize change variable response arguments to json", e); } } }
ChangeVariable implements ServerResponse { @Override public String toMessage() throws ResponseException { try { final Builder<String, Object> argsBuilder = ImmutableMap.<String, Object> builder() .put("name", variableName) .put("values", arguments) .put("scope", scope.name().toLowerCase()) .put("level", frameLevel); if (!path.isEmpty()) { argsBuilder.put("path", path); } final Map<String, Object> value = ImmutableMap.of("change_variable", argsBuilder.build()); return mapper.writeValueAsString(value); } catch (final IOException e) { throw new ResponseException("Unable to serialize change variable response arguments to json", e); } } ChangeVariable(final String varName, final VariableScope scope, final int frameLevel,
            final List<String> arguments);  ChangeVariable(final String varName, final VariableScope scope, final int frameLevel,
            final List<Object> path, final List<String> arguments); @VisibleForTesting  ChangeVariable(final ObjectMapper mapper, final String varName, final VariableScope scope,
            final int frameLevel, final List<Object> path, final List<String> arguments); }
ChangeVariable implements ServerResponse { @Override public String toMessage() throws ResponseException { try { final Builder<String, Object> argsBuilder = ImmutableMap.<String, Object> builder() .put("name", variableName) .put("values", arguments) .put("scope", scope.name().toLowerCase()) .put("level", frameLevel); if (!path.isEmpty()) { argsBuilder.put("path", path); } final Map<String, Object> value = ImmutableMap.of("change_variable", argsBuilder.build()); return mapper.writeValueAsString(value); } catch (final IOException e) { throw new ResponseException("Unable to serialize change variable response arguments to json", e); } } ChangeVariable(final String varName, final VariableScope scope, final int frameLevel,
            final List<String> arguments);  ChangeVariable(final String varName, final VariableScope scope, final int frameLevel,
            final List<Object> path, final List<String> arguments); @VisibleForTesting  ChangeVariable(final ObjectMapper mapper, final String varName, final VariableScope scope,
            final int frameLevel, final List<Object> path, final List<String> arguments); @Override String toMessage(); }
ChangeVariable implements ServerResponse { @Override public String toMessage() throws ResponseException { try { final Builder<String, Object> argsBuilder = ImmutableMap.<String, Object> builder() .put("name", variableName) .put("values", arguments) .put("scope", scope.name().toLowerCase()) .put("level", frameLevel); if (!path.isEmpty()) { argsBuilder.put("path", path); } final Map<String, Object> value = ImmutableMap.of("change_variable", argsBuilder.build()); return mapper.writeValueAsString(value); } catch (final IOException e) { throw new ResponseException("Unable to serialize change variable response arguments to json", e); } } ChangeVariable(final String varName, final VariableScope scope, final int frameLevel,
            final List<String> arguments);  ChangeVariable(final String varName, final VariableScope scope, final int frameLevel,
            final List<Object> path, final List<String> arguments); @VisibleForTesting  ChangeVariable(final ObjectMapper mapper, final String varName, final VariableScope scope,
            final int frameLevel, final List<Object> path, final List<String> arguments); @Override String toMessage();  }