@Test public void exceptionIsThrownForWronglyConstructedJsonDictionary_6() { final Map<String, Object> eventMap = ImmutableMap.of("expression_result", newArrayList(ImmutableMap.of("arg", "foo"))); assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> ExpressionEvaluatedEvent.from(eventMap)); }
public static ExpressionEvaluatedEvent from(final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("expression_result"); final Map<String, Object> result = Events.ensureOrderedMapOfStringsToObjects((Map<?, ?>) arguments.get(0)); final ExpressionType type = ExpressionType.valueOf(((String) result.get("type")).toUpperCase()); final Integer id = (Integer) result.get("id"); final String exprResult = (String) result.get("result"); final String error = (String) result.get("error"); if (id == null || exprResult == null && error == null) { throw new IllegalArgumentException( "Expression event should either have evaluation result or exception message"); } return new ExpressionEvaluatedEvent(id.intValue(), type, exprResult, error); }
ExpressionEvaluatedEvent { public static ExpressionEvaluatedEvent from(final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("expression_result"); final Map<String, Object> result = Events.ensureOrderedMapOfStringsToObjects((Map<?, ?>) arguments.get(0)); final ExpressionType type = ExpressionType.valueOf(((String) result.get("type")).toUpperCase()); final Integer id = (Integer) result.get("id"); final String exprResult = (String) result.get("result"); final String error = (String) result.get("error"); if (id == null || exprResult == null && error == null) { throw new IllegalArgumentException( "Expression event should either have evaluation result or exception message"); } return new ExpressionEvaluatedEvent(id.intValue(), type, exprResult, error); } }
ExpressionEvaluatedEvent { public static ExpressionEvaluatedEvent from(final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("expression_result"); final Map<String, Object> result = Events.ensureOrderedMapOfStringsToObjects((Map<?, ?>) arguments.get(0)); final ExpressionType type = ExpressionType.valueOf(((String) result.get("type")).toUpperCase()); final Integer id = (Integer) result.get("id"); final String exprResult = (String) result.get("result"); final String error = (String) result.get("error"); if (id == null || exprResult == null && error == null) { throw new IllegalArgumentException( "Expression event should either have evaluation result or exception message"); } return new ExpressionEvaluatedEvent(id.intValue(), type, exprResult, error); } ExpressionEvaluatedEvent(final int id, final ExpressionType type, final String result, final String error); }
ExpressionEvaluatedEvent { public static ExpressionEvaluatedEvent from(final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("expression_result"); final Map<String, Object> result = Events.ensureOrderedMapOfStringsToObjects((Map<?, ?>) arguments.get(0)); final ExpressionType type = ExpressionType.valueOf(((String) result.get("type")).toUpperCase()); final Integer id = (Integer) result.get("id"); final String exprResult = (String) result.get("result"); final String error = (String) result.get("error"); if (id == null || exprResult == null && error == null) { throw new IllegalArgumentException( "Expression event should either have evaluation result or exception message"); } return new ExpressionEvaluatedEvent(id.intValue(), type, exprResult, error); } ExpressionEvaluatedEvent(final int id, final ExpressionType type, final String result, final String error); static ExpressionEvaluatedEvent from(final Map<String, Object> eventMap); int getId(); ExpressionType getType(); Optional<String> getResult(); Optional<String> getError(); @Override boolean equals(final Object obj); @Override int hashCode(); }
ExpressionEvaluatedEvent { public static ExpressionEvaluatedEvent from(final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("expression_result"); final Map<String, Object> result = Events.ensureOrderedMapOfStringsToObjects((Map<?, ?>) arguments.get(0)); final ExpressionType type = ExpressionType.valueOf(((String) result.get("type")).toUpperCase()); final Integer id = (Integer) result.get("id"); final String exprResult = (String) result.get("result"); final String error = (String) result.get("error"); if (id == null || exprResult == null && error == null) { throw new IllegalArgumentException( "Expression event should either have evaluation result or exception message"); } return new ExpressionEvaluatedEvent(id.intValue(), type, exprResult, error); } ExpressionEvaluatedEvent(final int id, final ExpressionType type, final String result, final String error); static ExpressionEvaluatedEvent from(final Map<String, Object> eventMap); int getId(); ExpressionType getType(); Optional<String> getResult(); Optional<String> getError(); @Override boolean equals(final Object obj); @Override int hashCode();  }