@Test public void exceptionIsThrownForWronglyConstructedJsonDictionary_8() { final Map<String, Object> eventMap = ImmutableMap.of("condition_result", newArrayList(ImmutableMap.of("error", 1))); assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> ConditionEvaluatedEvent.from(eventMap)); }
public static ConditionEvaluatedEvent from(final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("condition_result"); final Map<String, Object> result = Events.ensureOrderedMapOfStringsToObjects((Map<?, ?>) arguments.get(0)); final Boolean conditionResult = (Boolean) result.get("result"); final String error = (String) result.get("error"); if (conditionResult == null && error == null) { throw new IllegalArgumentException( "Condition event should either have evaluation result or exception message"); } return conditionResult != null ? new ConditionEvaluatedEvent(conditionResult) : new ConditionEvaluatedEvent(error); }
ConditionEvaluatedEvent { public static ConditionEvaluatedEvent from(final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("condition_result"); final Map<String, Object> result = Events.ensureOrderedMapOfStringsToObjects((Map<?, ?>) arguments.get(0)); final Boolean conditionResult = (Boolean) result.get("result"); final String error = (String) result.get("error"); if (conditionResult == null && error == null) { throw new IllegalArgumentException( "Condition event should either have evaluation result or exception message"); } return conditionResult != null ? new ConditionEvaluatedEvent(conditionResult) : new ConditionEvaluatedEvent(error); } }
ConditionEvaluatedEvent { public static ConditionEvaluatedEvent from(final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("condition_result"); final Map<String, Object> result = Events.ensureOrderedMapOfStringsToObjects((Map<?, ?>) arguments.get(0)); final Boolean conditionResult = (Boolean) result.get("result"); final String error = (String) result.get("error"); if (conditionResult == null && error == null) { throw new IllegalArgumentException( "Condition event should either have evaluation result or exception message"); } return conditionResult != null ? new ConditionEvaluatedEvent(conditionResult) : new ConditionEvaluatedEvent(error); } ConditionEvaluatedEvent(final String error);  ConditionEvaluatedEvent(final Boolean conditionResult); }
ConditionEvaluatedEvent { public static ConditionEvaluatedEvent from(final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("condition_result"); final Map<String, Object> result = Events.ensureOrderedMapOfStringsToObjects((Map<?, ?>) arguments.get(0)); final Boolean conditionResult = (Boolean) result.get("result"); final String error = (String) result.get("error"); if (conditionResult == null && error == null) { throw new IllegalArgumentException( "Condition event should either have evaluation result or exception message"); } return conditionResult != null ? new ConditionEvaluatedEvent(conditionResult) : new ConditionEvaluatedEvent(error); } ConditionEvaluatedEvent(final String error);  ConditionEvaluatedEvent(final Boolean conditionResult); static ConditionEvaluatedEvent from(final Map<String, Object> eventMap); Optional<Boolean> getResult(); Optional<String> getError(); @Override boolean equals(final Object obj); @Override int hashCode(); }
ConditionEvaluatedEvent { public static ConditionEvaluatedEvent from(final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("condition_result"); final Map<String, Object> result = Events.ensureOrderedMapOfStringsToObjects((Map<?, ?>) arguments.get(0)); final Boolean conditionResult = (Boolean) result.get("result"); final String error = (String) result.get("error"); if (conditionResult == null && error == null) { throw new IllegalArgumentException( "Condition event should either have evaluation result or exception message"); } return conditionResult != null ? new ConditionEvaluatedEvent(conditionResult) : new ConditionEvaluatedEvent(error); } ConditionEvaluatedEvent(final String error);  ConditionEvaluatedEvent(final Boolean conditionResult); static ConditionEvaluatedEvent from(final Map<String, Object> eventMap); Optional<Boolean> getResult(); Optional<String> getError(); @Override boolean equals(final Object obj); @Override int hashCode();  }