2222import static org .apache .commons .csv .Constants .CR ;
2323import static org .apache .commons .csv .Constants .CRLF ;
2424import static org .apache .commons .csv .Constants .LF ;
25- import static org .junit . jupiter . api . Assertions . assertArrayEquals ;
25+ import static org .apache . commons . csv . CsvAssertions . assertValuesEquals ;
2626import static org .junit .jupiter .api .Assertions .assertEquals ;
2727import static org .junit .jupiter .api .Assertions .assertFalse ;
2828import static org .junit .jupiter .api .Assertions .assertInstanceOf ;
@@ -217,7 +217,7 @@ void testBackslashEscapingOld() throws IOException {
217217 assertEquals (res .length , records .size ());
218218 assertFalse (records .isEmpty ());
219219 for (int i = 0 ; i < res .length ; i ++) {
220- assertArrayEquals (res [i ], records .get (i ). values ( ));
220+ assertValuesEquals (res [i ], records .get (i ));
221221 }
222222 }
223223 }
@@ -479,7 +479,7 @@ void testEmptyLineBehaviorCSV() throws Exception {
479479 assertEquals (res .length , records .size ());
480480 assertFalse (records .isEmpty ());
481481 for (int i = 0 ; i < res .length ; i ++) {
482- assertArrayEquals (res [i ], records .get (i ). values ( ));
482+ assertValuesEquals (res [i ], records .get (i ));
483483 }
484484 }
485485 }
@@ -496,7 +496,7 @@ void testEmptyLineBehaviorExcel() throws Exception {
496496 assertEquals (res .length , records .size ());
497497 assertFalse (records .isEmpty ());
498498 for (int i = 0 ; i < res .length ; i ++) {
499- assertArrayEquals (res [i ], records .get (i ). values ( ));
499+ assertValuesEquals (res [i ], records .get (i ));
500500 }
501501 }
502502 }
@@ -521,7 +521,7 @@ void testEndOfFileBehaviorCSV() throws Exception {
521521 assertEquals (res .length , records .size ());
522522 assertFalse (records .isEmpty ());
523523 for (int i = 0 ; i < res .length ; i ++) {
524- assertArrayEquals (res [i ], records .get (i ). values ( ));
524+ assertValuesEquals (res [i ], records .get (i ));
525525 }
526526 }
527527 }
@@ -540,7 +540,7 @@ void testEndOfFileBehaviorExcel() throws Exception {
540540 assertEquals (res .length , records .size ());
541541 assertFalse (records .isEmpty ());
542542 for (int i = 0 ; i < res .length ; i ++) {
543- assertArrayEquals (res [i ], records .get (i ). values ( ));
543+ assertValuesEquals (res [i ], records .get (i ));
544544 }
545545 }
546546 }
@@ -556,7 +556,7 @@ void testExcelFormat1() throws IOException {
556556 assertEquals (res .length , records .size ());
557557 assertFalse (records .isEmpty ());
558558 for (int i = 0 ; i < res .length ; i ++) {
559- assertArrayEquals (res [i ], records .get (i ). values ( ));
559+ assertValuesEquals (res [i ], records .get (i ));
560560 }
561561 }
562562 }
@@ -570,7 +570,7 @@ void testExcelFormat2() throws Exception {
570570 assertEquals (res .length , records .size ());
571571 assertFalse (records .isEmpty ());
572572 for (int i = 0 ; i < res .length ; i ++) {
573- assertArrayEquals (res [i ], records .get (i ). values ( ));
573+ assertValuesEquals (res [i ], records .get (i ));
574574 }
575575 }
576576 }
@@ -629,9 +629,9 @@ void testForEach() throws Exception {
629629 records .add (record );
630630 }
631631 assertEquals (3 , records .size ());
632- assertArrayEquals (new String [] { "a" , "b" , "c" }, records .get (0 ). values ( ));
633- assertArrayEquals (new String [] { "1" , "2" , "3" }, records .get (1 ). values ( ));
634- assertArrayEquals (new String [] { "x" , "y" , "z" }, records .get (2 ). values ( ));
632+ assertValuesEquals (new String [] { "a" , "b" , "c" }, records .get (0 ));
633+ assertValuesEquals (new String [] { "1" , "2" , "3" }, records .get (1 ));
634+ assertValuesEquals (new String [] { "x" , "y" , "z" }, records .get (2 ));
635635 }
636636 }
637637
@@ -756,7 +756,7 @@ void testGetHeaderNamesReadOnly() throws IOException {
756756 void testGetLine () throws IOException {
757757 try (CSVParser parser = CSVParser .parse (CSV_INPUT , CSVFormat .DEFAULT .withIgnoreSurroundingSpaces ())) {
758758 for (final String [] re : RESULT ) {
759- assertArrayEquals (re , parser .nextRecord (). values ());
759+ assertValuesEquals (re , parser .nextRecord ());
760760 }
761761
762762 assertNull (parser .nextRecord ());
@@ -782,7 +782,7 @@ void testGetLineNumberWithLF() throws Exception {
782782 void testGetOneLine () throws IOException {
783783 try (CSVParser parser = CSVParser .parse (CSV_INPUT_1 , CSVFormat .DEFAULT )) {
784784 final CSVRecord record = parser .getRecords ().get (0 );
785- assertArrayEquals (RESULT [0 ], record . values () );
785+ assertValuesEquals (RESULT [0 ], record );
786786 }
787787 }
788788
@@ -803,11 +803,11 @@ void testGetOneLineOneParser() throws IOException {
803803 writer .append (CSV_INPUT_1 );
804804 writer .append (format .getRecordSeparator ());
805805 final CSVRecord record1 = parser .nextRecord ();
806- assertArrayEquals (RESULT [0 ], record1 . values () );
806+ assertValuesEquals (RESULT [0 ], record1 );
807807 writer .append (CSV_INPUT_2 );
808808 writer .append (format .getRecordSeparator ());
809809 final CSVRecord record2 = parser .nextRecord ();
810- assertArrayEquals (RESULT [1 ], record2 . values () );
810+ assertValuesEquals (RESULT [1 ], record2 );
811811 }
812812 }
813813
@@ -877,7 +877,7 @@ void testGetRecords() throws IOException {
877877 assertEquals (RESULT .length , records .size ());
878878 assertFalse (records .isEmpty ());
879879 for (int i = 0 ; i < RESULT .length ; i ++) {
880- assertArrayEquals (RESULT [i ], records .get (i ). values ( ));
880+ assertValuesEquals (RESULT [i ], records .get (i ));
881881 }
882882 }
883883 }
@@ -899,7 +899,7 @@ void testGetRecordsMaxRows(final long maxRows) throws IOException {
899899 assertEquals (expectedLength , records .size ());
900900 assertFalse (records .isEmpty ());
901901 for (int i = 0 ; i < expectedLength ; i ++) {
902- assertArrayEquals (RESULT [i ], records .get (i ). values ( ));
902+ assertValuesEquals (RESULT [i ], records .get (i ));
903903 }
904904 }
905905 }
@@ -1155,12 +1155,12 @@ void testIterator() throws Exception {
11551155 final Iterator <CSVRecord > iterator = parser .iterator ();
11561156 assertTrue (iterator .hasNext ());
11571157 assertThrows (UnsupportedOperationException .class , iterator ::remove );
1158- assertArrayEquals (new String [] { "a" , "b" , "c" }, iterator .next (). values ());
1159- assertArrayEquals (new String [] { "1" , "2" , "3" }, iterator .next (). values ());
1158+ assertValuesEquals (new String [] { "a" , "b" , "c" }, iterator .next ());
1159+ assertValuesEquals (new String [] { "1" , "2" , "3" }, iterator .next ());
11601160 assertTrue (iterator .hasNext ());
11611161 assertTrue (iterator .hasNext ());
11621162 assertTrue (iterator .hasNext ());
1163- assertArrayEquals (new String [] { "x" , "y" , "z" }, iterator .next (). values ());
1163+ assertValuesEquals (new String [] { "x" , "y" , "z" }, iterator .next ());
11641164 assertFalse (iterator .hasNext ());
11651165 assertThrows (NoSuchElementException .class , iterator ::next );
11661166 }
@@ -1174,20 +1174,20 @@ void testIteratorMaxRows(final long maxRows) throws Exception {
11741174 final Iterator <CSVRecord > iterator = parser .iterator ();
11751175 assertTrue (iterator .hasNext ());
11761176 assertThrows (UnsupportedOperationException .class , iterator ::remove );
1177- assertArrayEquals (new String [] { "a" , "b" , "c" }, iterator .next (). values ());
1177+ assertValuesEquals (new String [] { "a" , "b" , "c" }, iterator .next ());
11781178 final boolean noLimit = maxRows <= 0 ;
11791179 final int fixtureLen = 3 ;
11801180 final long expectedLen = noLimit ? fixtureLen : Math .min (fixtureLen , maxRows );
11811181 if (expectedLen > 1 ) {
11821182 assertTrue (iterator .hasNext ());
1183- assertArrayEquals (new String [] { "1" , "2" , "3" }, iterator .next (). values ());
1183+ assertValuesEquals (new String [] { "1" , "2" , "3" }, iterator .next ());
11841184 }
11851185 assertEquals (expectedLen > 2 , iterator .hasNext ());
11861186 // again
11871187 assertEquals (expectedLen > 2 , iterator .hasNext ());
11881188 if (expectedLen == fixtureLen ) {
11891189 assertTrue (iterator .hasNext ());
1190- assertArrayEquals (new String [] { "x" , "y" , "z" }, iterator .next (). values ());
1190+ assertValuesEquals (new String [] { "x" , "y" , "z" }, iterator .next ());
11911191 }
11921192 assertFalse (iterator .hasNext ());
11931193 assertThrows (NoSuchElementException .class , iterator ::next );
@@ -1584,7 +1584,7 @@ void testParsingPrintedEmptyFirstColumn(final CSVFormat.Predefined format) throw
15841584 .setFormat (format .getFormat ())
15851585 .get ()) {
15861586 for (final String [] line : lines ) {
1587- assertArrayEquals (line , csvRecords .nextRecord (). values ());
1587+ assertValuesEquals (line , csvRecords .nextRecord ());
15881588 }
15891589 assertNull (csvRecords .nextRecord ());
15901590 }
@@ -1715,7 +1715,7 @@ void testStartWithEmptyLinesThenHeaders() throws Exception {
17151715 assertEquals (res .length , records .size ());
17161716 assertFalse (records .isEmpty ());
17171717 for (int i = 0 ; i < res .length ; i ++) {
1718- assertArrayEquals (res [i ], records .get (i ). values ( ));
1718+ assertValuesEquals (res [i ], records .get (i ));
17191719 }
17201720 }
17211721 }
@@ -1727,9 +1727,9 @@ void testStream() throws Exception {
17271727 try (CSVParser parser = CSVFormat .DEFAULT .parse (in )) {
17281728 final List <CSVRecord > list = parser .stream ().collect (Collectors .toList ());
17291729 assertFalse (list .isEmpty ());
1730- assertArrayEquals (new String [] { "a" , "b" , "c" }, list .get (0 ). values ( ));
1731- assertArrayEquals (new String [] { "1" , "2" , "3" }, list .get (1 ). values ( ));
1732- assertArrayEquals (new String [] { "x" , "y" , "z" }, list .get (2 ). values ( ));
1730+ assertValuesEquals (new String [] { "a" , "b" , "c" }, list .get (0 ));
1731+ assertValuesEquals (new String [] { "1" , "2" , "3" }, list .get (1 ));
1732+ assertValuesEquals (new String [] { "x" , "y" , "z" }, list .get (2 ));
17331733 }
17341734 }
17351735
@@ -1740,12 +1740,12 @@ void testStreamMaxRows(final long maxRows) throws Exception {
17401740 try (CSVParser parser = CSVFormat .DEFAULT .builder ().setMaxRows (maxRows ).get ().parse (in )) {
17411741 final List <CSVRecord > list = parser .stream ().collect (Collectors .toList ());
17421742 assertFalse (list .isEmpty ());
1743- assertArrayEquals (new String [] { "a" , "b" , "c" }, list .get (0 ). values ( ));
1743+ assertValuesEquals (new String [] { "a" , "b" , "c" }, list .get (0 ));
17441744 if (maxRows <= 0 || maxRows > 1 ) {
1745- assertArrayEquals (new String [] { "1" , "2" , "3" }, list .get (1 ). values ( ));
1745+ assertValuesEquals (new String [] { "1" , "2" , "3" }, list .get (1 ));
17461746 }
17471747 if (maxRows <= 0 || maxRows > 2 ) {
1748- assertArrayEquals (new String [] { "x" , "y" , "z" }, list .get (2 ). values ( ));
1748+ assertValuesEquals (new String [] { "x" , "y" , "z" }, list .get (2 ));
17491749 }
17501750 }
17511751 }
0 commit comments