rdblue commented on code in PR #4716:
URL: https://github.com/apache/iceberg/pull/4716#discussion_r875309128


##########
core/src/test/java/org/apache/iceberg/TestMetadataUpdateParser.java:
##########
@@ -251,11 +274,120 @@ public void testAddSortOrderFromJson() {
     assertEquals(action, expected, MetadataUpdateParser.fromJson(json));
   }
 
+  @Test
+  public void testSetDefaultSortOrderToJson() {
+    String action = MetadataUpdateParser.SET_DEFAULT_SORT_ORDER;
+    int sortOrderId = 2;
+    String expected = 
String.format("{\"action\":\"%s\",\"sort-order-id\":%d}", action, sortOrderId);
+    MetadataUpdate update = new 
MetadataUpdate.SetDefaultSortOrder(sortOrderId);
+    String actual = MetadataUpdateParser.toJson(update);
+    Assert.assertEquals("Set default sort order should serialize to the 
correct JSON value", expected, actual);
+  }
+
+  @Test
+  public void testSetDefaultSortOrderFromJson() {
+    String action = MetadataUpdateParser.SET_DEFAULT_SORT_ORDER;
+    int sortOrderId = 2;
+    String json = String.format("{\"action\":\"%s\",\"sort-order-id\":%d}", 
action, sortOrderId);
+    MetadataUpdate expected = new 
MetadataUpdate.SetDefaultSortOrder(sortOrderId);
+    assertEquals(action, expected, MetadataUpdateParser.fromJson(json));
+  }
+
+  // TODO - AddSnapshot tests.
+
+  // TODO - Tests that handle multiple snapshot ids.
+  @Test
+  public void testRemoveSnapshotsFromJson() {
+    String action = MetadataUpdateParser.REMOVE_SNAPSHOTS;
+    long[] snapshotIds = { 2L };
+    String json = String.format("{\"action\":\"%s\",\"snapshot-ids\":%s}", 
action, Arrays.toString(snapshotIds));
+    MetadataUpdate expected = new 
MetadataUpdate.RemoveSnapshot(snapshotIds[0]);
+    assertEquals(action, expected, MetadataUpdateParser.fromJson(json));
+  }
+
+  // TODO - Tests that handle multiple snapshot ids.
+  @Test
+  public void testRemoveSnapshotsToJson() {
+    String action = MetadataUpdateParser.REMOVE_SNAPSHOTS;
+    long[] snapshotIds = { 2L };
+    String expected = String.format("{\"action\":\"%s\",\"snapshot-ids\":%s}", 
action, Arrays.toString(snapshotIds));

Review Comment:
   I think it would be better to just embed `[ 2 ]` rather than relying on 
`Arrays.toString`.



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