@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_sourceLines_has_more_elements_then_lineCount() {
    reportReader.putFileSourceLines(FILE_REF, "line1", "line2", "line3");

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