assertMessagesSorted(expression, false);
}
protected void assertMessagesSorted(Expression expression, boolean ascending) {
String type = ascending ? "ascending" : "descending";
ExpressionComparator comparator = new ExpressionComparator(expression);
List<Exchange> list = getReceivedExchanges();
for (int i = 1; i < list.size(); i++) {
int j = i - 1;
Exchange e1 = list.get(j);
Exchange e2 = list.get(i);
int result = comparator.compare(e1, e2);
if (result == 0) {
fail("Messages not " + type + ". Messages" + j + " and " + i + " are equal with value: "
+ expression.evaluate(e1, Object.class) + " for expression: " + expression + ". Exchanges: " + e1 + " and " + e2);
} else {
if (!ascending) {