diff options
author | Michal Duda <michal.duda@sonarsource.com> | 2019-05-09 16:23:52 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-05-22 20:21:17 +0200 |
commit | 2410133d009b32f7e61beab9dae6d15a7aabf0f7 (patch) | |
tree | e8f72b12db722f8d04065b4e49d92c2c95d64377 /server/sonar-ce-task-projectanalysis | |
parent | 8f699a85b3f9f87df99e2a91550e4da60d092cc7 (diff) | |
download | sonarqube-2410133d009b32f7e61beab9dae6d15a7aabf0f7.tar.gz sonarqube-2410133d009b32f7e61beab9dae6d15a7aabf0f7.zip |
SONAR-11950 copy revisions migration
Diffstat (limited to 'server/sonar-ce-task-projectanalysis')
2 files changed, 3 insertions, 42 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistAnalysisPropertiesStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistAnalysisPropertiesStep.java index 2557964e411..57b39a71fd3 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistAnalysisPropertiesStep.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistAnalysisPropertiesStep.java @@ -40,7 +40,6 @@ import static org.sonar.core.config.CorePropertyDefinitions.SONAR_ANALYSIS; public class PersistAnalysisPropertiesStep implements ComputationStep { private static final String SONAR_PULL_REQUEST = "sonar.pullrequest."; - private static final String SCM_REVISION_ID = "sonar.analysis.scm_revision_id"; private final DbClient dbClient; private final AnalysisMetadataHolder analysisMetadataHolder; @@ -72,12 +71,6 @@ public class PersistAnalysisPropertiesStep implements ComputationStep { }); } - analysisMetadataHolder.getScmRevisionId().ifPresent(scmRevisionId -> analysisPropertyDtos.add(new AnalysisPropertyDto() - .setUuid(uuidFactory.create()) - .setKey(SCM_REVISION_ID) - .setValue(scmRevisionId) - .setSnapshotUuid(analysisMetadataHolder.getUuid()))); - if (analysisPropertyDtos.isEmpty()) { return; } diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistAnalysisPropertiesStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistAnalysisPropertiesStepTest.java index d4d4222a878..956fbc1d4e4 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistAnalysisPropertiesStepTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistAnalysisPropertiesStepTest.java @@ -79,32 +79,6 @@ public class PersistAnalysisPropertiesStepTest { underTest.execute(new TestComputationStepContext()); - assertThat(dbTester.countRowsOfTable("analysis_properties")).isEqualTo(9); - List<AnalysisPropertyDto> propertyDtos = dbTester.getDbClient() - .analysisPropertiesDao().selectBySnapshotUuid(dbTester.getSession(), SNAPSHOT_UUID); - - assertThat(propertyDtos) - .extracting(AnalysisPropertyDto::getSnapshotUuid, AnalysisPropertyDto::getKey, AnalysisPropertyDto::getValue) - .containsExactlyInAnyOrder( - tuple(SNAPSHOT_UUID, "sonar.analysis.branch", SMALL_VALUE2), - tuple(SNAPSHOT_UUID, "sonar.analysis.empty_string", ""), - tuple(SNAPSHOT_UUID, "sonar.analysis.big_value", BIG_VALUE), - tuple(SNAPSHOT_UUID, "sonar.analysis.", SMALL_VALUE3), - tuple(SNAPSHOT_UUID, "sonar.analysis.scm_revision_id", SCM_REV_ID), - tuple(SNAPSHOT_UUID, "sonar.pullrequest.branch", VALUE_PREFIX_FOR_PR_PROPERTIES + SMALL_VALUE2), - tuple(SNAPSHOT_UUID, "sonar.pullrequest.empty_string", ""), - tuple(SNAPSHOT_UUID, "sonar.pullrequest.big_value", VALUE_PREFIX_FOR_PR_PROPERTIES + BIG_VALUE), - tuple(SNAPSHOT_UUID, "sonar.pullrequest.", VALUE_PREFIX_FOR_PR_PROPERTIES + SMALL_VALUE3)); - } - - @Test - public void persist_should_not_stores_sonarDotAnalysisDotscm_revision_id_properties_when_its_not_available_in_report_metada() { - when(batchReportReader.readContextProperties()).thenReturn(CloseableIterator.from(PROPERTIES.iterator())); - when(analysisMetadataHolder.getUuid()).thenReturn(SNAPSHOT_UUID); - when(analysisMetadataHolder.getScmRevisionId()).thenReturn(Optional.empty()); - - underTest.execute(new TestComputationStepContext()); - assertThat(dbTester.countRowsOfTable("analysis_properties")).isEqualTo(8); List<AnalysisPropertyDto> propertyDtos = dbTester.getDbClient() .analysisPropertiesDao().selectBySnapshotUuid(dbTester.getSession(), SNAPSHOT_UUID); @@ -136,24 +110,18 @@ public class PersistAnalysisPropertiesStepTest { underTest.execute(new TestComputationStepContext()); - assertThat(dbTester.countRowsOfTable("analysis_properties")).isEqualTo(1); + assertThat(dbTester.countRowsOfTable("analysis_properties")).isEqualTo(0); } @Test - public void persist_should_only_store_scmRevisionId_if_there_is_no_context_properties() { + public void persist_should_store_nothing_if_there_are_no_context_properties() { when(analysisMetadataHolder.getScmRevisionId()).thenReturn(Optional.of(SCM_REV_ID)); when(batchReportReader.readContextProperties()).thenReturn(CloseableIterator.emptyCloseableIterator()); when(analysisMetadataHolder.getUuid()).thenReturn(SNAPSHOT_UUID); underTest.execute(new TestComputationStepContext()); - assertThat(dbTester.countRowsOfTable("analysis_properties")).isEqualTo(1); - List<AnalysisPropertyDto> propertyDtos = dbTester.getDbClient() - .analysisPropertiesDao().selectBySnapshotUuid(dbTester.getSession(), SNAPSHOT_UUID); - - assertThat(propertyDtos) - .extracting(AnalysisPropertyDto::getSnapshotUuid, AnalysisPropertyDto::getKey, AnalysisPropertyDto::getValue) - .containsExactlyInAnyOrder(tuple(SNAPSHOT_UUID, "sonar.analysis.scm_revision_id", SCM_REV_ID)); + assertThat(dbTester.countRowsOfTable("analysis_properties")).isEqualTo(0); } @Test |