/** * test for or w/ text. */ @Test public void textOr() { StringOption option = new StringOption(); assertThat(option.or(new Text("Hello")).toString(), is("Hello")); assertThat(option.isNull(), is(true)); option.modify(new Text("World")); assertThat(option.or(new Text("Other")).toString(), is("World")); }
private String[][] parse(int columns, String string) { CsvConfiguration conf = new CsvConfiguration( CsvConfiguration.DEFAULT_CHARSET, CsvConfiguration.DEFAULT_HEADER_CELLS, CsvConfiguration.DEFAULT_TRUE_FORMAT, CsvConfiguration.DEFAULT_FALSE_FORMAT, CsvConfiguration.DEFAULT_DATE_FORMAT, CsvConfiguration.DEFAULT_DATE_TIME_FORMAT); List<String[]> results = new ArrayList<>(); ByteArrayInputStream input = new ByteArrayInputStream(string.getBytes(conf.getCharset())); try (CsvParser parser = new CsvParser(input, string, conf)) { StringOption buffer = new StringOption(); while (parser.next()) { String[] line = new String[columns]; for (int i = 0; i < columns; i++) { parser.fill(buffer); line[i] = buffer.or((String) null); } parser.endRecord(); results.add(line); } } catch (Exception e) { throw new AssertionError(e); } return results.toArray(new String[results.size()][]); }