diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-07-19 18:12:07 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-07-19 18:12:07 +0200 |
commit | 370ca7c85339a65fe247567ee81ae528f4244e35 (patch) | |
tree | 08ba41ca7e551d673868b9f0dc338e0c6dd41294 /server | |
parent | 5eb2c93c1ffebc39d720bb32b4d7db995f2ba669 (diff) | |
parent | bb7a09800eb894465e302cab84c28a5a4a960f27 (diff) | |
download | sonarqube-370ca7c85339a65fe247567ee81ae528f4244e35.tar.gz sonarqube-370ca7c85339a65fe247567ee81ae528f4244e35.zip |
Merge branch 'branch-5.6'
Diffstat (limited to 'server')
4 files changed, 32 insertions, 21 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/ProjectViewAttributes.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/ProjectViewAttributes.java index 646db69d9a2..e267b0dcb24 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/component/ProjectViewAttributes.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/ProjectViewAttributes.java @@ -19,6 +19,8 @@ */ package org.sonar.server.computation.component; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; import static java.util.Objects.requireNonNull; @@ -26,19 +28,28 @@ import static java.util.Objects.requireNonNull; @Immutable public class ProjectViewAttributes { private final String projectUuid; + @CheckForNull + private final Long analysisDate; - public ProjectViewAttributes(String projectUuid) { + public ProjectViewAttributes(String projectUuid, @Nullable Long analysisDate) { this.projectUuid = requireNonNull(projectUuid, "projectUuid can't be null"); + this.analysisDate = analysisDate; } public String getProjectUuid() { return projectUuid; } + @CheckForNull + public Long getAnalysisDate() { + return analysisDate; + } + @Override public String toString() { return "ProjectViewAttributes{" + - ", projectUuid='" + projectUuid + '\'' + - '}'; + ", projectUuid='" + projectUuid + '\'' + + ", analysisDate=" + analysisDate + + '}'; } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/VisitorsCrawler.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/VisitorsCrawler.java index f390aa9ac36..b89216d64ae 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/component/VisitorsCrawler.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/VisitorsCrawler.java @@ -156,6 +156,8 @@ public class VisitorsCrawler implements ComponentCrawler { private static class MatchVisitorMaxDepth implements Predicate<VisitorWrapper> { private static final Map<Component.Type, MatchVisitorMaxDepth> INSTANCES = buildInstances(); + private final Component.Type type; + private static Map<Component.Type, MatchVisitorMaxDepth> buildInstances() { ImmutableMap.Builder<Component.Type, MatchVisitorMaxDepth> builder = ImmutableMap.builder(); for (Component.Type type : Component.Type.values()) { @@ -164,8 +166,6 @@ public class VisitorsCrawler implements ComponentCrawler { return builder.build(); } - private final Component.Type type; - private MatchVisitorMaxDepth(Component.Type type) { this.type = requireNonNull(type); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistAnalysisStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistAnalysisStep.java index f095b4d328b..11b948d8260 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistAnalysisStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistAnalysisStep.java @@ -46,7 +46,7 @@ public class PersistAnalysisStep implements ComputationStep { private final PeriodsHolder periodsHolder; public PersistAnalysisStep(System2 system2, DbClient dbClient, TreeRootHolder treeRootHolder, - AnalysisMetadataHolder analysisMetadataHolder, PeriodsHolder periodsHolder) { + AnalysisMetadataHolder analysisMetadataHolder, PeriodsHolder periodsHolder) { this.system2 = system2; this.dbClient = dbClient; this.treeRootHolder = treeRootHolder; @@ -59,7 +59,7 @@ public class PersistAnalysisStep implements ComputationStep { DbSession session = dbClient.openSession(false); try { new PathAwareCrawler<>( - new PersistSnapshotsPathAwareVisitor(session, analysisMetadataHolder.getAnalysisDate())) + new PersistSnapshotsPathAwareVisitor(session, analysisMetadataHolder.getAnalysisDate())) .visit(treeRootHolder.getRoot()); session.commit(); } finally { @@ -104,13 +104,13 @@ public class PersistAnalysisStep implements ComputationStep { private SnapshotDto createAnalysis(String snapshotUuid, Component component, boolean setVersion) { String componentUuid = component.getUuid(); return new SnapshotDto() - .setUuid(snapshotUuid) - .setVersion(setVersion ? component.getReportAttributes().getVersion() : null) - .setComponentUuid(componentUuid) - .setLast(false) - .setStatus(SnapshotDto.STATUS_UNPROCESSED) - .setCreatedAt(analysisDate) - .setBuildDate(system2.now()); + .setUuid(snapshotUuid) + .setVersion(setVersion ? component.getReportAttributes().getVersion() : null) + .setComponentUuid(componentUuid) + .setLast(false) + .setStatus(SnapshotDto.STATUS_UNPROCESSED) + .setCreatedAt(analysisDate) + .setBuildDate(system2.now()); } private void persist(SnapshotDto snapshotDto, DbSession dbSession) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsPersistComponentsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsPersistComponentsStepTest.java index 0abaf7f1e5b..ef1485d05d0 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsPersistComponentsStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsPersistComponentsStepTest.java @@ -124,7 +124,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { treeRootHolder.setRoot( createViewBuilder() - .addChildren(createProjectView1Builder(project).build()) + .addChildren(createProjectView1Builder(project, null).build()) .build()); underTest.execute(); @@ -205,7 +205,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { .addChildren( createSubView1Builder() .addChildren( - createProjectView1Builder(project).build()) + createProjectView1Builder(project, null).build()) .build()) .build()); @@ -252,7 +252,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { treeRootHolder.setRoot( createViewBuilder() - .addChildren(createProjectView1Builder(project).build()) + .addChildren(createProjectView1Builder(project, null).build()) .build()); underTest.execute(); @@ -282,7 +282,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { treeRootHolder.setRoot( createViewBuilder() // Project view in the View is linked to the first project2 - .addChildren(createProjectView1Builder(project2).build()) + .addChildren(createProjectView1Builder(project2, null).build()) .build()); underTest.execute(); @@ -304,12 +304,12 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { return builder(SUBVIEW, SUBVIEW_1_KEY).setUuid(SUBVIEW_1_UUID).setName(SUBVIEW_1_NAME).setDescription(SUBVIEW_1_DESCRIPTION); } - private static ViewsComponent.Builder createProjectView1Builder(ComponentDto project) { + private static ViewsComponent.Builder createProjectView1Builder(ComponentDto project, Long analysisDate) { return builder(PROJECT_VIEW, PROJECT_VIEW_1_KEY) .setUuid(PROJECT_VIEW_1_UUID) .setName(PROJECT_VIEW_1_NAME) .setDescription("project view description is not persisted") - .setProjectViewAttributes(new ProjectViewAttributes(project.uuid())); + .setProjectViewAttributes(new ProjectViewAttributes(project.uuid(), analysisDate)); } private void persistComponents(ComponentDto... componentDtos) { @@ -352,7 +352,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { } /** - * Assertions to verify the DTO created from {@link #createProjectView1Builder(ComponentDto)} + * Assertions to verify the DTO created from {@link #createProjectView1Builder(ComponentDto, Long)} */ private void assertDtoIsSubView1(ComponentDto viewDto, ComponentDto sv1Dto) { assertThat(sv1Dto.name()).isEqualTo(SUBVIEW_1_NAME); |