ExpressionResolver { public boolean containsExpression(final Object source) { if (source == null) { return false; } else if (source instanceof String) { return containsExpressionString((String) source); } else if (source instanceof ObjectNode) { return containsExpressionMap(mapper.convertValue(source, MAP_STRING_OBJECT_TYPE)); } else if (source instanceof Map<?, ?>) { return containsExpressionMap((Map<String, ?>) source); } else if (source instanceof List<?>) { return containsExpressionList((List<?>) source); } else { return false; } } ExpressionResolver(ExpressionManager expressionManager,
        ObjectMapper mapper,
        DelegateInterceptor delegateInterceptor); Map<String, Object> resolveExpressionsMap(final ExpressionEvaluator expressionEvaluator,
                                                     final Map<String, ?> sourceMap); boolean containsExpression(final Object source);  }
@Test public void containsExpression_should_returnFalse_when_sourceIsNull() { boolean containsExpression = expressionResolver.containsExpression(null); assertThat(containsExpression).isFalse(); }
@Test public void containsExpression_should_returnFalse_when_stringDoesNotContainExpressionPattern() { boolean containsExpression = expressionResolver.containsExpression("{just string with brackets, this is not an expression}"); assertThat(containsExpression).isFalse(); }
@Test public void containsExpression_should_returnTrue_when_stringContainsExpressionPattern() { boolean containsExpression = expressionResolver.containsExpression("${this is an expression}"); assertThat(containsExpression).isTrue(); }
@Test public void containsExpression_should_returnFalse_when_ObjectNodeDoesNotContainExpressionPattern() throws Exception { ObjectNode objectNode = mapper.readValue("{\"name\": \"Peter\"}", ObjectNode.class); boolean containsExpression = expressionResolver.containsExpression(objectNode); assertThat(containsExpression).isFalse(); }
@Test public void containsExpression_should_returnTrue_when_ObjectNodeContainsExpressionPattern() throws Exception { ObjectNode objectNode = mapper.readValue("{\"name\": \"${name}\"}", ObjectNode.class); boolean containsExpression = expressionResolver.containsExpression(objectNode); assertThat(containsExpression).isTrue(); }
@Test public void containsExpression_should_returnFalse_when_MapValueDoesNotContainExpressionPattern() { Map<String, Integer> source = singletonMap("age", 10); boolean containsExpression = expressionResolver.containsExpression(source); assertThat(containsExpression).isFalse(); }
@Test public void containsExpression_should_returnTrue_when_MapValueContainsExpressionPattern() { Map<String, String> source = singletonMap("age", "${age}"); boolean containsExpression = expressionResolver.containsExpression(source); assertThat(containsExpression).isTrue(); }
@Test public void containsExpression_should_returnFalse_when_ListDoesNotContainExpressionPattern() { List<String> source = asList("first", "second"); boolean containsExpression = expressionResolver.containsExpression(source); assertThat(containsExpression).isFalse(); }
@Test public void containsExpression_should_returnTrue_when_ListContainsExpressionPattern() { List<String> source = asList("first", "${position}", "third"); boolean containsExpression = expressionResolver.containsExpression(source); assertThat(containsExpression).isTrue(); }