Simplify test
This commit is contained in:
parent
989116cdb1
commit
6293899720
|
@ -26,6 +26,7 @@ import java.io.StringWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.commons.csv.CSVFormat;
|
import org.apache.commons.csv.CSVFormat;
|
||||||
import org.apache.commons.csv.CSVParser;
|
import org.apache.commons.csv.CSVParser;
|
||||||
|
@ -55,17 +56,12 @@ import org.junit.jupiter.api.Test;
|
||||||
// 3 a b,c,d "quoted" e
|
// 3 a b,c,d "quoted" e
|
||||||
//
|
//
|
||||||
public class JiraCsv290Test {
|
public class JiraCsv290Test {
|
||||||
|
|
||||||
private void testHelper(final String filename, final CSVFormat format) throws Exception {
|
private void testHelper(final String filename, final CSVFormat format) throws Exception {
|
||||||
final List<List<String>> content = new ArrayList<>();
|
List<List<String>> content = new ArrayList<>();
|
||||||
try (CSVParser csvParser = CSVParser.parse(new InputStreamReader(
|
try (CSVParser csvParser = CSVParser.parse(new InputStreamReader(this.getClass().getResourceAsStream("/org/apache/commons/csv/CSV-290/" + filename)),
|
||||||
this.getClass().getResourceAsStream("/org/apache/commons/csv/CSV-290/" + filename)), format)) {
|
format)) {
|
||||||
for (CSVRecord csvRecord : csvParser) {
|
content = csvParser.stream().collect(Collectors.mapping(CSVRecord::toList, Collectors.toList()));
|
||||||
final List<String> row = new ArrayList<>();
|
|
||||||
content.add(row);
|
|
||||||
for (int i = 0; i < csvRecord.size(); i++) {
|
|
||||||
row.add(csvRecord.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(3, content.size());
|
assertEquals(3, content.size());
|
||||||
|
|
Loading…
Reference in New Issue