You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/06/23 19:25:46 UTC

[commons-csv] 01/02: Sort methods.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-csv.git

commit 2d6090b6dde459485e90154876626a996dc62a8c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jun 23 15:14:08 2021 -0400

    Sort methods.
---
 .../java/org/apache/commons/csv/CSVRecordTest.java | 56 +++++++++++-----------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/src/test/java/org/apache/commons/csv/CSVRecordTest.java b/src/test/java/org/apache/commons/csv/CSVRecordTest.java
index 46ce41c..4bd1a40 100644
--- a/src/test/java/org/apache/commons/csv/CSVRecordTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVRecordTest.java
@@ -81,6 +81,14 @@ public class CSVRecordTest {
     }
 
     @Test
+    public void testCSVRecordNULLValues() throws IOException {
+        final CSVParser parser = CSVParser.parse("A,B\r\nONE,TWO", CSVFormat.DEFAULT.withHeader());
+        final CSVRecord csvRecord = new CSVRecord(parser, null, null, 0L, 0L);
+        assertEquals(0, csvRecord.size());
+        assertThrows(IllegalArgumentException.class, () -> csvRecord.get("B"));
+    }
+
+    @Test
     public void testGetInt() {
         assertEquals(values[0], record.get(0));
         assertEquals(values[1], record.get(1));
@@ -88,6 +96,11 @@ public class CSVRecordTest {
     }
 
     @Test
+    public void testGetNullEnum() {
+        assertThrows(IllegalArgumentException.class, () -> recordWithHeader.get((Enum<?>) null));
+    }
+
+    @Test
     public void testGetString() {
         assertEquals(values[0], recordWithHeader.get("first"));
         assertEquals(values[1], recordWithHeader.get("second"));
@@ -111,11 +124,6 @@ public class CSVRecordTest {
     }
 
     @Test
-    public void testGetNullEnum() {
-        assertThrows(IllegalArgumentException.class, () -> recordWithHeader.get((Enum<?>) null));
-    }
-
-    @Test
     public void testGetUnmappedName() {
         assertThrows(IllegalArgumentException.class, () -> assertNull(recordWithHeader.get("fourth")));
     }
@@ -131,6 +139,13 @@ public class CSVRecordTest {
     }
 
     @Test
+    public void testGetWithEnum() {
+        assertEquals(recordWithHeader.get("first"), recordWithHeader.get(EnumHeader.FIRST));
+        assertEquals(recordWithHeader.get("second"), recordWithHeader.get(EnumHeader.SECOND));
+        assertThrows(IllegalArgumentException.class, () -> recordWithHeader.get(EnumFixture.UNKNOWN_COLUMN));
+    }
+
+    @Test
     public void testIsConsistent() {
         assertTrue(record.isConsistent());
         assertTrue(recordWithHeader.isConsistent());
@@ -281,6 +296,14 @@ public class CSVRecordTest {
         }
     }
 
+    @Test
+    public void testToString() {
+        assertNotNull(recordWithHeader.toString());
+        assertTrue(recordWithHeader.toString().contains("comment="));
+        assertTrue(recordWithHeader.toString().contains("recordNumber="));
+        assertTrue(recordWithHeader.toString().contains("values="));
+    }
+
     private void validateMap(final Map<String, String> map, final boolean allowsNulls) {
         assertTrue(map.containsKey("first"));
         assertTrue(map.containsKey("second"));
@@ -294,27 +317,4 @@ public class CSVRecordTest {
         assertEquals("C", map.get("third"));
         assertEquals(null, map.get("fourth"));
     }
-
-    @Test
-    public void testToString() {
-        assertNotNull(recordWithHeader.toString());
-        assertTrue(recordWithHeader.toString().contains("comment="));
-        assertTrue(recordWithHeader.toString().contains("recordNumber="));
-        assertTrue(recordWithHeader.toString().contains("values="));
-    }
-
-    @Test
-    public void testGetWithEnum() {
-        assertEquals(recordWithHeader.get("first"), recordWithHeader.get(EnumHeader.FIRST));
-        assertEquals(recordWithHeader.get("second"), recordWithHeader.get(EnumHeader.SECOND));
-        assertThrows(IllegalArgumentException.class, () -> recordWithHeader.get(EnumFixture.UNKNOWN_COLUMN));
-    }
-
-    @Test
-    public void testCSVRecordNULLValues() throws IOException {
-        final CSVParser parser = CSVParser.parse("A,B\r\nONE,TWO", CSVFormat.DEFAULT.withHeader());
-        final CSVRecord csvRecord = new CSVRecord(parser, null, null, 0L, 0L);
-        assertEquals(0, csvRecord.size());
-        assertThrows(IllegalArgumentException.class, () -> csvRecord.get("B"));
-    }
 }