VariableElResolver implements VariableScopeItemELResolver { @Override public Object resolve(String property, VariableScope variableScope) { VariableInstance variableInstance = variableScope.getVariableInstance(property); Object value = variableInstance.getValue(); if (hasJsonType(variableInstance) && (value instanceof JsonNode) && ((JsonNode) value).isArray()) { return objectMapper.convertValue(value, List.class); } else { return value; } } VariableElResolver(ObjectMapper objectMapper); @Override boolean canResolve(String property, VariableScope variableScope); @Override Object resolve(String property, VariableScope variableScope);  }
@Test public void resolve_should_returnVariableInstanceValueWhenItsNotJsonArray() { VariableScope variableScope = buildVariableScope("myVar", "myValue", "string"); Object result = resolver.resolve("myVar", variableScope); assertThat(result).isEqualTo("myValue"); }
@Test public void resolve_should_returnVariableInstanceValueConvertedToListWhenItsJsonArray() throws Exception { JsonNode jsonNode = objectMapper.readTree("[\"green\", \"blue\", \"red\"]"); VariableScope variableScope = buildVariableScope("colors", jsonNode, "json"); Object result = resolver.resolve("colors", variableScope); assertThat(result).isEqualTo(Arrays.asList("green", "blue", "red")); }