aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-07-06 11:32:34 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-07-06 15:45:19 +0200
commit6c7fae043cb0dc7fe586a77e3096660364e92804 (patch)
tree3db59f0e9951b37aaa6ff4613e2d3666b05fc33b /server
parent969a0c08299cb3e4fbd419ec57b571fd83bd1bbd (diff)
downloadsonarqube-6c7fae043cb0dc7fe586a77e3096660364e92804.tar.gz
sonarqube-6c7fae043cb0dc7fe586a77e3096660364e92804.zip
SONAR-7705 refactoring
including some renaming of "snapshot" to "analysis"
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/BuildComponentTreeStep.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/EnableAnalysisStep.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/PeriodResolver.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistAnalysisStep.java (renamed from server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistSnapshotsStep.java)18
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/ReportComputationSteps.java5
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/ValidateProjectStep.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryService.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/SearchAction.java16
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeDataLoader.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/project/ws/SearchMyProjectsDataLoader.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/BuildComponentTreeStepTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/EnableAnalysisStepTest.java75
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadCrossProjectDuplicationsRepositoryStepTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportComputeMeasureVariationsStepTest.java28
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportPersistAnalysisStepTest.java (renamed from server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportPersistSnapshotsStepTest.java)16
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/ValidateProjectStepTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsComputeMeasureVariationsStepTest.java18
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsPersistAnalysisStepTest.java (renamed from server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsPersistSnapshotsStepTest.java)14
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/IssueBulkChangeServiceMediumTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/IssueCommentServiceMediumTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java15
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/project/ws/GhostsActionTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/project/ws/ProvisionedActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchMyProjectsActionTest.java10
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java16
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentNavigationActionTest.java26
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/ignore_quality_model_measures.xml18
36 files changed, 171 insertions, 175 deletions
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 c0dfa740a93..ee1e180f032 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
@@ -69,7 +69,7 @@ public class BuildComponentTreeStep implements ComputationStep {
private void setBaseProjectSnapshot(String projectUuid) {
DbSession dbSession = dbClient.openSession(false);
try {
- SnapshotDto snapshotDto = dbClient.snapshotDao().selectSnapshotByQuery(dbSession,
+ SnapshotDto snapshotDto = dbClient.snapshotDao().selectAnalysisByQuery(dbSession,
new SnapshotQuery()
.setComponentUuid(projectUuid)
.setIsLast(true));
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/EnableAnalysisStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/EnableAnalysisStep.java
index 3d77dffbb2e..b009eb7c154 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/EnableAnalysisStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/EnableAnalysisStep.java
@@ -43,8 +43,7 @@ public class EnableAnalysisStep implements ComputationStep {
DbSession dbSession = dbClient.openSession(false);
try {
Component project = treeRootHolder.getRoot();
- dbClient.snapshotDao().unsetIsLastFlagForComponentUuid(dbSession, project.getUuid());
- dbClient.snapshotDao().setIsLastFlagForAnalysisUuid(dbSession, analysisMetadataHolder.getUuid());
+ dbClient.snapshotDao().switchIsLastFlagAndSetProcessedStatus(dbSession, project.getUuid(), analysisMetadataHolder.getUuid());
dbSession.commit();
} finally {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PeriodResolver.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PeriodResolver.java
index d20ed0e8bfd..81e8427860f 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PeriodResolver.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PeriodResolver.java
@@ -110,7 +110,7 @@ public class PeriodResolver {
@CheckForNull
private Period findByDays(int index, int days) {
- List<SnapshotDto> snapshots = dbClient.snapshotDao().selectSnapshotsByQuery(session, createCommonQuery(projectUuid).setCreatedBefore(analysisDate).setSort(BY_DATE, ASC));
+ List<SnapshotDto> snapshots = dbClient.snapshotDao().selectAnalysesByQuery(session, createCommonQuery(projectUuid).setCreatedBefore(analysisDate).setSort(BY_DATE, ASC));
long targetDate = DateUtils.addDays(new Date(analysisDate), -days).getTime();
SnapshotDto snapshot = findNearestSnapshotToTargetDate(snapshots, targetDate);
if (snapshot == null) {
@@ -167,7 +167,7 @@ public class PeriodResolver {
@CheckForNull
private SnapshotDto findFirstSnapshot(DbSession session, SnapshotQuery query) {
- List<SnapshotDto> snapshots = dbClient.snapshotDao().selectSnapshotsByQuery(session, query);
+ List<SnapshotDto> snapshots = dbClient.snapshotDao().selectAnalysesByQuery(session, query);
if (!snapshots.isEmpty()) {
return snapshots.get(0);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistSnapshotsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistAnalysisStep.java
index b1413e57c1f..98845e53b96 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistSnapshotsStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistAnalysisStep.java
@@ -29,7 +29,6 @@ import org.sonar.db.component.SnapshotDto;
import org.sonar.server.computation.analysis.AnalysisMetadataHolder;
import org.sonar.server.computation.component.Component;
import org.sonar.server.computation.component.CrawlerDepthLimit;
-import org.sonar.server.computation.component.DbIdsRepositoryImpl;
import org.sonar.server.computation.component.PathAwareCrawler;
import org.sonar.server.computation.component.PathAwareVisitorAdapter;
import org.sonar.server.computation.component.TreeRootHolder;
@@ -37,10 +36,9 @@ import org.sonar.server.computation.period.Period;
import org.sonar.server.computation.period.PeriodsHolder;
/**
- * Persist snapshots
- * Also feed the components cache {@link DbIdsRepositoryImpl} with snapshot ids
+ * Persist analysis
*/
-public class PersistSnapshotsStep implements ComputationStep {
+public class PersistAnalysisStep implements ComputationStep {
private final System2 system2;
private final DbClient dbClient;
@@ -48,8 +46,8 @@ public class PersistSnapshotsStep implements ComputationStep {
private final AnalysisMetadataHolder analysisMetadataHolder;
private final PeriodsHolder periodsHolder;
- public PersistSnapshotsStep(System2 system2, DbClient dbClient, TreeRootHolder treeRootHolder, AnalysisMetadataHolder analysisMetadataHolder,
- PeriodsHolder periodsHolder) {
+ public PersistAnalysisStep(System2 system2, DbClient dbClient, TreeRootHolder treeRootHolder, AnalysisMetadataHolder analysisMetadataHolder,
+ PeriodsHolder periodsHolder) {
this.system2 = system2;
this.dbClient = dbClient;
this.treeRootHolder = treeRootHolder;
@@ -83,14 +81,14 @@ public class PersistSnapshotsStep implements ComputationStep {
@Override
public void visitProject(Component project, Path<SnapshotDtoHolder> path) {
- SnapshotDto snapshot = createSnapshot(analysisMetadataHolder.getUuid(), project, true);
+ SnapshotDto snapshot = createAnalysis(analysisMetadataHolder.getUuid(), project, true);
updateSnapshotPeriods(snapshot);
persist(snapshot, dbSession);
}
@Override
public void visitView(Component view, Path<SnapshotDtoHolder> path) {
- SnapshotDto snapshot = createSnapshot(Uuids.create(), view, false);
+ SnapshotDto snapshot = createAnalysis(Uuids.create(), view, false);
updateSnapshotPeriods(snapshot);
persist(snapshot, dbSession);
}
@@ -104,7 +102,7 @@ public class PersistSnapshotsStep implements ComputationStep {
}
}
- private SnapshotDto createSnapshot(String snapshotUuid, Component component, boolean setVersion) {
+ private SnapshotDto createAnalysis(String snapshotUuid, Component component, boolean setVersion) {
String componentUuid = component.getUuid();
return new SnapshotDto()
.setUuid(snapshotUuid)
@@ -162,6 +160,6 @@ public class PersistSnapshotsStep implements ComputationStep {
@Override
public String getDescription() {
- return "Persist snapshots";
+ return "Persist analysis";
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ReportComputationSteps.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ReportComputationSteps.java
index f331815ceb9..1f183b51e30 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ReportComputationSteps.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ReportComputationSteps.java
@@ -86,7 +86,7 @@ public class ReportComputationSteps extends AbstractComputationSteps {
// Persist data
PersistComponentsStep.class,
- PersistSnapshotsStep.class,
+ PersistAnalysisStep.class,
PersistDevelopersStep.class,
PersistMeasuresStep.class,
PersistIssuesStep.class,
@@ -95,9 +95,8 @@ public class ReportComputationSteps extends AbstractComputationSteps {
PersistFileSourcesStep.class,
PersistTestsStep.class,
PersistCrossProjectDuplicationIndexStep.class,
-
- // Switch snapshot and purge
EnableAnalysisStep.class,
+
UpdateQualityProfilesLastUsedDateStep.class,
IndexComponentsStep.class,
PurgeDatastoresStep.class,
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ValidateProjectStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ValidateProjectStep.java
index 3d8b946a5d3..5379ffee18f 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ValidateProjectStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ValidateProjectStep.java
@@ -147,9 +147,9 @@ public class ValidateProjectStep implements ComputationStep {
private void validateAnalysisDate(Optional<ComponentDto> baseProject) {
if (baseProject.isPresent()) {
- java.util.Optional<SnapshotDto> snapshotDto = dbClient.snapshotDao().selectLastSnapshotByRootComponentUuid(session, baseProject.get().uuid());
+ java.util.Optional<SnapshotDto> snapshotDto = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(session, baseProject.get().uuid());
long currentAnalysisDate = analysisMetadataHolder.getAnalysisDate();
- Long lastAnalysisDate = snapshotDto.isPresent() ? snapshotDto.get().getCreatedAt() : null;
+ Long lastAnalysisDate = snapshotDto.map(SnapshotDto::getCreatedAt).orElse(null);
if (lastAnalysisDate != null && currentAnalysisDate <= lastAnalysisDate) {
validationMessages.add(format("Date of analysis cannot be older than the date of the last known analysis on this project. Value: \"%s\". " +
"Latest analysis: \"%s\". It's only possible to rebuild the past in a chronological order.",
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryService.java b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryService.java
index c30862a9b3b..4ffc976929a 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryService.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryService.java
@@ -249,7 +249,7 @@ public class IssueQueryService {
@CheckForNull
private Date findCreatedAfterFromComponentUuid(DbSession dbSession, String uuid) {
ComponentDto component = checkFoundWithOptional(componentService.getByUuid(uuid), "Component with id '%s' not found", uuid);
- Optional<SnapshotDto> snapshot = dbClient.snapshotDao().selectLastSnapshotByComponentUuid(dbSession, component.uuid());
+ Optional<SnapshotDto> snapshot = dbClient.snapshotDao().selectLastAnalysisByComponentUuid(dbSession, component.uuid());
if (snapshot.isPresent()) {
return longToDate(snapshot.get().getPeriodDate(1));
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/SearchAction.java
index 10a8af689db..dab7baf46de 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/SearchAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/SearchAction.java
@@ -100,23 +100,23 @@ public class SearchAction implements CustomMeasuresWsAction {
DbSession dbSession = dbClient.openSession(false);
try {
- ComponentDto project = componentFinder.getByUuidOrKey(dbSession, projectUuid, projectKey, PROJECT_ID_AND_KEY);
- checkPermissions(userSession, project);
- Long lastAnalysisDateMs = searchLastSnapshotDate(dbSession, project);
- List<CustomMeasureDto> customMeasures = searchCustomMeasures(dbSession, project, searchOptions);
- int nbCustomMeasures = countTotalOfCustomMeasures(dbSession, project);
+ ComponentDto component = componentFinder.getByUuidOrKey(dbSession, projectUuid, projectKey, PROJECT_ID_AND_KEY);
+ checkPermissions(userSession, component);
+ Long lastAnalysisDateMs = searchLastSnapshotDate(dbSession, component);
+ List<CustomMeasureDto> customMeasures = searchCustomMeasures(dbSession, component, searchOptions);
+ int nbCustomMeasures = countTotalOfCustomMeasures(dbSession, component);
Map<String, UserDto> usersByLogin = usersByLogin(dbSession, customMeasures);
Map<Integer, MetricDto> metricsById = metricsById(dbSession, customMeasures);
- writeResponse(response, customMeasures, nbCustomMeasures, project, metricsById, usersByLogin, lastAnalysisDateMs, searchOptions, fieldsToReturn);
+ writeResponse(response, customMeasures, nbCustomMeasures, component, metricsById, usersByLogin, lastAnalysisDateMs, searchOptions, fieldsToReturn);
} finally {
MyBatis.closeQuietly(dbSession);
}
}
@CheckForNull
- private Long searchLastSnapshotDate(DbSession dbSession, ComponentDto project) {
- Optional<SnapshotDto> lastSnapshot = dbClient.snapshotDao().selectLastSnapshotByComponentUuid(dbSession, project.projectUuid());
+ private Long searchLastSnapshotDate(DbSession dbSession, ComponentDto component) {
+ Optional<SnapshotDto> lastSnapshot = dbClient.snapshotDao().selectLastAnalysisByComponentUuid(dbSession, component.projectUuid());
return lastSnapshot.isPresent() ? lastSnapshot.get().getBuildDate() : null;
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java
index 018c95db2f6..f3ff13a3669 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java
@@ -138,7 +138,7 @@ public class ComponentAction implements MeasuresWsAction {
Long developerId = searchDeveloperId(dbSession, request);
Optional<ComponentDto> refComponent = getReferenceComponent(dbSession, component);
checkPermissions(component);
- SnapshotDto analysis = dbClient.snapshotDao().selectLastSnapshotByRootComponentUuid(dbSession, component.projectUuid()).orElse(null);
+ SnapshotDto analysis = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(dbSession, component.projectUuid()).orElse(null);
List<MetricDto> metrics = searchMetrics(dbSession, request);
List<WsMeasures.Period> periods = snapshotToWsPeriods(analysis);
List<MeasureDto> measures = searchMeasures(dbSession, component, analysis, metrics, periods, developerId);
diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeDataLoader.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeDataLoader.java
index 1bccfd3c3a6..6304bc21367 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeDataLoader.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeDataLoader.java
@@ -102,7 +102,7 @@ public class ComponentTreeDataLoader {
try {
ComponentDto baseComponent = componentFinder.getByUuidOrKey(dbSession, wsRequest.getBaseComponentId(), wsRequest.getBaseComponentKey(), BASE_COMPONENT_ID_AND_KEY);
checkPermissions(baseComponent);
- java.util.Optional<SnapshotDto> baseSnapshot = dbClient.snapshotDao().selectLastSnapshotByRootComponentUuid(dbSession, baseComponent.projectUuid());
+ java.util.Optional<SnapshotDto> baseSnapshot = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(dbSession, baseComponent.projectUuid());
if (!baseSnapshot.isPresent()) {
return ComponentTreeData.builder()
.setBaseComponent(baseComponent)
diff --git a/server/sonar-server/src/main/java/org/sonar/server/project/ws/SearchMyProjectsDataLoader.java b/server/sonar-server/src/main/java/org/sonar/server/project/ws/SearchMyProjectsDataLoader.java
index 62de10c3fc5..879c9b3099d 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/project/ws/SearchMyProjectsDataLoader.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/project/ws/SearchMyProjectsDataLoader.java
@@ -59,7 +59,7 @@ public class SearchMyProjectsDataLoader {
List<ComponentDto> projects = searchResult.projects;
List<String> projectUuids = Lists.transform(projects, ComponentDto::projectUuid);
List<ComponentLinkDto> projectLinks = dbClient.componentLinkDao().selectByComponentUuids(dbSession, projectUuids);
- List<SnapshotDto> snapshots = dbClient.snapshotDao().selectLastSnapshotsByRootComponentUuids(dbSession, projectUuids);
+ List<SnapshotDto> snapshots = dbClient.snapshotDao().selectLastAnalysesByRootComponentUuids(dbSession, projectUuids);
MetricDto gateStatusMetric = dbClient.metricDao().selectOrFailByKey(dbSession, CoreMetrics.ALERT_STATUS_KEY);
MeasureQuery measureQuery = MeasureQuery.builder()
.setComponentUuids(projectUuids)
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java
index cd6ab965e73..ce4c6acd578 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java
@@ -144,7 +144,7 @@ public class ProjectStatusAction implements QGateWsAction {
private ProjectAndSnapshot getProjectThenSnapshot(DbSession dbSession, ProjectStatusWsRequest request) {
ComponentDto projectDto = componentFinder.getByUuidOrKey(dbSession, request.getProjectId(), request.getProjectKey(), ParamNames.PROJECT_ID_AND_KEY);
- java.util.Optional<SnapshotDto> snapshot = dbClient.snapshotDao().selectLastSnapshotByRootComponentUuid(dbSession, projectDto.projectUuid());
+ java.util.Optional<SnapshotDto> snapshot = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(dbSession, projectDto.projectUuid());
return new ProjectAndSnapshot(projectDto, snapshot.orElse(null));
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java
index 3674be2b221..3d42c845fc5 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java
@@ -116,7 +116,7 @@ public class ComponentNavigationAction implements NavigationWsAction {
userSession.checkComponentUuidPermission(UserRole.USER, component.projectUuid());
- Optional<SnapshotDto> analysis = dbClient.snapshotDao().selectLastSnapshotByRootComponentUuid(session, component.projectUuid());
+ Optional<SnapshotDto> analysis = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(session, component.projectUuid());
JsonWriter json = response.newJsonWriter();
json.beginObject();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java
index e71bc29a384..cbe6c54ab83 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java
@@ -172,7 +172,7 @@ public class AppActionTest {
.setLongName("src/main/java/org/sonar/api/Plugin.java")
.setPath("src/main/java/org/sonar/api/Plugin.java");
dbTester.getDbClient().componentDao().insert(dbTester.getSession(), project, module, file);
- SnapshotDto analysis = SnapshotTesting.newSnapshotForProject(project)
+ SnapshotDto analysis = SnapshotTesting.newAnalysis(project)
.setUuid(ANALYSIS_UUID);
dbTester.getDbClient().snapshotDao().insert(dbTester.getSession(), analysis);
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/BuildComponentTreeStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/BuildComponentTreeStepTest.java
index 944f401463a..e9aa39e1217 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/BuildComponentTreeStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/BuildComponentTreeStepTest.java
@@ -51,7 +51,7 @@ import static org.sonar.db.component.ComponentTesting.newDirectory;
import static org.sonar.db.component.ComponentTesting.newFileDto;
import static org.sonar.db.component.ComponentTesting.newModuleDto;
import static org.sonar.db.component.ComponentTesting.newProjectDto;
-import static org.sonar.db.component.SnapshotTesting.newSnapshotForProject;
+import static org.sonar.db.component.SnapshotTesting.newAnalysis;
import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.DIRECTORY;
import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.FILE;
import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.MODULE;
@@ -281,7 +281,7 @@ public class BuildComponentTreeStepTest {
@Test
public void set_no_base_project_snapshot_when_no_last_snapshot() throws Exception {
ComponentDto project = insertComponent(newProjectDto("ABCD").setKey(REPORT_PROJECT_KEY));
- insertSnapshot(newSnapshotForProject(project).setLast(false));
+ insertSnapshot(newAnalysis(project).setLast(false));
reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY));
underTest.execute();
@@ -292,7 +292,7 @@ public class BuildComponentTreeStepTest {
@Test
public void set_base_project_snapshot_when_last_snapshot_exist() throws Exception {
ComponentDto project = insertComponent(newProjectDto("ABCD").setKey(REPORT_PROJECT_KEY));
- insertSnapshot(newSnapshotForProject(project).setLast(true));
+ insertSnapshot(newAnalysis(project).setLast(true));
reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY));
underTest.execute();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/EnableAnalysisStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/EnableAnalysisStepTest.java
index 740472651d4..e9479f4add8 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/EnableAnalysisStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/EnableAnalysisStepTest.java
@@ -19,43 +19,80 @@
*/
package org.sonar.server.computation.step;
+import java.util.Optional;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.utils.System2;
import org.sonar.db.DbTester;
+import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
+import org.sonar.db.component.SnapshotDto;
+import org.sonar.db.component.SnapshotTesting;
+import org.sonar.server.computation.analysis.MutableAnalysisMetadataHolderRule;
import org.sonar.server.computation.batch.TreeRootHolderRule;
-import org.sonar.server.computation.component.DbIdsRepositoryImpl;
+import org.sonar.server.computation.component.ReportComponent;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.server.computation.component.Component.Type.PROJECT;
public class EnableAnalysisStepTest {
+ private static final ReportComponent REPORT_PROJECT = ReportComponent.builder(PROJECT, 1).build();
+ private static final String PREVIOUS_ANALYSIS_UUID = "ANALYSIS_1";
+ private static final String CURRENT_ANALYSIS_UUID = "ANALYSIS_2";
+
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
@Rule
public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule();
- DbIdsRepositoryImpl dbIdsRepository = new DbIdsRepositoryImpl();
+ @Rule
+ public MutableAnalysisMetadataHolderRule analysisMetadataHolder = new MutableAnalysisMetadataHolderRule();
+
+ EnableAnalysisStep underTest = new EnableAnalysisStep(db.getDbClient(), treeRootHolder, analysisMetadataHolder);
- EnableAnalysisStep underTest;
+ @Test
+ public void switch_islast_flag_and_mark_analysis_as_processed() {
+ ComponentDto project = ComponentTesting.newProjectDto(REPORT_PROJECT.getUuid());
+ db.getDbClient().componentDao().insert(db.getSession(), project);
+ insertAnalysis(project, PREVIOUS_ANALYSIS_UUID, SnapshotDto.STATUS_PROCESSED, true);
+ insertAnalysis(project, CURRENT_ANALYSIS_UUID, SnapshotDto.STATUS_UNPROCESSED, false);
+ db.commit();
+ treeRootHolder.setRoot(REPORT_PROJECT);
+ analysisMetadataHolder.setUuid(CURRENT_ANALYSIS_UUID);
+
+ underTest.execute();
-// @Before
-// public void before() {
-// System2 system2 = mock(System2.class);
-// when(system2.now()).thenReturn(DateUtils.parseDate("2011-09-29").getTime());
-// underTest = new EnableAnalysisStep(new DbClient(db.database(), db.myBatis(), new SnapshotDao()), treeRootHolder, dbIdsRepository);
-// }
+ verifyAnalysis(PREVIOUS_ANALYSIS_UUID, SnapshotDto.STATUS_PROCESSED, false);
+ verifyAnalysis(CURRENT_ANALYSIS_UUID, SnapshotDto.STATUS_PROCESSED, true);
+ }
@Test
- public void one_switch_with_a_snapshot_and_his_children() {
-// db.prepareDbUnit(getClass(), "snapshots.xml");
-//
-// Component project = ReportComponent.DUMB_PROJECT;
-// treeRootHolder.setRoot(project);
-// dbIdsRepository.setSnapshotId(project, 1);
-//
-// underTest.execute();
-//
-// db.assertDbUnit(getClass(), "snapshots-result.xml", "snapshots");
+ public void set_islast_flag_and_mark_as_processed_if_no_previous_analysis() {
+ ComponentDto project = ComponentTesting.newProjectDto(REPORT_PROJECT.getUuid());
+ db.getDbClient().componentDao().insert(db.getSession(), project);
+ insertAnalysis(project, CURRENT_ANALYSIS_UUID, SnapshotDto.STATUS_UNPROCESSED, false);
+ db.commit();
+ treeRootHolder.setRoot(REPORT_PROJECT);
+ analysisMetadataHolder.setUuid(CURRENT_ANALYSIS_UUID);
+
+ underTest.execute();
+
+ verifyAnalysis(CURRENT_ANALYSIS_UUID, SnapshotDto.STATUS_PROCESSED, true);
+ }
+
+ private void verifyAnalysis(String uuid, String expectedStatus, boolean expectedLastFlag) {
+ Optional<SnapshotDto> analysis = db.getDbClient().snapshotDao().selectByUuid(db.getSession(), uuid);
+ assertThat(analysis.get().getStatus()).isEqualTo(expectedStatus);
+ assertThat(analysis.get().getLast()).isEqualTo(expectedLastFlag);
+ }
+
+ private void insertAnalysis(ComponentDto project, String uuid, String status, boolean isLastFlag) {
+ SnapshotDto snapshot = SnapshotTesting.newAnalysis(project)
+ .setLast(isLastFlag)
+ .setStatus(status)
+ .setUuid(uuid);
+ db.getDbClient().snapshotDao().insert(db.getSession(), snapshot);
}
}
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 ec257177fb2..064f14acbbe 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
@@ -109,7 +109,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest {
public void setUp() throws Exception {
ComponentDto project = ComponentTesting.newProjectDto();
dbClient.componentDao().insert(dbSession, project);
- SnapshotDto projectSnapshot = SnapshotTesting.newSnapshotForProject(project);
+ SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(project);
dbClient.snapshotDao().insert(dbSession, projectSnapshot);
dbSession.commit();
@@ -332,7 +332,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest {
}
private SnapshotDto createProjectSnapshot(ComponentDto project) {
- SnapshotDto projectSnapshot = SnapshotTesting.newSnapshotForProject(project);
+ SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(project);
dbClient.snapshotDao().insert(dbSession, projectSnapshot);
dbSession.commit();
return projectSnapshot;
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportComputeMeasureVariationsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportComputeMeasureVariationsStepTest.java
index 77a22e0c018..76008c40c70 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportComputeMeasureVariationsStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportComputeMeasureVariationsStepTest.java
@@ -45,7 +45,7 @@ import org.sonar.server.computation.period.Period;
import org.sonar.server.computation.period.PeriodsHolderRule;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.SnapshotTesting.newSnapshotForProject;
+import static org.sonar.db.component.SnapshotTesting.newAnalysis;
import static org.sonar.server.computation.measure.Measure.newMeasureBuilder;
public class ReportComputeMeasureVariationsStepTest {
@@ -94,7 +94,7 @@ public class ReportComputeMeasureVariationsStepTest {
@Test
public void do_nothing_when_no_raw_measure() {
- SnapshotDto period1ProjectSnapshot = newSnapshotForProject(PROJECT_DTO);
+ SnapshotDto period1ProjectSnapshot = newAnalysis(PROJECT_DTO);
dbClient.snapshotDao().insert(session, period1ProjectSnapshot);
dbClient.measureDao().insert(session, newMeasureDto(ISSUES_METRIC.getId(), PROJECT_DTO.uuid(), period1ProjectSnapshot.getUuid(), 60d));
session.commit();
@@ -122,7 +122,7 @@ public class ReportComputeMeasureVariationsStepTest {
@Test
public void set_variation() {
// Project
- SnapshotDto period1Snapshot = newSnapshotForProject(PROJECT_DTO);
+ SnapshotDto period1Snapshot = newAnalysis(PROJECT_DTO);
dbClient.snapshotDao().insert(session, period1Snapshot);
dbClient.measureDao().insert(session, newMeasureDto(ISSUES_METRIC.getId(), PROJECT_DTO.uuid(), period1Snapshot.getUuid(), 60d));
@@ -150,7 +150,7 @@ public class ReportComputeMeasureVariationsStepTest {
@Test
public void set_zero_variation_when_no_change() {
// Project
- SnapshotDto period1Snapshot = newSnapshotForProject(PROJECT_DTO);
+ SnapshotDto period1Snapshot = newAnalysis(PROJECT_DTO);
dbClient.snapshotDao().insert(session, period1Snapshot);
dbClient.measureDao().insert(session, newMeasureDto(ISSUES_METRIC.getId(), PROJECT_DTO.uuid(), period1Snapshot.getUuid(), 60d));
@@ -178,8 +178,8 @@ public class ReportComputeMeasureVariationsStepTest {
@Test
public void set_variation_to_raw_value_on_new_component() throws Exception {
// Project
- SnapshotDto past1ProjectSnapshot = newSnapshotForProject(PROJECT_DTO).setCreatedAt(1000_000_000L);
- SnapshotDto currentProjectSnapshot = newSnapshotForProject(PROJECT_DTO).setCreatedAt(2000_000_000L);
+ SnapshotDto past1ProjectSnapshot = newAnalysis(PROJECT_DTO).setCreatedAt(1000_000_000L);
+ SnapshotDto currentProjectSnapshot = newAnalysis(PROJECT_DTO).setCreatedAt(2000_000_000L);
dbClient.snapshotDao().insert(session, past1ProjectSnapshot);
dbClient.snapshotDao().insert(session, currentProjectSnapshot);
dbClient.measureDao().insert(session, newMeasureDto(ISSUES_METRIC.getId(), PROJECT_DTO.uuid(), past1ProjectSnapshot.getUuid(), 60d));
@@ -205,11 +205,11 @@ public class ReportComputeMeasureVariationsStepTest {
@Test
public void set_variations_on_all_periods() {
- SnapshotDto period1ProjectSnapshot = newSnapshotForProject(PROJECT_DTO).setLast(false);
- SnapshotDto period2ProjectSnapshot = newSnapshotForProject(PROJECT_DTO).setLast(false);
- SnapshotDto period3ProjectSnapshot = newSnapshotForProject(PROJECT_DTO).setLast(false);
- SnapshotDto period4ProjectSnapshot = newSnapshotForProject(PROJECT_DTO).setLast(false);
- SnapshotDto period5ProjectSnapshot = newSnapshotForProject(PROJECT_DTO).setLast(false);
+ SnapshotDto period1ProjectSnapshot = newAnalysis(PROJECT_DTO).setLast(false);
+ SnapshotDto period2ProjectSnapshot = newAnalysis(PROJECT_DTO).setLast(false);
+ SnapshotDto period3ProjectSnapshot = newAnalysis(PROJECT_DTO).setLast(false);
+ SnapshotDto period4ProjectSnapshot = newAnalysis(PROJECT_DTO).setLast(false);
+ SnapshotDto period5ProjectSnapshot = newAnalysis(PROJECT_DTO).setLast(false);
dbClient.snapshotDao().insert(session, period1ProjectSnapshot, period2ProjectSnapshot, period3ProjectSnapshot, period4ProjectSnapshot, period5ProjectSnapshot);
dbClient.measureDao().insert(session,
@@ -245,7 +245,7 @@ public class ReportComputeMeasureVariationsStepTest {
@Test
public void set_variation_on_all_numeric_metrics() {
- SnapshotDto period1ProjectSnapshot = newSnapshotForProject(PROJECT_DTO);
+ SnapshotDto period1ProjectSnapshot = newAnalysis(PROJECT_DTO);
dbClient.snapshotDao().insert(session, period1ProjectSnapshot);
dbClient.measureDao().insert(session,
newMeasureDto(ISSUES_METRIC.getId(), PROJECT_DTO.uuid(), period1ProjectSnapshot.getUuid(), 60d),
@@ -275,7 +275,7 @@ public class ReportComputeMeasureVariationsStepTest {
@Test
public void do_not_set_variations_on_numeric_metric_for_developer() {
- SnapshotDto period1ProjectSnapshot = newSnapshotForProject(PROJECT_DTO);
+ SnapshotDto period1ProjectSnapshot = newAnalysis(PROJECT_DTO);
dbClient.snapshotDao().insert(session, period1ProjectSnapshot);
dbClient.measureDao().insert(session,
newMeasureDto(ISSUES_METRIC.getId(), PROJECT_DTO.uuid(), period1ProjectSnapshot.getUuid(), 60d));
@@ -297,7 +297,7 @@ public class ReportComputeMeasureVariationsStepTest {
@Test
public void does_not_update_existing_variations() throws Exception {
- SnapshotDto period1ProjectSnapshot = newSnapshotForProject(PROJECT_DTO);
+ SnapshotDto period1ProjectSnapshot = newAnalysis(PROJECT_DTO);
dbClient.snapshotDao().insert(session, period1ProjectSnapshot);
dbClient.measureDao().insert(session, newMeasureDto(NEW_DEBT.getId(), PROJECT_DTO.uuid(), period1ProjectSnapshot.getUuid(), 60d));
session.commit();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportPersistSnapshotsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportPersistAnalysisStepTest.java
index c23e33706ee..ca4dd935da1 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportPersistSnapshotsStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportPersistAnalysisStepTest.java
@@ -47,7 +47,7 @@ import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_DAT
import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS;
-public class ReportPersistSnapshotsStepTest extends BaseStepTest {
+public class ReportPersistAnalysisStepTest extends BaseStepTest {
private static final String PROJECT_KEY = "PROJECT_KEY";
private static final String ANALYSIS_UUID = "U1";
@@ -71,7 +71,7 @@ public class ReportPersistSnapshotsStepTest extends BaseStepTest {
long now;
- PersistSnapshotsStep underTest;
+ PersistAnalysisStep underTest;
@Before
public void setup() {
@@ -84,7 +84,7 @@ public class ReportPersistSnapshotsStepTest extends BaseStepTest {
when(system2.now()).thenReturn(now);
- underTest = new PersistSnapshotsStep(system2, dbClient, treeRootHolder, analysisMetadataHolder, periodsHolder);
+ underTest = new PersistAnalysisStep(system2, dbClient, treeRootHolder, analysisMetadataHolder, periodsHolder);
// initialize PeriodHolder to empty by default
periodsHolder.setPeriods();
@@ -96,7 +96,7 @@ public class ReportPersistSnapshotsStepTest extends BaseStepTest {
}
@Test
- public void persist_snapshot() {
+ public void persist_analysis() {
ComponentDto projectDto = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(dbTester.getSession(), projectDto);
ComponentDto moduleDto = ComponentTesting.newModuleDto("BCDE", projectDto).setKey("MODULE_KEY").setName("Module");
@@ -139,7 +139,7 @@ public class ReportPersistSnapshotsStepTest extends BaseStepTest {
public void persist_snapshots_with_periods() {
ComponentDto projectDto = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(dbTester.getSession(), projectDto);
- SnapshotDto snapshotDto = SnapshotTesting.newSnapshotForProject(projectDto).setCreatedAt(DateUtils.parseDateQuietly("2015-01-01").getTime());
+ SnapshotDto snapshotDto = SnapshotTesting.newAnalysis(projectDto).setCreatedAt(DateUtils.parseDateQuietly("2015-01-01").getTime());
dbClient.snapshotDao().insert(dbTester.getSession(), snapshotDto);
dbTester.getSession().commit();
periodsHolder.setPeriods(new Period(1, TIMEMACHINE_MODE_DATE, "2015-01-01", analysisDate, "u1"));
@@ -162,7 +162,7 @@ public class ReportPersistSnapshotsStepTest extends BaseStepTest {
ComponentDto projectDto = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(dbTester.getSession(), projectDto);
- SnapshotDto projectSnapshot = SnapshotTesting.newSnapshotForProject(projectDto);
+ SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(projectDto);
dbClient.snapshotDao().insert(dbTester.getSession(), projectSnapshot);
ComponentDto moduleDto = ComponentTesting.newModuleDto("BCDE", projectDto).setKey("MODULE_KEY").setName("Module");
@@ -197,7 +197,7 @@ public class ReportPersistSnapshotsStepTest extends BaseStepTest {
public void set_no_period_on_snapshots_when_no_period() {
ComponentDto projectDto = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(dbTester.getSession(), projectDto);
- SnapshotDto snapshotDto = SnapshotTesting.newSnapshotForProject(projectDto);
+ SnapshotDto snapshotDto = SnapshotTesting.newAnalysis(projectDto);
dbClient.snapshotDao().insert(dbTester.getSession(), snapshotDto);
dbTester.getSession().commit();
@@ -214,7 +214,7 @@ public class ReportPersistSnapshotsStepTest extends BaseStepTest {
}
private SnapshotDto getUnprocessedSnapshot(String componentUuid) {
- List<SnapshotDto> projectSnapshots = dbClient.snapshotDao().selectSnapshotsByQuery(dbTester.getSession(),
+ List<SnapshotDto> projectSnapshots = dbClient.snapshotDao().selectAnalysesByQuery(dbTester.getSession(),
new SnapshotQuery().setComponentUuid(componentUuid).setIsLast(false).setStatus(SnapshotDto.STATUS_UNPROCESSED));
assertThat(projectSnapshots).hasSize(1);
return projectSnapshots.get(0);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ValidateProjectStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ValidateProjectStepTest.java
index e95898e84a7..9ca9a3e7f87 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ValidateProjectStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ValidateProjectStepTest.java
@@ -255,7 +255,7 @@ public class ValidateProjectStepTest {
ComponentDto project = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY);
dbClient.componentDao().insert(dbTester.getSession(), project);
- dbClient.snapshotDao().insert(dbTester.getSession(), SnapshotTesting.newSnapshotForProject(project).setCreatedAt(1420088400000L)); // 2015-01-01
+ dbClient.snapshotDao().insert(dbTester.getSession(), SnapshotTesting.newAnalysis(project).setCreatedAt(1420088400000L)); // 2015-01-01
dbTester.getSession().commit();
treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).build());
@@ -276,7 +276,7 @@ public class ValidateProjectStepTest {
ComponentDto project = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY);
dbClient.componentDao().insert(dbTester.getSession(), project);
- dbClient.snapshotDao().insert(dbTester.getSession(), SnapshotTesting.newSnapshotForProject(project).setCreatedAt(1433131200000L)); // 2015-06-01
+ dbClient.snapshotDao().insert(dbTester.getSession(), SnapshotTesting.newAnalysis(project).setCreatedAt(1433131200000L)); // 2015-06-01
dbTester.getSession().commit();
treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).build());
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsComputeMeasureVariationsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsComputeMeasureVariationsStepTest.java
index db7899fcabf..584edf8e72d 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsComputeMeasureVariationsStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsComputeMeasureVariationsStepTest.java
@@ -43,7 +43,7 @@ import org.sonar.server.computation.period.Period;
import org.sonar.server.computation.period.PeriodsHolderRule;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.SnapshotTesting.newSnapshotForProject;
+import static org.sonar.db.component.SnapshotTesting.newAnalysis;
public class ViewsComputeMeasureVariationsStepTest {
@@ -92,7 +92,7 @@ public class ViewsComputeMeasureVariationsStepTest {
@Test
public void do_nothing_when_no_raw_measure() {
- SnapshotDto period1ViewSnapshot = newSnapshotForProject(VIEW_DTO);
+ SnapshotDto period1ViewSnapshot = newAnalysis(VIEW_DTO);
dbClient.snapshotDao().insert(session, period1ViewSnapshot);
dbClient.measureDao().insert(session, newMeasureDto(ISSUES_METRIC.getId(), VIEW_DTO.uuid(), period1ViewSnapshot.getUuid(), 60d));
session.commit();
@@ -120,7 +120,7 @@ public class ViewsComputeMeasureVariationsStepTest {
@Test
public void set_variation() {
// View
- SnapshotDto period1Snapshot = newSnapshotForProject(VIEW_DTO);
+ SnapshotDto period1Snapshot = newAnalysis(VIEW_DTO);
dbClient.snapshotDao().insert(session, period1Snapshot);
dbClient.measureDao().insert(session, newMeasureDto(ISSUES_METRIC.getId(), VIEW_DTO.uuid(), period1Snapshot.getUuid(), 60d));
@@ -147,11 +147,11 @@ public class ViewsComputeMeasureVariationsStepTest {
@Test
public void set_variations_on_all_periods() {
- SnapshotDto period1ViewSnapshot = newSnapshotForProject(VIEW_DTO).setLast(false);
- SnapshotDto period2ViewSnapshot = newSnapshotForProject(VIEW_DTO).setLast(false);
- SnapshotDto period3ViewSnapshot = newSnapshotForProject(VIEW_DTO).setLast(false);
- SnapshotDto period4ViewSnapshot = newSnapshotForProject(VIEW_DTO).setLast(false);
- SnapshotDto period5ViewSnapshot = newSnapshotForProject(VIEW_DTO).setLast(false);
+ SnapshotDto period1ViewSnapshot = newAnalysis(VIEW_DTO).setLast(false);
+ SnapshotDto period2ViewSnapshot = newAnalysis(VIEW_DTO).setLast(false);
+ SnapshotDto period3ViewSnapshot = newAnalysis(VIEW_DTO).setLast(false);
+ SnapshotDto period4ViewSnapshot = newAnalysis(VIEW_DTO).setLast(false);
+ SnapshotDto period5ViewSnapshot = newAnalysis(VIEW_DTO).setLast(false);
dbClient.snapshotDao().insert(session, period1ViewSnapshot, period2ViewSnapshot, period3ViewSnapshot, period4ViewSnapshot, period5ViewSnapshot);
dbClient.measureDao().insert(session,
@@ -187,7 +187,7 @@ public class ViewsComputeMeasureVariationsStepTest {
@Test
public void set_variation_on_all_numeric_metrics() {
- SnapshotDto period1ViewSnapshot = newSnapshotForProject(VIEW_DTO);
+ SnapshotDto period1ViewSnapshot = newAnalysis(VIEW_DTO);
dbClient.snapshotDao().insert(session, period1ViewSnapshot);
dbClient.measureDao().insert(session,
newMeasureDto(ISSUES_METRIC.getId(), VIEW_DTO.uuid(), period1ViewSnapshot.getUuid(), 60d),
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsPersistSnapshotsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsPersistAnalysisStepTest.java
index cce2316e6b2..638b8f1aeda 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsPersistSnapshotsStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsPersistAnalysisStepTest.java
@@ -33,7 +33,6 @@ import org.sonar.db.component.SnapshotQuery;
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.MapBasedDbIdsRepository;
import org.sonar.server.computation.component.ViewsComponent;
import org.sonar.server.computation.period.Period;
import org.sonar.server.computation.period.PeriodsHolderRule;
@@ -49,9 +48,8 @@ import static org.sonar.db.component.ComponentTesting.newView;
import static org.sonar.server.computation.component.Component.Type.PROJECT_VIEW;
import static org.sonar.server.computation.component.Component.Type.SUBVIEW;
import static org.sonar.server.computation.component.Component.Type.VIEW;
-import static org.sonar.server.computation.component.ComponentFunctions.toKey;
-public class ViewsPersistSnapshotsStepTest extends BaseStepTest {
+public class ViewsPersistAnalysisStepTest extends BaseStepTest {
private static final String ANALYSIS_UUID = "U1";
@@ -69,15 +67,13 @@ public class ViewsPersistSnapshotsStepTest extends BaseStepTest {
System2 system2 = mock(System2.class);
- MapBasedDbIdsRepository<String> dbIdsRepository = new MapBasedDbIdsRepository<>(toKey());
-
DbClient dbClient = dbTester.getDbClient();
long analysisDate;
long now;
- PersistSnapshotsStep underTest;
+ PersistAnalysisStep underTest;
@Before
public void setup() {
@@ -89,7 +85,7 @@ public class ViewsPersistSnapshotsStepTest extends BaseStepTest {
when(system2.now()).thenReturn(now);
- underTest = new PersistSnapshotsStep(system2, dbClient, treeRootHolder, analysisMetadataHolder, periodsHolder);
+ underTest = new PersistAnalysisStep(system2, dbClient, treeRootHolder, analysisMetadataHolder, periodsHolder);
// initialize PeriodHolder to empty by default
periodsHolder.setPeriods();
@@ -101,7 +97,7 @@ public class ViewsPersistSnapshotsStepTest extends BaseStepTest {
}
@Test
- public void persist_snapshot() {
+ public void persist_analysis() {
ComponentDto viewDto = save(newView("UUID_VIEW").setKey("KEY_VIEW"));
ComponentDto subViewDto = save(newSubView(viewDto, "UUID_SUBVIEW", "KEY_SUBVIEW"));
ComponentDto projectDto = save(newProjectDto("proj"));
@@ -152,7 +148,7 @@ public class ViewsPersistSnapshotsStepTest extends BaseStepTest {
}
private SnapshotDto getUnprocessedSnapshot(String componentUuid) {
- List<SnapshotDto> projectSnapshots = dbClient.snapshotDao().selectSnapshotsByQuery(dbTester.getSession(),
+ List<SnapshotDto> projectSnapshots = dbClient.snapshotDao().selectAnalysesByQuery(dbTester.getSession(),
new SnapshotQuery().setComponentUuid(componentUuid).setIsLast(false).setStatus(SnapshotDto.STATUS_UNPROCESSED));
assertThat(projectSnapshots).hasSize(1);
return projectSnapshots.get(0);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueBulkChangeServiceMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueBulkChangeServiceMediumTest.java
index 7b465817cf3..2ddc44798c4 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueBulkChangeServiceMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueBulkChangeServiceMediumTest.java
@@ -87,12 +87,11 @@ public class IssueBulkChangeServiceMediumTest {
project = ComponentTesting.newProjectDto().setKey("MyProject");
tester.get(ComponentDao.class).insert(session, project);
- SnapshotDto projectSnapshot = SnapshotTesting.newSnapshotForProject(project);
+ SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(project);
tester.get(SnapshotDao.class).insert(session, projectSnapshot);
file = ComponentTesting.newFileDto(project).setKey("MyComponent");
tester.get(ComponentDao.class).insert(session, file);
- //tester.get(SnapshotDao.class).insert(session, SnapshotTesting.createForComponent(file, projectSnapshot));
// project can be seen by anyone
session.commit();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueCommentServiceMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueCommentServiceMediumTest.java
index 9a267406354..f98aed6c7a6 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueCommentServiceMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueCommentServiceMediumTest.java
@@ -81,12 +81,11 @@ public class IssueCommentServiceMediumTest {
project = ComponentTesting.newProjectDto();
tester.get(ComponentDao.class).insert(session, project);
- SnapshotDto projectSnapshot = SnapshotTesting.newSnapshotForProject(project);
+ SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(project);
tester.get(SnapshotDao.class).insert(session, projectSnapshot);
file = ComponentTesting.newFileDto(project);
tester.get(ComponentDao.class).insert(session, file);
- //tester.get(SnapshotDao.class).insert(session, SnapshotTesting.createForComponent(file, projectSnapshot));
// project can be seen by anyone
session.commit();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java
index b55e127549b..5d92cce89c5 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java
@@ -37,7 +37,6 @@ import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentTesting;
-import org.sonar.db.component.SnapshotDto;
import org.sonar.db.issue.IssueDto;
import org.sonar.db.rule.RuleDao;
import org.sonar.db.rule.RuleDto;
@@ -66,7 +65,7 @@ import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
import static org.sonar.core.util.Uuids.UUID_EXAMPLE_02;
import static org.sonar.db.component.ComponentTesting.newFileDto;
import static org.sonar.db.component.ComponentTesting.newModuleDto;
-import static org.sonar.db.component.SnapshotTesting.newSnapshotForProject;
+import static org.sonar.db.component.SnapshotTesting.newAnalysis;
public class SearchActionComponentsMediumTest {
@@ -190,10 +189,9 @@ public class SearchActionComponentsMediumTest {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("P1").setKey("PK1"));
setDefaultProjectPermission(project);
ComponentDto file = insertComponent(newFileDto(project, "F1").setKey("FK1"));
- SnapshotDto projectSnapshot = db.snapshotDao().insert(session,
- newSnapshotForProject(project)
+ db.snapshotDao().insert(session,
+ newAnalysis(project)
.setPeriodDate(1, parseDateTime("2015-09-03T00:00:00+0100").getTime()));
- //db.snapshotDao().insert(session, SnapshotTesting.createForComponent(file, projectSnapshot));
RuleDto rule = newRule();
IssueDto issueAfterLeak = IssueTesting.newDto(rule, file, project)
.setKee(UUID_EXAMPLE_01)
@@ -220,11 +218,8 @@ public class SearchActionComponentsMediumTest {
setDefaultProjectPermission(project);
ComponentDto module = insertComponent(newModuleDto(project));
ComponentDto file = insertComponent(newFileDto(module, "F1").setKey("FK1"));
- SnapshotDto projectSnapshot = db.snapshotDao().insert(session,
- newSnapshotForProject(project)
- .setPeriodDate(1, parseDateTime("2015-09-03T00:00:00+0100").getTime()));
-// SnapshotDto moduleSnapshot = db.snapshotDao().insert(session, SnapshotTesting.createForComponent(module, projectSnapshot));
-// db.snapshotDao().insert(session, SnapshotTesting.createForComponent(file, moduleSnapshot));
+ db.snapshotDao().insert(session,
+ newAnalysis(project).setPeriodDate(1, parseDateTime("2015-09-03T00:00:00+0100").getTime()));
RuleDto rule = newRule();
IssueDto issueAfterLeak = IssueTesting.newDto(rule, file, project)
.setKee(UUID_EXAMPLE_01)
diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java
index 8ba7b01c841..8dd8a5e719a 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java
@@ -189,7 +189,7 @@ public class SearchActionTest {
dbClient.customMeasureDao().insert(dbSession, newCustomMeasure(1, metric)
.setCreatedAt(yesterday)
.setUpdatedAt(yesterday));
- dbClient.snapshotDao().insert(dbSession, SnapshotTesting.newSnapshotForProject(defaultProject));
+ dbClient.snapshotDao().insert(dbSession, SnapshotTesting.newAnalysis(defaultProject));
dbSession.commit();
String response = newRequest()
diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java
index 25a81a97ee5..0e2cc1dfa81 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java
@@ -311,7 +311,7 @@ public class ComponentActionTest {
private void insertJsonExampleData() {
ComponentDto project = newProjectDto(PROJECT_UUID);
- SnapshotDto projectSnapshot = SnapshotTesting.newSnapshotForProject(project)
+ SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(project)
.setPeriodDate(1, parseDateTime("2016-01-11T10:49:50+0100").getTime())
.setPeriodMode(1, "previous_version")
.setPeriodParam(1, "1.0-SNAPSHOT")
diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java
index d4a6633ca0e..158449e9487 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java
@@ -62,7 +62,7 @@ import static org.sonar.db.component.ComponentTesting.newDeveloper;
import static org.sonar.db.component.ComponentTesting.newDirectory;
import static org.sonar.db.component.ComponentTesting.newFileDto;
import static org.sonar.db.component.ComponentTesting.newProjectDto;
-import static org.sonar.db.component.SnapshotTesting.newSnapshotForProject;
+import static org.sonar.db.component.SnapshotTesting.newAnalysis;
import static org.sonar.db.measure.MeasureTesting.newMeasureDto;
import static org.sonar.db.metric.MetricTesting.newMetricDto;
import static org.sonar.server.measure.ws.ComponentTreeAction.CHILDREN_STRATEGY;
@@ -143,7 +143,7 @@ public class ComponentTreeActionTest {
ComponentDto projectDto = newProjectDto("project-uuid");
componentDb.insertComponent(projectDto);
SnapshotDto projectSnapshot = dbClient.snapshotDao().insert(dbSession,
- newSnapshotForProject(projectDto)
+ newAnalysis(projectDto)
.setPeriodDate(1, System.currentTimeMillis())
.setPeriodMode(1, "last_version")
.setPeriodDate(3, System.currentTimeMillis())
@@ -641,7 +641,7 @@ public class ComponentTreeActionTest {
.setName("My Project")
.setQualifier(Qualifiers.PROJECT);
componentDb.insertComponent(project);
- SnapshotDto projectSnapshot = dbClient.snapshotDao().insert(dbSession, newSnapshotForProject(project)
+ SnapshotDto projectSnapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project)
.setPeriodDate(1, parseDateTime("2016-01-11T10:49:50+0100").getTime())
.setPeriodMode(1, "previous_version")
.setPeriodParam(1, "1.0-SNAPSHOT")
diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java
index ed00c19b01f..9be6fa38854 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java
@@ -206,7 +206,7 @@ public class BulkDeleteActionTest {
dbClient.ruleDao().insert(dbSession, rule);
IssueDto issue = IssueTesting.newDto(rule, project, project).setKee("issue-key-" + suffix);
dbClient.componentDao().insert(dbSession, project);
- SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, SnapshotTesting.newSnapshotForProject(project));
+ SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, SnapshotTesting.newAnalysis(project));
dbClient.issueDao().insert(dbSession, issue);
dbSession.commit();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java
index e7708782b39..5f2485f3b2a 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java
@@ -225,7 +225,7 @@ public class DeleteActionTest {
dbClient.ruleDao().insert(dbSession, rule);
IssueDto issue = IssueTesting.newDto(rule, project, project).setKee("issue-key-" + suffix);
dbClient.componentDao().insert(dbSession, project);
- SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, SnapshotTesting.newSnapshotForProject(project));
+ SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, SnapshotTesting.newAnalysis(project));
dbClient.issueDao().insert(dbSession, issue);
dbSession.commit();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/GhostsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/GhostsActionTest.java
index 85e680a0708..e9afb14e8ca 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/GhostsActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/GhostsActionTest.java
@@ -131,14 +131,14 @@ public class GhostsActionTest {
.setName("HBase")
.setCreatedAt(DateUtils.parseDateTime("2015-03-04T23:03:44+0100"));
dbClient.componentDao().insert(db.getSession(), hBaseProject);
- dbClient.snapshotDao().insert(db.getSession(), SnapshotTesting.newSnapshotForProject(hBaseProject)
+ dbClient.snapshotDao().insert(db.getSession(), SnapshotTesting.newAnalysis(hBaseProject)
.setStatus(SnapshotDto.STATUS_UNPROCESSED));
ComponentDto roslynProject = ComponentTesting.newProjectDto("c526ef20-131b-4486-9357-063fa64b5079")
.setKey("com.microsoft.roslyn:roslyn")
.setName("Roslyn")
.setCreatedAt(DateUtils.parseDateTime("2013-03-04T23:03:44+0100"));
dbClient.componentDao().insert(db.getSession(), roslynProject);
- dbClient.snapshotDao().insert(db.getSession(), SnapshotTesting.newSnapshotForProject(roslynProject)
+ dbClient.snapshotDao().insert(db.getSession(), SnapshotTesting.newAnalysis(roslynProject)
.setStatus(SnapshotDto.STATUS_UNPROCESSED));
db.getSession().commit();
@@ -160,7 +160,7 @@ public class GhostsActionTest {
.setName("ghost-name-" + id)
.setKey("ghost-key-" + id);
dbClient.componentDao().insert(db.getSession(), project);
- SnapshotDto snapshot = SnapshotTesting.newSnapshotForProject(project)
+ SnapshotDto snapshot = SnapshotTesting.newAnalysis(project)
.setStatus(SnapshotDto.STATUS_UNPROCESSED);
dbClient.snapshotDao().insert(db.getSession(), snapshot);
db.getSession().commit();
@@ -172,7 +172,7 @@ public class GhostsActionTest {
.setName("analyzed-name-" + id)
.setKey("analyzed-key-" + id);
dbClient.componentDao().insert(db.getSession(), project);
- SnapshotDto snapshot = SnapshotTesting.newSnapshotForProject(project);
+ SnapshotDto snapshot = SnapshotTesting.newAnalysis(project);
dbClient.snapshotDao().insert(db.getSession(), snapshot);
db.getSession().commit();
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/ProvisionedActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/ProvisionedActionTest.java
index 0b352d5c898..21224eaab9f 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/ProvisionedActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/ProvisionedActionTest.java
@@ -70,7 +70,7 @@ public class ProvisionedActionTest {
userSessionRule.setGlobalPermissions(GlobalPermissions.PROVISIONING);
ComponentDto analyzedProject = ComponentTesting.newProjectDto("analyzed-uuid-1");
componentDao.insert(db.getSession(), newProvisionedProject("1"), newProvisionedProject("2"), analyzedProject);
- SnapshotDto snapshot = SnapshotTesting.newSnapshotForProject(analyzedProject);
+ SnapshotDto snapshot = SnapshotTesting.newAnalysis(analyzedProject);
dbClient.snapshotDao().insert(db.getSession(), snapshot);
db.getSession().commit();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchMyProjectsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchMyProjectsActionTest.java
index eb040d2e1d5..a57147b7ba7 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchMyProjectsActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchMyProjectsActionTest.java
@@ -62,7 +62,7 @@ import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY;
import static org.sonar.db.component.ComponentTesting.newDeveloper;
import static org.sonar.db.component.ComponentTesting.newProjectDto;
import static org.sonar.db.component.ComponentTesting.newView;
-import static org.sonar.db.component.SnapshotTesting.newSnapshotForProject;
+import static org.sonar.db.component.SnapshotTesting.newAnalysis;
import static org.sonar.db.measure.MeasureTesting.newMeasureDto;
import static org.sonar.db.metric.MetricTesting.newMetricDto;
import static org.sonar.db.user.GroupTesting.newGroupDto;
@@ -109,8 +109,8 @@ public class SearchMyProjectsActionTest {
new ComponentLinkDto().setComponentUuid(jdk7.uuid()).setHref("http://download.java.net/openjdk/jdk8/").setType(ComponentLinkDto.TYPE_SOURCES).setName("Sources"));
long oneTime = DateUtils.parseDateTime("2016-06-10T13:17:53+0000").getTime();
long anotherTime = DateUtils.parseDateTime("2016-06-11T14:25:53+0000").getTime();
- SnapshotDto jdk7Snapshot = dbClient.snapshotDao().insert(dbSession, newSnapshotForProject(jdk7).setCreatedAt(oneTime));
- SnapshotDto cLangSnapshot = dbClient.snapshotDao().insert(dbSession, newSnapshotForProject(cLang).setCreatedAt(anotherTime));
+ SnapshotDto jdk7Snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(jdk7).setCreatedAt(oneTime));
+ SnapshotDto cLangSnapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(cLang).setCreatedAt(anotherTime));
dbClient.measureDao().insert(dbSession, newMeasureDto(alertStatusMetric, jdk7, jdk7Snapshot).setData(Level.ERROR.name()));
dbClient.measureDao().insert(dbSession, newMeasureDto(alertStatusMetric, cLang, cLangSnapshot).setData(Level.OK.name()));
insertUserPermission(UserRole.ADMIN, user.getId(), jdk7.getId());
@@ -242,7 +242,7 @@ public class SearchMyProjectsActionTest {
ComponentDto sonarqube = componentDb.insertComponent(newProjectDto().setName("ONE_PROJECT_NAME"));
ComponentDto jdk8 = componentDb.insertComponent(newProjectDto().setName("TWO_PROJECT_NAME"));
ComponentDto ruby = componentDb.insertComponent(newProjectDto().setName("ANOTHER_42"));
- dbClient.snapshotDao().insert(dbSession, newSnapshotForProject(sonarqube), newSnapshotForProject(jdk8), newSnapshotForProject(ruby));
+ dbClient.snapshotDao().insert(dbSession, newAnalysis(sonarqube), newAnalysis(jdk8), newAnalysis(ruby));
componentDb.indexAllComponents();
db.commit();
@@ -262,7 +262,7 @@ public class SearchMyProjectsActionTest {
public void search_my_projects_by_exact_match_on_key() {
ComponentDto sonarqube = componentDb.insertComponent(newProjectDto().setKey("MY_PROJECT_KEY"));
ComponentDto ruby = componentDb.insertComponent(newProjectDto().setKey("MY_PROJECT_KEY_OR_ELSE"));
- dbClient.snapshotDao().insert(dbSession, newSnapshotForProject(sonarqube), newSnapshotForProject(ruby));
+ dbClient.snapshotDao().insert(dbSession, newAnalysis(sonarqube), newAnalysis(ruby));
componentDb.indexAllComponents();
db.commit();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java
index 81949dcb3e7..7a8e50c9574 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java
@@ -50,7 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.core.permission.GlobalPermissions.PROVISIONING;
import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN;
import static org.sonar.db.component.ComponentTesting.newProjectDto;
-import static org.sonar.db.component.SnapshotTesting.newSnapshotForProject;
+import static org.sonar.db.component.SnapshotTesting.newAnalysis;
import static org.sonar.db.measure.MeasureTesting.newMeasureDto;
import static org.sonar.db.metric.MetricTesting.newMetricDto;
import static org.sonar.test.JsonAssert.assertJson;
@@ -86,7 +86,7 @@ public class ProjectStatusActionTest {
userSession.setGlobalPermissions(SYSTEM_ADMIN);
ComponentDto project = componentDb.insertComponent(newProjectDto("project-uuid"));
- SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newSnapshotForProject(project)
+ SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project)
.setPeriodMode(1, "last_period")
.setPeriodDate(1, 956789123456L)
.setPeriodMode(2, "last_version")
@@ -115,7 +115,7 @@ public class ProjectStatusActionTest {
userSession.setGlobalPermissions(SYSTEM_ADMIN);
ComponentDto project = componentDb.insertComponent(newProjectDto("project-uuid"));
- SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newSnapshotForProject(project)
+ SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project)
.setPeriodMode(1, "last_period")
.setPeriodDate(1, 956789123456L)
.setPeriodMode(2, "last_version")
@@ -144,7 +144,7 @@ public class ProjectStatusActionTest {
userSession.setGlobalPermissions(SYSTEM_ADMIN);
ComponentDto project = componentDb.insertComponent(newProjectDto("project-uuid").setKey("project-key"));
- SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newSnapshotForProject(project)
+ SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project)
.setPeriodMode(1, "last_period")
.setPeriodDate(1, 956789123456L)
.setPeriodMode(2, "last_version")
@@ -173,7 +173,7 @@ public class ProjectStatusActionTest {
userSession.setGlobalPermissions(SYSTEM_ADMIN);
ComponentDto project = componentDb.insertComponent(newProjectDto("project-uuid"));
- SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newSnapshotForProject(project));
+ SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project));
dbSession.commit();
ProjectStatusWsResponse result = call(snapshot.getUuid());
@@ -198,7 +198,7 @@ public class ProjectStatusActionTest {
userSession.addProjectUuidPermissions(UserRole.ADMIN, "project-uuid");
ComponentDto project = componentDb.insertComponent(newProjectDto("project-uuid"));
- SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newSnapshotForProject(project));
+ SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project));
dbSession.commit();
call(snapshot.getUuid());
@@ -209,7 +209,7 @@ public class ProjectStatusActionTest {
userSession.addProjectUuidPermissions(UserRole.USER, "project-uuid");
ComponentDto project = componentDb.insertComponent(newProjectDto("project-uuid"));
- SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newSnapshotForProject(project));
+ SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project));
dbSession.commit();
call(snapshot.getUuid());
@@ -230,7 +230,7 @@ public class ProjectStatusActionTest {
userSession.setGlobalPermissions(PROVISIONING);
ComponentDto project = componentDb.insertComponent(newProjectDto("project-uuid"));
- SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newSnapshotForProject(project));
+ SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project));
dbSession.commit();
expectedException.expect(ForbiddenException.class);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentNavigationActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentNavigationActionTest.java
index 756beac9096..f7c5ecfcf6c 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentNavigationActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentNavigationActionTest.java
@@ -196,7 +196,7 @@ public class ComponentNavigationActionTest {
ComponentDto project = ComponentTesting.newProjectDto("abcd")
.setKey("polop").setName("Polop").setLanguage("xoo");
dbClient.componentDao().insert(dbTester.getSession(), project);
- dbClient.snapshotDao().insert(dbTester.getSession(), SnapshotTesting.newSnapshotForProject(project));
+ dbClient.snapshotDao().insert(dbTester.getSession(), SnapshotTesting.newAnalysis(project));
dbTester.getSession().commit();
userSessionRule.addProjectUuidPermissions(UserRole.USER, "abcd");
@@ -210,7 +210,7 @@ public class ComponentNavigationActionTest {
ComponentDto project = ComponentTesting.newProjectDto("abcd")
.setKey("polop").setName("Polop").setLanguage("xoo");
dbClient.componentDao().insert(dbTester.getSession(), project);
- dbClient.snapshotDao().insert(dbTester.getSession(), SnapshotTesting.newSnapshotForProject(project));
+ dbClient.snapshotDao().insert(dbTester.getSession(), SnapshotTesting.newAnalysis(project));
dbTester.getSession().commit();
userSessionRule
@@ -351,25 +351,17 @@ public class ComponentNavigationActionTest {
ComponentDto module = ComponentTesting.newModuleDto("bcde", project)
.setKey("palap").setName("Palap");
ComponentDto directory = ComponentTesting.newDirectory(module, "src/main/xoo");
- ComponentDto file = ComponentTesting.newFileDto(module, "cdef").setName("Source.xoo")
+ ComponentDto file = ComponentTesting.newFileDto(directory, "cdef").setName("Source.xoo")
.setKey("palap:src/main/xoo/Source.xoo")
.setPath(directory.path());
dbClient.componentDao().insert(dbTester.getSession(), project, module, directory, file);
-// SnapshotDto projectSnapshot = SnapshotTesting.newSnapshotForProject(project);
-// dbClient.snapshotDao().insert(dbTester.getSession(), projectSnapshot);
-// SnapshotDto moduleSnapshot = SnapshotTesting.createForComponent(module, projectSnapshot);
-// dbClient.snapshotDao().insert(dbTester.getSession(), moduleSnapshot);
-// SnapshotDto directorySnapshot = SnapshotTesting.createForComponent(directory, moduleSnapshot);
-// dbClient.snapshotDao().insert(dbTester.getSession(), directorySnapshot);
-// dbClient.snapshotDao().insert(dbTester.getSession(), SnapshotTesting.createForComponent(file, directorySnapshot));
-//
-// dbTester.getSession().commit();
-//
-// userSessionRule.addProjectUuidPermissions(UserRole.USER, "abcd");
-//
-// WsTester wsTester = newdWsTester();
-// wsTester.newGetRequest("api/navigation", "component").setParam("componentKey", "palap:src/main/xoo/Source.xoo").execute().assertJson(getClass(), "breadcrumbs.json");
+ dbTester.getSession().commit();
+
+ userSessionRule.addProjectUuidPermissions(UserRole.USER, "abcd");
+
+ WsTester wsTester = newdWsTester();
+ wsTester.newGetRequest("api/navigation", "component").setParam("componentKey", "palap:src/main/xoo/Source.xoo").execute().assertJson(getClass(), "breadcrumbs.json");
}
private WsTester newdWsTester(View... views) {
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/ignore_quality_model_measures.xml b/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/ignore_quality_model_measures.xml
index 4242edcfbc8..ef5898de571 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/ignore_quality_model_measures.xml
+++ b/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/ignore_quality_model_measures.xml
@@ -72,22 +72,4 @@
description="[null]"
person_id="[null]"/>
- <!-- details of the measure by model characteristic -->
- <!--project_measures id="1002" metric_id="1" value="300" characteristic_id="30000"
- url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
- variation_value_4="[null]" variation_value_5="400"
- rule_priority="[null]" alert_text="[null]" RULES_CATEGORY_ID="[null]"
- RULE_ID="[null]" text_value="[null]"
- component_uuid="ABCD"
- alert_status="[null]" description="[null]" person_id="[null]"/>-->
-
- <!--project_measures id="1003" metric_id="1" value="200" characteristic_id="40000"
- url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
- variation_value_4="[null]" variation_value_5="400"
- alert_text="[null]" RULES_CATEGORY_ID="[null]"
- RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" component_uuid="ABCD"
- alert_status="[null]" description="[null]" person_id="[null]"/>
- text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
- alert_status="[null]" description="[null]" person_id="[null]"/>-->
-
</dataset>