]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9577 Store incremental analysis flag in database
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Thu, 27 Jul 2017 10:43:35 +0000 (12:43 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Mon, 7 Aug 2017 09:44:06 +0000 (11:44 +0200)
24 files changed:
server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl
server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotDto.java
server/sonar-db-dao/src/main/resources/org/sonar/db/component/SnapshotMapper.xml
server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDtoTest.java
server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis-result.xml
server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis.xml
server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/close_issues_clean_index_and_files_sources_of_specified_components-result.xml
server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/close_issues_clean_index_and_files_sources_of_specified_components.xml
server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAbortedBuilds-result.xml
server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAbortedBuilds.xml
server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAnalyses-result.xml
server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAnalyses.xml
server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml
server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml
server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject-result.xml
server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject.xml
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddIncrementalColumnToSnapshotsTable.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/package-info.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/MigrationConfigurationModuleTest.java
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistAnalysisStep.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistAnalysisStepTest.java

index 81c8fe51945fc01ecdbcdf934dd043313e2b4c92..c8cbe0b5ea44bf685c70e0a60a5edb9ba4cac048 100644 (file)
@@ -124,7 +124,8 @@ CREATE TABLE "SNAPSHOTS" (
   "PERIOD4_DATE" BIGINT,
   "PERIOD5_MODE" VARCHAR(100),
   "PERIOD5_PARAM" VARCHAR(100),
-  "PERIOD5_DATE" BIGINT
+  "PERIOD5_DATE" BIGINT,
+  "INCREMENTAL" BOOLEAN DEFAULT FALSE
 );
 CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID");
 CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS" ("UUID");
index e326b4da5115f9a7a40097f905d64b91ccfb388d..e2bb957ea7f2b1901ed6f309d401917dda4bf6ae 100644 (file)
@@ -42,6 +42,7 @@ public final class SnapshotDto {
   private String periodMode;
   private String periodParam;
   private Long periodDate;
+  private boolean incremental = false;
 
   public Long getId() {
     return id;
@@ -155,6 +156,15 @@ public final class SnapshotDto {
     return this;
   }
 
+  public boolean getIncremental() {
+    return incremental;
+  }
+
+  public SnapshotDto setIncremental(boolean incremental) {
+    this.incremental = incremental;
+    return this;
+  }
+
   /**
    * @return analysis date
    */
index 8060e105448de0112583b9730a688628b4001019..b838cf23afe1532f070059a70300eb7034a98808 100644 (file)
@@ -14,7 +14,8 @@
     s.version as version,
     s.period1_mode as periodMode,
     s.period1_param as periodParam,
-    s.period1_date as periodDate
+    s.period1_date as periodDate,
+    s.incremental as incremental
   </sql>
 
   <sql id="viewsSnapshotColumns">
     version,
     period1_mode,
     period1_param,
-    period1_date)
+    period1_date,
+    incremental)
     values (
     #{uuid, jdbcType=VARCHAR},
     #{componentUuid, jdbcType=VARCHAR},
     #{version, jdbcType=VARCHAR},
     #{periodMode, jdbcType=VARCHAR},
     #{periodParam, jdbcType=VARCHAR},
-    #{periodDate, jdbcType=BIGINT})
+    #{periodDate, jdbcType=BIGINT},
+    #{incremental, jdbcType=BOOLEAN})
   </insert>
 </mapper>
 
index aad175a6f50050baefdc1913bb31a37bbeaa4c7c..291143024b4878c478b98bff7fc28271d621ec2f 100644 (file)
@@ -73,6 +73,7 @@ public class SnapshotDaoTest {
       .setPeriodParam("30")
       .setPeriodDate(1500000000001L)
       .setVersion("2.1-SNAPSHOT")
+      .setIncremental(false)
       .setBuildDate(1500000000006L)
       .setCreatedAt(1403042400000L));
 
@@ -90,6 +91,8 @@ public class SnapshotDaoTest {
     assertThat(result.getBuildDate()).isEqualTo(1500000000006L);
     assertThat(result.getCreatedAt()).isEqualTo(1403042400000L);
     assertThat(result.getVersion()).isEqualTo("2.1-SNAPSHOT");
+    assertThat(result.getIncremental()).isFalse();
+
 
     assertThat(underTest.selectByUuid(db.getSession(), "DOES_NOT_EXIST").isPresent()).isFalse();
   }
@@ -266,6 +269,7 @@ public class SnapshotDaoTest {
       .setPeriodDate(1500000000001L)
       .setVersion("2.1-SNAPSHOT")
       .setBuildDate(1500000000006L)
+      .setIncremental(true)
       .setCreatedAt(1403042400000L));
 
     assertThat(dto.getId()).isNotNull();
@@ -280,6 +284,8 @@ public class SnapshotDaoTest {
     assertThat(dto.getBuildDate()).isEqualTo(1500000000006L);
     assertThat(dto.getCreatedAt()).isEqualTo(1403042400000L);
     assertThat(dto.getVersion()).isEqualTo("2.1-SNAPSHOT");
+    assertThat(dto.getIncremental()).isTrue();
+
   }
 
   @Test
@@ -387,7 +393,8 @@ public class SnapshotDaoTest {
       .setPeriodMode("days1")
       .setPeriodParam("30")
       .setPeriodDate(1_500_000_000_001L)
-      .setBuildDate(1_500_000_000_006L);
+      .setBuildDate(1_500_000_000_006L)
+      .setIncremental(false);
   }
 
   private CeActivityDto insertActivity(SnapshotDto analysis, CeActivityDto.Status status) {
index 4b8dd3e26afe9caa8bee81c75dd01654713f19bc..04ad42674546eb06d681f301f0172eb1dd79f51b 100644 (file)
@@ -36,6 +36,7 @@ public class SnapshotDtoTest {
       .setVersion("1.0")
       .setPeriodMode("mode1")
       .setPeriodParam("param1")
+      .setIncremental(true)
       .setPeriodDate(parseDate("2014-06-01").getTime());
 
     assertThat(snapshotDto.getId()).isEqualTo(10L);
@@ -45,6 +46,7 @@ public class SnapshotDtoTest {
     assertThat(snapshotDto.getVersion()).isEqualTo("1.0");
     assertThat(snapshotDto.getPeriodMode()).isEqualTo("mode1");
     assertThat(snapshotDto.getPeriodModeParameter()).isEqualTo("param1");
+    assertThat(snapshotDto.getIncremental()).isTrue();
     assertThat(snapshotDto.getPeriodDate()).isEqualTo(parseDate("2014-06-01").getTime());
   }
 
index 6cb45a58538f79abf31a712f21b154a417793e84..ef080fd3f6417056894edae1b6206208933ce19a 100644 (file)
@@ -32,6 +32,7 @@ Note that measures, events and reviews are not deleted.
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
   <!--switched_off="[null]" permanent_id="[null]" FAILURE_LEVEL="2"-->
@@ -96,6 +97,7 @@ Note that measures, events and reviews are not deleted.
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
 
index d086021a1514d9c48034ff5464519a809e819b2b..15104619310baee1dabc8adf6c3fce056e3eaeff 100644 (file)
@@ -24,6 +24,7 @@
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
   <project_measures ID="1"
@@ -88,6 +89,7 @@
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
   <project_measures ID="2"
index de51ded1e3535e3055436aecd8702f3dad799e3c..5515cd38ea452896569b790e6a1eccb630982dfa 100644 (file)
@@ -146,6 +146,7 @@ What has been changed :
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
       />
 
   <!-- Open issue on file -->
index 8db639ce3613dda4893d7dc9bfc5f15197742029..43d7229f269756d4a606fbc188e089e635779c77 100644 (file)
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
   <!-- Open issue on file -->
index e5c679bf4c5e0a8f00740c71db85505e794dccc5..dd294d38bf2429a032a49b165b800fef37f7fc70 100644 (file)
@@ -50,6 +50,7 @@ Snapshot 2 has been deleted
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
   <!-- snapshot with status "processed" and flagged as "last" -> do not purge and do not delete -->
@@ -77,6 +78,7 @@ Snapshot 2 has been deleted
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
 </dataset>
index 9acb701f9e9b700ff819aaad00fad401cb3fadbc..3f493acd7eb722fa9c094477775c3a2e5389c1cf 100644 (file)
@@ -45,6 +45,7 @@
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
   <!-- snapshot with status "unprocessed" -> to be deleted -->
@@ -72,6 +73,7 @@
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
   <!-- snapshot with status "processed" and flagged as "last" -> do not purge and do not delete -->
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
 </dataset>
index 878595a3c80740039128b238798d9b2df320ca30..d5393b6756a74799925d4338feeab3aa898cd06c 100644 (file)
@@ -25,6 +25,7 @@
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
   <!-- delete only resource 1 -->
@@ -52,6 +53,7 @@
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
 </dataset>
index d4cdd2565323c4c8975a56aee326cd1680ab187d..9d351499f2a01b015020c6b76f82da85e2813834 100644 (file)
@@ -25,6 +25,7 @@
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
   <!-- delete only resource 1 -->
@@ -52,6 +53,7 @@
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
   <!-- to be deleted -->
@@ -79,6 +81,7 @@
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
 </dataset>
index 89086990a7611fe8c48d785d6b02cc757d6cd2cb..73c511a1b7403b6a7b188f5686604606fcfea9b5 100644 (file)
@@ -148,6 +148,7 @@ What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
   <!-- snapshots to be purged -->
@@ -175,6 +176,7 @@ What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
 </dataset>
index 38e737bf8f5b627451aa1c8a79763b2e94170e6a..4abc4eefd7372b1ea301ba6a9a693667188fbdde 100644 (file)
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
   <!-- snapshots to be purged -->
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
 </dataset>
index 5bfd2ffe1f54d61767a1e7fd420d47b44af78c0f..e8178d60f1cbfd564d2dab8deede5ba3edc7f337 100644 (file)
@@ -65,6 +65,7 @@
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
 
@@ -93,6 +94,7 @@
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
   <!-- snapshot to be purged -->
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
 </dataset>
index 8b86cbd140a325b1fcd403e648e956154ad46dc9..2c48394a5bc4ab7953dc829e3acdc3e0f3a9634e 100644 (file)
@@ -64,6 +64,7 @@
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
 
@@ -92,6 +93,7 @@
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
   <!-- snapshot to be purged -->
              created_at="1228222680000"
              build_date="1228222680000"
              version="[null]"
+             incremental="[false]"
   />
 
 </dataset>
index 25f9b7e35b5e468d8b2c9ed9a52c21c246d79a46..43de1b33971352a4ab11cd411d5dfee10c7fa452 100644 (file)
@@ -31,6 +31,7 @@ import org.sonar.server.platform.db.migration.version.v62.DbVersion62;
 import org.sonar.server.platform.db.migration.version.v63.DbVersion63;
 import org.sonar.server.platform.db.migration.version.v64.DbVersion64;
 import org.sonar.server.platform.db.migration.version.v65.DbVersion65;
+import org.sonar.server.platform.db.migration.version.v66.DbVersion66;
 
 public class MigrationConfigurationModule extends Module {
   @Override
@@ -45,6 +46,7 @@ public class MigrationConfigurationModule extends Module {
       DbVersion63.class,
       DbVersion64.class,
       DbVersion65.class,
+      DbVersion66.class,
 
       // migration steps
       MigrationStepRegistryImpl.class,
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddIncrementalColumnToSnapshotsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddIncrementalColumnToSnapshotsTable.java
new file mode 100644 (file)
index 0000000..960626c
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v66;
+
+import java.sql.SQLException;
+
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.def.BooleanColumnDef;
+import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class AddIncrementalColumnToSnapshotsTable extends DdlChange {
+
+  public AddIncrementalColumnToSnapshotsTable(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new AddColumnsBuilder(getDialect(), "snapshots")
+      .addColumn(BooleanColumnDef.newBooleanColumnDefBuilder()
+        .setColumnName("incremental")
+        .setDefaultValue(false)
+        .build())
+      .build());
+  }
+
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66.java
new file mode 100644 (file)
index 0000000..a9bb2dc
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.platform.db.migration.version.v66;
+
+import org.sonar.server.platform.db.migration.step.MigrationStepRegistry;
+import org.sonar.server.platform.db.migration.version.DbVersion;
+
+public class DbVersion66 implements DbVersion {
+  @Override
+  public void addSteps(MigrationStepRegistry registry) {
+    registry.add(1800, "Add incremental column to snapthots table", AddIncrementalColumnToSnapshotsTable.class);
+  }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/package-info.java
new file mode 100644 (file)
index 0000000..d0c2be7
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.server.platform.db.migration.version.v66;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
index eb18aa71c0a7f1070e42d66ed043a2bd8f40d889..edea77696f75510841e139867630c963cb70d9df 100644 (file)
@@ -37,7 +37,7 @@ public class MigrationConfigurationModuleTest {
     assertThat(container.getPicoContainer().getComponentAdapters())
       .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER
         // DbVersion classes
-        + 8
+        + 9
         // Others
         + 3);
   }
index ef8e57dc3a20625fc5f2346619fa43c786f0b188..5af65d9c03f2e104dbe4461442f99851d4888935 100644 (file)
@@ -19,6 +19,8 @@
  */
 package org.sonar.server.computation.task.projectanalysis.step;
 
+import javax.annotation.Nullable;
+
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
@@ -76,14 +78,14 @@ public class PersistAnalysisStep implements ComputationStep {
 
     @Override
     public void visitProject(Component project) {
-      SnapshotDto snapshot = createAnalysis(analysisMetadataHolder.getUuid(), project, true);
+      SnapshotDto snapshot = createAnalysis(analysisMetadataHolder.getUuid(), project, true, analysisMetadataHolder.isIncrementalAnalysis());
       updateSnapshotPeriods(snapshot);
       persist(snapshot, dbSession);
     }
 
     @Override
     public void visitView(Component view) {
-      SnapshotDto snapshot = createAnalysis(analysisMetadataHolder.getUuid(), view, false);
+      SnapshotDto snapshot = createAnalysis(analysisMetadataHolder.getUuid(), view, false, null);
       updateSnapshotPeriods(snapshot);
       persist(snapshot, dbSession);
     }
@@ -98,12 +100,13 @@ public class PersistAnalysisStep implements ComputationStep {
       snapshotDto.setPeriodDate(period.getSnapshotDate());
     }
 
-    private SnapshotDto createAnalysis(String snapshotUuid, Component component, boolean setVersion) {
+    private SnapshotDto createAnalysis(String snapshotUuid, Component component, boolean setVersion, @Nullable Boolean incremental) {
       String componentUuid = component.getUuid();
       return new SnapshotDto()
         .setUuid(snapshotUuid)
         .setVersion(setVersion ? component.getReportAttributes().getVersion() : null)
         .setComponentUuid(componentUuid)
+        .setIncremental(incremental)
         .setLast(false)
         .setStatus(SnapshotDto.STATUS_UNPROCESSED)
         .setCreatedAt(analysisDate)
index 40fbf42f13384a631dbc63e7935ca41740640b7a..a892fc57f9d3fe778c8f02d577573c1aca58fc18 100644 (file)
@@ -98,6 +98,7 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
 
   @Test
   public void persist_analysis() {
+    analysisMetadataHolder.setIncrementalAnalysis(false);
     OrganizationDto organizationDto = dbTester.organizations().insert();
     ComponentDto projectDto = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD").setDbKey(PROJECT_KEY).setName("Project");
     dbClient.componentDao().insert(dbTester.getSession(), projectDto);
@@ -132,6 +133,7 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
     assertThat(projectSnapshot.getStatus()).isEqualTo("U");
     assertThat(projectSnapshot.getCreatedAt()).isEqualTo(analysisDate);
     assertThat(projectSnapshot.getBuildDate()).isEqualTo(now);
+    assertThat(projectSnapshot.getIncremental()).isFalse();
 
     assertThat(dbIdsRepository.getComponentId(module)).isEqualTo(moduleDto.getId());
     assertThat(dbIdsRepository.getComponentId(directory)).isEqualTo(directoryDto.getId());
@@ -140,6 +142,7 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
 
   @Test
   public void persist_snapshots_with_leak_period() {
+    analysisMetadataHolder.setIncrementalAnalysis(false);
     OrganizationDto organizationDto = dbTester.organizations().insert();
     ComponentDto projectDto = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD").setDbKey(PROJECT_KEY).setName("Project");
     dbClient.componentDao().insert(dbTester.getSession(), projectDto);
@@ -162,6 +165,7 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
 
   @Test
   public void only_persist_snapshots_with_leak_period_on_project_and_module() {
+    analysisMetadataHolder.setIncrementalAnalysis(false);
     periodsHolder.setPeriod(new Period(LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS, null, analysisDate, "u1"));
 
     OrganizationDto organizationDto = dbTester.organizations().insert();
@@ -200,6 +204,7 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
 
   @Test
   public void set_no_period_on_snapshots_when_no_period() {
+    analysisMetadataHolder.setIncrementalAnalysis(false);
     ComponentDto projectDto = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setDbKey(PROJECT_KEY).setName("Project");
     dbClient.componentDao().insert(dbTester.getSession(), projectDto);
     SnapshotDto snapshotDto = SnapshotTesting.newAnalysis(projectDto);