@Override
  public CloseableIterator<String> readLines(Component file) {
    requireNonNull(file, "Component should not be null");
    checkArgument(file.getType() == FILE, "Component '%s' is not a file", file);

    Optional<CloseableIterator<String>> linesIteratorOptional = reportReader.readFileSource(file.getReportAttributes().getRef());

    checkState(linesIteratorOptional.isPresent(), "File '%s' has no source code", file);
    CloseableIterator<String> lineIterator = linesIteratorOptional.get();

    return new ComponentLinesCloseableIterator(file, lineIterator, file.getFileAttributes().getLines());
  }
@Test
  public void read_lines_throws_ISE_when_sourceLine_has_less_elements_then_lineCount_minus_1() {
    reportReader.putFileSourceLines(FILE_REF, "line1", "line2");

    assertThatThrownBy(() -> consume(underTest.readLines(createComponent(10))))
      .isInstanceOf(IllegalStateException.class)
      .hasMessage("Source of file 'ReportComponent{ref=2, key='FILE_KEY', type=FILE}' has less lines (2) than the expected number (10)");
  }