aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-07-20 17:42:20 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-07-21 13:37:42 +0200
commit6c7cd94ff8802a49fe88cad39abfb5bf238ea388 (patch)
tree0b70d1141dc436b4049d55cdeadf40397b29257e
parent57069a6f42b78326955733a0b2f04c6b83599478 (diff)
downloadsonarqube-6c7cd94ff8802a49fe88cad39abfb5bf238ea388.tar.gz
sonarqube-6c7cd94ff8802a49fe88cad39abfb5bf238ea388.zip
SONAR-7779 rename class Snapshot to Analysis
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/analysis/Analysis.java (renamed from server/sonar-server/src/main/java/org/sonar/server/computation/snapshot/Snapshot.java)16
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/analysis/AnalysisMetadataHolder.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/analysis/AnalysisMetadataHolderImpl.java9
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/analysis/MutableAnalysisMetadataHolder.java5
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/filemove/FileMoveDetectionStep.java6
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/snapshot/package-info.java24
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/BuildComponentTreeStep.java8
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadCrossProjectDuplicationsRepositoryStep.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/analysis/AnalysisImplTest.java (renamed from server/sonar-server/src/test/java/org/sonar/server/computation/snapshot/SnapshotImplTest.java)48
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/analysis/AnalysisMetadataHolderImplTest.java9
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/analysis/AnalysisMetadataHolderRule.java9
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/analysis/MutableAnalysisMetadataHolderRule.java7
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/filemove/FileMoveDetectionStepTest.java30
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/scm/ScmInfoRepositoryImplTest.java24
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadCrossProjectDuplicationsRepositoryStepTest.java16
15 files changed, 95 insertions, 125 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/snapshot/Snapshot.java b/server/sonar-server/src/main/java/org/sonar/server/computation/analysis/Analysis.java
index 28ae303b75d..f926d24c526 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/snapshot/Snapshot.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/analysis/Analysis.java
@@ -17,7 +17,7 @@
* 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.computation.snapshot;
+package org.sonar.server.computation.analysis;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
@@ -26,13 +26,13 @@ import javax.annotation.concurrent.Immutable;
import static com.google.common.base.Preconditions.checkNotNull;
@Immutable
-public class Snapshot {
+public class Analysis {
private long id;
private String uuid;
private long createdAt;
- private Snapshot(Builder builder) {
+ private Analysis(Builder builder) {
this.id = builder.id;
this.uuid = builder.uuid;
this.createdAt = builder.createdAt;
@@ -73,11 +73,11 @@ public class Snapshot {
return this;
}
- public Snapshot build() {
+ public Analysis build() {
checkNotNull(id, "id cannot be null");
checkNotNull(uuid, "uuid cannot be null");
checkNotNull(createdAt, "createdAt cannot be null");
- return new Snapshot(this);
+ return new Analysis(this);
}
}
@@ -90,8 +90,8 @@ public class Snapshot {
return false;
}
- Snapshot snapshot = (Snapshot) o;
- return id == snapshot.id;
+ Analysis analysis = (Analysis) o;
+ return id == analysis.id;
}
@Override
@@ -101,7 +101,7 @@ public class Snapshot {
@Override
public String toString() {
- return "Snapshot{" +
+ return "Analysis{" +
"id=" + id +
", uuid='" + uuid + '\'' +
", createdAt=" + createdAt +
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/analysis/AnalysisMetadataHolder.java b/server/sonar-server/src/main/java/org/sonar/server/computation/analysis/AnalysisMetadataHolder.java
index 020c1dd7fd0..fb577751321 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/analysis/AnalysisMetadataHolder.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/analysis/AnalysisMetadataHolder.java
@@ -22,7 +22,6 @@ package org.sonar.server.computation.analysis;
import java.util.Map;
import javax.annotation.CheckForNull;
import org.sonar.server.computation.qualityprofile.QualityProfile;
-import org.sonar.server.computation.snapshot.Snapshot;
public interface AnalysisMetadataHolder {
@@ -51,7 +50,7 @@ public interface AnalysisMetadataHolder {
* @throws IllegalStateException if baseProjectSnapshot has not been set
*/
@CheckForNull
- Snapshot getBaseProjectSnapshot();
+ Analysis getBaseProjectSnapshot();
/**
* @throws IllegalStateException if cross project duplication flag has not been set
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/analysis/AnalysisMetadataHolderImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/analysis/AnalysisMetadataHolderImpl.java
index e13cc9ec850..b279ca951ea 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/analysis/AnalysisMetadataHolderImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/analysis/AnalysisMetadataHolderImpl.java
@@ -24,7 +24,6 @@ import java.util.Map;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.server.computation.qualityprofile.QualityProfile;
-import org.sonar.server.computation.snapshot.Snapshot;
import org.sonar.server.computation.util.InitializedProperty;
import static com.google.common.base.Preconditions.checkState;
@@ -35,7 +34,7 @@ public class AnalysisMetadataHolderImpl implements MutableAnalysisMetadataHolder
private final InitializedProperty<Long> analysisDate = new InitializedProperty<>();
- private final InitializedProperty<Snapshot> baseProjectSnapshot = new InitializedProperty<>();
+ private final InitializedProperty<Analysis> baseProjectSnapshot = new InitializedProperty<>();
private final InitializedProperty<Boolean> crossProjectDuplicationEnabled = new InitializedProperty<>();
@@ -77,15 +76,15 @@ public class AnalysisMetadataHolderImpl implements MutableAnalysisMetadataHolder
}
@Override
- public MutableAnalysisMetadataHolder setBaseProjectSnapshot(@Nullable Snapshot baseProjectSnapshot) {
+ public MutableAnalysisMetadataHolder setBaseProjectSnapshot(@Nullable Analysis baseProjectAnalysis) {
checkState(!this.baseProjectSnapshot.isInitialized(), "Base project snapshot has already been set");
- this.baseProjectSnapshot.setProperty(baseProjectSnapshot);
+ this.baseProjectSnapshot.setProperty(baseProjectAnalysis);
return this;
}
@Override
@CheckForNull
- public Snapshot getBaseProjectSnapshot() {
+ public Analysis getBaseProjectSnapshot() {
checkState(baseProjectSnapshot.isInitialized(), "Base project snapshot has not been set");
return baseProjectSnapshot.getProperty();
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/analysis/MutableAnalysisMetadataHolder.java b/server/sonar-server/src/main/java/org/sonar/server/computation/analysis/MutableAnalysisMetadataHolder.java
index c9eb49425ec..f72ad1639dc 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/analysis/MutableAnalysisMetadataHolder.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/analysis/MutableAnalysisMetadataHolder.java
@@ -22,7 +22,6 @@ package org.sonar.server.computation.analysis;
import java.util.Map;
import javax.annotation.Nullable;
import org.sonar.server.computation.qualityprofile.QualityProfile;
-import org.sonar.server.computation.snapshot.Snapshot;
public interface MutableAnalysisMetadataHolder extends AnalysisMetadataHolder {
@@ -37,9 +36,9 @@ public interface MutableAnalysisMetadataHolder extends AnalysisMetadataHolder {
MutableAnalysisMetadataHolder setAnalysisDate(long date);
/**
- * @throws IllegalStateException if baseProjectSnapshot has already been set
+ * @throws IllegalStateException if baseProjectAnalysis has already been set
*/
- MutableAnalysisMetadataHolder setBaseProjectSnapshot(@Nullable Snapshot baseProjectSnapshot);
+ MutableAnalysisMetadataHolder setBaseProjectSnapshot(@Nullable Analysis baseProjectAnalysis);
/**
* @throws IllegalStateException if cross project duplication flag has already been set
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/filemove/FileMoveDetectionStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/filemove/FileMoveDetectionStep.java
index 11c509acf94..a1d28d70789 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/filemove/FileMoveDetectionStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/filemove/FileMoveDetectionStep.java
@@ -50,7 +50,7 @@ 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.filemove.FileSimilarity.File;
-import org.sonar.server.computation.snapshot.Snapshot;
+import org.sonar.server.computation.analysis.Analysis;
import org.sonar.server.computation.source.SourceLinesRepository;
import org.sonar.server.computation.step.ComputationStep;
@@ -92,8 +92,8 @@ public class FileMoveDetectionStep implements ComputationStep {
@Override
public void execute() {
// do nothing if no files in db (first analysis)
- Snapshot baseProjectSnapshot = analysisMetadataHolder.getBaseProjectSnapshot();
- if (baseProjectSnapshot == null) {
+ Analysis baseProjectAnalysis = analysisMetadataHolder.getBaseProjectSnapshot();
+ if (baseProjectAnalysis == null) {
LOG.debug("First analysis. Do nothing.");
return;
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/snapshot/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/computation/snapshot/package-info.java
deleted file mode 100644
index e3a1a18538f..00000000000
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/snapshot/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.computation.snapshot;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/BuildComponentTreeStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/BuildComponentTreeStep.java
index ee1e180f032..d6f0c4fc9cd 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/BuildComponentTreeStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/BuildComponentTreeStep.java
@@ -34,7 +34,7 @@ import org.sonar.server.computation.component.Component;
import org.sonar.server.computation.component.ComponentImpl;
import org.sonar.server.computation.component.MutableTreeRootHolder;
import org.sonar.server.computation.component.UuidFactory;
-import org.sonar.server.computation.snapshot.Snapshot;
+import org.sonar.server.computation.analysis.Analysis;
import static com.google.common.collect.Iterables.toArray;
import static org.sonar.server.computation.component.ComponentImpl.builder;
@@ -73,15 +73,15 @@ public class BuildComponentTreeStep implements ComputationStep {
new SnapshotQuery()
.setComponentUuid(projectUuid)
.setIsLast(true));
- analysisMetadataHolder.setBaseProjectSnapshot(toSnapshot(snapshotDto));
+ analysisMetadataHolder.setBaseProjectSnapshot(toAnalysis(snapshotDto));
} finally {
dbClient.closeSession(dbSession);
}
}
@CheckForNull
- private static Snapshot toSnapshot(@Nullable SnapshotDto snapshotDto) {
- return snapshotDto == null ? null : new Snapshot.Builder()
+ private static Analysis toAnalysis(@Nullable SnapshotDto snapshotDto) {
+ return snapshotDto == null ? null : new Analysis.Builder()
.setId(snapshotDto.getId())
.setUuid(snapshotDto.getUuid())
.setCreatedAt(snapshotDto.getCreatedAt())
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadCrossProjectDuplicationsRepositoryStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadCrossProjectDuplicationsRepositoryStep.java
index 11e8860d04a..7d7aa77de57 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadCrossProjectDuplicationsRepositoryStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadCrossProjectDuplicationsRepositoryStep.java
@@ -40,7 +40,7 @@ import org.sonar.server.computation.component.TreeRootHolder;
import org.sonar.server.computation.component.TypeAwareVisitorAdapter;
import org.sonar.server.computation.duplication.CrossProjectDuplicationStatusHolder;
import org.sonar.server.computation.duplication.IntegrateCrossProjectDuplications;
-import org.sonar.server.computation.snapshot.Snapshot;
+import org.sonar.server.computation.analysis.Analysis;
import static com.google.common.collect.FluentIterable.from;
import static com.google.common.collect.Lists.newArrayList;
@@ -117,8 +117,8 @@ public class LoadCrossProjectDuplicationsRepositoryStep implements ComputationSt
private List<DuplicationUnitDto> selectDuplicates(Component file, Collection<String> hashes) {
DbSession dbSession = dbClient.openSession(false);
try {
- Snapshot projectSnapshot = analysisMetadataHolder.getBaseProjectSnapshot();
- String analysisUuid = projectSnapshot == null ? null : projectSnapshot.getUuid();
+ Analysis projectAnalysis = analysisMetadataHolder.getBaseProjectSnapshot();
+ String analysisUuid = projectAnalysis == null ? null : projectAnalysis.getUuid();
return dbClient.duplicationDao().selectCandidates(dbSession, analysisUuid, file.getFileAttributes().getLanguageKey(), hashes);
} finally {
dbClient.closeSession(dbSession);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/snapshot/SnapshotImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/analysis/AnalysisImplTest.java
index 51420bd87d3..933b39c876f 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/snapshot/SnapshotImplTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/analysis/AnalysisImplTest.java
@@ -17,7 +17,7 @@
* 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.computation.snapshot;
+package org.sonar.server.computation.analysis;
import org.junit.Rule;
import org.junit.Test;
@@ -25,7 +25,7 @@ import org.junit.rules.ExpectedException;
import static org.assertj.core.api.Assertions.assertThat;
-public class SnapshotImplTest {
+public class AnalysisImplTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
@@ -36,15 +36,15 @@ public class SnapshotImplTest {
@Test
public void build_snapshot() throws Exception {
- Snapshot snapshot = new Snapshot.Builder()
+ Analysis analysis = new Analysis.Builder()
.setId(ID)
.setUuid(UUID)
.setCreatedAt(CREATED_AT)
.build();
- assertThat(snapshot.getId()).isEqualTo(ID);
- assertThat(snapshot.getUuid()).isEqualTo(UUID);
- assertThat(snapshot.getCreatedAt()).isEqualTo(CREATED_AT);
+ assertThat(analysis.getId()).isEqualTo(ID);
+ assertThat(analysis.getUuid()).isEqualTo(UUID);
+ assertThat(analysis.getCreatedAt()).isEqualTo(CREATED_AT);
}
@Test
@@ -52,7 +52,7 @@ public class SnapshotImplTest {
thrown.expect(NullPointerException.class);
thrown.expectMessage("id cannot be null");
- new Snapshot.Builder()
+ new Analysis.Builder()
.setUuid(UUID)
.setCreatedAt(CREATED_AT)
.build();
@@ -63,7 +63,7 @@ public class SnapshotImplTest {
thrown.expect(NullPointerException.class);
thrown.expectMessage("uuid cannot be null");
- new Snapshot.Builder()
+ new Analysis.Builder()
.setId(ID)
.setCreatedAt(CREATED_AT)
.build();
@@ -74,7 +74,7 @@ public class SnapshotImplTest {
thrown.expect(NullPointerException.class);
thrown.expectMessage("createdAt cannot be null");
- new Snapshot.Builder()
+ new Analysis.Builder()
.setId(ID)
.setUuid(UUID)
.build();
@@ -82,46 +82,46 @@ public class SnapshotImplTest {
@Test
public void test_toString() throws Exception {
- assertThat(new Snapshot.Builder()
+ assertThat(new Analysis.Builder()
.setId(ID)
.setUuid(UUID)
.setCreatedAt(CREATED_AT)
.build().toString())
- .isEqualTo("Snapshot{id=10, uuid='uuid ', createdAt=123456789}");
+ .isEqualTo("Analysis{id=10, uuid='uuid ', createdAt=123456789}");
}
@Test
public void test_equals_and_hascode() throws Exception {
- Snapshot snapshot = new Snapshot.Builder()
+ Analysis analysis = new Analysis.Builder()
.setId(ID)
.setUuid(UUID)
.setCreatedAt(CREATED_AT)
.build();
- Snapshot sameSnapshot = new Snapshot.Builder()
+ Analysis sameAnalysis = new Analysis.Builder()
.setId(ID)
.setUuid(UUID)
.setCreatedAt(CREATED_AT)
.build();
- Snapshot sameSnapshotNotSameUuid = new Snapshot.Builder()
+ Analysis sameAnalysisNotSameUuid = new Analysis.Builder()
.setId(ID)
.setUuid("other uuid")
.setCreatedAt(CREATED_AT)
.build();
- Snapshot otherSnapshot = new Snapshot.Builder()
+ Analysis otherAnalysis = new Analysis.Builder()
.setId(11L)
.setUuid(UUID)
.setCreatedAt(CREATED_AT)
.build();
- assertThat(snapshot).isEqualTo(snapshot);
- assertThat(snapshot).isEqualTo(sameSnapshot);
- assertThat(snapshot).isEqualTo(sameSnapshotNotSameUuid);
- assertThat(snapshot).isNotEqualTo(otherSnapshot);
- assertThat(snapshot).isNotEqualTo(null);
+ assertThat(analysis).isEqualTo(analysis);
+ assertThat(analysis).isEqualTo(sameAnalysis);
+ assertThat(analysis).isEqualTo(sameAnalysisNotSameUuid);
+ assertThat(analysis).isNotEqualTo(otherAnalysis);
+ assertThat(analysis).isNotEqualTo(null);
- assertThat(snapshot.hashCode()).isEqualTo(snapshot.hashCode());
- assertThat(snapshot.hashCode()).isEqualTo(sameSnapshot.hashCode());
- assertThat(snapshot.hashCode()).isEqualTo(sameSnapshotNotSameUuid.hashCode());
- assertThat(snapshot.hashCode()).isNotEqualTo(otherSnapshot.hashCode());
+ assertThat(analysis.hashCode()).isEqualTo(analysis.hashCode());
+ assertThat(analysis.hashCode()).isEqualTo(sameAnalysis.hashCode());
+ assertThat(analysis.hashCode()).isEqualTo(sameAnalysisNotSameUuid.hashCode());
+ assertThat(analysis.hashCode()).isNotEqualTo(otherAnalysis.hashCode());
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/analysis/AnalysisMetadataHolderImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/analysis/AnalysisMetadataHolderImplTest.java
index 029815d10e5..a3d20faee3b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/analysis/AnalysisMetadataHolderImplTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/analysis/AnalysisMetadataHolderImplTest.java
@@ -22,7 +22,6 @@ package org.sonar.server.computation.analysis;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.server.computation.snapshot.Snapshot;
import static org.assertj.core.api.Assertions.assertThat;
@@ -31,7 +30,7 @@ public class AnalysisMetadataHolderImplTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
- static Snapshot BASE_PROJECT_SNAPSHOT = new Snapshot.Builder()
+ static Analysis baseProjectAnalysis = new Analysis.Builder()
.setId(1)
.setUuid("uuid_1")
.setCreatedAt(123456789L)
@@ -79,7 +78,7 @@ public class AnalysisMetadataHolderImplTest {
public void isFirstAnalysis_return_false() throws Exception {
AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
- underTest.setBaseProjectSnapshot(BASE_PROJECT_SNAPSHOT);
+ underTest.setBaseProjectSnapshot(baseProjectAnalysis);
assertThat(underTest.isFirstAnalysis()).isFalse();
}
@@ -102,11 +101,11 @@ public class AnalysisMetadataHolderImplTest {
@Test
public void setBaseProjectSnapshot_throws_ISE_when_called_twice() {
AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
- underTest.setBaseProjectSnapshot(BASE_PROJECT_SNAPSHOT);
+ underTest.setBaseProjectSnapshot(baseProjectAnalysis);
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("Base project snapshot has already been set");
- underTest.setBaseProjectSnapshot(BASE_PROJECT_SNAPSHOT);
+ underTest.setBaseProjectSnapshot(baseProjectAnalysis);
}
@Test
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/analysis/AnalysisMetadataHolderRule.java b/server/sonar-server/src/test/java/org/sonar/server/computation/analysis/AnalysisMetadataHolderRule.java
index c87cf4bcc4a..9237846c43b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/analysis/AnalysisMetadataHolderRule.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/analysis/AnalysisMetadataHolderRule.java
@@ -25,7 +25,6 @@ import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.junit.rules.ExternalResource;
import org.sonar.server.computation.qualityprofile.QualityProfile;
-import org.sonar.server.computation.snapshot.Snapshot;
import org.sonar.server.computation.util.InitializedProperty;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -37,7 +36,7 @@ public class AnalysisMetadataHolderRule extends ExternalResource implements Muta
private final InitializedProperty<Long> analysisDate = new InitializedProperty<>();
- private final InitializedProperty<Snapshot> baseProjectSnapshot = new InitializedProperty<>();
+ private final InitializedProperty<Analysis> baseProjectSnapshot = new InitializedProperty<>();
private final InitializedProperty<Boolean> crossProjectDuplicationEnabled = new InitializedProperty<>();
@@ -85,14 +84,14 @@ public class AnalysisMetadataHolderRule extends ExternalResource implements Muta
}
@Override
- public AnalysisMetadataHolderRule setBaseProjectSnapshot(@Nullable Snapshot baseProjectSnapshot) {
- this.baseProjectSnapshot.setProperty(baseProjectSnapshot);
+ public AnalysisMetadataHolderRule setBaseProjectSnapshot(@Nullable Analysis baseProjectAnalysis) {
+ this.baseProjectSnapshot.setProperty(baseProjectAnalysis);
return this;
}
@Override
@CheckForNull
- public Snapshot getBaseProjectSnapshot() {
+ public Analysis getBaseProjectSnapshot() {
checkState(baseProjectSnapshot.isInitialized(), "Base project snapshot has not been set");
return baseProjectSnapshot.getProperty();
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/analysis/MutableAnalysisMetadataHolderRule.java b/server/sonar-server/src/test/java/org/sonar/server/computation/analysis/MutableAnalysisMetadataHolderRule.java
index 065eed1bd81..d28cc74c486 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/analysis/MutableAnalysisMetadataHolderRule.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/analysis/MutableAnalysisMetadataHolderRule.java
@@ -24,7 +24,6 @@ import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.junit.rules.ExternalResource;
import org.sonar.server.computation.qualityprofile.QualityProfile;
-import org.sonar.server.computation.snapshot.Snapshot;
public class MutableAnalysisMetadataHolderRule extends ExternalResource implements MutableAnalysisMetadataHolder {
@@ -61,14 +60,14 @@ public class MutableAnalysisMetadataHolderRule extends ExternalResource implemen
}
@Override
- public MutableAnalysisMetadataHolderRule setBaseProjectSnapshot(@Nullable Snapshot baseProjectSnapshot) {
- delegate.setBaseProjectSnapshot(baseProjectSnapshot);
+ public MutableAnalysisMetadataHolderRule setBaseProjectSnapshot(@Nullable Analysis baseProjectAnalysis) {
+ delegate.setBaseProjectSnapshot(baseProjectAnalysis);
return this;
}
@Override
@CheckForNull
- public Snapshot getBaseProjectSnapshot() {
+ public Analysis getBaseProjectSnapshot() {
return delegate.getBaseProjectSnapshot();
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/filemove/FileMoveDetectionStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/filemove/FileMoveDetectionStepTest.java
index 71d83844226..b68de72e6ba 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/filemove/FileMoveDetectionStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/filemove/FileMoveDetectionStepTest.java
@@ -47,7 +47,7 @@ import org.sonar.server.computation.analysis.AnalysisMetadataHolderRule;
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.snapshot.Snapshot;
+import org.sonar.server.computation.analysis.Analysis;
import org.sonar.server.computation.source.SourceLinesRepositoryRule;
import static com.google.common.base.Joiner.on;
@@ -65,7 +65,7 @@ import static org.sonar.server.computation.component.ReportComponent.builder;
public class FileMoveDetectionStepTest {
private static final long SNAPSHOT_ID = 98765;
- private static final Snapshot SNAPSHOT = new Snapshot.Builder()
+ private static final Analysis ANALYSIS = new Analysis.Builder()
.setId(SNAPSHOT_ID)
.setUuid("uuid_1")
.setCreatedAt(86521)
@@ -258,7 +258,7 @@ public class FileMoveDetectionStepTest {
@Test
public void execute_detects_no_move_if_baseSnapshot_has_no_file_and_report_has_no_file() {
- analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(ANALYSIS);
underTest.execute();
@@ -267,7 +267,7 @@ public class FileMoveDetectionStepTest {
@Test
public void execute_detects_no_move_if_baseSnapshot_has_no_file() {
- analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(ANALYSIS);
setFilesInReport(FILE_1, FILE_2);
underTest.execute();
@@ -277,7 +277,7 @@ public class FileMoveDetectionStepTest {
@Test
public void execute_retrieves_only_file_and_unit_tests_from_last_snapshot() {
- analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(ANALYSIS);
ArgumentCaptor<ComponentTreeQuery> captor = ArgumentCaptor.forClass(ComponentTreeQuery.class);
when(componentDao.selectDescendants(eq(dbSession), captor.capture()))
.thenReturn(Collections.emptyList());
@@ -294,7 +294,7 @@ public class FileMoveDetectionStepTest {
@Test
public void execute_detects_no_move_if_there_is_no_file_in_report() {
- analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(ANALYSIS);
mockComponents( /* no components */);
setFilesInReport();
@@ -305,7 +305,7 @@ public class FileMoveDetectionStepTest {
@Test
public void execute_detects_no_move_if_file_key_exists_in_both_DB_and_report() {
- analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(ANALYSIS);
mockComponents(FILE_1.getKey(), FILE_2.getKey());
setFilesInReport(FILE_2, FILE_1);
@@ -316,7 +316,7 @@ public class FileMoveDetectionStepTest {
@Test
public void execute_detects_move_if_content_of_file_is_same_in_DB_and_report() {
- analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(ANALYSIS);
ComponentDto[] dtos = mockComponents(FILE_1.getKey());
mockContentOfFileInDb(FILE_1.getKey(), CONTENT1);
setFilesInReport(FILE_2);
@@ -333,7 +333,7 @@ public class FileMoveDetectionStepTest {
@Test
public void execute_detects_no_move_if_content_of_file_is_not_similar_enough() {
- analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(ANALYSIS);
mockComponents(FILE_1.getKey());
mockContentOfFileInDb(FILE_1.getKey(), CONTENT1);
setFilesInReport(FILE_2);
@@ -346,7 +346,7 @@ public class FileMoveDetectionStepTest {
@Test
public void execute_detects_no_move_if_content_of_file_is_empty_in_DB() {
- analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(ANALYSIS);
mockComponents(FILE_1.getKey());
mockContentOfFileInDb(FILE_1.getKey(), CONTENT_EMPTY);
setFilesInReport(FILE_2);
@@ -359,7 +359,7 @@ public class FileMoveDetectionStepTest {
@Test
public void execute_detects_no_move_if_content_of_file_is_empty_in_report() {
- analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(ANALYSIS);
mockComponents(FILE_1.getKey());
mockContentOfFileInDb(FILE_1.getKey(), CONTENT1);
setFilesInReport(FILE_2);
@@ -372,7 +372,7 @@ public class FileMoveDetectionStepTest {
@Test
public void execute_detects_no_move_if_two_added_files_have_same_content_as_the_one_in_db() {
- analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(ANALYSIS);
mockComponents(FILE_1.getKey());
mockContentOfFileInDb(FILE_1.getKey(), CONTENT1);
setFilesInReport(FILE_2, FILE_3);
@@ -386,7 +386,7 @@ public class FileMoveDetectionStepTest {
@Test
public void execute_detects_no_move_if_two_deleted_files_have_same_content_as_the_one_added() {
- analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(ANALYSIS);
mockComponents(FILE_1.getKey(), FILE_2.getKey());
mockContentOfFileInDb(FILE_1.getKey(), CONTENT1);
mockContentOfFileInDb(FILE_2.getKey(), CONTENT1);
@@ -405,7 +405,7 @@ public class FileMoveDetectionStepTest {
// - file2 deleted
// - file4 untouched
// - file5 renamed to file6 with a small change
- analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(ANALYSIS);
Component file4 = fileComponent(5);
Component file5 = fileComponent(6);
Component file6 = fileComponent(7);
@@ -437,7 +437,7 @@ public class FileMoveDetectionStepTest {
*/
@Test
public void real_life_use_case() throws Exception {
- analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(ANALYSIS);
List<String> componentDtoKey = new ArrayList<>();
for (File f : FileUtils.listFiles(new File("src/test/resources/org/sonar/server/computation/filemove/FileMoveDetectionStepTest/v1"), null, false)) {
componentDtoKey.add(f.getName());
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/scm/ScmInfoRepositoryImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/scm/ScmInfoRepositoryImplTest.java
index 85eb2112923..83d239feacd 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/scm/ScmInfoRepositoryImplTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/scm/ScmInfoRepositoryImplTest.java
@@ -46,7 +46,7 @@ import org.sonar.server.computation.batch.BatchReportReaderRule;
import org.sonar.server.computation.component.Component;
import org.sonar.server.computation.component.ReportComponent;
import org.sonar.server.computation.component.ViewsComponent;
-import org.sonar.server.computation.snapshot.Snapshot;
+import org.sonar.server.computation.analysis.Analysis;
import org.sonar.server.computation.source.SourceHashRepository;
import org.sonar.server.computation.source.SourceHashRepositoryImpl;
import org.sonar.server.computation.source.SourceLinesRepositoryImpl;
@@ -66,7 +66,7 @@ public class ScmInfoRepositoryImplTest {
static final long DATE_1 = 123456789L;
static final long DATE_2 = 1234567810L;
- static Snapshot BASE_PROJECT_SNAPSHOT = new Snapshot.Builder()
+ static Analysis baseProjectAnalysis = new Analysis.Builder()
.setId(1)
.setUuid("uuid_1")
.setCreatedAt(123456789L)
@@ -90,7 +90,7 @@ public class ScmInfoRepositoryImplTest {
@Test
public void read_from_report() throws Exception {
- analysisMetadataHolder.setBaseProjectSnapshot(BASE_PROJECT_SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(baseProjectAnalysis);
addChangesetInReport("john", DATE_1, "rev-1");
ScmInfo scmInfo = underTest.getScmInfo(FILE).get();
@@ -101,7 +101,7 @@ public class ScmInfoRepositoryImplTest {
@Test
public void getScmInfo_returns_absent_if_CopyFromPrevious_is_false_and_there_is_no_changeset_in_report() {
- analysisMetadataHolder.setBaseProjectSnapshot(BASE_PROJECT_SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(baseProjectAnalysis);
// put data in DB, which should not be used
addFileSourceInDb("henry", DATE_1, "rev-1", computeSourceHash(1));
addFileSourceInReport(1);
@@ -111,7 +111,7 @@ public class ScmInfoRepositoryImplTest {
@Test
public void getScmInfo_returns_ScmInfo_from_DB_CopyFromPrevious_is_true_if_hashes_are_the_same() throws Exception {
- analysisMetadataHolder.setBaseProjectSnapshot(BASE_PROJECT_SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(baseProjectAnalysis);
addFileSourceInDb("henry", DATE_1, "rev-1", computeSourceHash(1));
addFileSourceInReport(1);
addCopyFromPreviousChangesetInReport();
@@ -124,7 +124,7 @@ public class ScmInfoRepositoryImplTest {
@Test
public void getScmInfo_returns_absent_when_CopyFromPrevious_is_true_but_hashes_are_not_the_same() throws Exception {
- analysisMetadataHolder.setBaseProjectSnapshot(BASE_PROJECT_SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(baseProjectAnalysis);
addFileSourceInDb("henry", DATE_1, "rev-1", computeSourceHash(1) + "_different");
addFileSourceInReport(1);
addCopyFromPreviousChangesetInReport();
@@ -136,7 +136,7 @@ public class ScmInfoRepositoryImplTest {
@Test
public void read_from_report_even_if_data_in_db_exists() throws Exception {
- analysisMetadataHolder.setBaseProjectSnapshot(BASE_PROJECT_SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(baseProjectAnalysis);
addFileSourceInDb("henry", DATE_1, "rev-1", computeSourceHash(1));
addChangesetInReport("john", DATE_2, "rev-2");
@@ -150,7 +150,7 @@ public class ScmInfoRepositoryImplTest {
@Test
public void read_from_db_even_if_data_in_report_exists_when_CopyFromPrevious_is_true() throws Exception {
- analysisMetadataHolder.setBaseProjectSnapshot(BASE_PROJECT_SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(baseProjectAnalysis);
addFileSourceInDb("henry", DATE_1, "rev-1", computeSourceHash(1));
addFileSourceInReport(1);
addChangesetInReport("john", DATE_2, "rev-2", true);
@@ -165,13 +165,13 @@ public class ScmInfoRepositoryImplTest {
@Test
public void return_nothing_when_no_data_in_report_nor_db() throws Exception {
- analysisMetadataHolder.setBaseProjectSnapshot(BASE_PROJECT_SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(baseProjectAnalysis);
assertThat(underTest.getScmInfo(FILE)).isAbsent();
}
@Test
public void return_nothing_when_nothing_in_report_and_db_has_no_scm() throws Exception {
- analysisMetadataHolder.setBaseProjectSnapshot(BASE_PROJECT_SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(baseProjectAnalysis);
addFileSourceInDb(null, null, null, "don't care");
addFileSourceInReport(1);
@@ -180,7 +180,7 @@ public class ScmInfoRepositoryImplTest {
@Test
public void fail_with_NPE_when_component_is_null() throws Exception {
- analysisMetadataHolder.setBaseProjectSnapshot(BASE_PROJECT_SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(baseProjectAnalysis);
thrown.expect(NullPointerException.class);
thrown.expectMessage("Component cannot be bull");
@@ -219,7 +219,7 @@ public class ScmInfoRepositoryImplTest {
@Test
public void load_scm_info_from_cache_when_already_read() throws Exception {
- analysisMetadataHolder.setBaseProjectSnapshot(BASE_PROJECT_SNAPSHOT);
+ analysisMetadataHolder.setBaseProjectSnapshot(baseProjectAnalysis);
addChangesetInReport("john", DATE_1, "rev-1");
ScmInfo scmInfo = underTest.getScmInfo(FILE).get();
assertThat(scmInfo.getAllChangesets()).hasSize(1);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadCrossProjectDuplicationsRepositoryStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadCrossProjectDuplicationsRepositoryStepTest.java
index 064f14acbbe..b1166492bf4 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadCrossProjectDuplicationsRepositoryStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadCrossProjectDuplicationsRepositoryStepTest.java
@@ -50,7 +50,7 @@ import org.sonar.server.computation.component.FileAttributes;
import org.sonar.server.computation.component.ReportComponent;
import org.sonar.server.computation.duplication.CrossProjectDuplicationStatusHolder;
import org.sonar.server.computation.duplication.IntegrateCrossProjectDuplications;
-import org.sonar.server.computation.snapshot.Snapshot;
+import org.sonar.server.computation.analysis.Analysis;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
@@ -100,7 +100,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest {
IntegrateCrossProjectDuplications integrateCrossProjectDuplications = mock(IntegrateCrossProjectDuplications.class);
- Snapshot baseProjectSnapshot;
+ Analysis baseProjectAnalysis;
ComputationStep underTest = new LoadCrossProjectDuplicationsRepositoryStep(treeRootHolder, batchReportReader, analysisMetadataHolder, crossProjectDuplicationStatusHolder,
integrateCrossProjectDuplications, dbClient);
@@ -113,7 +113,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest {
dbClient.snapshotDao().insert(dbSession, projectSnapshot);
dbSession.commit();
- baseProjectSnapshot = new Snapshot.Builder()
+ baseProjectAnalysis = new Analysis.Builder()
.setId(projectSnapshot.getId())
.setUuid(projectSnapshot.getUuid())
.setCreatedAt(projectSnapshot.getCreatedAt())
@@ -123,7 +123,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest {
@Test
public void call_compute_cpd_on_one_duplication() throws Exception {
when(crossProjectDuplicationStatusHolder.isEnabled()).thenReturn(true);
- analysisMetadataHolder.setBaseProjectSnapshot(baseProjectSnapshot);
+ analysisMetadataHolder.setBaseProjectSnapshot(baseProjectAnalysis);
ComponentDto otherProject = createProject("OTHER_PROJECT_KEY");
SnapshotDto otherProjectSnapshot = createProjectSnapshot(otherProject);
@@ -173,7 +173,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest {
@Test
public void call_compute_cpd_on_many_duplication() throws Exception {
when(crossProjectDuplicationStatusHolder.isEnabled()).thenReturn(true);
- analysisMetadataHolder.setBaseProjectSnapshot(baseProjectSnapshot);
+ analysisMetadataHolder.setBaseProjectSnapshot(baseProjectAnalysis);
ComponentDto otherProject = createProject("OTHER_PROJECT_KEY");
SnapshotDto otherProjectSnapshot = createProjectSnapshot(otherProject);
@@ -261,7 +261,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest {
@Test
public void nothing_to_do_when_cross_project_duplication_is_disabled() throws Exception {
when(crossProjectDuplicationStatusHolder.isEnabled()).thenReturn(false);
- analysisMetadataHolder.setBaseProjectSnapshot(baseProjectSnapshot);
+ analysisMetadataHolder.setBaseProjectSnapshot(baseProjectAnalysis);
ComponentDto otherProject = createProject("OTHER_PROJECT_KEY");
SnapshotDto otherProjectSnapshot = createProjectSnapshot(otherProject);
@@ -296,7 +296,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest {
@Test
public void nothing_to_do_when_no_cpd_text_blocks_found() throws Exception {
when(crossProjectDuplicationStatusHolder.isEnabled()).thenReturn(true);
- analysisMetadataHolder.setBaseProjectSnapshot(baseProjectSnapshot);
+ analysisMetadataHolder.setBaseProjectSnapshot(baseProjectAnalysis);
batchReportReader.putDuplicationBlocks(FILE_REF, Collections.<ScannerReport.CpdTextBlock>emptyList());
@@ -308,7 +308,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest {
@Test
public void nothing_to_do_when_cpd_text_blocks_exists_but_no_duplicated_found() throws Exception {
when(crossProjectDuplicationStatusHolder.isEnabled()).thenReturn(true);
- analysisMetadataHolder.setBaseProjectSnapshot(baseProjectSnapshot);
+ analysisMetadataHolder.setBaseProjectSnapshot(baseProjectAnalysis);
ScannerReport.CpdTextBlock originBlock = ScannerReport.CpdTextBlock.newBuilder()
.setHash("a8998353e96320ec")