]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6397 Use ScmInfoRepo in PersistFileSourcesStep
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 30 Sep 2015 16:44:04 +0000 (18:44 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 2 Oct 2015 09:48:29 +0000 (11:48 +0200)
server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/PersistFileSourcesStepTest.java
server/sonar-server/src/main/java/org/sonar/server/computation/source/ScmLineReader.java
server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java
server/sonar-server/src/test/java/org/sonar/server/computation/source/ScmLineReaderTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistFileSourcesStepTest.java

index e57ba565c94eeeefb6ab4ebebd277fd3c9d7bf3b..87ad097dbab158c341f04f9c7424ed65de12718e 100644 (file)
@@ -42,8 +42,10 @@ import org.sonar.server.computation.batch.BatchReportReaderImpl;
 import org.sonar.server.computation.batch.TreeRootHolderRule;
 import org.sonar.server.computation.component.Component;
 import org.sonar.server.computation.component.ReportComponent;
+import org.sonar.server.computation.scm.ScmInfoRepositoryImpl;
 import org.sonar.server.computation.source.SourceLinesRepositoryImpl;
 import org.sonar.server.computation.step.PersistFileSourcesStep;
+import org.sonar.server.source.SourceService;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
@@ -82,7 +84,10 @@ public class PersistFileSourcesStepTest {
     BatchReportDirectoryHolderImpl batchReportDirectoryHolder = new BatchReportDirectoryHolderImpl();
     batchReportDirectoryHolder.setDirectory(reportDir);
     org.sonar.server.computation.batch.BatchReportReader batchReportReader = new BatchReportReaderImpl(batchReportDirectoryHolder);
-    PersistFileSourcesStep step = new PersistFileSourcesStep(dbClient, System2.INSTANCE, treeRootHolder, batchReportReader, new SourceLinesRepositoryImpl(batchReportReader));
+    SourceService sourceService = new SourceService(dbClient, null);
+    ScmInfoRepositoryImpl scmInfoRepository = new ScmInfoRepositoryImpl(batchReportReader, dbClient, sourceService);
+    PersistFileSourcesStep step = new PersistFileSourcesStep(dbClient, System2.INSTANCE, treeRootHolder, batchReportReader,
+      new SourceLinesRepositoryImpl(batchReportReader), scmInfoRepository);
     step.execute();
 
     long end = System.currentTimeMillis();
index 35bacf16ffba251b29764a122e20f0b6c6fd8139..17d17e4e2ff029a1447102d01f5f5040e60899c4 100644 (file)
 package org.sonar.server.computation.source;
 
 import javax.annotation.CheckForNull;
-import org.sonar.batch.protocol.output.BatchReport;
 import org.sonar.db.protobuf.DbFileSources;
-
-import static com.google.common.base.Preconditions.checkArgument;
+import org.sonar.server.computation.scm.Changeset;
+import org.sonar.server.computation.scm.ScmInfo;
 
 public class ScmLineReader implements LineReader {
 
-  private final BatchReport.Changesets scmReport;
+  private final ScmInfo scmReport;
   @CheckForNull
-  private BatchReport.Changesets.Changeset latestChange;
+  private Changeset latestChange;
 
-  public ScmLineReader(BatchReport.Changesets scmReport) {
+  public ScmLineReader(ScmInfo scmReport) {
     this.scmReport = scmReport;
   }
 
   @Override
   public void read(DbFileSources.Line.Builder lineBuilder) {
-    int changeSetIndex = scmReport.getChangesetIndexByLine(lineBuilder.getLine() - 1);
-    BatchReport.Changesets.Changeset changeset = scmReport.getChangeset(changeSetIndex);
-    boolean hasAuthor = changeset.hasAuthor();
-    if (hasAuthor) {
-      lineBuilder.setScmAuthor(changeset.getAuthor());
-    }
-    boolean hasRevision = changeset.hasRevision();
-    if (hasRevision) {
-      lineBuilder.setScmRevision(changeset.getRevision());
+    Changeset changeset = scmReport.getChangesetForLine(lineBuilder.getLine());
+    String author = changeset.getAuthor();
+    if (author != null) {
+      lineBuilder.setScmAuthor(author);
     }
-    boolean hasDate = changeset.hasDate();
-    if (hasDate) {
-      lineBuilder.setScmDate(changeset.getDate());
-    }
-
-    checkArgument(
-      hasAuthor || hasRevision || hasDate,
-      "A changeset must contain at least one of : author, revision or date");
+    lineBuilder.setScmRevision(changeset.getRevision());
+    lineBuilder.setScmDate(changeset.getDate());
     updateLatestChange(changeset);
   }
 
-  private void updateLatestChange(BatchReport.Changesets.Changeset newChangeSet) {
-    if (this.latestChange == null) {
-      this.latestChange = newChangeSet;
-    } else if (newChangeSet.hasDate() && this.latestChange.hasDate()
-      && newChangeSet.getDate() > this.latestChange.getDate()) {
-      this.latestChange = newChangeSet;
+  private void updateLatestChange(Changeset newChangeSet) {
+    if (latestChange == null) {
+      latestChange = newChangeSet;
+    } else {
+      long newChangesetDate = newChangeSet.getDate();
+      long latestChangeDate = latestChange.getDate();
+      if (newChangesetDate > latestChangeDate) {
+        latestChange = newChangeSet;
+      }
     }
   }
 
   @CheckForNull
-  public BatchReport.Changesets.Changeset getLatestChange() {
+  public Changeset getLatestChange() {
     return latestChange;
   }
 }
index 49f9d86eac1e40d583c83f9fbda62c7f8f622d6c..adf2201b00dc9229d654520bf81dca4ad4ffc14f 100644 (file)
 
 package org.sonar.server.computation.step;
 
+import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableMap;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.ibatis.session.ResultContext;
 import org.apache.ibatis.session.ResultHandler;
@@ -45,6 +40,9 @@ import org.sonar.server.computation.component.CrawlerDepthLimit;
 import org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler;
 import org.sonar.server.computation.component.TreeRootHolder;
 import org.sonar.server.computation.component.TypeAwareVisitorAdapter;
+import org.sonar.server.computation.scm.Changeset;
+import org.sonar.server.computation.scm.ScmInfo;
+import org.sonar.server.computation.scm.ScmInfoRepository;
 import org.sonar.server.computation.source.ComputeFileSourceData;
 import org.sonar.server.computation.source.CoverageLineReader;
 import org.sonar.server.computation.source.DuplicationLineReader;
@@ -54,6 +52,14 @@ import org.sonar.server.computation.source.ScmLineReader;
 import org.sonar.server.computation.source.SourceLinesRepository;
 import org.sonar.server.computation.source.SymbolsLineReader;
 
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import static org.sonar.server.computation.component.ComponentVisitor.Order.PRE_ORDER;
 
 public class PersistFileSourcesStep implements ComputationStep {
@@ -63,13 +69,16 @@ public class PersistFileSourcesStep implements ComputationStep {
   private final TreeRootHolder treeRootHolder;
   private final BatchReportReader reportReader;
   private final SourceLinesRepository sourceLinesRepository;
+  private final ScmInfoRepository scmInfoRepository;
 
-  public PersistFileSourcesStep(DbClient dbClient, System2 system2, TreeRootHolder treeRootHolder, BatchReportReader reportReader, SourceLinesRepository sourceLinesRepository) {
+  public PersistFileSourcesStep(DbClient dbClient, System2 system2, TreeRootHolder treeRootHolder, BatchReportReader reportReader, SourceLinesRepository sourceLinesRepository,
+    ScmInfoRepository scmInfoRepository) {
     this.dbClient = dbClient;
     this.system2 = system2;
     this.treeRootHolder = treeRootHolder;
     this.reportReader = reportReader;
     this.sourceLinesRepository = sourceLinesRepository;
+    this.scmInfoRepository = scmInfoRepository;
   }
 
   @Override
@@ -114,7 +123,7 @@ public class PersistFileSourcesStep implements ComputationStep {
       int fileRef = file.getReportAttributes().getRef();
       BatchReport.Component component = reportReader.readComponent(fileRef);
       CloseableIterator<String> linesIterator = sourceLinesRepository.readLines(file);
-      LineReaders lineReaders = new LineReaders(reportReader, fileRef);
+      LineReaders lineReaders = new LineReaders(reportReader, scmInfoRepository, file);
       try {
         ComputeFileSourceData computeFileSourceData = new ComputeFileSourceData(linesIterator, lineReaders.readers(), component.getLines());
         ComputeFileSourceData.Data fileSourceData = computeFileSourceData.compute();
@@ -128,7 +137,7 @@ public class PersistFileSourcesStep implements ComputationStep {
     }
 
     private void persistSource(ComputeFileSourceData.Data fileSourceData, String componentUuid,
-      @Nullable BatchReport.Changesets.Changeset latestChange) {
+      @Nullable Changeset latestChange) {
       DbFileSources.Data fileData = fileSourceData.getFileSourceData();
 
       byte[] data = FileSourceDto.encodeSourceData(fileData);
@@ -171,7 +180,7 @@ public class PersistFileSourcesStep implements ComputationStep {
   }
 
   @CheckForNull
-  private static String computeRevision(FileSourceDto previousDto, @Nullable BatchReport.Changesets.Changeset latestChange) {
+  private static String computeRevision(FileSourceDto previousDto, @Nullable Changeset latestChange) {
     if (latestChange == null) {
       return previousDto.getRevision();
     }
@@ -179,7 +188,7 @@ public class PersistFileSourcesStep implements ComputationStep {
   }
 
   @CheckForNull
-  private static String computeRevision(@Nullable BatchReport.Changesets.Changeset latestChange) {
+  private static String computeRevision(@Nullable Changeset latestChange) {
     if (latestChange == null) {
       return null;
     }
@@ -192,14 +201,15 @@ public class PersistFileSourcesStep implements ComputationStep {
     @CheckForNull
     private final ScmLineReader scmLineReader;
 
-    LineReaders(BatchReportReader reportReader, int componentRef) {
+    LineReaders(BatchReportReader reportReader, ScmInfoRepository scmInfoRepository, Component component) {
+      int componentRef = component.getReportAttributes().getRef();
       CloseableIterator<BatchReport.Coverage> coverageIt = reportReader.readComponentCoverage(componentRef);
       closeables.add(coverageIt);
       readers.add(new CoverageLineReader(coverageIt));
 
-      BatchReport.Changesets scmReport = reportReader.readChangesets(componentRef);
-      if (scmReport != null) {
-        this.scmLineReader = new ScmLineReader(scmReport);
+      Optional<ScmInfo> scmInfoOptional = scmInfoRepository.getScmInfo(component);
+      if (scmInfoOptional.isPresent()) {
+        this.scmLineReader = new ScmLineReader(scmInfoOptional.get());
         readers.add(scmLineReader);
       } else {
         this.scmLineReader = null;
@@ -229,7 +239,7 @@ public class PersistFileSourcesStep implements ComputationStep {
     }
 
     @CheckForNull
-    public BatchReport.Changesets.Changeset getLatestChange() {
+    public Changeset getLatestChange() {
       if (scmLineReader == null) {
         return null;
       }
index 30ce8f560ff7bd88f0f3a528d711ec7a9794b4be..5fb2f9b972beb3bd5812042cbe6c867d959ee2b7 100644 (file)
 
 package org.sonar.server.computation.source;
 
+import com.google.common.collect.ImmutableList;
+import java.util.List;
 import org.junit.Test;
-import org.sonar.batch.protocol.output.BatchReport;
 import org.sonar.db.protobuf.DbFileSources;
+import org.sonar.server.computation.scm.Changeset;
+import org.sonar.server.computation.scm.ScmInfo;
+import org.sonar.server.computation.scm.ScmInfoImpl;
 
+import static com.google.common.collect.Lists.newArrayList;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown;
 
 public class ScmLineReaderTest {
 
   @Test
   public void set_scm() {
-    BatchReport.Changesets scmReport = BatchReport.Changesets.newBuilder()
-      .addChangeset(newChangeSetBuilder()
+    ScmInfo scmInfo = new ScmInfoImpl(newArrayList(
+      Changeset.newChangesetBuilder()
         .setAuthor("john")
         .setDate(123456789L)
         .setRevision("rev-1")
-        .build())
-      .addChangesetIndexByLine(0)
-      .build();
+        .build()
+      ));
 
-    ScmLineReader lineScm = new ScmLineReader(scmReport);
+    ScmLineReader lineScm = new ScmLineReader(scmInfo);
 
     DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
     lineScm.read(lineBuilder);
@@ -51,90 +54,33 @@ public class ScmLineReaderTest {
   }
 
   @Test
-  public void set_only_author() {
-    BatchReport.Changesets scmReport = BatchReport.Changesets.newBuilder()
-      .addChangeset(newChangeSetBuilder()
-        .setAuthor("john")
-        .build())
-      .addChangesetIndexByLine(0)
-      .build();
-
-    ScmLineReader lineScm = new ScmLineReader(scmReport);
-
-    DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
-    lineScm.read(lineBuilder);
-
-    assertThat(lineBuilder.getScmAuthor()).isEqualTo("john");
-    assertThat(lineBuilder.hasScmDate()).isFalse();
-    assertThat(lineBuilder.hasScmRevision()).isFalse();
-  }
-
-  @Test
-  public void set_only_date() {
-    BatchReport.Changesets scmReport = BatchReport.Changesets.newBuilder()
-      .addChangeset(newChangeSetBuilder()
+  public void set_scm_with_minim_fields() {
+    ScmInfo scmInfo = new ScmInfoImpl(newArrayList(
+      Changeset.newChangesetBuilder()
         .setDate(123456789L)
-        .build())
-      .addChangesetIndexByLine(0)
-      .build();
-
-    ScmLineReader lineScm = new ScmLineReader(scmReport);
-
-    DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
-    lineScm.read(lineBuilder);
-
-    assertThat(lineBuilder.hasScmAuthor()).isFalse();
-    assertThat(lineBuilder.getScmDate()).isEqualTo(123456789L);
-    assertThat(lineBuilder.hasScmRevision()).isFalse();
-  }
-
-  @Test
-  public void set_only_revision() {
-    BatchReport.Changesets scmReport = BatchReport.Changesets.newBuilder()
-      .addChangeset(newChangeSetBuilder()
         .setRevision("rev-1")
-        .build())
-      .addChangesetIndexByLine(0)
-      .build();
+        .build()
+      ));
 
-    ScmLineReader lineScm = new ScmLineReader(scmReport);
+    ScmLineReader lineScm = new ScmLineReader(scmInfo);
 
     DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
     lineScm.read(lineBuilder);
 
     assertThat(lineBuilder.hasScmAuthor()).isFalse();
-    assertThat(lineBuilder.hasScmDate()).isFalse();
+    assertThat(lineBuilder.getScmDate()).isEqualTo(123456789L);
     assertThat(lineBuilder.getScmRevision()).isEqualTo("rev-1");
   }
 
-  @Test
-  public void fail_when_changeset_is_empty() {
-    BatchReport.Changesets scmReport = BatchReport.Changesets.newBuilder()
-      .addChangeset(newChangeSetBuilder()
-        .build())
-      .addChangesetIndexByLine(0)
-      .build();
-
-    ScmLineReader lineScm = new ScmLineReader(scmReport);
-
-    DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
-    try {
-      lineScm.read(lineBuilder);
-      failBecauseExceptionWasNotThrown(IllegalArgumentException.class);
-    } catch (IllegalArgumentException e) {
-      assertThat(e).hasMessage("A changeset must contain at least one of : author, revision or date");
-    }
-  }
-
   @Test
   public void getLatestChange_returns_changeset_with_highest_date_of_read_lines() {
     long refDate = 123456789L;
-    BatchReport.Changesets.Changeset changeset0 = newChangeSetBuilder().setDate(refDate - 636).build();
-    BatchReport.Changesets.Changeset changeset1 = newChangeSetBuilder().setDate(refDate + 1).build();
-    BatchReport.Changesets.Changeset changeset2 = newChangeSetBuilder().setDate(refDate + 2).build();
-    BatchReport.Changesets scmReport = setup8LinesChangeset(changeset0, changeset1, changeset2);
+    Changeset changeset0 = Changeset.newChangesetBuilder().setDate(refDate - 636).setRevision("rev-1").build();
+    Changeset changeset1 = Changeset.newChangesetBuilder().setDate(refDate + 1).setRevision("rev-2").build();
+    Changeset changeset2 = Changeset.newChangesetBuilder().setDate(refDate + 2).setRevision("rev-3").build();
+    ScmInfo scmInfo = new ScmInfoImpl(setup8LinesChangeset(changeset0, changeset1, changeset2));
 
-    ScmLineReader lineScm = new ScmLineReader(scmReport);
+    ScmLineReader lineScm = new ScmLineReader(scmInfo);
 
     // before any line is read, the latest change is null
     assertThat(lineScm.getLatestChange()).isNull();
@@ -158,78 +104,14 @@ public class ScmLineReaderTest {
     readLineAndAssertLatestChangeDate(lineScm, 8, changeset2);
   }
 
-  @Test
-  public void getLatestChange_returns_first_changeset_when_none_have_dates() {
-    BatchReport.Changesets.Changeset changeset0 = newChangeSetBuilder().setRevision("0").build();
-    BatchReport.Changesets.Changeset changeset1 = newChangeSetBuilder().setRevision("1").build();
-    BatchReport.Changesets.Changeset changeset2 = newChangeSetBuilder().setRevision("2").build();
-    BatchReport.Changesets scmReport = setup8LinesChangeset(changeset0, changeset1, changeset2);
-
-    ScmLineReader lineScm = new ScmLineReader(scmReport);
-
-    // before any line is read, the latest change is null
-    assertThat(lineScm.getLatestChange()).isNull();
-
-    // read lines 1 to 8, no date => changeset 0
-    readLineAndAssertLatestChangeDate(lineScm, 1, changeset0);
-    readLineAndAssertLatestChangeDate(lineScm, 2, changeset0);
-    readLineAndAssertLatestChangeDate(lineScm, 3, changeset0);
-    readLineAndAssertLatestChangeDate(lineScm, 4, changeset0);
-    readLineAndAssertLatestChangeDate(lineScm, 5, changeset0);
-    readLineAndAssertLatestChangeDate(lineScm, 6, changeset0);
-    readLineAndAssertLatestChangeDate(lineScm, 7, changeset0);
-    readLineAndAssertLatestChangeDate(lineScm, 8, changeset0);
+  private static List<Changeset> setup8LinesChangeset(Changeset changeset0, Changeset changeset1, Changeset changeset2) {
+    return ImmutableList.of(changeset0, changeset1, changeset1, changeset2, changeset0, changeset1, changeset0, changeset0);
   }
 
-  @Test
-  public void getLatestChange_returns_first_changeset_when_the_first_one_has_no_date() {
-    BatchReport.Changesets.Changeset changeset0 = newChangeSetBuilder().setRevision("0").build();
-    BatchReport.Changesets.Changeset changeset1 = newChangeSetBuilder().setRevision("1").setDate(95454154L).build();
-    BatchReport.Changesets.Changeset changeset2 = newChangeSetBuilder().setRevision("2").setDate(9654545444L).build();
-    BatchReport.Changesets scmReport = setup8LinesChangeset(changeset0, changeset1, changeset2);
-
-    ScmLineReader lineScm = new ScmLineReader(scmReport);
-
-    // before any line is read, the latest change is null
-    assertThat(lineScm.getLatestChange()).isNull();
-
-    // read lines 1 to 8, first encountered changeset has no date => changeset 0
-    readLineAndAssertLatestChangeDate(lineScm, 1, changeset0);
-    readLineAndAssertLatestChangeDate(lineScm, 2, changeset0);
-    readLineAndAssertLatestChangeDate(lineScm, 3, changeset0);
-    readLineAndAssertLatestChangeDate(lineScm, 4, changeset0);
-    readLineAndAssertLatestChangeDate(lineScm, 5, changeset0);
-    readLineAndAssertLatestChangeDate(lineScm, 6, changeset0);
-    readLineAndAssertLatestChangeDate(lineScm, 7, changeset0);
-    readLineAndAssertLatestChangeDate(lineScm, 8, changeset0);
-  }
-
-  private static BatchReport.Changesets setup8LinesChangeset(BatchReport.Changesets.Changeset changeset0,
-    BatchReport.Changesets.Changeset changeset1,
-    BatchReport.Changesets.Changeset changeset2) {
-    return BatchReport.Changesets.newBuilder()
-      .addChangeset(changeset0)
-      .addChangeset(changeset1)
-      .addChangeset(changeset2)
-      .addChangesetIndexByLine(0)
-      .addChangesetIndexByLine(1)
-      .addChangesetIndexByLine(1)
-      .addChangesetIndexByLine(2)
-      .addChangesetIndexByLine(0)
-      .addChangesetIndexByLine(1)
-      .addChangesetIndexByLine(0)
-      .addChangesetIndexByLine(0)
-      .build();
-  }
-
-  private void readLineAndAssertLatestChangeDate(ScmLineReader lineScm, int line, BatchReport.Changesets.Changeset expectedChangeset) {
+  private void readLineAndAssertLatestChangeDate(ScmLineReader lineScm, int line, Changeset expectedChangeset) {
     DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(line);
     lineScm.read(lineBuilder);
     assertThat(lineScm.getLatestChange()).isSameAs(expectedChangeset);
   }
 
-  private static BatchReport.Changesets.Changeset.Builder newChangeSetBuilder() {
-    return BatchReport.Changesets.Changeset.newBuilder();
-  }
-
 }
index 54af795b52997475f7e3a2411cf41b55589afbd1..d8909a5104ee675215a451152743f4532fa7c850 100644 (file)
@@ -37,6 +37,8 @@ import org.sonar.server.computation.batch.BatchReportReaderRule;
 import org.sonar.server.computation.batch.TreeRootHolderRule;
 import org.sonar.server.computation.component.Component;
 import org.sonar.server.computation.component.ReportComponent;
+import org.sonar.server.computation.scm.Changeset;
+import org.sonar.server.computation.scm.ScmInfoRepositoryRule;
 import org.sonar.server.computation.source.SourceLinesRepositoryRule;
 import org.sonar.test.DbTests;
 
@@ -66,6 +68,9 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
   @Rule
   public BatchReportReaderRule reportReader = new BatchReportReaderRule();
 
+  @Rule
+  public ScmInfoRepositoryRule scmInfoRepository = new ScmInfoRepositoryRule();
+
   @Rule
   public SourceLinesRepositoryRule fileSourceRepository = new SourceLinesRepositoryRule();
 
@@ -80,7 +85,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
   public void setup() {
     dbTester.truncateTables();
     when(system2.now()).thenReturn(now);
-    underTest = new PersistFileSourcesStep(dbClient, system2, treeRootHolder, reportReader, fileSourceRepository);
+    underTest = new PersistFileSourcesStep(dbClient, system2, treeRootHolder, reportReader, fileSourceRepository, scmInfoRepository);
   }
 
   @Override
@@ -189,15 +194,10 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
   @Test
   public void persist_scm() {
     initBasicReport(1);
-
-    reportReader.putChangesets(BatchReport.Changesets.newBuilder()
-      .setComponentRef(FILE_REF)
-      .addChangeset(BatchReport.Changesets.Changeset.newBuilder()
-        .setAuthor("john")
-        .setDate(123456789L)
-        .setRevision("rev-1")
-        .build())
-      .addChangesetIndexByLine(0)
+    scmInfoRepository.setScmInfo(FILE_REF, Changeset.newChangesetBuilder()
+      .setAuthor("john")
+      .setDate(123456789L)
+      .setRevision("rev-1")
       .build());
 
     underTest.execute();
@@ -357,15 +357,12 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
 
     initBasicReport(1);
 
-    reportReader.putChangesets(BatchReport.Changesets.newBuilder()
-        .setComponentRef(FILE_REF)
-        .addChangeset(BatchReport.Changesets.Changeset.newBuilder()
-            .setAuthor("john")
-            .setDate(123456789L)
-            .setRevision("rev-1")
-            .build())
-        .addChangesetIndexByLine(0)
-        .build());
+    scmInfoRepository.setScmInfo(FILE_REF, Changeset.newChangesetBuilder()
+      .setAuthor("john")
+      .setDate(123456789L)
+      .setRevision("rev-1")
+      .build());
+
 
     underTest.execute();