@Before
  public void setUp() {
    dbTester.truncateTables();

    dbClient =
        new DbClient(
            dbTester.database(),
            dbTester.myBatis(),
            new MeasureDao(),
            new ComponentDao(),
            new MetricDao(),
            new RuleDao(System2.INSTANCE));
    session = dbClient.openSession(false);

    MeasureRepository measureRepository =
        new MeasureRepositoryImpl(dbClient, reportReader, metricRepository);
    session.commit();

    sut =
        new PersistMeasuresStep(
            dbClient, metricRepository, dbIdsRepository, treeRootHolder, measureRepository);

    projectDto = addComponent("project-key");
    fileDto = addComponent("file-key");

    Component file =
        DumbComponent.builder(Component.Type.FILE, FILE_REF)
            .setUuid("CDEF")
            .setKey("MODULE_KEY:file")
            .build();
    Component project =
        DumbComponent.builder(Component.Type.PROJECT, PROJECT_REF)
            .setUuid("ABCD")
            .setKey(PROJECT_KEY)
            .addChildren(file)
            .build();
    treeRootHolder.setRoot(project);

    dbIdsRepository.setComponentId(project, projectDto.getId());
    dbIdsRepository.setSnapshotId(project, 3L);
    dbIdsRepository.setComponentId(file, fileDto.getId());
    dbIdsRepository.setSnapshotId(file, 4L);
  }
 @Override
 public void execute() {
   DbSession session = dbClient.openSession(true);
   try {
     if (crossProjectDuplicationStatusHolder.isEnabled()) {
       Component project = treeRootHolder.getRoot();
       long projectSnapshotId = dbIdsRepository.getSnapshotId(project);
       new DepthTraversalTypeAwareCrawler(new DuplicationVisitor(session, projectSnapshotId))
           .visit(project);
     }
     session.commit();
   } finally {
     dbClient.closeSession(session);
   }
 }
  @Override
  public void execute() {
    NumberOfDaysSinceLastCommitVisitor visitor = new NumberOfDaysSinceLastCommitVisitor();
    Component project = treeRootHolder.getRoot();
    new DepthTraversalTypeAwareCrawler(visitor).visit(project);

    long lastCommitTimestamp = visitor.lastCommitTimestampFromReport;
    if (lastCommitTimestamp == 0L) {
      Long lastCommitFromIndex = lastCommitFromIndex(treeRootHolder.getRoot().getUuid());
      lastCommitTimestamp = firstNonNull(lastCommitFromIndex, lastCommitTimestamp);
    }

    if (lastCommitTimestamp != 0L) {
      persistNumberOfDaysSinceLastCommit(
          lastCommitTimestamp, dbIdsRepository.getSnapshotId(project));
    }
  }