kevinrr888 commented on code in PR #5948:
URL: https://github.com/apache/accumulo/pull/5948#discussion_r2414886823
##########
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:
```suggestion
assertEquals(expectedJson, actualJson);
```
JsonNodes can be compared directly
--
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]