kevinrr888 commented on code in PR #5948:
URL: https://github.com/apache/accumulo/pull/5948#discussion_r2418095895
##########
server/manager/src/test/java/org/apache/accumulo/manager/upgrade/Upgrader11to12Test.java:
##########
@@ -436,8 +440,25 @@ public void upgradeZooKeeperTest() throws Exception {
upgrader.removeZKProblemReports(context);
upgrader.initializeScanRefTable(context);
- assertEquals(zKRootV2, new String(byteCapture.getValue(), UTF_8));
-
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode expectedJson = mapper.readTree(zKRootV2);
+ JsonNode actualJson = mapper.readTree(new String(byteCapture.getValue(),
UTF_8));
+
+ expectedJson.fieldNames().forEachRemaining(field -> {
+ JsonNode expectedValue = expectedJson.get(field);
+ JsonNode actualValue = actualJson.get(field);
+
+ assertNotNull(actualValue, "Missing field in actual JSON: " + field);
+
+ if (!expectedValue.isObject()) {
+ assertEquals(expectedValue, actualValue, "Mismatch at field: " +
field);
+ } else {
+ // check that actual contains all keys
+ expectedValue.fieldNames().forEachRemaining(subField -> {
+ assertTrue(actualValue.has(subField), "Missing sub-field '" +
subField + "' in " + field);
+ });
+ }
+ });
Review Comment:
From
https://www.javadoc.io/doc/com.fasterxml.jackson.core/jackson-databind/latest/com/fasterxml/jackson/databind/JsonNode.html:
public abstract boolean
equals([Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true)
o)
Equality for node objects is defined as full (deep) value equality. This
means that it is possible to compare complete JSON trees for equality by
comparing equality of root nodes.
Note: marked as abstract to ensure all implementation classes define it
properly and not rely on definition from
[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true).
Overrides:
[equals](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#equals-java.lang.Object-)
in class
[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]