nastra commented on code in PR #11354:
URL: https://github.com/apache/iceberg/pull/11354#discussion_r1812056517


##########
core/src/test/java/org/apache/iceberg/TestSnapshotJson.java:
##########
@@ -35,6 +40,58 @@ public class TestSnapshotJson {
 
   public TableOperations ops = new LocalTableOperations(temp);
 
+  @Test
+  public void testToJson() throws IOException {
+    int snapshotId = 23;
+    Long parentId = null;
+    String manifestList = createManifestListWithManifestFiles(snapshotId, 
parentId);
+
+    Snapshot expected =
+        new BaseSnapshot(
+            0, snapshotId, parentId, System.currentTimeMillis(), null, null, 
1, manifestList);
+    String json = SnapshotParser.toJson(expected);
+
+    // Assert that summary field is not present in the JSON
+    ObjectMapper objectMapper = new ObjectMapper();
+    JsonNode jsonNode = objectMapper.readTree(json);
+    assertThat(jsonNode.has("summary")).isFalse();

Review Comment:
   can be simplified into a single line. Also it's better to use `anyMatch` 
here instead of `isFalse()`/`isTrue()`, because  `isFalse()`/`isTrue()` won't 
show the content of the json node if the assertion ever fails:
   
   `assertThat(new ObjectMapper().readTree(json)).anyMatch(node -> 
!node.has("summary"));`
   
   



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to