kevinrr888 commented on code in PR #5948:
URL: https://github.com/apache/accumulo/pull/5948#discussion_r2418084810
##########
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:
I ran it with just the assertEquals comparison without issues
also tested:
```
ObjectMapper mapper = new ObjectMapper();
JsonNode node1 = mapper.readTree("{\"foo\":1,\"bar\":2}");
JsonNode node2 = mapper.readTree("{\"bar\":2,\"foo\":1}");
assertEquals(node1, node2);
```
to be sure, and that passes as well.
--
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]