@Test public void shouldConfigurePadding() { UniVocityFixedWidthDataFormat dataFormat = new UniVocityFixedWidthDataFormat().setFieldLengths(new int[] {1, 2, 3}).setPadding('p'); assertEquals(Character.valueOf('p'), dataFormat.getPadding()); assertEquals('p', dataFormat.createAndConfigureWriterSettings().getFormat().getPadding()); assertEquals('p', dataFormat.createAndConfigureParserSettings().getFormat().getPadding()); }
@Test public void shouldConfigureRecordEndsOnNewline() { UniVocityFixedWidthDataFormat dataFormat = new UniVocityFixedWidthDataFormat() .setFieldLengths(new int[] {1, 2, 3}) .setRecordEndsOnNewline(true); assertTrue(dataFormat.getRecordEndsOnNewline()); assertTrue(dataFormat.createAndConfigureParserSettings().getRecordEndsOnNewline()); }
@Test public void shouldConfigureNumberOfRecordsToRead() { UniVocityFixedWidthDataFormat dataFormat = new UniVocityFixedWidthDataFormat() .setFieldLengths(new int[] {1, 2, 3}) .setNumberOfRecordsToRead(42); assertEquals(Integer.valueOf(42), dataFormat.getNumberOfRecordsToRead()); assertEquals(42, dataFormat.createAndConfigureParserSettings().getNumberOfRecordsToRead()); }
@Test public void shouldConfigureHeaderExtractionEnabled() { UniVocityFixedWidthDataFormat dataFormat = new UniVocityFixedWidthDataFormat() .setFieldLengths(new int[] {1, 2, 3}) .setHeaderExtractionEnabled(true); assertTrue(dataFormat.getHeaderExtractionEnabled()); assertTrue(dataFormat.createAndConfigureParserSettings().isHeaderExtractionEnabled()); }
@Test public void shouldConfigureIgnoreLeadingWhitespaces() { UniVocityFixedWidthDataFormat dataFormat = new UniVocityFixedWidthDataFormat() .setFieldLengths(new int[] {1, 2, 3}) .setIgnoreLeadingWhitespaces(true); assertTrue(dataFormat.getIgnoreLeadingWhitespaces()); assertTrue(dataFormat.createAndConfigureWriterSettings().getIgnoreLeadingWhitespaces()); assertTrue(dataFormat.createAndConfigureParserSettings().getIgnoreLeadingWhitespaces()); }
@Test public void shouldConfigureNullValue() { UniVocityFixedWidthDataFormat dataFormat = new UniVocityFixedWidthDataFormat() .setFieldLengths(new int[] {1, 2, 3}) .setNullValue("N/A"); assertEquals("N/A", dataFormat.getNullValue()); assertEquals("N/A", dataFormat.createAndConfigureWriterSettings().getNullValue()); assertEquals("N/A", dataFormat.createAndConfigureParserSettings().getNullValue()); }
@Test public void shouldConfigureHeaders() { UniVocityFixedWidthDataFormat dataFormat = new UniVocityFixedWidthDataFormat() .setFieldLengths(new int[] {1, 2, 3}) .setHeaders(new String[] {"A", "B", "C"}); assertArrayEquals(new String[] {"A", "B", "C"}, dataFormat.getHeaders()); assertArrayEquals( new String[] {"A", "B", "C"}, dataFormat.createAndConfigureWriterSettings().getHeaders()); assertArrayEquals( new String[] {"A", "B", "C"}, dataFormat.createAndConfigureParserSettings().getHeaders()); }
@Test public void shouldConfigureNormalizedLineSeparator() { UniVocityFixedWidthDataFormat dataFormat = new UniVocityFixedWidthDataFormat() .setFieldLengths(new int[] {1, 2, 3}) .setNormalizedLineSeparator('n'); assertEquals(Character.valueOf('n'), dataFormat.getNormalizedLineSeparator()); assertEquals( 'n', dataFormat.createAndConfigureWriterSettings().getFormat().getNormalizedNewline()); assertEquals( 'n', dataFormat.createAndConfigureParserSettings().getFormat().getNormalizedNewline()); }
@Test public void shouldConfigureLineSeparator() { UniVocityFixedWidthDataFormat dataFormat = new UniVocityFixedWidthDataFormat() .setFieldLengths(new int[] {1, 2, 3}) .setLineSeparator("ls"); assertEquals("ls", dataFormat.getLineSeparator()); assertEquals( "ls", dataFormat.createAndConfigureWriterSettings().getFormat().getLineSeparatorString()); assertEquals( "ls", dataFormat.createAndConfigureParserSettings().getFormat().getLineSeparatorString()); }