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


##########
core/src/test/java/org/apache/iceberg/TestContentFileParser.java:
##########
@@ -210,6 +210,57 @@ public void testPartitionArrayRespectsSpecOrder() throws 
Exception {
     assertThat(deserializedContentFile.partition().get(1, 
String.class)).isEqualTo("foo");
   }
 
+  @Test
+  public void testInvalidContentType() throws Exception {
+    String jsonStr =
+        "{\"spec-id\":0,"
+            + "\"content\":\"invalid-content\","
+            + "\"file-path\":\"/path/to/file.parquet\","
+            + "\"file-format\":\"parquet\","
+            + "\"partition\":{},"
+            + "\"file-size-in-bytes\":1,"
+            + "\"record-count\":1}";
+
+    JsonNode node = JsonUtil.mapper().readTree(jsonStr);
+
+    assertThatThrownBy(
+            () -> ContentFileParser.fromJson(node, Map.of(0, 
PartitionSpec.unpartitioned())))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("Invalid file content value: 'invalid-content'");
+  }
+
+  @ParameterizedTest
+  @MethodSource("enumContentTypeCases")
+  public void testEnumContentTypeSerialization(FileContent content, String 
expectedJsonContent)
+      throws Exception {
+    String jsonStr =
+        "{\"spec-id\":0,"
+            + "\"content\":\""
+            + content.name()
+            + "\","
+            + "\"file-path\":\"/path/to/data.parquet\","
+            + "\"file-format\":\"parquet\","

Review Comment:
   can we also make sure that sending the format as uppercase still works?



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