@Override
  public LineHashesComputer getLineHashesComputerToPersist(Component component) {
    boolean cacheHit = cache.contains(component);

    // check if line hashes are cached and if we can use it
    if (cacheHit && !dbLineHashesVersion.hasLineHashesWithoutSignificantCode(component)) {
      return new CachedLineHashesComputer(cache.get(component));
    }

    Optional<LineRange[]> significantCodePerLine = significantCodeRepository.getRangesPerLine(component);
    if (cacheHit && !significantCodePerLine.isPresent()) {
      return new CachedLineHashesComputer(cache.get(component));
    }

    // Generate the line hashes taking into account significant code ranges
    return createLineHashesProcessor(component.getFileAttributes().getLines(), significantCodePerLine);
  }
@Test
  public void should_generate_to_persist_if_needed() {
    List<String> lineHashes = Lists.newArrayList("line1", "line2", "line3");
    LineRange[] lineRanges = {new LineRange(0, 1), null, new LineRange(1, 5)};

    sourceLinesHashCache.computeIfAbsent(file, c -> lineHashes);

    // DB has line hashes without significant code and significant code is available in the report, so we need to generate new line hashes
    when(dbLineHashVersion.hasLineHashesWithoutSignificantCode(file)).thenReturn(true);
    when(significantCodeRepository.getRangesPerLine(file)).thenReturn(Optional.of(lineRanges));

    LineHashesComputer hashesComputer = underTest.getLineHashesComputerToPersist(file);

    assertThat(hashesComputer).isInstanceOf(SignificantCodeLineHashesComputer.class);
  }