annhchen89 commented on code in PR #5948:
URL: https://github.com/apache/accumulo/pull/5948#discussion_r2418049037
##########
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:
@kevinrr888 I tried using assertEquals(expectedJson, actualJson) earlier,
but it failed because the JSON fields were in a different order. The current
approach checks each key/value individually so it remains order-insensitive and
passes consistently.
--
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]