gilvansfilho commented on code in PR #10388: URL: https://github.com/apache/camel/pull/10388#discussion_r1232291356
########## core/camel-support/src/main/java/org/apache/camel/support/builder/ExpressionBuilder.java: ########## @@ -2036,4 +2038,42 @@ public String toString() { }; } + /** + * Returns the expression for the message body as pretty formatted string + */ + public static Expression prettyBodyExpression() { + return new ExpressionAdapter() { + @Override + public Object evaluate(Exchange exchange) { + String body = exchange.getIn().getBody(String.class); + + if (body == null) { + return null; + } else if (body.startsWith("{") && body.endsWith("}") || body.startsWith("[") && body.endsWith("]")) { + return Jsoner.prettyPrint(body); //json + } else if(body.startsWith("<") && body.endsWith(">")) { Review Comment: I ran it and nothing happens. Running with `-P sourcecheck` I could see that checkstyle error is at `core/camel-support/src/test/java/org/apache/camel/support/RestConsumerContextPathMatcherTest.java` which was not changed by this PR. According with checkstyle this `https://github.com/apache/camel/blob/main/core/camel-support/src/test/java/org/apache/camel/support/RestConsumerContextPathMatcherTest.java#L29` must be `final` Doing so introduces a new error as below: ``` [ERROR] Tests run: 6, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.048 s <<< FAILURE! -- in org.apache.camel.support.RestConsumerContextPathMatcherTest [ERROR] org.apache.camel.support.RestConsumerContextPathMatcherTest.testRestConsumerContextPathMatcherWithAmbiguousPaths -- Time elapsed: 0.022 s <<< FAILURE! org.opentest4j.AssertionFailedError: Expected java.lang.IllegalStateException to be thrown, but nothing was thrown. ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org