]> source.dussan.org Git - sonarqube.git/commitdiff
fix coverage of PersistScannerContextStep
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 24 Aug 2016 10:34:41 +0000 (12:34 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 25 Aug 2016 13:05:41 +0000 (15:05 +0200)
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistScannerContextStepTest.java

index 0dafc1374999ede8d7b51364561445a9d329d3c8..be31c20ea6b038f856cce537f6af90c6e00f0b54 100644 (file)
@@ -29,6 +29,7 @@ import org.sonar.server.computation.task.projectanalysis.analysis.AnalysisMetada
 import org.sonar.server.computation.task.projectanalysis.batch.BatchReportReaderRule;
 
 import static java.util.Arrays.asList;
+import static java.util.Collections.emptyList;
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class PersistScannerContextStepTest {
@@ -52,7 +53,7 @@ public class PersistScannerContextStepTest {
   }
 
   @Test
-  public void log_scanner_logs() {
+  public void executes_persist_lines_of_reportReader() {
     reportReader.setScannerLogs(asList("log1", "log2"));
 
     underTest.execute();
@@ -61,4 +62,14 @@ public class PersistScannerContextStepTest {
       .contains("log1" + '\n' + "log2");
   }
 
+  @Test
+  public void executes_persist_does_not_persit_any_scanner_context_if_iterator_is_empty() {
+    reportReader.setScannerLogs(emptyList());
+
+    underTest.execute();
+
+    assertThat(dbClient.scannerContextDao().selectScannerContext(dbTester.getSession(), ANALYSIS_UUID))
+      .isEmpty();
+  }
+
 }