### Question:
JsonSimplePredicate implements Predicate { static String toOgnl(final Matcher matcher) { final String expression = matcher.group(1); if (!(expression.startsWith("body.") || expression.startsWith("body[")) || isCollectionPath(expression)) { return expression; } final StringBuilder ognl = new StringBuilder(expression.length() + 5); final char[] chars = expression.toCharArray(); boolean start = true; for (final char ch : chars) { if (ch == '.' || ch == '[') { if (!start) { ognl.append(']'); } start = false; ognl.append('['); } else if (ch == '$') { ognl.append("\\$"); } else if (ch != ']') { ognl.append(ch); } } if (!start) { ognl.append(']'); } return ognl.toString(); } JsonSimplePredicate(final String expression, final CamelContext context); @Override @SuppressFBWarnings({"NP_LOAD_OF_KNOWN_NULL_VALUE", "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE", "RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE"}) // https://github.com/spotbugs/spotbugs/issues/868 though this code is fishy (TODO) boolean matches(final Exchange exchange);  }### Answer:
@Test @Parameters({"body.prop, body[prop]", "body.size(), body.size()", "body[3], body[3]", "body[3].prop, body[3][prop]", "body.fr_op.gl$op.ml0op[3], body[fr_op][gl\\$op][ml0op][3]"}) public void shouldConvertSimpleToOgnl(final String simple, final String ognl) { final Matcher matcher = Pattern.compile("(.*)").matcher(simple); matcher.find(); assertThat(JsonSimplePredicate.toOgnl(matcher)).isEqualTo(ognl); }