ArafatKhan2198 commented on code in PR #6500:
URL: https://github.com/apache/ozone/pull/6500#discussion_r1567089022


##########
hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/heatmap/TestHeatMapInfo.java:
##########
@@ -745,35 +743,43 @@ public void setUp() throws Exception {
   public void testHeatMapGeneratedInfo() throws IOException {
     // Setup
     // Run the test
-    JsonElement jsonElement = JsonParser.parseString(auditRespStr);
-    JsonObject jsonObject = jsonElement.getAsJsonObject();
-    JsonElement facets = jsonObject.get("facets");
-    JsonObject facetsBucketsObject =
-        facets.getAsJsonObject().get("resources")
-            .getAsJsonObject();
-    ObjectMapper objectMapper = new ObjectMapper();
+    // Parse the JSON string to JsonNode
+    JsonNode rootNode = JsonUtils.readTree(auditRespStr);
 
-    HeatMapProviderDataResource auditLogFacetsResources =
-        objectMapper.readValue(
-            facetsBucketsObject.toString(), HeatMapProviderDataResource.class);
-    EntityMetaData[] entities = auditLogFacetsResources.getMetaDataList();
-    List<EntityMetaData> entityMetaDataList =
-        Arrays.stream(entities).collect(Collectors.toList());
-    EntityReadAccessHeatMapResponse entityReadAccessHeatMapResponse =
-        heatMapUtil.generateHeatMap(entityMetaDataList);
-    
assertThat(entityReadAccessHeatMapResponse.getChildren().size()).isGreaterThan(0);
-    assertEquals(12, entityReadAccessHeatMapResponse.getChildren().size());
-    assertEquals(25600, entityReadAccessHeatMapResponse.getSize());
-    assertEquals(2924, entityReadAccessHeatMapResponse.getMinAccessCount());
-    assertEquals(155074, entityReadAccessHeatMapResponse.getMaxAccessCount());
-    assertEquals("root", entityReadAccessHeatMapResponse.getLabel());
-    assertEquals(0.0, 
entityReadAccessHeatMapResponse.getChildren().get(0).getColor());
-    assertEquals(0.442,
-        entityReadAccessHeatMapResponse.getChildren().get(0).getChildren()
-            .get(0).getChildren().get(1).getColor());
-    assertEquals(0.058,
-        entityReadAccessHeatMapResponse.getChildren().get(0).getChildren()
-            .get(1).getChildren().get(3).getColor());
+    JsonNode facetsNode = rootNode.path("facets");
+    JsonNode resourcesNode = facetsNode.path("resources");
+
+    // Deserialize the resources node directly if it's not missing
+    HeatMapProviderDataResource auditLogFacetsResources = null;
+
+    if (!resourcesNode.isMissingNode()) {
+      auditLogFacetsResources = JsonUtils.treeToValue(resourcesNode,
+          HeatMapProviderDataResource.class);
+    }
+
+    if (auditLogFacetsResources != null) {

Review Comment:
   Added the assertion thanks!
   The checks for missing nodes are performed using !isMissingNode() instead of 
checking if the value is not `JsonNull`.
   



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to