Skip to content

Commit

Permalink
Fix BeanAssert (Backport)
Browse files Browse the repository at this point in the history
* Fix message to handle arrays correctly
* Fix output to handle equals at the property level correctly
  • Loading branch information
jodastephen committed Dec 29, 2024
1 parent ce4a15e commit 78d4d27
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/main/java/org/joda/beans/test/BeanAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package org.joda.beans.test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -216,6 +215,9 @@ private static void buildMessage(List<String> diffs, String prefix, Object expec
diffs.add(prefix + ": Was null, but expected " + buildSummary(expected, true));
return;
}
if (expected.equals(actual)) {
return;
}
if (expected instanceof List && actual instanceof List) {
List<?> expectedList = (List<?>) expected;
List<?> actualList = (List<?>) actual;
Expand Down Expand Up @@ -319,14 +321,7 @@ private static void buildMessage(List<String> diffs, String prefix, Object expec
*/
private static String buildSummary(Object obj, boolean includeType) {
String type = obj.getClass().getSimpleName();
String toStr;
if (obj instanceof double[]) {
toStr = Arrays.toString((double[]) obj);
} else if (obj instanceof float[]) {
toStr = Arrays.toString((float[]) obj);
} else {
toStr = obj.toString();
}
String toStr = JodaBeanUtils.toString(obj);
if (toStr.length() > 60) {
toStr = toStr.substring(0, 57) + "...";
}
Expand Down

0 comments on commit 78d4d27

Please sign in to comment.