francisohara24 commented on code in PR #31853:
URL: https://github.com/apache/beam/pull/31853#discussion_r1674642315


##########
sdks/java/io/csv/src/test/java/org/apache/beam/sdk/io/csv/CsvIOParseHelpersTest.java:
##########
@@ -33,6 +34,77 @@
 @RunWith(JUnit4.class)
 public class CsvIOParseHelpersTest {
 
+  /** Tests for {@link CsvIOParseHelpers#validate(CSVFormat)}. */
+  @Test
+  public void givenCSVFormatWithHeader_validates() {
+    CSVFormat format = csvFormatWithHeader();
+    CsvIOParseHelpers.validate(format);
+  }
+
+  @Test
+  public void givenCSVFormatWithNullHeader_throwsException() {
+    CSVFormat format = csvFormat();
+    String gotMessage =
+        assertThrows(IllegalArgumentException.class, () -> 
CsvIOParseHelpers.validate(format))
+            .getMessage();
+    assertEquals("Illegal class org.apache.commons.csv.CSVFormat: header is 
required", gotMessage);

Review Comment:
   I also think it's important to check the error message because 
`CsvIOParseHelpers::validate(CSVFormat)` throws an `IllegalArgumentException` 
for every error condition, so the error message will ensure that the right 
`IllegalArgumentException` exception was thrown given a particular error 
condition.



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

Reply via email to