@Test public void exceptionIsThrownForWronglyConstructedJsonDictionary_4() { final Map<String, Object> eventMap = ImmutableMap.of("variables", newArrayList("foo")); assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> VariablesEvent.from(eventMap)); }
public static VariablesEvent from(final Map<String, Object> eventMap) { final Map<?, ?> arguments = (Map<?, ?>) ((List<?>) eventMap.get("variables")).get(0); final List<?> varScopes = (List<?>) arguments.get("var_scopes"); final String error = (String) arguments.get("error"); if (varScopes == null) { throw new IllegalArgumentException("Variables events should have scopes provided"); } return new VariablesEvent(extractVariableScopes(varScopes), error); }
VariablesEvent { public static VariablesEvent from(final Map<String, Object> eventMap) { final Map<?, ?> arguments = (Map<?, ?>) ((List<?>) eventMap.get("variables")).get(0); final List<?> varScopes = (List<?>) arguments.get("var_scopes"); final String error = (String) arguments.get("error"); if (varScopes == null) { throw new IllegalArgumentException("Variables events should have scopes provided"); } return new VariablesEvent(extractVariableScopes(varScopes), error); } }
VariablesEvent { public static VariablesEvent from(final Map<String, Object> eventMap) { final Map<?, ?> arguments = (Map<?, ?>) ((List<?>) eventMap.get("variables")).get(0); final List<?> varScopes = (List<?>) arguments.get("var_scopes"); final String error = (String) arguments.get("error"); if (varScopes == null) { throw new IllegalArgumentException("Variables events should have scopes provided"); } return new VariablesEvent(extractVariableScopes(varScopes), error); } VariablesEvent(final List<Map<Variable, VariableTypedValue>> variables, final String error); }
VariablesEvent { public static VariablesEvent from(final Map<String, Object> eventMap) { final Map<?, ?> arguments = (Map<?, ?>) ((List<?>) eventMap.get("variables")).get(0); final List<?> varScopes = (List<?>) arguments.get("var_scopes"); final String error = (String) arguments.get("error"); if (varScopes == null) { throw new IllegalArgumentException("Variables events should have scopes provided"); } return new VariablesEvent(extractVariableScopes(varScopes), error); } VariablesEvent(final List<Map<Variable, VariableTypedValue>> variables, final String error); static VariablesEvent from(final Map<String, Object> eventMap); List<Map<Variable, VariableTypedValue>> getVariables(); boolean hasError(); Optional<String> getError(); @Override boolean equals(final Object obj); @Override int hashCode(); }
VariablesEvent { public static VariablesEvent from(final Map<String, Object> eventMap) { final Map<?, ?> arguments = (Map<?, ?>) ((List<?>) eventMap.get("variables")).get(0); final List<?> varScopes = (List<?>) arguments.get("var_scopes"); final String error = (String) arguments.get("error"); if (varScopes == null) { throw new IllegalArgumentException("Variables events should have scopes provided"); } return new VariablesEvent(extractVariableScopes(varScopes), error); } VariablesEvent(final List<Map<Variable, VariableTypedValue>> variables, final String error); static VariablesEvent from(final Map<String, Object> eventMap); List<Map<Variable, VariableTypedValue>> getVariables(); boolean hasError(); Optional<String> getError(); @Override boolean equals(final Object obj); @Override int hashCode();  }