### Question:
NonBlockingBufferReader implements AutoCloseable { public List<TextBlock> readLines(final int minRecords, final boolean strict) throws IOException { final List<TextBlock> records = new LinkedList<>(); nread = 0; boolean maxNumRecordsNotReached = true; while (reader.ready() && (records.isEmpty() || records.size() < minRecords)) { nread = reader.read(buffer, bufferOffset, buffer.length - bufferOffset); if (nread > 0) { bufferOffset += nread; maxNumRecordsNotReached = fillWithBufferedLinesUntil(records, minRecords, strict); if (records.isEmpty() && bufferOffset == buffer.length) { char[] newbuf = new char[buffer.length * 2]; System.arraycopy(buffer, 0, newbuf, 0, buffer.length); buffer = newbuf; } } } final boolean isEOF = !reader.ready(); if (isEOF && maxNumRecordsNotReached && strict) { maxNumRecordsNotReached = fillWithBufferedLinesUntil(records, minRecords, true); } if (isEOF && maxNumRecordsNotReached && remaining()) { LOG.info("End of file reached - flushing remaining bytes from reader buffer ({}).", isAutoFlushOnEOF); if (isAutoFlushOnEOF) { final String line = new String(buffer, 0, bufferOffset); records.add(new TextBlock(line, charset, offset, offset + bufferOffset, bufferOffset)); offset += bufferOffset; bufferOffset = 0; } } return records; } NonBlockingBufferReader(final File file,
                                   final Charset charset);  NonBlockingBufferReader(final File file,
                                   final int initialCapacity,
                                   final Charset charset); Charset charset(); long position(); void enableAutoFlush(); void disableAutoFlush(); List<TextBlock> readLines(final int minRecords, final boolean strict); boolean remaining(); boolean hasNext(); void seekTo(final Long offset); @Override void close(); static final int DEFAULT_INITIAL_CAPACITY; }### Answer:
@Test public void shouldAttemptToReadMoreLinesThanMinimumGivenStrictEqualsFalse() throws Exception { generateLines(writer, NLINES, CR + LF, false); try(NonBlockingBufferReader reader = createReaderWithCapacity(file, DEFAULT_INITIAL_CAPACITY)) { List<TextBlock> records = reader.readLines(1, false); Assert.assertTrue(records.size() > 1); } }
@Test public void shouldNotAttemptToReadMoreLinesThanMinimumGivenStrictEqualsTrue() throws Exception { generateLines(writer, NLINES, CR + LF, false); try(NonBlockingBufferReader reader = createReaderWithCapacity(file, DEFAULT_INITIAL_CAPACITY)) { List<TextBlock> records = reader.readLines(1, true); Assert.assertEquals(1, records.size()); } }