Merge branch '1.5.x'
This commit is contained in:
commit
c465fcefad
|
@ -55,7 +55,7 @@ public class ConditionEvaluationReportMessage {
|
||||||
report.getConditionAndOutcomesBySource());
|
report.getConditionAndOutcomesBySource());
|
||||||
for (Map.Entry<String, ConditionAndOutcomes> entry : shortOutcomes.entrySet()) {
|
for (Map.Entry<String, ConditionAndOutcomes> entry : shortOutcomes.entrySet()) {
|
||||||
if (entry.getValue().isFullMatch()) {
|
if (entry.getValue().isFullMatch()) {
|
||||||
addLogMessage(message, entry.getKey(), entry.getValue());
|
addMatchLogMessage(message, entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
message.append(String.format("%n%n"));
|
message.append(String.format("%n%n"));
|
||||||
|
@ -63,7 +63,7 @@ public class ConditionEvaluationReportMessage {
|
||||||
message.append(String.format("-----------------%n"));
|
message.append(String.format("-----------------%n"));
|
||||||
for (Map.Entry<String, ConditionAndOutcomes> entry : shortOutcomes.entrySet()) {
|
for (Map.Entry<String, ConditionAndOutcomes> entry : shortOutcomes.entrySet()) {
|
||||||
if (!entry.getValue().isFullMatch()) {
|
if (!entry.getValue().isFullMatch()) {
|
||||||
addLogMessage(message, entry.getKey(), entry.getValue());
|
addNonMatchLogMessage(message, entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
message.append(String.format("%n%n"));
|
message.append(String.format("%n%n"));
|
||||||
|
@ -109,26 +109,54 @@ public class ConditionEvaluationReportMessage {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addLogMessage(StringBuilder message, String source,
|
private void addMatchLogMessage(StringBuilder message, String source,
|
||||||
|
ConditionAndOutcomes matches) {
|
||||||
|
message.append(String.format("%n %s matched:%n", source));
|
||||||
|
for (ConditionAndOutcome match : matches) {
|
||||||
|
logConditionAndOutcome(message, " ", match);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addNonMatchLogMessage(StringBuilder message, String source,
|
||||||
ConditionAndOutcomes conditionAndOutcomes) {
|
ConditionAndOutcomes conditionAndOutcomes) {
|
||||||
message.append(String.format("%n %s", source));
|
message.append(String.format("%n %s:%n", source));
|
||||||
message.append(conditionAndOutcomes.isFullMatch() ? " matched" : " did not match")
|
List<ConditionAndOutcome> matches = new ArrayList<ConditionAndOutcome>();
|
||||||
.append(String.format("%n"));
|
List<ConditionAndOutcome> nonMatches = new ArrayList<ConditionAndOutcome>();
|
||||||
for (ConditionAndOutcome conditionAndOutcome : conditionAndOutcomes) {
|
for (ConditionAndOutcome conditionAndOutcome : conditionAndOutcomes) {
|
||||||
message.append(" - ");
|
if (conditionAndOutcome.getOutcome().isMatch()) {
|
||||||
String outcomeMessage = conditionAndOutcome.getOutcome().getMessage();
|
matches.add(conditionAndOutcome);
|
||||||
if (StringUtils.hasLength(outcomeMessage)) {
|
|
||||||
message.append(outcomeMessage);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
message.append(conditionAndOutcome.getOutcome().isMatch() ? "matched"
|
nonMatches.add(conditionAndOutcome);
|
||||||
: "did not match");
|
|
||||||
}
|
}
|
||||||
message.append(" (");
|
|
||||||
message.append(ClassUtils
|
|
||||||
.getShortName(conditionAndOutcome.getCondition().getClass()));
|
|
||||||
message.append(String.format(")%n"));
|
|
||||||
}
|
}
|
||||||
|
message.append(String.format(" Did not match:%n"));
|
||||||
|
for (ConditionAndOutcome nonMatch : nonMatches) {
|
||||||
|
logConditionAndOutcome(message, " ", nonMatch);
|
||||||
|
}
|
||||||
|
if (!matches.isEmpty()) {
|
||||||
|
message.append(String.format(" Matched:%n"));
|
||||||
|
for (ConditionAndOutcome match : matches) {
|
||||||
|
logConditionAndOutcome(message, " ", match);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logConditionAndOutcome(StringBuilder message, String indent,
|
||||||
|
ConditionAndOutcome conditionAndOutcome) {
|
||||||
|
message.append(String.format("%s- ", indent));
|
||||||
|
String outcomeMessage = conditionAndOutcome.getOutcome().getMessage();
|
||||||
|
if (StringUtils.hasLength(outcomeMessage)) {
|
||||||
|
message.append(outcomeMessage);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
message.append(conditionAndOutcome.getOutcome().isMatch() ? "matched"
|
||||||
|
: "did not match");
|
||||||
|
}
|
||||||
|
message.append(" (");
|
||||||
|
message.append(
|
||||||
|
ClassUtils.getShortName(conditionAndOutcome.getCondition().getClass()));
|
||||||
|
message.append(String.format(")%n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue