YamlRecordReader implements RecordReader<String> { @Override public YamlRecord readRecord() { if (!scanner.hasNextLine()) { return null; } StringBuilder stringBuilder = new StringBuilder(); while (scanner.hasNext()) { String line = scanner.nextLine(); if (!line.equals("---")) { stringBuilder.append(line); stringBuilder.append(Utils.LINE_SEPARATOR); } else { break; } } Header header = new Header(++currentRecordNumber, getDataSourceName(), LocalDateTime.now()); return new YamlRecord(header, stringBuilder.toString()); } YamlRecordReader(InputStream inputStream);  YamlRecordReader(InputStream inputStream, Charset charset); @Override void open(); @Override YamlRecord readRecord(); @Override void close();  }
@Test public void readRecord() { Record<String> record = recordReader.readRecord(); assertThat(record).isNotNull().isInstanceOf(YamlRecord.class); assertThat(record.getPayload()).isEqualTo("name: Foo" + LINE_SEPARATOR + "age: 28" + LINE_SEPARATOR); record = recordReader.readRecord(); assertThat(record).isNotNull().isInstanceOf(YamlRecord.class); assertThat(record.getPayload()).isEqualTo("name: Bar" + LINE_SEPARATOR + "age: 25" + LINE_SEPARATOR); record = recordReader.readRecord(); assertThat(record).isNotNull().isInstanceOf(YamlRecord.class); assertThat(record.getPayload()).isEqualTo("name: Baz" + LINE_SEPARATOR + "age: 30" + LINE_SEPARATOR); record = recordReader.readRecord(); assertThat(record).isNull(); }