]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-17352 Refactor component keys to not include branch suffix
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Tue, 20 Sep 2022 16:59:16 +0000 (11:59 -0500)
committersonartech <sonartech@sonarsource.com>
Wed, 12 Oct 2022 20:03:43 +0000 (20:03 +0000)
330 files changed:
server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java
server/sonar-ce-common/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/analysis/Branch.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/measurecomputer/MeasureComputerContextImpl.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/BranchPersisterImpl.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/Component.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ComponentImpl.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ComponentTreeBuilder.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImpl.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/DepthTraversalTypeAwareCrawler.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/PathAwareCrawler.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ReferenceBranchComponentUuids.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/SiblingComponentsWithOpenIssues.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/VisitorsCrawler.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/duplication/Duplication.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/duplication/DuplicationRepositoryImpl.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/duplication/IntegrateCrossProjectDuplications.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/filemove/MutableMovedFilesRepositoryImpl.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IntegrateIssuesVisitor.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/ProjectTrackerBaseLazyInput.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/SiblingsIssuesLoader.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/SourceBranchComponentUuids.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/TargetBranchComponentUuids.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/TrackerReferenceBranchInputFactory.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/TrackerSourceBranchInputFactory.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/TrackerTargetBranchInputFactory.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/MapBasedRawMeasureRepository.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/period/NewCodeReferenceBranchComponentUuids.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoDbLoader.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoRepositoryImpl.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/source/DbLineHashVersion.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/source/PersistFileSourcesStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/source/SourceHashRepositoryImpl.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/source/SourceLinesDiffImpl.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/source/linereader/HighlightingLineReader.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/source/linereader/SymbolsLineReader.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/BuildComponentTreeStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/LoadCrossProjectDuplicationsRepositoryStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistDuplicationDataStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/QualityGateEventsStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ExportComponentsStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/taskprocessor/ProjectDescriptor.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisFromSonarQube94VisitorTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/ProjectConfigurationFactoryTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/BranchPersisterImplTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/CallRecorderPathAwareVisitor.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/CallRecorderTypeAwareVisitor.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentImplTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentTreeBuilderTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryWithMigrationTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ProjectPersisterTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ReferenceBranchComponentUuidsTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/SiblingComponentsWithOpenIssuesTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ViewsPostOrderDepthTraversalTypeAwareCrawlerTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ViewsPreOrderDepthTraversalTypeAwareCrawlerTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ViewsVisitorsCrawlerTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/FileMoveDetectionStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IntegrateIssuesVisitorTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/MovedIssueVisitorTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/ProjectTrackerBaseLazyInputTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/PullRequestSourceBranchMergerTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/SiblingsIssueMergerTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/SourceBranchComponentUuidsTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TargetBranchComponentUuidsTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TrackerReferenceBranchInputFactoryTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TrackerSourceBranchInputFactoryTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TrackerTargetBranchInputFactoryTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/period/NewCodeReferenceBranchComponentUuidsTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoDbLoaderTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/DbLineHashVersionTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/BuildComponentTreeStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadCrossProjectDuplicationsRepositoryStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadReportAnalysisMetadataHolderStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistDuplicationDataStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistLiveMeasuresStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistMeasuresStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateEventsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistAnalysisStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/UpdateNeedIssueSyncStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistAnalysisStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/analysis/ExportAnalysesStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/component/ExportComponentsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/rule/ExportAdHocRulesStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/ExportEventsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/ExportLinksStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/ExportMeasuresStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/ExportNewCodePeriodsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/ExportSettingsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/LoadProjectStepTest.java
server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/component/ReportComponent.java
server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/component/TreeComponentProvider.java
server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/component/TreeRootHolderRule.java
server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/component/ViewsComponent.java
server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/measure/MeasureRepositoryRule.java
server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java
server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java
server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchDao.java
server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java
server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java
server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java
server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentUpdateDto.java
server/sonar-db-dao/src/main/java/org/sonar/db/component/UuidWithBranchUuidDto.java [new file with mode: 0644]
server/sonar-db-dao/src/main/java/org/sonar/db/component/UuidWithProjectUuidDto.java [deleted file]
server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDao.java
server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDto.java
server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java
server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java
server/sonar-db-dao/src/main/resources/org/sonar/db/component/BranchMapper.xml
server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
server/sonar-db-dao/src/main/resources/org/sonar/db/component/SnapshotMapper.xml
server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml
server/sonar-db-dao/src/schema/schema-sq.ddl
server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/ApplicationProjectsDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDtoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/ScrollForFileMoveComponentDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueMapperTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/measure/ProjectMeasuresIndexerIteratorTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoWithPersisterTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/portfolio/PortfolioDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/property/InternalComponentPropertiesDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/property/PropertiesDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/ProjectQgateAssociationDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/report/RegulatoryReportDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/source/FileSourceDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/user/UserTokenDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDaoWithPersisterTest.java
server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java
server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java
server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/SnapshotTesting.java
server/sonar-db-dao/src/testFixtures/java/org/sonar/db/measure/MeasureTesting.java
server/sonar-db-dao/src/testFixtures/java/org/sonar/db/source/FileSourceTester.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/CreateIndexForComponentsBranchUuid.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/DbVersion97.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/DropIndexForComponentsKey.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/DropIndexForComponentsProjectUuid.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/RenameProjectUuidToBranchUuidInComponents.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v97/CreateIndexForComponentsBranchUuidTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v97/DropIndexForComponentsProjectUuidTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v97/RenameProjectUuidToBranchUuidInComponentsTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v97/CreateIndexForComponentsBranchUuidTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v97/DropIndexForComponentsProjectUuidTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v97/RenameProjectUuidToBranchUuidInComponentsTest/schema.sql [new file with mode: 0644]
server/sonar-server-common/src/main/java/org/sonar/server/component/index/ComponentIndexer.java
server/sonar-server-common/src/main/java/org/sonar/server/es/ProjectIndexers.java
server/sonar-server-common/src/main/java/org/sonar/server/favorite/FavoriteUpdater.java
server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIndexer.java
server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIteratorFactory.java
server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIteratorForSingleChunk.java
server/sonar-server-common/src/main/java/org/sonar/server/setting/ProjectConfigurationLoaderImpl.java
server/sonar-server-common/src/main/java/org/sonar/server/view/index/ViewIndexer.java
server/sonar-server-common/src/test/java/org/sonar/server/component/index/ComponentIndexerTest.java
server/sonar-server-common/src/test/java/org/sonar/server/issue/index/IssueIteratorFactoryTest.java
server/sonar-server-common/src/test/java/org/sonar/server/setting/ProjectConfigurationLoaderImplTest.java
server/sonar-server-common/src/test/java/org/sonar/server/view/index/ViewIndexerTest.java
server/sonar-server-common/src/testFixtures/java/org/sonar/server/issue/IssueDocTesting.java
server/sonar-webserver-auth/src/main/java/org/sonar/server/user/AbstractUserSession.java
server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/user/ThreadLocalUserSessionTest.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/user/TokenUserSessionTest.java
server/sonar-webserver-auth/src/testFixtures/java/org/sonar/server/tester/AbstractMockUserSession.java
server/sonar-webserver-core/src/test/java/org/sonar/server/project/ProjectQGChangeEventListenerTest.java
server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java
server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureFavoriteTest.java
server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureRecentlyBrowsedTest.java
server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexScoreTest.java
server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java
server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchWindowExceededTest.java
server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java
server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFiltersTest.java
server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSyncProgressCheckerTest.java
server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java
server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java
server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java
server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTextSearchTest.java
server/sonar-webserver-monitoring/src/test/java/org/sonar/server/monitoring/ce/RecentTasksDurationTaskTest.java
server/sonar-webserver-pushapi/src/main/java/org/sonar/server/pushapi/issues/IssueChangeEventServiceImpl.java
server/sonar-webserver-pushapi/src/test/java/org/sonar/server/pushapi/issues/IssueChangeEventServiceImplTest.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/ImportHelper.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/gitlab/ImportGitLabProjectAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/queue/BranchSupport.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/queue/ReportSubmitter.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentFinder.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentUpdater.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/ComponentViewerJsonWriter.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/ShowAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SuggestionsAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/TreeAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/developers/ws/SearchEventsAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/duplication/ws/Duplication.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/duplication/ws/DuplicationsParser.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/duplication/ws/ShowResponseBuilder.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/favorite/ws/SearchAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/HotspotWsResponseFormatter.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/SearchAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ShowAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/live/LiveMeasureComputerImpl.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/live/LiveMeasureTreeUpdaterImpl.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/live/MeasureMatrix.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentDtoToWsComponent.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/ListAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/PermissionTemplateService.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/CreateAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/SearchAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/SearchMyProjectsAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/ws/IssueSnippetsAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/ws/LinesAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/ComponentAction.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/ImportHelperTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/azure/ImportAzureProjectActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/bitbucketcloud/ImportBitbucketCloudRepoActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/bitbucketcloud/SearchBitbucketCloudReposActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/bitbucketserver/ImportBitbucketServerProjectActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/bitbucketserver/SearchBitbucketServerReposActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/github/ImportGithubProjectActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/github/ListGithubRepositoriesActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/batch/ProjectDataLoaderTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/branch/ws/DeleteActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/branch/ws/ListActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/queue/BranchReportSubmitterTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/queue/BranchSupportTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/queue/ReportSubmitterTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/ActivityActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/ActivityStatusActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/AnalysisStatusActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/CancelActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/ComponentActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/TaskActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/TaskFormatterTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ComponentFinderTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ComponentServiceUpdateKeyTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ComponentUpdaterTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/AppActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/SearchActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/ShowActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/SuggestionsActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/TreeActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/developers/ws/SearchEventsActionNewIssuesTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/developers/ws/SearchEventsActionQualityGateTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/developers/ws/SearchEventsActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/duplication/ws/DuplicationsParserTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/duplication/ws/ShowActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/AddActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/RemoveActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/SearchActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/hotspot/ws/SearchActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/hotspot/ws/ShowActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullTaintActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchResponseFormatFormatOperationTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/SearchActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/ShowActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/AddActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/ListActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/RemoveActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/PermissionTemplateServiceTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddUserActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/GroupsActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveUserActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/UsersActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/ApplyTemplateActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/BulkApplyTemplateActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/CreateActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/ProjectFinderTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/SearchActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/SearchMyProjectsActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/SearchMyScannableProjectsActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateKeyActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateVisibilityActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/UnsetBaselineActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectdump/ws/ExportActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectdump/ws/StatusActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectlink/ws/CreateActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectlink/ws/SearchActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/projecttag/ws/SearchActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/projecttag/ws/SetActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/DeselectActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/GetByProjectActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/SelectActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/ListDefinitionsActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/ResetActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/SetActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/ValuesActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/source/ws/IndexActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/source/ws/LinesActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/source/ws/ScmActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CurrentActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/usertoken/ws/SearchActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/webhook/ws/CreateActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/webhook/ws/WebhookDeliveriesActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/webhook/ws/WebhookDeliveryActionTest.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorValidator.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java

index ab5953f13b337df505e17b7d7b23446c6f7decac..b207dd7e410d696d01be354527672250eeea924c 100644 (file)
@@ -352,14 +352,14 @@ public class CeQueueImpl implements CeQueue {
 
     String componentUuid = taskDto.getComponentUuid();
     if (component != null) {
-      builder.setComponent(new CeTask.Component(component.uuid(), component.getDbKey(), component.name()));
+      builder.setComponent(new CeTask.Component(component.uuid(), component.getKey(), component.name()));
     } else if (componentUuid != null) {
       builder.setComponent(new CeTask.Component(componentUuid, null, null));
     }
 
     String mainComponentUuid = taskDto.getMainComponentUuid();
     if (mainComponent != null) {
-      builder.setMainComponent(new CeTask.Component(mainComponent.uuid(), mainComponent.getDbKey(), mainComponent.name()));
+      builder.setMainComponent(new CeTask.Component(mainComponent.uuid(), mainComponent.getKey(), mainComponent.name()));
     } else if (mainComponentUuid != null) {
       builder.setMainComponent(new CeTask.Component(mainComponentUuid, null, null));
     }
index 8a7e205bd3ca0061a61130e7fb48dab779011ff6..7ea2ba50bafef9472201c4f6244f1a19675da9fa 100644 (file)
@@ -507,7 +507,7 @@ public class CeQueueImplTest {
     if (componentDto != null) {
       CeTask.Component component = task.getComponent().get();
       assertThat(component.getUuid()).isEqualTo(componentDto.uuid());
-      assertThat(component.getKey()).contains(componentDto.getDbKey());
+      assertThat(component.getKey()).contains(componentDto.getKey());
       assertThat(component.getName()).contains(componentDto.name());
     } else if (taskSubmit.getComponent().isPresent()) {
       assertThat(task.getComponent()).contains(new CeTask.Component(taskSubmit.getComponent().get().getUuid(), null, null));
@@ -517,7 +517,7 @@ public class CeQueueImplTest {
     if (mainComponentDto != null) {
       CeTask.Component component = task.getMainComponent().get();
       assertThat(component.getUuid()).isEqualTo(mainComponentDto.uuid());
-      assertThat(component.getKey()).contains(mainComponentDto.getDbKey());
+      assertThat(component.getKey()).contains(mainComponentDto.getKey());
       assertThat(component.getName()).contains(mainComponentDto.name());
     } else if (taskSubmit.getComponent().isPresent()) {
       assertThat(task.getMainComponent()).contains(new CeTask.Component(taskSubmit.getComponent().get().getMainComponentUuid(), null, null));
index 08f8865ac383b60a684a75692e9b087d89582501..9fff3120fde7610a0f2603981e78a36d18b1a1aa 100644 (file)
  */
 package org.sonar.ce.task.projectanalysis.analysis;
 
+import javax.annotation.Nullable;
 import javax.annotation.concurrent.Immutable;
 import org.sonar.ce.task.projectanalysis.component.ComponentKeyGenerator;
 import org.sonar.db.component.BranchType;
 
+import static org.apache.logging.log4j.util.Strings.trimToNull;
+import static org.sonar.core.component.ComponentKeys.createEffectiveKey;
+
 @Immutable
 public interface Branch extends ComponentKeyGenerator {
 
@@ -61,4 +65,13 @@ public interface Branch extends ComponentKeyGenerator {
    * @throws IllegalStateException if this branch configuration is not a pull request.
    */
   String getTargetBranchName();
+
+  @Override
+  default String generateKey(String projectKey, @Nullable String fileOrDirPath) {
+    if (fileOrDirPath == null) {
+      return projectKey;
+    } else {
+      return createEffectiveKey(projectKey, trimToNull(fileOrDirPath));
+    }
+  }
 }
index f5c2283b3ffea44651ad44fa87356c49f06fc032..de24223936eb3818f9b4f077022ab98935a0d8c1 100644 (file)
@@ -169,7 +169,7 @@ public class MeasureComputerContextImpl implements MeasureComputerContext {
     checkArgument(definition.getOutputMetrics().contains(metric.getKey()), "Only metrics in %s can be used to add measures. Metric '%s' is not allowed.",
       definition.getOutputMetrics(), metric.getKey());
     if (measureRepository.getRawMeasure(internalComponent, metric).isPresent()) {
-      throw new UnsupportedOperationException(String.format("A measure on metric '%s' already exists on component '%s'", metric.getKey(), internalComponent.getDbKey()));
+      throw new UnsupportedOperationException(String.format("A measure on metric '%s' already exists on component '%s'", metric.getKey(), internalComponent.getKey()));
     }
   }
 
@@ -180,7 +180,7 @@ public class MeasureComputerContextImpl implements MeasureComputerContext {
 
   private static Component newComponent(org.sonar.ce.task.projectanalysis.component.Component component) {
     return new ComponentImpl(
-      component.getDbKey(),
+      component.getKey(),
       Component.Type.valueOf(component.getType().name()),
       component.getType() == org.sonar.ce.task.projectanalysis.component.Component.Type.FILE
         ? new ComponentImpl.FileAttributesImpl(component.getFileAttributes().getLanguageKey(), component.getFileAttributes().isUnitTest())
index 03aa3ee0fa9d1380f8f06ff61055a61f4a52416c..60a686166d59d23088d5bcc6db61a57be4314dee 100644 (file)
@@ -81,7 +81,7 @@ public class BranchPersisterImpl implements BranchPersister {
     dto.setUuid(componentDto.uuid());
 
     // MainBranchProjectUuid will be null if it's a main branch
-    String projectUuid = firstNonNull(componentDto.getMainBranchProjectUuid(), componentDto.projectUuid());
+    String projectUuid = firstNonNull(componentDto.getMainBranchProjectUuid(), componentDto.branchUuid());
     dto.setProjectUuid(projectUuid);
     dto.setBranchType(branch.getType());
     dto.setExcludeFromPurge(excludeFromPurge);
index 31bff319be0b694c3ba0b1be34426b154431c0c9..4889401417ae1370b7a21bfa9676db5a2604d53f 100644 (file)
@@ -75,13 +75,6 @@ public interface Component {
    */
   String getUuid();
 
-  /**
-   * Returns the component key <b>as defined in database</b>
-   * It may differ from keys listed in scanner report
-   * when analyzing a branch.
-   */
-  String getDbKey();
-
   /**
    * Returns the key as it will be displayed in the ui.
    * If legacy branch feature is used, the key will contain the branch name
index 3aca5f5287d341b1d63142ba3834085cba2ec052..a9ac6fbbd26d3f4d02527aba9b12595d313ca1ac 100644 (file)
@@ -41,7 +41,6 @@ public class ComponentImpl implements Component {
   private final Status status;
   private final String name;
   private final String shortName;
-  private final String dbKey;
   private final String key;
   private final String uuid;
 
@@ -57,8 +56,7 @@ public class ComponentImpl implements Component {
   private ComponentImpl(Builder builder) {
     this.type = builder.type;
     this.status = builder.status;
-    this.dbKey = builder.dbKey;
-    this.key = MoreObjects.firstNonNull(builder.key, builder.dbKey);
+    this.key = builder.key;
     this.name = builder.name;
     this.shortName = MoreObjects.firstNonNull(builder.shortName, builder.name).intern();
     this.description = builder.description;
@@ -84,11 +82,6 @@ public class ComponentImpl implements Component {
     return uuid;
   }
 
-  @Override
-  public String getDbKey() {
-    return dbKey;
-  }
-
   @Override
   public String getKey() {
     return key;
@@ -153,7 +146,6 @@ public class ComponentImpl implements Component {
 
   public static final class Builder {
 
-    private static final String DB_KEY_CANNOT_BE_NULL = "DB key can't be null";
     private static final String KEY_CANNOT_BE_NULL = "Key can't be null";
     private static final String UUID_CANNOT_BE_NULL = "uuid can't be null";
     private static final String REPORT_ATTRIBUTES_CANNOT_BE_NULL = "reportAttributes can't be null";
@@ -165,7 +157,6 @@ public class ComponentImpl implements Component {
     private ProjectAttributes projectAttributes;
     private ReportAttributes reportAttributes;
     private String uuid;
-    private String dbKey;
     private String key;
     private String name;
     private String shortName;
@@ -192,11 +183,6 @@ public class ComponentImpl implements Component {
       return this;
     }
 
-    public Builder setDbKey(String s) {
-      this.dbKey = requireNonNull(s, DB_KEY_CANNOT_BE_NULL);
-      return this;
-    }
-
     public Builder setKey(String key) {
       this.key = requireNonNull(key, KEY_CANNOT_BE_NULL);
       return this;
@@ -244,7 +230,7 @@ public class ComponentImpl implements Component {
     public ComponentImpl build() {
       requireNonNull(reportAttributes, REPORT_ATTRIBUTES_CANNOT_BE_NULL);
       requireNonNull(uuid, UUID_CANNOT_BE_NULL);
-      requireNonNull(dbKey, DB_KEY_CANNOT_BE_NULL);
+      requireNonNull(key, KEY_CANNOT_BE_NULL);
       requireNonNull(name, NAME_CANNOT_BE_NULL);
       requireNonNull(status, STATUS_CANNOT_BE_NULL);
       checkProjectAttributes(this.projectAttributes);
@@ -262,7 +248,6 @@ public class ComponentImpl implements Component {
       "type=" + type +
       ", status=" + status +
       ", name='" + name + '\'' +
-      ", dbKey='" + dbKey + '\'' +
       ", key='" + key + '\'' +
       ", uuid='" + uuid + '\'' +
       ", description='" + description + '\'' +
index 6808c7b6db81f3f294f0ea2c9800f7f9423f2816..4ca4a8ab048da61e7c86b4823079c19a4ae7c17d 100644 (file)
@@ -45,9 +45,7 @@ import static org.apache.commons.lang.StringUtils.trimToNull;
 import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.FILE;
 
 public class ComponentTreeBuilder {
-
   private final ComponentKeyGenerator keyGenerator;
-  private final ComponentKeyGenerator publicKeyGenerator;
   /**
    * Will supply the UUID for any component in the tree, given it's key.
    * <p>
@@ -72,7 +70,6 @@ public class ComponentTreeBuilder {
 
   public ComponentTreeBuilder(
     ComponentKeyGenerator keyGenerator,
-    ComponentKeyGenerator publicKeyGenerator,
     UnaryOperator<String> uuidSupplier,
     Function<Integer, ScannerReport.Component> scannerComponentSupplier,
     Project project,
@@ -80,7 +77,6 @@ public class ComponentTreeBuilder {
     ProjectAttributes projectAttributes) {
 
     this.keyGenerator = keyGenerator;
-    this.publicKeyGenerator = publicKeyGenerator;
     this.uuidSupplier = uuidSupplier;
     this.scannerComponentSupplier = scannerComponentSupplier;
     this.project = project;
@@ -169,11 +165,9 @@ public class ComponentTreeBuilder {
   private Component buildProject(List<Component> children) {
     String projectKey = keyGenerator.generateKey(rootComponent.getKey(), null);
     String uuid = uuidSupplier.apply(projectKey);
-    String projectPublicKey = publicKeyGenerator.generateKey(rootComponent.getKey(), null);
     ComponentImpl.Builder builder = ComponentImpl.builder(Component.Type.PROJECT)
       .setUuid(uuid)
-      .setDbKey(projectKey)
-      .setKey(projectPublicKey)
+      .setKey(projectKey)
       .setStatus(convertStatus(rootComponent.getStatus()))
       .setProjectAttributes(projectAttributes)
       .setReportAttributes(createAttributesBuilder(rootComponent.getRef(), rootComponent.getProjectRelativePath(), scmBasePath).build())
@@ -184,11 +178,9 @@ public class ComponentTreeBuilder {
 
   private ComponentImpl buildFile(ScannerReport.Component component) {
     String key = keyGenerator.generateKey(rootComponent.getKey(), component.getProjectRelativePath());
-    String publicKey = publicKeyGenerator.generateKey(rootComponent.getKey(), component.getProjectRelativePath());
     return ComponentImpl.builder(Component.Type.FILE)
       .setUuid(uuidSupplier.apply(key))
-      .setDbKey(key)
-      .setKey(publicKey)
+      .setKey(key)
       .setName(component.getProjectRelativePath())
       .setShortName(FilenameUtils.getName(component.getProjectRelativePath()))
       .setStatus(convertStatus(component.getStatus()))
@@ -200,11 +192,9 @@ public class ComponentTreeBuilder {
 
   private ComponentImpl buildDirectory(String parentPath, String path, List<Component> children) {
     String key = keyGenerator.generateKey(rootComponent.getKey(), path);
-    String publicKey = publicKeyGenerator.generateKey(rootComponent.getKey(), path);
     return ComponentImpl.builder(Component.Type.DIRECTORY)
       .setUuid(uuidSupplier.apply(key))
-      .setDbKey(key)
-      .setKey(publicKey)
+      .setKey(key)
       .setName(path)
       .setShortName(removeStart(removeStart(path, parentPath), "/"))
       .setStatus(convertStatus(FileStatus.UNAVAILABLE))
@@ -268,7 +258,6 @@ public class ComponentTreeBuilder {
   private static ComponentImpl.Builder changedComponentBuilder(Component component, String newShortName) {
     return ComponentImpl.builder(component.getType())
       .setUuid(component.getUuid())
-      .setDbKey(component.getDbKey())
       .setKey(component.getKey())
       .setStatus(component.getStatus())
       .setReportAttributes(component.getReportAttributes())
index b07d637679e3c82423b870776a3d6d817f866d5b..80ce63ab8998ca0a58a89b2945598492fdee1514 100644 (file)
@@ -73,12 +73,4 @@ public class DefaultBranchImpl implements Branch {
   public String getTargetBranchName() {
     throw new IllegalStateException("Only on a pull request");
   }
-
-  @Override
-  public String generateKey(String projectKey, @Nullable String fileOrDirPath) {
-    if (isEmpty(fileOrDirPath)) {
-      return projectKey;
-    }
-    return ComponentKeys.createEffectiveKey(projectKey, trimToNull(fileOrDirPath));
-  }
 }
index a937e967ce17522d88aa1290ac502a886f8d785d..6b40dc47f8c95dc45e145f8d551b76bc13d96e9b 100644 (file)
@@ -38,7 +38,7 @@ public final class DepthTraversalTypeAwareCrawler implements ComponentCrawler {
     try {
       visitImpl(component);
     } catch (RuntimeException e) {
-      VisitException.rethrowOrWrap(e, "Visit of Component {key=%s,uuid=%s,type=%s} failed", component.getDbKey(), component.getUuid(), component.getType());
+      VisitException.rethrowOrWrap(e, "Visit of Component {key=%s,uuid=%s,type=%s} failed", component.getKey(), component.getUuid(), component.getType());
     }
   }
 
index 37ae2e227e5410e9a3ab515c1a167f02550ce68f..d0c643eed038b071883a3c71e832e487ad3ae10d 100644 (file)
@@ -52,7 +52,7 @@ public final class PathAwareCrawler<T> implements ComponentCrawler {
       VisitException.rethrowOrWrap(
         e,
         "Visit failed for Component {key=%s,type=%s} %s",
-        component.getDbKey(), component.getType(), new ComponentPathPrinter<>(stack));
+        component.getKey(), component.getType(), new ComponentPathPrinter<>(stack));
     }
   }
 
@@ -169,7 +169,7 @@ public final class PathAwareCrawler<T> implements ComponentCrawler {
       @Override
       @Nonnull
       public String apply(@Nonnull PathAwareVisitor.PathElement<?> input) {
-        return format("%s(type=%s)", input.getComponent().getDbKey(), input.getComponent().getType());
+        return format("%s(type=%s)", input.getComponent().getKey(), input.getComponent().getType());
       }
     }
   }
index 809b0eea78679c54c041150362ee43dbad19ae06..f77a898e369885e4c21c85fcaa47a4fd62543917 100644 (file)
@@ -69,7 +69,7 @@ public class ReferenceBranchComponentUuids {
     hasReferenceBranchAnalysis = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(dbSession, referenceBranchUuid).isPresent();
 
     if (hasReferenceBranchAnalysis) {
-      List<ComponentDto> components = dbClient.componentDao().selectByProjectUuid(referenceBranchUuid, dbSession);
+      List<ComponentDto> components = dbClient.componentDao().selectByBranchUuid(referenceBranchUuid, dbSession);
       for (ComponentDto dto : components) {
         referenceBranchComponentsUuidsByKey.put(dto.getKey(), dto.uuid());
       }
index 668e2115cd1dd94433065832d8c11fa3a8977123..ffa537805b2c468c8f98a0974b0d4b5baf5bfa4a 100644 (file)
@@ -76,7 +76,7 @@ public class SiblingComponentsWithOpenIssues {
 
     List<KeyWithUuidDto> components = dbClient.componentDao().selectComponentsFromBranchesThatHaveOpenIssues(dbSession, branchUuids);
     for (KeyWithUuidDto dto : components) {
-      uuidsByKey.computeIfAbsent(removeBranchAndPullRequestFromKey(dto.key()), s -> new HashSet<>()).add(dto.uuid());
+      uuidsByKey.computeIfAbsent(dto.key(), s -> new HashSet<>()).add(dto.uuid());
     }
   }
 
@@ -84,7 +84,7 @@ public class SiblingComponentsWithOpenIssues {
     List<KeyWithUuidDto> components = dbClient.componentDao().selectComponentsFromPullRequestsTargetingCurrentBranchThatHaveOpenIssues(
       dbSession, referenceBranchUuid, currentBranchUuid);
     for (KeyWithUuidDto dto : components) {
-      uuidsByKey.computeIfAbsent(removeBranchAndPullRequestFromKey(dto.key()), s -> new HashSet<>()).add(dto.uuid());
+      uuidsByKey.computeIfAbsent(dto.key(), s -> new HashSet<>()).add(dto.uuid());
     }
   }
 
index 32da9e33c9a7d05e3d017ff3e9be669ec2045942..c5239c88d1d08db8edc7fd029d26af8aade5ef4c 100644 (file)
@@ -71,7 +71,7 @@ public class VisitorsCrawler implements ComponentCrawler {
       VisitException.rethrowOrWrap(
         e,
         "Visit of Component {key=%s,type=%s} failed",
-        component.getDbKey(), component.getType());
+        component.getKey(), component.getType());
     }
   }
 
@@ -110,7 +110,7 @@ public class VisitorsCrawler implements ComponentCrawler {
 
   private void visitNode(Component component, VisitorWrapper visitor) {
     Profiler profiler = Profiler.create(Loggers.get(visitor.getWrappedVisitor().getClass()))
-      .startTrace("Visiting component {}", component.getDbKey());
+      .startTrace("Visiting component {}", component.getKey());
     visitor.visitAny(component);
     switch (component.getType()) {
       case PROJECT:
index 07874e2ccf220804ee78e8bb359a999633fbba05..9f349fbfe1f9061f28abd384a461f8f3fa81a0b9 100644 (file)
@@ -148,7 +148,7 @@ public final class Duplication {
         return "";
       }
       if (duplicate instanceof InProjectDuplicate) {
-        return ((InProjectDuplicate) duplicate).getFile().getDbKey();
+        return ((InProjectDuplicate) duplicate).getFile().getKey();
       }
       if (duplicate instanceof CrossProjectDuplicate) {
         return ((CrossProjectDuplicate) duplicate).getFileKey();
index e2f30e018aab08770f8a1043ced721b8347ad840..fa3d895b8ebcfe0044b8c0b14e3888cc0bf040e6 100644 (file)
@@ -39,7 +39,7 @@ public class DuplicationRepositoryImpl implements DuplicationRepository {
   public Iterable<Duplication> getDuplications(Component file) {
     checkFileComponentArgument(file);
 
-    Collection<Duplication> res = this.duplications.asMap().get(file.getDbKey());
+    Collection<Duplication> res = this.duplications.asMap().get(file.getKey());
     if (res == null) {
       return Collections.emptyList();
     }
@@ -51,7 +51,7 @@ public class DuplicationRepositoryImpl implements DuplicationRepository {
     checkFileComponentArgument(file);
     checkNotNull(duplication, "duplication can not be null");
 
-    duplications.put(file.getDbKey(), duplication);
+    duplications.put(file.getKey(), duplication);
   }
 
   private static void checkFileComponentArgument(Component file) {
index 38f79cb3ccaaa40483a4f977237e3b0088560ad3..273a6dc68e87313f535032c91e26ff409ee53000 100644 (file)
@@ -91,7 +91,7 @@ public class IntegrateCrossProjectDuplications {
     for (CloneGroup duplication : duplications) {
       cloneGroupCount++;
       if (cloneGroupCount > MAX_CLONE_GROUP_PER_FILE) {
-        LOGGER.warn("Too many duplication groups on file {}. Keeping only the first {} groups.", file.getDbKey(), MAX_CLONE_GROUP_PER_FILE);
+        LOGGER.warn("Too many duplication groups on file {}. Keeping only the first {} groups.", file.getKey(), MAX_CLONE_GROUP_PER_FILE);
         break;
       }
       addDuplication(file, duplication);
@@ -174,7 +174,7 @@ public class IntegrateCrossProjectDuplications {
     public boolean test(@Nonnull ClonePart input) {
       if (counter == MAX_CLONE_PART_PER_GROUP) {
         LOGGER.warn("Too many duplication references on file {} for block at line {}. Keeping only the first {} references.",
-          file.getDbKey(), originPart.getStartLine(), MAX_CLONE_PART_PER_GROUP);
+          file.getKey(), originPart.getStartLine(), MAX_CLONE_PART_PER_GROUP);
       }
       boolean res = counter < MAX_CLONE_GROUP_PER_FILE;
       counter++;
index ee56d5086867e88d95e3be85598029b946d69147..b05ba83cf86b9250c54b7d6c47ef24d2e50236f0 100644 (file)
@@ -37,11 +37,11 @@ public class MutableMovedFilesRepositoryImpl implements MutableMovedFilesReposit
     requireNonNull(originalFile, "originalFile can't be null");
     checkArgument(file.getType() == Component.Type.FILE, "file must be of type FILE");
 
-    OriginalFile existingOriginalFile = originalFiles.get(file.getDbKey());
+    OriginalFile existingOriginalFile = originalFiles.get(file.getKey());
     checkState(existingOriginalFile == null || existingOriginalFile.equals(originalFile),
       "Original file %s already registered for file %s. Unable to register %s.", existingOriginalFile, file, originalFile);
     if (existingOriginalFile == null) {
-      originalFiles.put(file.getDbKey(), originalFile);
+      originalFiles.put(file.getKey(), originalFile);
     }
   }
 
@@ -52,6 +52,6 @@ public class MutableMovedFilesRepositoryImpl implements MutableMovedFilesReposit
       return Optional.empty();
     }
 
-    return Optional.ofNullable(originalFiles.get(file.getDbKey()));
+    return Optional.ofNullable(originalFiles.get(file.getKey()));
   }
 }
index 805354d96e0ec94a06cdfc17e2ba5d2a5ffe276d..db09538cac3c94e7fed52291b546045273b993ae 100644 (file)
@@ -103,7 +103,7 @@ public class IntegrateIssuesVisitor extends TypeAwareVisitorAdapter {
       }
       issueVisitors.afterComponent(component);
     } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to process issues of component '%s'", component.getDbKey()), e);
+      throw new IllegalStateException(String.format("Fail to process issues of component '%s'", component.getKey()), e);
     }
   }
 
index df0a01e52aad2b778bebab4ab0202ba11b3cdd2c..ea027852f8380bb0705d2946ef4b9e235c5a24bf 100644 (file)
@@ -72,7 +72,7 @@ class ProjectTrackerBaseLazyInput extends BaseInputFactory.BaseLazyInput {
       if (!dirOrModulesUuidsWithIssues.isEmpty()) {
         Map<String, String> pathByModuleKey = reportModulesPath.get();
         // Migrate issues that were previously on modules or directories to the root project
-        Map<String, ComponentDto> modulesByUuid = dbClient.componentDao().selectProjectAndModulesFromProjectKey(dbSession, component.getDbKey(), true)
+        Map<String, ComponentDto> modulesByUuid = dbClient.componentDao().selectProjectAndModulesFromProjectKey(dbSession, component.getKey(), true)
           .stream().collect(Collectors.toMap(ComponentDto::uuid, Function.identity()));
         List<ComponentDto> dirOrModulesWithIssues = dbClient.componentDao().selectByUuids(dbSession, dirOrModulesUuidsWithIssues);
         dirOrModulesWithIssues.forEach(c -> {
index 641ce331a27484b89594b4d3196fb0794e79c579..60c94d1f999a764bfded4bf11fb12ee997a9c67d 100644 (file)
@@ -52,7 +52,7 @@ public class SiblingsIssuesLoader {
   }
 
   public Collection<SiblingIssue> loadCandidateSiblingIssuesForMerging(Component component) {
-    String componentKey = ComponentDto.removeBranchAndPullRequestFromKey(component.getDbKey());
+    String componentKey = ComponentDto.removeBranchAndPullRequestFromKey(component.getKey());
     Set<String> uuids = siblingComponentsWithOpenIssues.getUuids(componentKey);
     if (uuids.isEmpty()) {
       return Collections.emptyList();
index 06c108f27e3c5c25b1133f24f76af98f1b98db0c..409c8204d4803cd188ef8918acb0252f2314d5ad 100644 (file)
@@ -66,7 +66,7 @@ public class SourceBranchComponentUuids {
     String sourceBranchUuid = branchDtoOpt.map(BranchDto::getUuid).orElse(null);
     hasSourceBranchAnalysis = sourceBranchUuid != null && dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(dbSession, sourceBranchUuid).isPresent();
     if (hasSourceBranchAnalysis) {
-      List<ComponentDto> targetComponents = dbClient.componentDao().selectByProjectUuid(sourceBranchUuid, dbSession);
+      List<ComponentDto> targetComponents = dbClient.componentDao().selectByBranchUuid(sourceBranchUuid, dbSession);
       for (ComponentDto dto : targetComponents) {
         sourceBranchComponentsUuidsByKey.put(dto.getKey(), dto.uuid());
       }
index 126db444ec3746d1422628e25019018359269e93..725cf52f6da46a3e080aac2e73ebc816e353806a 100644 (file)
@@ -40,8 +40,6 @@ public class TargetBranchComponentUuids {
   private final DbClient dbClient;
   private Map<String, String> targetBranchComponentsUuidsByKey;
   private boolean hasTargetBranchAnalysis;
-  @CheckForNull
-  private String targetBranchUuid;
 
   public TargetBranchComponentUuids(AnalysisMetadataHolder analysisMetadataHolder, DbClient dbClient) {
     this.analysisMetadataHolder = analysisMetadataHolder;
@@ -65,10 +63,10 @@ public class TargetBranchComponentUuids {
   private void initForTargetBranch(DbSession dbSession) {
     Optional<BranchDto> branchDtoOpt = dbClient.branchDao().selectByBranchKey(dbSession, analysisMetadataHolder.getProject().getUuid(),
       analysisMetadataHolder.getBranch().getTargetBranchName());
-    targetBranchUuid = branchDtoOpt.map(BranchDto::getUuid).orElse(null);
+    String targetBranchUuid = branchDtoOpt.map(BranchDto::getUuid).orElse(null);
     hasTargetBranchAnalysis = targetBranchUuid != null && dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(dbSession, targetBranchUuid).isPresent();
     if (hasTargetBranchAnalysis) {
-      List<ComponentDto> targetComponents = dbClient.componentDao().selectByProjectUuid(targetBranchUuid, dbSession);
+      List<ComponentDto> targetComponents = dbClient.componentDao().selectByBranchUuid(targetBranchUuid, dbSession);
       for (ComponentDto dto : targetComponents) {
         targetBranchComponentsUuidsByKey.put(dto.getKey(), dto.uuid());
       }
@@ -81,9 +79,8 @@ public class TargetBranchComponentUuids {
   }
 
   @CheckForNull
-  public String getTargetBranchComponentUuid(String dbKey) {
+  public String getTargetBranchComponentUuid(String key) {
     lazyInit();
-    String cleanComponentKey = removeBranchAndPullRequestFromKey(dbKey);
-    return targetBranchComponentsUuidsByKey.get(cleanComponentKey);
+    return targetBranchComponentsUuidsByKey.get(key);
   }
 }
index 1af1181f31478062de9abff20e3d67b5aced3d4d..cde50da955622834bca845755391c6309721d29a 100644 (file)
@@ -46,7 +46,7 @@ public class TrackerReferenceBranchInputFactory {
   }
 
   public Input<DefaultIssue> create(Component component) {
-    String referenceBranchComponentUuid = referenceBranchComponentUuids.getComponentUuid(component.getDbKey());
+    String referenceBranchComponentUuid = referenceBranchComponentUuids.getComponentUuid(component.getKey());
     return new ReferenceLazyInput(component.getType(), referenceBranchComponentUuid);
   }
 
index 01aa876990e1c1f70cd3376d49eae43d416c06f3..0a7b5fcae60395081dfc37379774a8fcf2820750 100644 (file)
@@ -49,7 +49,7 @@ public class TrackerSourceBranchInputFactory {
   }
 
   public Input<DefaultIssue> createForSourceBranch(Component component) {
-    String sourceBranchComponentUuid = sourceBranchComponentUuids.getSourceBranchComponentUuid(component.getDbKey());
+    String sourceBranchComponentUuid = sourceBranchComponentUuids.getSourceBranchComponentUuid(component.getKey());
     return new SourceBranchLazyInput(component.getType(), sourceBranchComponentUuid);
   }
 
index 326a9ff2e3d661fd4680b8b9574c65351157c1fa..1e28a40b382858015db93edf1a3e0c3f8e3713d5 100644 (file)
@@ -50,7 +50,7 @@ public class TrackerTargetBranchInputFactory {
   }
 
   public Input<DefaultIssue> createForTargetBranch(Component component) {
-    String targetBranchComponentUuid = targetBranchComponentUuids.getTargetBranchComponentUuid(component.getDbKey());
+    String targetBranchComponentUuid = targetBranchComponentUuids.getTargetBranchComponentUuid(component.getKey());
     return new TargetLazyInput(component.getType(), targetBranchComponentUuid);
   }
 
index 18ea64976ee294df41c78e61ca83c39825e3c97c..187699ee7c9fd77b3fcdb44d5de36ddb5e520ca7 100644 (file)
@@ -70,7 +70,7 @@ public final class MapBasedRawMeasureRepository<T> implements MeasureRepository
       throw new UnsupportedOperationException(
         format(
           "a measure can be set only once for a specific Component (key=%s), Metric (key=%s). Use update method",
-          component.getDbKey(),
+          component.getKey(),
           metric.getKey()));
     }
     add(component, metric, measure, OverridePolicy.OVERRIDE);
@@ -86,7 +86,7 @@ public final class MapBasedRawMeasureRepository<T> implements MeasureRepository
       throw new UnsupportedOperationException(
         format(
           "a measure can be updated only if one already exists for a specific Component (key=%s), Metric (key=%s). Use add method",
-          component.getDbKey(),
+          component.getKey(),
           metric.getKey()));
     }
     add(component, metric, measure, OverridePolicy.OVERRIDE);
index d57e0b0c489c0c99d9ab345dd50fc2c5f16923ae..c45a933d1d32b61e2dde1fe82bc77b558e89e3c3 100644 (file)
@@ -68,7 +68,7 @@ public class NewCodeReferenceBranchComponentUuids {
     boolean hasReferenceBranchAnalysis = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(dbSession, referenceBranchUuid).isPresent();
 
     if (hasReferenceBranchAnalysis) {
-      List<ComponentDto> components = dbClient.componentDao().selectByProjectUuid(referenceBranchUuid, dbSession);
+      List<ComponentDto> components = dbClient.componentDao().selectByBranchUuid(referenceBranchUuid, dbSession);
       for (ComponentDto dto : components) {
         referenceBranchComponentsUuidsByKey.put(dto.getKey(), dto.uuid());
       }
index fc35319a17f846119620d6ee827b1948644e7e6b..a6741048cc94ab8ebc63216e8bd3555a764b2b7a 100644 (file)
@@ -83,7 +83,7 @@ public class ScmInfoDbLoader {
     }
 
     if (isReferenceBranch()) {
-      var referencedBranchComponentUuid = newCodeReferenceBranchComponentUuids.getComponentUuid(file.getDbKey());
+      var referencedBranchComponentUuid = newCodeReferenceBranchComponentUuids.getComponentUuid(file.getKey());
       if (referencedBranchComponentUuid != null) {
         return Optional.of(referencedBranchComponentUuid);
       }
@@ -94,7 +94,7 @@ public class ScmInfoDbLoader {
     // at this point, it's the first analysis of a branch with copyFromPrevious flag true or any analysis of a PR
     Branch branch = analysisMetadataHolder.getBranch();
     if (!branch.isMain()) {
-      return Optional.ofNullable(referenceBranchComponentUuid.getComponentUuid(file.getDbKey()));
+      return Optional.ofNullable(referenceBranchComponentUuid.getComponentUuid(file.getKey()));
     }
 
     return Optional.empty();
index 609a3e942e98c55697ab3967ddf646731f09758e..ae9ae38d6379e8514a5b8ee2a9c5c798e176f537 100644 (file)
@@ -69,7 +69,7 @@ public class ScmInfoRepositoryImpl implements ScmInfoRepository {
     ScannerReport.Changesets changesets = scannerReportReader.readChangesets(component.getReportAttributes().getRef());
 
     if (changesets == null) {
-      LOGGER.trace("No SCM info for file '{}'", component.getDbKey());
+      LOGGER.trace("No SCM info for file '{}'", component.getKey());
       // SCM not available. It might have been available before - copy information for unchanged lines but don't keep author and revision.
       return generateAndMergeDb(component, false);
     }
@@ -82,7 +82,7 @@ public class ScmInfoRepositoryImpl implements ScmInfoRepository {
   }
 
   private static Optional<ScmInfo> getScmInfoFromReport(Component file, ScannerReport.Changesets changesets) {
-    LOGGER.trace("Reading SCM info from report for file '{}'", file.getDbKey());
+    LOGGER.trace("Reading SCM info from report for file '{}'", file.getKey());
     return Optional.of(ReportScmInfo.create(changesets));
   }
 
index 2ebe386f67067cba6d6c91461b2710f6d0dfa4a3..432ac99ff8a1887befc602de018fbb02625c8440 100644 (file)
@@ -74,7 +74,7 @@ public class DbLineHashVersion {
   @CheckForNull
   private String getReferenceComponentUuid(Component component) {
     if (analysisMetadataHolder.isPullRequest()) {
-      return referenceBranchComponentUuids.getComponentUuid(component.getDbKey());
+      return referenceBranchComponentUuids.getComponentUuid(component.getKey());
     } else {
       return component.getUuid();
     }
index 7748b6206f337be71a487467cb9b90ccd7099f53..8bbed5af9c8cbebfe20b8ecedb021aec0043f270 100644 (file)
@@ -96,7 +96,7 @@ public class PersistFileSourcesStep implements ComputationStep {
         FileSourceDataComputer.Data fileSourceData = fileSourceDataComputer.compute(file, fileSourceDataWarnings);
         persistSource(fileSourceData, file);
       } catch (Exception e) {
-        throw new IllegalStateException(String.format("Cannot persist sources of %s", file.getDbKey()), e);
+        throw new IllegalStateException(String.format("Cannot persist sources of %s", file.getKey()), e);
       }
     }
 
index c2d81df3cdd5d80bd900c204e788776016da5d2c..6c08682bd6222e9c3b35a5350e7689aa9b48c2be 100644 (file)
@@ -43,12 +43,12 @@ public class SourceHashRepositoryImpl implements SourceHashRepository {
   @Override
   public String getRawSourceHash(Component file) {
     checkComponentArgument(file);
-    if (rawSourceHashesByKey.containsKey(file.getDbKey())) {
-      return checkSourceHash(file.getDbKey(), rawSourceHashesByKey.get(file.getDbKey()));
+    if (rawSourceHashesByKey.containsKey(file.getKey())) {
+      return checkSourceHash(file.getKey(), rawSourceHashesByKey.get(file.getKey()));
     } else {
       String newSourceHash = computeRawSourceHash(file);
-      rawSourceHashesByKey.put(file.getDbKey(), newSourceHash);
-      return checkSourceHash(file.getDbKey(), newSourceHash);
+      rawSourceHashesByKey.put(file.getKey(), newSourceHash);
+      return checkSourceHash(file.getKey(), newSourceHash);
     }
   }
 
index 17c9e49775ce212b08eddd3790821672f7e669f8..2774ea8330935c88df942166d310e5bf2880e700 100644 (file)
@@ -69,9 +69,9 @@ public class SourceLinesDiffImpl implements SourceLinesDiff {
     try (DbSession dbSession = dbClient.openSession(false)) {
       String uuid;
       if (analysisMetadataHolder.isPullRequest()) {
-        uuid = referenceBranchComponentUuids.getComponentUuid(component.getDbKey());
+        uuid = referenceBranchComponentUuids.getComponentUuid(component.getKey());
       } else if (periodHolder.hasPeriod() && periodHolder.getPeriod().getMode().equals(NewCodePeriodType.REFERENCE_BRANCH.name())) {
-        uuid = newCodeReferenceBranchComponentUuids.getComponentUuid(component.getDbKey());
+        uuid = newCodeReferenceBranchComponentUuids.getComponentUuid(component.getKey());
       } else {
         Optional<MovedFilesRepository.OriginalFile> originalFile = movedFilesRepository.getOriginalFile(component);
         uuid = originalFile.map(MovedFilesRepository.OriginalFile::getUuid).orElse(component.getUuid());
index 02fabbadb64b69f255c6c01970286a8da55473d6..aa62cb9a48f22848d746f0a521d7a7cf5f46782e 100644 (file)
@@ -80,7 +80,7 @@ public class HighlightingLineReader implements LineReader {
         processHighlightings(lineBuilder);
       } catch (RangeOffsetConverterException e) {
         readError = new ReadError(HIGHLIGHTING, lineBuilder.getLine());
-        LOG.debug(format("Inconsistency detected in Highlighting data. Highlighting will be ignored for file '%s'", file.getDbKey()), e);
+        LOG.debug(format("Inconsistency detected in Highlighting data. Highlighting will be ignored for file '%s'", file.getKey()), e);
       }
     }
     return Optional.ofNullable(readError);
index 17e36140311b820084a1ed9ad0f32eef1226ae87..262e88e4cd04b9ac237b7cd1b05a59bf700ea5d1 100644 (file)
@@ -72,7 +72,7 @@ public class SymbolsLineReader implements LineReader {
         processSymbols(lineBuilder);
       } catch (RangeOffsetConverter.RangeOffsetConverterException e) {
         readError = new ReadError(Data.SYMBOLS, lineBuilder.getLine());
-        LOG.warn(format("Inconsistency detected in Symbols data. Symbols will be ignored for file '%s'", file.getDbKey()), e);
+        LOG.warn(format("Inconsistency detected in Symbols data. Symbols will be ignored for file '%s'", file.getKey()), e);
       }
     }
     return Optional.ofNullable(readError);
index 15b3dc5a7926b3ccc1b61a49ac2d767f42b7077e..6607b973a75a0ed8826f29f76e0291cfd223218b 100644 (file)
@@ -23,14 +23,12 @@ import java.util.Optional;
 import java.util.function.Function;
 import javax.annotation.Nullable;
 import org.sonar.ce.task.projectanalysis.analysis.Analysis;
-import org.sonar.ce.task.projectanalysis.analysis.Branch;
 import org.sonar.ce.task.projectanalysis.analysis.MutableAnalysisMetadataHolder;
 import org.sonar.ce.task.projectanalysis.batch.BatchReportReader;
 import org.sonar.ce.task.projectanalysis.component.Component;
 import org.sonar.ce.task.projectanalysis.component.ComponentKeyGenerator;
 import org.sonar.ce.task.projectanalysis.component.ComponentTreeBuilder;
 import org.sonar.ce.task.projectanalysis.component.ComponentUuidFactoryWithMigration;
-import org.sonar.ce.task.projectanalysis.component.DefaultBranchImpl;
 import org.sonar.ce.task.projectanalysis.component.MutableTreeRootHolder;
 import org.sonar.ce.task.projectanalysis.component.ProjectAttributes;
 import org.sonar.ce.task.projectanalysis.component.ReportModulesPath;
@@ -75,7 +73,6 @@ public class BuildComponentTreeStep implements ComputationStep {
     try (DbSession dbSession = dbClient.openSession(false)) {
       ScannerReport.Component reportProject = reportReader.readComponent(analysisMetadataHolder.getRootComponentRef());
       ComponentKeyGenerator keyGenerator = loadKeyGenerator();
-      ComponentKeyGenerator publicKeyGenerator = loadPublicKeyGenerator();
       ScannerReport.Metadata metadata = reportReader.readMetadata();
 
       // root key of branch, not necessarily of project
@@ -87,7 +84,7 @@ public class BuildComponentTreeStep implements ComputationStep {
       String rootUuid = componentUuidFactoryWithMigration.getOrCreateForKey(rootKey);
       Optional<SnapshotDto> baseAnalysis = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(dbSession, rootUuid);
 
-      ComponentTreeBuilder builder = new ComponentTreeBuilder(keyGenerator, publicKeyGenerator,
+      ComponentTreeBuilder builder = new ComponentTreeBuilder(keyGenerator,
         componentUuidFactoryWithMigration::getOrCreateForKey,
         reportReader::readComponent,
         analysisMetadataHolder.getProject(),
@@ -131,16 +128,6 @@ public class BuildComponentTreeStep implements ComputationStep {
     return analysisMetadataHolder.getBranch();
   }
 
-  private ComponentKeyGenerator loadPublicKeyGenerator() {
-    Branch branch = analysisMetadataHolder.getBranch();
-
-    // for non-legacy branches, the public key is different from the DB key.
-    if (!branch.isMain()) {
-      return new DefaultBranchImpl();
-    }
-    return branch;
-  }
-
   private static Analysis toAnalysis(SnapshotDto dto) {
     return new Analysis.Builder()
       .setUuid(dto.getUuid())
index db681383f585e4d73d2dc08d1504a32b5d65ba47..c1a4c03ff0a80b5d250836c31a907cb34e135e89 100644 (file)
@@ -100,7 +100,7 @@ public class LoadCrossProjectDuplicationsRepositoryStep implements ComputationSt
           cpdTextBlocks.add(blocksIt.next());
         }
       }
-      LOGGER.trace("Found {} cpd blocks on file {}", cpdTextBlocks.size(), file.getDbKey());
+      LOGGER.trace("Found {} cpd blocks on file {}", cpdTextBlocks.size(), file.getKey());
       if (cpdTextBlocks.isEmpty()) {
         return;
       }
@@ -112,8 +112,8 @@ public class LoadCrossProjectDuplicationsRepositoryStep implements ComputationSt
       }
 
       Collection<Block> duplicatedBlocks = dtos.stream().map(DtoToBlock.INSTANCE).collect(Collectors.toList());
-      Collection<Block> originBlocks = cpdTextBlocks.stream().map(new CpdTextBlockToBlock(file.getDbKey())).collect(Collectors.toList());
-      LOGGER.trace("Found {} duplicated cpd blocks on file {}", duplicatedBlocks.size(), file.getDbKey());
+      Collection<Block> originBlocks = cpdTextBlocks.stream().map(new CpdTextBlockToBlock(file.getKey())).collect(Collectors.toList());
+      LOGGER.trace("Found {} duplicated cpd blocks on file {}", duplicatedBlocks.size(), file.getKey());
 
       integrateCrossProjectDuplications.computeCpd(file, originBlocks, duplicatedBlocks);
     }
index 390f67cf315e803ca1cef11b8d98dab5752f46d9..16adb079fbdae2273777bec29f4d7e56c933cbbd 100644 (file)
@@ -139,7 +139,7 @@ public class PersistComponentsStep implements ComputationStep {
       if (Component.Type.VIEW == root.getType()) {
         return false;
       }
-      throw new IllegalStateException(String.format("The project '%s' is not stored in the database, during a project analysis.", root.getDbKey()));
+      throw new IllegalStateException(String.format("The project '%s' is not stored in the database, during a project analysis.", root.getKey()));
     }
     return rootDto.isPrivate();
   }
@@ -149,7 +149,7 @@ public class PersistComponentsStep implements ComputationStep {
    * disabled components.
    */
   private Map<String, ComponentDto> indexExistingDtosByUuids(DbSession session) {
-    return dbClient.componentDao().selectAllComponentsFromProjectKey(session, treeRootHolder.getRoot().getDbKey())
+    return dbClient.componentDao().selectAllComponentsFromProjectKey(session, treeRootHolder.getRoot().getKey())
       .stream()
       .collect(Collectors.toMap(ComponentDto::uuid, Function.identity()));
   }
@@ -237,7 +237,7 @@ public class PersistComponentsStep implements ComputationStep {
 
         // update the fields in memory in order the PathAwareVisitor.Path
         // to be up-to-date
-        existingComponent.setDbKey(updateDto.getBKey());
+        existingComponent.setKey(updateDto.getBKey());
         existingComponent.setCopyComponentUuid(updateDto.getBCopyComponentUuid());
         existingComponent.setDescription(updateDto.getBDescription());
         existingComponent.setEnabled(updateDto.isBEnabled());
@@ -264,7 +264,7 @@ public class PersistComponentsStep implements ComputationStep {
       res.setLongName(res.name());
       res.setDescription(project.getDescription());
 
-      res.setProjectUuid(res.uuid());
+      res.setBranchUuid(res.uuid());
       res.setRootUuid(res.uuid());
       res.setUuidPath(UUID_PATH_OF_ROOT);
       res.setModuleUuidPath(UUID_PATH_SEPARATOR + res.uuid() + UUID_PATH_SEPARATOR);
@@ -310,7 +310,7 @@ public class PersistComponentsStep implements ComputationStep {
       res.setDescription(view.getDescription());
       res.setLongName(res.name());
 
-      res.setProjectUuid(res.uuid());
+      res.setBranchUuid(res.uuid());
       res.setRootUuid(res.uuid());
       res.setUuidPath(UUID_PATH_OF_ROOT);
       res.setModuleUuidPath(UUID_PATH_SEPARATOR + res.uuid() + UUID_PATH_SEPARATOR);
@@ -348,12 +348,12 @@ public class PersistComponentsStep implements ComputationStep {
     }
 
     private ComponentDto createBase(Component component) {
-      String componentKey = component.getDbKey();
+      String componentKey = component.getKey();
       String componentUuid = component.getUuid();
 
       ComponentDto componentDto = new ComponentDto();
       componentDto.setUuid(componentUuid);
-      componentDto.setDbKey(componentKey);
+      componentDto.setKey(componentKey);
       componentDto.setMainBranchProjectUuid(mainBranchProjectUuid);
       componentDto.setEnabled(true);
       componentDto.setCreatedAt(new Date(system2.now()));
@@ -367,7 +367,7 @@ public class PersistComponentsStep implements ComputationStep {
     private void setRootAndParentModule(ComponentDto res, PathAwareVisitor.Path<ComponentDtoHolder> path) {
       ComponentDto rootDto = path.root().getDto();
       res.setRootUuid(rootDto.uuid());
-      res.setProjectUuid(rootDto.uuid());
+      res.setBranchUuid(rootDto.uuid());
 
       ComponentDto parentModule = path.parent().getDto();
       res.setUuidPath(formatUuidPathFromParent(parentModule));
@@ -380,7 +380,7 @@ public class PersistComponentsStep implements ComputationStep {
    * Applies to a node of type either DIRECTORY or FILE
    */
   private static void setParentModuleProperties(ComponentDto componentDto, PathAwareVisitor.Path<ComponentDtoHolder> path) {
-    componentDto.setProjectUuid(path.root().getDto().uuid());
+    componentDto.setBranchUuid(path.root().getDto().uuid());
 
     ComponentDto parentModule = StreamSupport.stream(path.getCurrentPath().spliterator(), false)
       .filter(p -> p.getComponent().getType() == Component.Type.PROJECT)
@@ -397,7 +397,7 @@ public class PersistComponentsStep implements ComputationStep {
   private static Optional<ComponentUpdateDto> compareForUpdate(ComponentDto existing, ComponentDto target) {
     boolean hasDifferences = !StringUtils.equals(existing.getCopyComponentUuid(), target.getCopyComponentUuid()) ||
       !StringUtils.equals(existing.description(), target.description()) ||
-      !StringUtils.equals(existing.getDbKey(), target.getDbKey()) ||
+      !StringUtils.equals(existing.getKey(), target.getKey()) ||
       !existing.isEnabled() ||
       !StringUtils.equals(existing.getUuidPath(), target.getUuidPath()) ||
       !StringUtils.equals(existing.language(), target.language()) ||
index 1f5a175952e9c50d4b7f157939caf7d68acd21d2..9d61445def2095136f8d67fa0fa2d65164ece22a 100644 (file)
@@ -106,7 +106,7 @@ public class PersistDuplicationDataStep implements ComputationStep {
     }
 
     private void computeDuplications(Component component, Iterable<Duplication> duplications) {
-      Measure measure = generateMeasure(component.getDbKey(), duplications);
+      Measure measure = generateMeasure(component.getKey(), duplications);
       LiveMeasureDto dto = measureToMeasureDto.toLiveMeasureDto(measure, duplicationDataMetric, component);
       nonPersistedBuffer.add(dto);
       persist(false);
@@ -161,10 +161,10 @@ public class PersistDuplicationDataStep implements ComputationStep {
         appendDuplication(xml, componentDbKey, duplicate);
       } else if (duplicate instanceof InExtendedProjectDuplicate) {
         // Duplication is on a different file that is not saved in the DB
-        appendDuplication(xml, ((InExtendedProjectDuplicate) duplicate).getFile().getDbKey(), duplicate.getTextBlock(), true);
+        appendDuplication(xml, ((InExtendedProjectDuplicate) duplicate).getFile().getKey(), duplicate.getTextBlock(), true);
       } else if (duplicate instanceof InProjectDuplicate) {
         // Duplication is on a different file
-        appendDuplication(xml, ((InProjectDuplicate) duplicate).getFile().getDbKey(), duplicate);
+        appendDuplication(xml, ((InProjectDuplicate) duplicate).getFile().getKey(), duplicate);
       } else if (duplicate instanceof CrossProjectDuplicate) {
         // Only componentKey is set for cross project duplications
         String crossProjectComponentKey = ((CrossProjectDuplicate) duplicate).getFileKey();
index 6f509796b8dd68950330de1f88ae3583c3a0e41a..0fcf5a36bb6478fe3a90874aeb3bf69929166ab1 100644 (file)
@@ -105,7 +105,7 @@ public class QualityGateEventsStep implements ComputationStep {
     }
 
     if (!baseMeasure.get().hasQualityGateStatus()) {
-      LOGGER.warn(String.format("Previous Quality gate status for project %s is not a supported value. Can not compute Quality Gate event", project.getDbKey()));
+      LOGGER.warn(String.format("Previous Quality gate status for project %s is not a supported value. Can not compute Quality Gate event", project.getKey()));
       checkNewQualityGate(project, rawStatus);
       return;
     }
index ab661165bcfbfd2acd8e22e0074c64a63c16f0f7..52716dd4e90307f3a666a79a423ec2c806113f2a 100644 (file)
@@ -67,8 +67,8 @@ public class ValidateProjectStep implements ComputationStep {
       validateTargetBranch(dbSession);
       Component root = treeRootHolder.getRoot();
       // FIXME if module have really be dropped, no more need to load them
-      List<ComponentDto> baseModules = dbClient.componentDao().selectEnabledModulesFromProjectKey(dbSession, root.getDbKey());
-      Map<String, ComponentDto> baseModulesByKey = baseModules.stream().collect(Collectors.toMap(ComponentDto::getDbKey, x -> x));
+      List<ComponentDto> baseModules = dbClient.componentDao().selectEnabledModulesFromProjectKey(dbSession, root.getKey());
+      Map<String, ComponentDto> baseModulesByKey = baseModules.stream().collect(Collectors.toMap(ComponentDto::getKey, x -> x));
       ValidateProjectsVisitor visitor = new ValidateProjectsVisitor(dbSession, dbClient.componentDao(), baseModulesByKey);
       new DepthTraversalTypeAwareCrawler(visitor).visit(root);
 
@@ -83,7 +83,7 @@ public class ValidateProjectStep implements ComputationStep {
       return;
     }
     String referenceBranchUuid = analysisMetadataHolder.getBranch().getReferenceBranchUuid();
-    int moduleCount = dbClient.componentDao().countEnabledModulesByProjectUuid(session, referenceBranchUuid);
+    int moduleCount = dbClient.componentDao().countEnabledModulesByBranchUuid(session, referenceBranchUuid);
     if (moduleCount > 0) {
       Optional<BranchDto> opt = dbClient.branchDao().selectByUuid(session, referenceBranchUuid);
       checkState(opt.isPresent(), "Reference branch '%s' does not exist", referenceBranchUuid);
@@ -112,7 +112,7 @@ public class ValidateProjectStep implements ComputationStep {
 
     @Override
     public void visitProject(Component rawProject) {
-      String rawProjectKey = rawProject.getDbKey();
+      String rawProjectKey = rawProject.getKey();
       Optional<ComponentDto> baseProjectOpt = loadBaseComponent(rawProjectKey);
       if (baseProjectOpt.isPresent()) {
         ComponentDto baseProject = baseProjectOpt.get();
index b0fbb6b12e1a8f1ea73e9472c8085f4ddd2a6347..d2505d8f20a130ba3dfd531c7217531b6f6af02b 100644 (file)
@@ -45,9 +45,9 @@ public class ExportComponentsStep implements ComputationStep {
   private static final String QUERY = "select" +
     " p.uuid, p.qualifier, p.uuid_path, p.kee, p.name," +
     " p.description, p.scope, p.language, p.long_name, p.path," +
-    " p.module_uuid, p.module_uuid_path, p.deprecated_kee, p.project_uuid, p.main_branch_project_uuid" +
+    " p.module_uuid, p.module_uuid_path, p.deprecated_kee, p.branch_uuid, p.main_branch_project_uuid" +
     " from components p" +
-    " join components pp on pp.uuid = p.project_uuid" +
+    " join components pp on pp.uuid = p.branch_uuid" +
     " join project_branches pb on pb.uuid = pp.uuid" +
     " where pb.project_uuid=? and pb.branch_type = 'BRANCH' and pb.exclude_from_purge=? and p.enabled=?";
   private final DbClient dbClient;
index d78c4252d373cc2234e1a93ee1b261ee29944415..cf6baffad0ea8920375a1d3fd2765fcc69361fa9 100644 (file)
@@ -42,7 +42,7 @@ public class ProjectDescriptor {
    * Build a {@link ProjectDescriptor} without checking qualifier of ComponentDto.
    */
   public static ProjectDescriptor of(ComponentDto project) {
-    return new ProjectDescriptor(project.uuid(), project.getDbKey(), project.name());
+    return new ProjectDescriptor(project.uuid(), project.getKey(), project.name());
   }
 
   public final String getUuid() {
index 19bd1e9196107a97b50af545c3d8308736fc347f..5c2fe225db9d476a98728bec10d2fd14d293f948 100644 (file)
@@ -57,7 +57,7 @@ public class AnalysisFromSonarQube94VisitorTest {
   @Test
   public void visitProject_createMeasureForMetric() {
     Component project = builder(FILE).setUuid("uuid")
-      .setDbKey("dbKey")
+      .setKey("dbKey")
       .setName("name")
       .setStatus(Component.Status.SAME)
       .setReportAttributes(mock(ReportAttributes.class))
index fb727aa27b85ee678dc672c89cdad4ed8699e3cc..f6c512561db72e77e19864309187c3a76cd4520a 100644 (file)
@@ -57,7 +57,7 @@ public class ProjectConfigurationFactoryTest {
       newComponentPropertyDto(project).setKey("2").setValue("val2"),
       newComponentPropertyDto(project).setKey("3").setValue("val3"));
 
-    Configuration config = underTest.newProjectConfiguration(project.getDbKey(), new DefaultBranchImpl());
+    Configuration config = underTest.newProjectConfiguration(project.getKey(), new DefaultBranchImpl());
 
     assertThat(config.get("1")).hasValue("val1");
     assertThat(config.get("2")).hasValue("val2");
@@ -71,7 +71,7 @@ public class ProjectConfigurationFactoryTest {
     db.properties().insertProperties(null, project.getKey(), project.name(), project.qualifier(),
       newComponentPropertyDto(project).setKey("key").setValue("value2"));
 
-    Configuration projectConfig = underTest.newProjectConfiguration(project.getDbKey(), new DefaultBranchImpl());
+    Configuration projectConfig = underTest.newProjectConfiguration(project.getKey(), new DefaultBranchImpl());
 
     assertThat(projectConfig.get("key")).hasValue("value2");
   }
index f441e18eed9db20d2c29b468d1c6dc291903b187..b87bd61a7d9557084b8515bbe767ea343a8bbb0a 100644 (file)
@@ -104,7 +104,7 @@ public class BranchPersisterImplTest {
     String branchName = "branch";
 
     // add project and branch in table PROJECTS
-    ComponentDto mainComponent = ComponentTesting.newPrivateProjectDto(MAIN.getUuid()).setDbKey(MAIN.getKey());
+    ComponentDto mainComponent = ComponentTesting.newPrivateProjectDto(MAIN.getUuid()).setKey(MAIN.getKey());
     ComponentDto component = ComponentTesting.newBranchComponent(mainComponent,
       new BranchDto().setUuid(BRANCH1.getUuid()).setKey(BRANCH1.getKey()).setBranchType(BRANCH));
     dbTester.components().insertComponents(mainComponent, component);
@@ -131,7 +131,7 @@ public class BranchPersisterImplTest {
   public void main_branch_is_excluded_from_branch_purge_by_default() {
     analysisMetadataHolder.setBranch(createBranch(BRANCH, true, "master"));
     treeRootHolder.setRoot(MAIN);
-    dbTester.components().insertPublicProject(p -> p.setDbKey(MAIN.getDbKey()).setUuid(MAIN.getUuid()));
+    dbTester.components().insertPublicProject(p -> p.setKey(MAIN.getKey()).setUuid(MAIN.getUuid()));
     dbTester.commit();
 
     underTest.persist(dbTester.getSession());
@@ -147,7 +147,7 @@ public class BranchPersisterImplTest {
     analysisMetadataHolder.setProject(PROJECT);
     analysisMetadataHolder.setBranch(createBranch(BRANCH, false, "BRANCH_KEY"));
     treeRootHolder.setRoot(BRANCH1);
-    ComponentDto mainComponent = dbTester.components().insertPublicProject(p -> p.setDbKey(MAIN.getDbKey()).setUuid(MAIN.getUuid()));
+    ComponentDto mainComponent = dbTester.components().insertPublicProject(p -> p.setKey(MAIN.getKey()).setUuid(MAIN.getUuid()));
     ComponentDto component = ComponentTesting.newBranchComponent(mainComponent,
       new BranchDto().setUuid(BRANCH1.getUuid()).setKey(BRANCH1.getKey()).setBranchType(BRANCH));
     dbTester.getDbClient().componentDao().insert(dbTester.getSession(), component);
@@ -165,7 +165,7 @@ public class BranchPersisterImplTest {
     analysisMetadataHolder.setProject(PROJECT);
     analysisMetadataHolder.setBranch(createBranch(BRANCH, false, "BRANCH_KEY"));
     treeRootHolder.setRoot(BRANCH1);
-    ComponentDto mainComponent = dbTester.components().insertPublicProject(p -> p.setDbKey(MAIN.getDbKey()).setUuid(MAIN.getUuid()));
+    ComponentDto mainComponent = dbTester.components().insertPublicProject(p -> p.setKey(MAIN.getKey()).setUuid(MAIN.getUuid()));
     ComponentDto component = ComponentTesting.newBranchComponent(mainComponent,
       new BranchDto().setUuid(BRANCH1.getUuid()).setKey(BRANCH1.getKey()).setBranchType(BRANCH));
     dbTester.getDbClient().componentDao().insert(dbTester.getSession(), component);
@@ -184,7 +184,7 @@ public class BranchPersisterImplTest {
     analysisMetadataHolder.setProject(PROJECT);
     analysisMetadataHolder.setBranch(createBranch(BRANCH, false, "BRANCH_KEY"));
     treeRootHolder.setRoot(BRANCH1);
-    ComponentDto mainComponent = dbTester.components().insertPublicProject(p -> p.setDbKey(MAIN.getDbKey()).setUuid(MAIN.getUuid()));
+    ComponentDto mainComponent = dbTester.components().insertPublicProject(p -> p.setKey(MAIN.getKey()).setUuid(MAIN.getUuid()));
     ComponentDto component = ComponentTesting.newBranchComponent(mainComponent,
       new BranchDto().setUuid(BRANCH1.getUuid()).setKey(BRANCH1.getKey()).setBranchType(BRANCH));
     dbTester.getDbClient().componentDao().insert(dbTester.getSession(), component);
@@ -205,7 +205,7 @@ public class BranchPersisterImplTest {
     analysisMetadataHolder.setBranch(createPullRequest(PR1.getKey(), MAIN.getUuid()));
     analysisMetadataHolder.setPullRequestKey(PR1.getKey());
     treeRootHolder.setRoot(PR1);
-    ComponentDto mainComponent = dbTester.components().insertPublicProject(p -> p.setDbKey(MAIN.getDbKey()).setUuid(MAIN.getUuid()));
+    ComponentDto mainComponent = dbTester.components().insertPublicProject(p -> p.setKey(MAIN.getKey()).setUuid(MAIN.getUuid()));
     ComponentDto component = ComponentTesting.newBranchComponent(mainComponent, new BranchDto()
       .setUuid(PR1.getUuid())
       .setKey(PR1.getKey())
@@ -228,7 +228,7 @@ public class BranchPersisterImplTest {
     analysisMetadataHolder.setProject(PROJECT);
     analysisMetadataHolder.setBranch(createBranch(BRANCH, false, "BRANCH_KEY"));
     treeRootHolder.setRoot(BRANCH1);
-    ComponentDto mainComponent = dbTester.components().insertPublicProject(p -> p.setDbKey(MAIN.getDbKey()).setUuid(MAIN.getUuid()));
+    ComponentDto mainComponent = dbTester.components().insertPublicProject(p -> p.setKey(MAIN.getKey()).setUuid(MAIN.getUuid()));
     ComponentDto component = ComponentTesting.newBranchComponent(mainComponent,
       new BranchDto().setUuid(BRANCH1.getUuid()).setKey(BRANCH1.getKey()).setBranchType(BRANCH));
     dbTester.getDbClient().componentDao().insert(dbTester.getSession(), component);
@@ -254,7 +254,7 @@ public class BranchPersisterImplTest {
     String pullRequestId = "pr-123";
 
     // add project and branch in table PROJECTS
-    ComponentDto mainComponent = ComponentTesting.newPrivateProjectDto(MAIN.getUuid()).setDbKey(MAIN.getKey());
+    ComponentDto mainComponent = ComponentTesting.newPrivateProjectDto(MAIN.getUuid()).setKey(MAIN.getKey());
     ComponentDto component = ComponentTesting.newBranchComponent(mainComponent,
       new BranchDto().setUuid(BRANCH1.getUuid()).setKey(BRANCH1.getKey()).setBranchType(PULL_REQUEST));
     dbTester.components().insertComponents(mainComponent, component);
index 945490fb4c2951e4bb3ec0a738823bdba6200658..9069b69b66fc5b74d2d6a5f806f8de75eaea9620 100644 (file)
@@ -34,7 +34,7 @@ class CallRecorderPathAwareVisitor extends PathAwareVisitorAdapter<Integer> {
     super(maxDepth, order, new SimpleStackElementFactory<Integer>() {
       @Override
       public Integer createForAny(Component component) {
-        return component.getType().isReportType() ? component.getReportAttributes().getRef() : Integer.valueOf(component.getDbKey());
+        return component.getType().isReportType() ? component.getReportAttributes().getRef() : Integer.valueOf(component.getKey());
       }
     });
   }
@@ -80,7 +80,7 @@ class CallRecorderPathAwareVisitor extends PathAwareVisitorAdapter<Integer> {
   }
 
   private static PathAwareCallRecord viewsCallRecord(Component component, Path<Integer> path, String method) {
-    return PathAwareCallRecord.viewsCallRecord(method, component.getDbKey(), path.current(), getParent(path), path.root(),
+    return PathAwareCallRecord.viewsCallRecord(method, component.getKey(), path.current(), getParent(path), path.root(),
       toValueList(path));
   }
 
index 6d747471a1808c82f338290b8cedf514a7c0de47..b5e7b4fa33e64a948ab623beaf4ec279188dc290 100644 (file)
@@ -69,7 +69,7 @@ class CallRecorderTypeAwareVisitor extends TypeAwareVisitorAdapter {
   }
 
   private static CallRecord viewsCallRecord(Component component, String method) {
-    return CallRecord.viewsCallRecord(method, component.getDbKey());
+    return CallRecord.viewsCallRecord(method, component.getKey());
   }
 
 }
index 0f493b4db78d196ed8229fd1259380aff1d443ae..0e3ba073adc706172b8b4b784bbb1a63e158d37e 100644 (file)
@@ -43,7 +43,7 @@ public class ComponentImplTest {
   public void verify_key_uuid_and_name() {
     ComponentImpl component = buildSimpleComponent(FILE, KEY).setUuid(UUID).setName("name").build();
 
-    assertThat(component.getDbKey()).isEqualTo(KEY);
+    assertThat(component.getKey()).isEqualTo(KEY);
     assertThat(component.getUuid()).isEqualTo(UUID);
     assertThat(component.getName()).isEqualTo("name");
   }
@@ -65,7 +65,7 @@ public class ComponentImplTest {
     assertThatThrownBy(() -> {
       builder(Component.Type.DIRECTORY)
         .setName("DIR")
-        .setDbKey(KEY)
+        .setKey(KEY)
         .setUuid(UUID)
         .setReportAttributes(ReportAttributes.newBuilder(1).build())
         .build();
@@ -81,7 +81,7 @@ public class ComponentImplTest {
 
   @Test
   public void set_uuid_throws_NPE_if_component_arg_is_Null() {
-    assertThatThrownBy(() -> builder(FILE).setDbKey(null))
+    assertThatThrownBy(() -> builder(FILE).setKey(null))
       .isInstanceOf(NullPointerException.class);
   }
 
@@ -93,7 +93,7 @@ public class ComponentImplTest {
 
   @Test
   public void build_without_uuid_throws_NPE_if_component_arg_is_Null() {
-    assertThatThrownBy(() -> builder(FILE).setDbKey(KEY).build())
+    assertThatThrownBy(() -> builder(FILE).setKey(KEY).build())
       .isInstanceOf(NullPointerException.class);
   }
 
@@ -192,14 +192,14 @@ public class ComponentImplTest {
   public void build_with_child() {
     ComponentImpl child = builder(FILE)
       .setName("CHILD_NAME")
-      .setDbKey("CHILD_KEY")
+      .setKey("CHILD_KEY")
       .setUuid("CHILD_UUID")
       .setStatus(Status.UNAVAILABLE)
       .setReportAttributes(ReportAttributes.newBuilder(2).build())
       .build();
     ComponentImpl componentImpl = builder(Component.Type.DIRECTORY)
       .setName("DIR")
-      .setDbKey(KEY)
+      .setKey(KEY)
       .setUuid(UUID)
       .setStatus(Status.UNAVAILABLE)
       .setReportAttributes(ReportAttributes.newBuilder(1).build())
@@ -208,7 +208,7 @@ public class ComponentImplTest {
 
     assertThat(componentImpl.getChildren()).hasSize(1);
     Component childReloaded = componentImpl.getChildren().iterator().next();
-    assertThat(childReloaded.getDbKey()).isEqualTo("CHILD_KEY");
+    assertThat(childReloaded.getKey()).isEqualTo("CHILD_KEY");
     assertThat(childReloaded.getUuid()).isEqualTo("CHILD_UUID");
     assertThat(childReloaded.getType()).isEqualTo(FILE);
   }
@@ -234,7 +234,7 @@ public class ComponentImplTest {
   private static ComponentImpl.Builder buildSimpleComponent(Component.Type type, String dbKey) {
     ComponentImpl.Builder builder = builder(type)
       .setName("name_" + dbKey)
-      .setDbKey(dbKey)
+      .setKey(dbKey)
       .setStatus(Status.UNAVAILABLE)
       .setUuid("uuid_" + dbKey)
       .setReportAttributes(ReportAttributes.newBuilder(dbKey.hashCode()).build());
index c5b115aa8a2e17466333dae21a2d1a792dfa0fad..62f11b55be322cebcf8ba521ad413468a622a38f 100644 (file)
@@ -46,17 +46,14 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order.PRE_ORDER;
 import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
-import static org.sonar.scanner.protocol.output.ScannerReport.Component.newBuilder;
 import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.FILE;
 import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.PROJECT;
 import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.UNRECOGNIZED;
+import static org.sonar.scanner.protocol.output.ScannerReport.Component.newBuilder;
 
 public class ComponentTreeBuilderTest {
 
-  private static final ComponentKeyGenerator KEY_GENERATOR = (projectKey, path) -> "generated_"
-    + ComponentKeys.createEffectiveKey(projectKey, path);
-  private static final ComponentKeyGenerator PUBLIC_KEY_GENERATOR = (projectKey, path) -> "public_"
-    + ComponentKeys.createEffectiveKey(projectKey, path);
+  private static final ComponentKeyGenerator KEY_GENERATOR = (projectKey, path) -> "generated_" + ComponentKeys.createEffectiveKey(projectKey, path);
   private static final UnaryOperator<String> UUID_SUPPLIER = (componentKey) -> componentKey + "_uuid";
   private static final EnumSet<ScannerReport.Component.ComponentType> REPORT_TYPES = EnumSet.of(PROJECT, FILE);
   private static final String NO_SCM_BASE_PATH = "";
@@ -64,11 +61,10 @@ public class ComponentTreeBuilderTest {
   private static final ProjectAttributes SOME_PROJECT_ATTRIBUTES = new ProjectAttributes(
     randomAlphabetic(20), new Random().nextBoolean() ? null : randomAlphabetic(12), "1def5123");
 
-
   @Rule
   public ScannerComponentProvider scannerComponentProvider = new ScannerComponentProvider();
 
-  private Project projectInDb = Project.from(newPrivateProjectDto(UUID_SUPPLIER.apply("K1")).setDbKey("K1").setDescription(null));
+  private Project projectInDb = Project.from(newPrivateProjectDto(UUID_SUPPLIER.apply("K1")).setKey("K1").setDescription(null));
 
   @Test
   public void build_throws_IAE_for_all_types_except_PROJECT_and_FILE() {
@@ -130,8 +126,7 @@ public class ComponentTreeBuilderTest {
       .build(), NO_SCM_BASE_PATH, new ProjectAttributes("6.5", buildString, "4124af4"));
 
     assertThat(root.getUuid()).isEqualTo("generated_K1_uuid");
-    assertThat(root.getDbKey()).isEqualTo("generated_K1");
-    assertThat(root.getKey()).isEqualTo("public_K1");
+    assertThat(root.getKey()).isEqualTo("generated_K1");
     assertThat(root.getType()).isEqualTo(Component.Type.PROJECT);
     assertThat(root.getName()).isEqualTo(nameInReport);
     assertThat(root.getShortName()).isEqualTo(nameInReport);
@@ -294,18 +289,15 @@ public class ComponentTreeBuilderTest {
     ScannerReport.Component project = createProject();
 
     Component root = call(project);
-    assertThat(root.getDbKey()).isEqualTo("generated_" + projectInDb.getKey());
-    assertThat(root.getKey()).isEqualTo("public_" + projectInDb.getKey());
+    assertThat(root.getKey()).isEqualTo("generated_" + projectInDb.getKey());
     assertThat(root.getChildren()).hasSize(1);
 
     Component directory = root.getChildren().iterator().next();
-    assertThat(directory.getDbKey()).isEqualTo("generated_" + projectInDb.getKey() + ":src/js");
-    assertThat(directory.getKey()).isEqualTo("public_" + projectInDb.getKey() + ":src/js");
+    assertThat(directory.getKey()).isEqualTo("generated_" + projectInDb.getKey() + ":src/js");
     assertThat(directory.getChildren()).hasSize(1);
 
     Component file = directory.getChildren().iterator().next();
-    assertThat(file.getDbKey()).isEqualTo("generated_" + projectInDb.getKey() + ":src/js/Foo.js");
-    assertThat(file.getKey()).isEqualTo("public_" + projectInDb.getKey() + ":src/js/Foo.js");
+    assertThat(file.getKey()).isEqualTo("generated_" + projectInDb.getKey() + ":src/js/Foo.js");
     assertThat(file.getChildren()).isEmpty();
   }
 
@@ -359,21 +351,21 @@ public class ComponentTreeBuilderTest {
     assertThat(root.getChildren()).hasSize(2);
 
     Component pom = root.getChildren().get(1);
-    assertThat(pom.getKey()).isEqualTo("public_K1:pom.xml");
+    assertThat(pom.getKey()).isEqualTo("generated_K1:pom.xml");
     assertThat(pom.getName()).isEqualTo("pom.xml");
 
     Component directory = root.getChildren().get(0);
-    assertThat(directory.getKey()).isEqualTo("public_K1:src");
+    assertThat(directory.getKey()).isEqualTo("generated_K1:src");
     assertThat(directory.getName()).isEqualTo("src");
 
     // folders are collapsed and they only contain one directory
     Component d1 = directory.getChildren().get(0);
-    assertThat(d1.getKey()).isEqualTo("public_K1:src/main/xoo");
+    assertThat(d1.getKey()).isEqualTo("generated_K1:src/main/xoo");
     assertThat(d1.getName()).isEqualTo("src/main/xoo");
     assertThat(d1.getShortName()).isEqualTo("main/xoo");
 
     Component d2 = directory.getChildren().get(1);
-    assertThat(d2.getKey()).isEqualTo("public_K1:src/test/xoo/org/sonar");
+    assertThat(d2.getKey()).isEqualTo("generated_K1:src/test/xoo/org/sonar");
     assertThat(d2.getName()).isEqualTo("src/test/xoo/org/sonar");
     assertThat(d2.getShortName()).isEqualTo("test/xoo/org/sonar");
   }
@@ -396,12 +388,12 @@ public class ComponentTreeBuilderTest {
 
     // folders are collapsed and they only contain one directory
     Component dir = root.getChildren().get(0);
-    assertThat(dir.getKey()).isEqualTo("public_K1:src/test/xoo/org/sonar");
+    assertThat(dir.getKey()).isEqualTo("generated_K1:src/test/xoo/org/sonar");
     assertThat(dir.getName()).isEqualTo("src/test/xoo/org/sonar");
     assertThat(dir.getShortName()).isEqualTo("src/test/xoo/org/sonar");
 
     Component file = dir.getChildren().get(0);
-    assertThat(file.getKey()).isEqualTo("public_K1:src/test/xoo/org/sonar/Foo2.js");
+    assertThat(file.getKey()).isEqualTo("generated_K1:src/test/xoo/org/sonar/Foo2.js");
     assertThat(file.getName()).isEqualTo("src/test/xoo/org/sonar/Foo2.js");
     assertThat(file.getShortName()).isEqualTo("Foo2.js");
   }
@@ -423,12 +415,12 @@ public class ComponentTreeBuilderTest {
     Component root = call(project);
 
     Component directory = root.getChildren().iterator().next();
-    assertThat(directory.getKey()).isEqualTo("public_K1:src/js");
+    assertThat(directory.getKey()).isEqualTo("generated_K1:src/js");
     assertThat(directory.getName()).isEqualTo("src/js");
     assertThat(directory.getShortName()).isEqualTo("src/js");
 
     Component file = directory.getChildren().iterator().next();
-    assertThat(file.getKey()).isEqualTo("public_K1:src/js/Foo.js");
+    assertThat(file.getKey()).isEqualTo("generated_K1:src/js/Foo.js");
     assertThat(file.getName()).isEqualTo("src/js/Foo.js");
     assertThat(file.getShortName()).isEqualTo("Foo.js");
   }
@@ -484,22 +476,22 @@ public class ComponentTreeBuilderTest {
     Component root = call(project);
 
     Component directory = root.getChildren().iterator().next();
-    assertThat(directory.getKey()).isEqualTo("public_K1:src");
+    assertThat(directory.getKey()).isEqualTo("generated_K1:src");
     assertThat(directory.getName()).isEqualTo("src");
     assertThat(directory.getShortName()).isEqualTo("src");
 
     Component directoryJava = directory.getChildren().get(0);
-    assertThat(directoryJava.getKey()).isEqualTo("public_K1:src/java");
+    assertThat(directoryJava.getKey()).isEqualTo("generated_K1:src/java");
     assertThat(directoryJava.getName()).isEqualTo("src/java");
     assertThat(directoryJava.getShortName()).isEqualTo("java");
 
     Component directoryJs = directory.getChildren().get(1);
-    assertThat(directoryJs.getKey()).isEqualTo("public_K1:src/js");
+    assertThat(directoryJs.getKey()).isEqualTo("generated_K1:src/js");
     assertThat(directoryJs.getName()).isEqualTo("src/js");
     assertThat(directoryJs.getShortName()).isEqualTo("js");
 
     Component file = directoryJs.getChildren().iterator().next();
-    assertThat(file.getKey()).isEqualTo("public_K1:src/js/Foo.js");
+    assertThat(file.getKey()).isEqualTo("generated_K1:src/js/Foo.js");
     assertThat(file.getName()).isEqualTo("src/js/Foo.js");
     assertThat(file.getShortName()).isEqualTo("Foo.js");
   }
@@ -524,8 +516,7 @@ public class ComponentTreeBuilderTest {
     Component root = call(project);
     Map<String, Component> componentsByKey = indexComponentByKey(root);
 
-    assertThat(componentsByKey.values()).extracting("key").startsWith("public_project 1");
-    assertThat(componentsByKey.values()).extracting("dbKey").startsWith("generated_project 1");
+    assertThat(componentsByKey.values()).extracting("key").startsWith("generated_project 1");
   }
 
   @Test
@@ -740,7 +731,7 @@ public class ComponentTreeBuilderTest {
       .setType(FILE)
       .setProjectRelativePath("src/js/Foo.js"));
 
-    assertThatThrownBy(() ->  call(project))
+    assertThatThrownBy(() -> call(project))
       .isInstanceOf(IllegalArgumentException.class)
       .hasMessage("File 'src/js/Foo.js' has no line");
   }
@@ -758,7 +749,7 @@ public class ComponentTreeBuilderTest {
       .setProjectRelativePath("src/js/Foo.js")
       .setLines(0));
 
-    assertThatThrownBy(() ->  call(project))
+    assertThatThrownBy(() -> call(project))
       .isInstanceOf(IllegalArgumentException.class)
       .hasMessage("File 'src/js/Foo.js' has no line");
   }
@@ -776,7 +767,7 @@ public class ComponentTreeBuilderTest {
       .setProjectRelativePath("src/js/Foo.js")
       .setLines(-10));
 
-    assertThatThrownBy(() ->  call(project))
+    assertThatThrownBy(() -> call(project))
       .isInstanceOf(IllegalArgumentException.class)
       .hasMessage("File 'src/js/Foo.js' has no line");
   }
@@ -817,8 +808,7 @@ public class ComponentTreeBuilderTest {
   private ComponentTreeBuilder newUnderTest(ProjectAttributes projectAttributes, boolean mainBranch) {
     Branch branch = mock(Branch.class);
     when(branch.isMain()).thenReturn(mainBranch);
-    return new ComponentTreeBuilder(KEY_GENERATOR, PUBLIC_KEY_GENERATOR, UUID_SUPPLIER, scannerComponentProvider,
-      projectInDb, branch, projectAttributes);
+    return new ComponentTreeBuilder(KEY_GENERATOR, UUID_SUPPLIER, scannerComponentProvider, projectInDb, branch, projectAttributes);
   }
 
   private static Map<String, Component> indexComponentByKey(Component root) {
@@ -827,7 +817,7 @@ public class ComponentTreeBuilderTest {
       new TypeAwareVisitorAdapter(CrawlerDepthLimit.FILE, PRE_ORDER) {
         @Override
         public void visitAny(Component any) {
-          componentsByKey.put(any.getDbKey(), any);
+          componentsByKey.put(any.getKey(), any);
         }
       }).visit(root);
     return componentsByKey;
index 224cb391815b7be4b15c05573818f772944438a0..230d04ee3d359903598d73bf4870355e438d1d3b 100644 (file)
@@ -43,156 +43,156 @@ public class ComponentUuidFactoryWithMigrationTest {
     ComponentDto project = db.components().insertPrivateProject();
     ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project));
     Map<String, String> reportModulesPath = Collections.singletonMap(module.getKey(), "module1_path");
-    pathToKey = path -> path != null ? project.getDbKey() + ":" + path : project.getDbKey();
+    pathToKey = path -> path != null ? project.getKey() + ":" + path : project.getKey();
 
-    ComponentUuidFactoryWithMigration underTest = new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getDbKey(), pathToKey, reportModulesPath);
+    ComponentUuidFactoryWithMigration underTest = new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getKey(), pathToKey, reportModulesPath);
 
-    assertThat(underTest.getOrCreateForKey(project.getDbKey())).isEqualTo(project.uuid());
-    assertThat(underTest.getOrCreateForKey(module.getDbKey())).isEqualTo(module.uuid());
+    assertThat(underTest.getOrCreateForKey(project.getKey())).isEqualTo(project.uuid());
+    assertThat(underTest.getOrCreateForKey(module.getKey())).isEqualTo(module.uuid());
   }
 
   @Test
   public void migrate_project_with_modules() {
-    ComponentDto project = db.components().insertPrivateProject(dto -> dto.setDbKey("project"));
+    ComponentDto project = db.components().insertPrivateProject(dto -> dto.setKey("project"));
     ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project)
-      .setDbKey("project:module1"));
+      .setKey("project:module1"));
     ComponentDto module2 = db.components().insertComponent(ComponentTesting.newModuleDto(module1)
-      .setDbKey("project:module1:module2"));
+      .setKey("project:module1:module2"));
     ComponentDto file1 = db.components().insertComponent(ComponentTesting.newFileDto(project)
-      .setDbKey("project:file1")
+      .setKey("project:file1")
       .setPath("file1_path"));
     ComponentDto file2 = db.components().insertComponent(ComponentTesting.newFileDto(module2)
-      .setDbKey("project:module1:module2:file2")
+      .setKey("project:module1:module2:file2")
       .setPath("file2_path"));
 
     assertThat(file2.moduleUuidPath()).isEqualTo("." + project.uuid() + "." + module1.uuid() + "." + module2.uuid() + ".");
     Map<String, String> modulesRelativePaths = new HashMap<>();
     modulesRelativePaths.put("project:module1", "module1_path");
     modulesRelativePaths.put("project:module1:module2", "module1_path/module2_path");
-    ComponentUuidFactoryWithMigration underTest = new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getDbKey(), pathToKey, modulesRelativePaths);
+    ComponentUuidFactoryWithMigration underTest = new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getKey(), pathToKey, modulesRelativePaths);
 
     // migrated files
     assertThat(underTest.getOrCreateForKey("project:file1_path")).isEqualTo(file1.uuid());
     assertThat(underTest.getOrCreateForKey("project:module1_path/module2_path/file2_path")).isEqualTo(file2.uuid());
 
     // project remains the same
-    assertThat(underTest.getOrCreateForKey(project.getDbKey())).isEqualTo(project.uuid());
+    assertThat(underTest.getOrCreateForKey(project.getKey())).isEqualTo(project.uuid());
   }
 
   @Test
   public void migrate_project_with_disabled_components_no_path() {
-    ComponentDto project = db.components().insertPrivateProject(dto -> dto.setDbKey("project"));
+    ComponentDto project = db.components().insertPrivateProject(dto -> dto.setKey("project"));
     ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project)
-      .setDbKey("project:module1"));
+      .setKey("project:module1"));
     ComponentDto file1 = db.components().insertComponent(ComponentTesting.newFileDto(project)
-      .setDbKey("project:file1")
+      .setKey("project:file1")
       .setPath("file1"));
     ComponentDto disabledFileNoPath = db.components().insertComponent(ComponentTesting.newFileDto(project)
-      .setDbKey("project:file2")
+      .setKey("project:file2")
       .setPath(null)
       .setEnabled(false));
 
     Map<String, String> modulesRelativePaths = new HashMap<>();
     modulesRelativePaths.put("project:module1", "module1_path");
-    ComponentUuidFactoryWithMigration underTest = new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getDbKey(), pathToKey, modulesRelativePaths);
+    ComponentUuidFactoryWithMigration underTest = new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getKey(), pathToKey, modulesRelativePaths);
 
     // migrated files
     assertThat(underTest.getOrCreateForKey("project:file1")).isEqualTo(file1.uuid());
 
     // project remains the same
-    assertThat(underTest.getOrCreateForKey(project.getDbKey())).isEqualTo(project.uuid());
+    assertThat(underTest.getOrCreateForKey(project.getKey())).isEqualTo(project.uuid());
   }
 
   @Test
   public void migrate_project_with_disabled_components_same_path() {
-    ComponentDto project = db.components().insertPrivateProject(dto -> dto.setDbKey("project"));
+    ComponentDto project = db.components().insertPrivateProject(dto -> dto.setKey("project"));
     ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project)
-      .setDbKey("project:module1"));
+      .setKey("project:module1"));
     ComponentDto file1 = db.components().insertComponent(ComponentTesting.newFileDto(project)
-      .setDbKey("project:file1")
+      .setKey("project:file1")
       .setPath("file1"));
     ComponentDto disabledFileSamePath = db.components().insertComponent(ComponentTesting.newFileDto(project)
-      .setDbKey("project:file2")
+      .setKey("project:file2")
       .setPath("file1")
       .setEnabled(false));
 
     Map<String, String> modulesRelativePaths = new HashMap<>();
     modulesRelativePaths.put("project:module1", "module1_path");
-    ComponentUuidFactoryWithMigration underTest = new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getDbKey(), pathToKey, modulesRelativePaths);
+    ComponentUuidFactoryWithMigration underTest = new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getKey(), pathToKey, modulesRelativePaths);
 
     // migrated files
     assertThat(underTest.getOrCreateForKey("project:file1")).isEqualTo(file1.uuid());
 
     // project remains the same
-    assertThat(underTest.getOrCreateForKey(project.getDbKey())).isEqualTo(project.uuid());
+    assertThat(underTest.getOrCreateForKey(project.getKey())).isEqualTo(project.uuid());
   }
 
   @Test
   public void prefers_component_having_same_key() {
-    ComponentDto project = db.components().insertPrivateProject(dto -> dto.setDbKey("project"));
+    ComponentDto project = db.components().insertPrivateProject(dto -> dto.setKey("project"));
     ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project)
-      .setDbKey("project:module1"));
+      .setKey("project:module1"));
     ComponentDto file1 = db.components().insertComponent(ComponentTesting.newFileDto(module1)
-      .setDbKey("project:module1:file1")
+      .setKey("project:module1:file1")
       .setPath("file1"));
     ComponentDto disabledFileSameKey = db.components().insertComponent(ComponentTesting.newFileDto(project)
-      .setDbKey("project:module1/file1")
+      .setKey("project:module1/file1")
       .setPath("module1_path/file1")
       .setEnabled(false));
 
     Map<String, String> modulesRelativePaths = new HashMap<>();
     modulesRelativePaths.put("project:module1", "module1_path");
-    ComponentUuidFactoryWithMigration underTest = new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getDbKey(), pathToKey, modulesRelativePaths);
+    ComponentUuidFactoryWithMigration underTest = new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getKey(), pathToKey, modulesRelativePaths);
 
     // in theory we should migrate file1. But since disabledFileSameKey already have the expected migrated key, let's reuse it.
     assertThat(underTest.getOrCreateForKey("project:module1/file1")).isEqualTo(disabledFileSameKey.uuid());
 
     // project remains the same
-    assertThat(underTest.getOrCreateForKey(project.getDbKey())).isEqualTo(project.uuid());
+    assertThat(underTest.getOrCreateForKey(project.getKey())).isEqualTo(project.uuid());
   }
 
   @Test
   public void migrate_branch_with_modules() {
-    pathToKey = path -> path != null ? "project:" + path + ":BRANCH:branch1" : "project:BRANCH:branch1";
-    ComponentDto project = db.components().insertPrivateProject(dto -> dto.setDbKey("project:BRANCH:branch1"));
+    pathToKey = path -> path != null ? "project:" + path : "project";
+    ComponentDto project = db.components().insertPrivateProject(dto -> dto.setKey("project"));
     ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project)
-      .setDbKey("project:module1:BRANCH:branch1"));
+      .setKey("project:module1"));
     ComponentDto module2 = db.components().insertComponent(ComponentTesting.newModuleDto(module1)
-      .setDbKey("project:module1:module2:BRANCH:branch1"));
+      .setKey("project:module1:module2"));
     ComponentDto file1 = db.components().insertComponent(ComponentTesting.newFileDto(project)
-      .setDbKey("project:file1:BRANCH:branch1")
+      .setKey("project:file1")
       .setPath("file1_path"));
     ComponentDto file2 = db.components().insertComponent(ComponentTesting.newFileDto(module2)
-      .setDbKey("project:module1:module2:file2:BRANCH:branch1")
+      .setKey("project:module1:module2:file2")
       .setPath("file2_path"));
 
     assertThat(file2.moduleUuidPath()).isEqualTo("." + project.uuid() + "." + module1.uuid() + "." + module2.uuid() + ".");
     Map<String, String> modulesRelativePaths = new HashMap<>();
     modulesRelativePaths.put("project:module1", "module1_path");
     modulesRelativePaths.put("project:module1:module2", "module1_path/module2_path");
-    ComponentUuidFactoryWithMigration underTest = new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getDbKey(), pathToKey, modulesRelativePaths);
+    ComponentUuidFactoryWithMigration underTest = new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getKey(), pathToKey, modulesRelativePaths);
 
     // migrated files
-    assertThat(underTest.getOrCreateForKey("project:file1_path:BRANCH:branch1")).isEqualTo(file1.uuid());
-    assertThat(underTest.getOrCreateForKey("project:module1_path/module2_path/file2_path:BRANCH:branch1")).isEqualTo(file2.uuid());
+    assertThat(underTest.getOrCreateForKey("project:file1_path")).isEqualTo(file1.uuid());
+    assertThat(underTest.getOrCreateForKey("project:module1_path/module2_path/file2_path")).isEqualTo(file2.uuid());
 
     // project remains the same
-    assertThat(underTest.getOrCreateForKey(project.getDbKey())).isEqualTo(project.uuid());
+    assertThat(underTest.getOrCreateForKey(project.getKey())).isEqualTo(project.uuid());
   }
 
   @Test
   public void migrate_project_with_root_folders() {
-    ComponentDto project = db.components().insertPrivateProject(dto -> dto.setDbKey("project"));
+    ComponentDto project = db.components().insertPrivateProject(dto -> dto.setKey("project"));
     ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project)
-      .setDbKey("project:module1"));
+      .setKey("project:module1"));
     ComponentDto dir1 = db.components().insertComponent(ComponentTesting.newDirectory(module1, "/")
-      .setDbKey("project:module1:/"));
+      .setKey("project:module1:/"));
 
     Map<String, String> modulesRelativePaths = Collections.singletonMap("project:module1", "module1_path");
-    ComponentUuidFactoryWithMigration underTest = new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getDbKey(), pathToKey, modulesRelativePaths);
+    ComponentUuidFactoryWithMigration underTest = new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getKey(), pathToKey, modulesRelativePaths);
 
     // project remains the same
-    assertThat(underTest.getOrCreateForKey(project.getDbKey())).isEqualTo(project.uuid());
+    assertThat(underTest.getOrCreateForKey(project.getKey())).isEqualTo(project.uuid());
 
     // module migrated to folder
     assertThat(underTest.getOrCreateForKey("project:module1_path")).isEqualTo(module1.uuid());
@@ -200,17 +200,17 @@ public class ComponentUuidFactoryWithMigrationTest {
 
   @Test
   public void dont_override_root_uuid_if_module_path_is_not_sent() {
-    ComponentDto project = db.components().insertPrivateProject(dto -> dto.setDbKey("project"));
+    ComponentDto project = db.components().insertPrivateProject(dto -> dto.setKey("project"));
     ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project)
-      .setDbKey("project:module1")
+      .setKey("project:module1")
       .setEnabled(false));
     ComponentDto module2 = db.components().insertComponent(ComponentTesting.newModuleDto(project)
-      .setDbKey("project:module2")
+      .setKey("project:module2")
       .setEnabled(false));
     Map<String, String> modulesRelativePaths = new HashMap<>();
     modulesRelativePaths.put("project", "");
     modulesRelativePaths.put("project:module2", "module2");
-    ComponentUuidFactoryWithMigration underTest = new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getDbKey(), pathToKey, modulesRelativePaths);
+    ComponentUuidFactoryWithMigration underTest = new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getKey(), pathToKey, modulesRelativePaths);
 
     // check root project.
     assertThat(underTest.getOrCreateForKey("project")).isEqualTo(project.uuid());
index f95daa30bb38a6ebbd2fa109362a0d33a2f09096..9f07abe0bfd34e4790abf8ed57fa844e75991a15 100644 (file)
@@ -75,7 +75,7 @@ public class ProjectPersisterTest {
   @Test
   public void update_description() {
     ProjectDto p1 = dbTester.components().insertPublicProjectDto(
-      c -> c.setUuid("PROJECT_UUID").setDbKey(ROOT.getKey()).setName(ROOT.getName()).setDescription("OLD_DESC"));
+      c -> c.setUuid("PROJECT_UUID").setKey(ROOT.getKey()).setName(ROOT.getName()).setDescription("OLD_DESC"));
 
     assertProject("OLD_DESC", ROOT.getName(), p1.getUpdatedAt());
     underTest.persist(dbTester.getSession());
@@ -85,7 +85,7 @@ public class ProjectPersisterTest {
   @Test
   public void update_name() {
     ProjectDto p1 = dbTester.components().insertPublicProjectDto(
-      c -> c.setUuid("PROJECT_UUID").setDbKey(ROOT.getKey()).setName("OLD_NAME").setDescription(ROOT.getDescription()));
+      c -> c.setUuid("PROJECT_UUID").setKey(ROOT.getKey()).setName("OLD_NAME").setDescription(ROOT.getDescription()));
 
     assertProject(ROOT.getDescription(), "OLD_NAME", p1.getUpdatedAt());
     underTest.persist(dbTester.getSession());
@@ -95,7 +95,7 @@ public class ProjectPersisterTest {
   @Test
   public void dont_update() {
     ProjectDto p1 = dbTester.components().insertPublicProjectDto(
-      c -> c.setUuid("PROJECT_UUID").setDbKey(ROOT.getKey()).setName(ROOT.getName()).setDescription(ROOT.getDescription()));
+      c -> c.setUuid("PROJECT_UUID").setKey(ROOT.getKey()).setName(ROOT.getName()).setDescription(ROOT.getDescription()));
 
     assertProject(ROOT.getDescription(), ROOT.getName(), p1.getUpdatedAt());
     underTest.persist(dbTester.getSession());
index 5b4775a44c1e9d89897ffa44bfc643f27fe8cd5a..9c0a1f8272af929947712e5b8701f540033bb2c2 100644 (file)
@@ -81,7 +81,7 @@ public class ReferenceBranchComponentUuidsTest {
     when(branch.getType()).thenReturn(BranchType.PULL_REQUEST);
     when(branch.getTargetBranchName()).thenReturn("notAnalyzedBranch");
     db.components().insertSnapshot(newAnalysis(branch1));
-    assertThat(underTest.getComponentUuid(pr1File.getDbKey())).isEqualTo(branch1File.uuid());
+    assertThat(underTest.getComponentUuid(pr1File.getKey())).isEqualTo(branch1File.uuid());
     assertThat(underTest.hasReferenceBranchAnalysis()).isTrue();
     assertThat(underTest.getReferenceBranchName()).isEqualTo("branch1");
   }
@@ -109,6 +109,6 @@ public class ReferenceBranchComponentUuidsTest {
     when(branch.getReferenceBranchUuid()).thenReturn(branch1.uuid());
     when(branch.getType()).thenReturn(BranchType.PULL_REQUEST);
     when(branch.getTargetBranchName()).thenReturn("notAnalyzedBranch");
-    assertThat(underTest.getComponentUuid(pr1File.getDbKey())).isNull();
+    assertThat(underTest.getComponentUuid(pr1File.getKey())).isNull();
   }
 }
index c3d0c03d4df22c7e228a2908eed50c1855d6ecce..a0e4080abe01c8f27896d442b834729c5fb1d7ab 100644 (file)
@@ -93,11 +93,11 @@ public class SiblingComponentsWithOpenIssuesTest {
 
     String fileKey = "file-x";
     fileXWithOneResolvedIssueOnBranch1Pr1 = db.components().insertComponent(ComponentTesting.newFileDto(branch1pr1, null)
-      .setDbKey(fileKey + ":BRANCH:branch1pr1"));
+      .setKey(fileKey));
     db.issues().insert(rule, branch1pr1, fileXWithOneResolvedIssueOnBranch1Pr1, i -> i.setStatus("RESOLVED"));
 
     fileXWithOneResolvedIssueOnBranch1Pr2 = db.components().insertComponent(ComponentTesting.newFileDto(branch1pr2, null)
-      .setDbKey(fileKey + ":BRANCH:branch1pr2"));
+      .setKey(fileKey));
     db.issues().insert(rule, branch1pr2, fileXWithOneResolvedIssueOnBranch1Pr2, i -> i.setStatus("RESOLVED"));
 
     branch2 = db.components().insertProjectBranch(project, b -> b.setKey("branch2"), b -> b.setBranchType(BranchType.BRANCH));
@@ -141,8 +141,7 @@ public class SiblingComponentsWithOpenIssuesTest {
     assertThat(underTest.getUuids(fileWithOneResolvedIssueOnBranch1Pr1.getKey())).isEmpty();
     assertThat(underTest.getUuids(fileWithOneOpenTwoResolvedIssuesOnBranch1Pr1.getKey())).isEmpty();
 
-    assertThat(underTest.getUuids(fileXWithOneResolvedIssueOnBranch1Pr1.getKey())).containsOnly(
-      fileXWithOneResolvedIssueOnBranch1Pr2.uuid());
+    assertThat(underTest.getUuids(fileXWithOneResolvedIssueOnBranch1Pr1.getKey())).containsOnly(fileXWithOneResolvedIssueOnBranch1Pr2.uuid());
   }
 
   @Test
index 5bb80181bbb235f5403690efda3f451c45935c07..a418537b178330df1bc64e836f601ba27ae96c61 100644 (file)
@@ -183,7 +183,7 @@ public class ViewsPostOrderDepthTraversalTypeAwareCrawlerTest {
   }
 
   private static CallRecord viewsCallRecord(String methodName, Component component) {
-    return CallRecord.viewsCallRecord(methodName, component.getDbKey());
+    return CallRecord.viewsCallRecord(methodName, component.getKey());
   }
 
 }
index d1528201994a47d909d9eb92dae96b56887759c3..36d4451b1d241000f2aed42010e8cc56470b41a1 100644 (file)
@@ -183,7 +183,7 @@ public class ViewsPreOrderDepthTraversalTypeAwareCrawlerTest {
   }
 
   private static CallRecord viewsCallRecord(String methodName, Component component) {
-    return CallRecord.viewsCallRecord(methodName, component.getDbKey());
+    return CallRecord.viewsCallRecord(methodName, component.getKey());
   }
 
 }
index 558acc0c377a172077faca9ea482a4ecdabfff4f..f50d8e2c4184168e0d6859e0f9213d7570342651 100644 (file)
@@ -153,7 +153,7 @@ public class ViewsVisitorsCrawlerTest {
       super(maxDepth, order, new SimpleStackElementFactory<Integer>() {
         @Override
         public Integer createForAny(Component component) {
-          return Integer.valueOf(component.getDbKey());
+          return Integer.valueOf(component.getKey());
         }
       });
     }
index b67e4bf4595d3f93b0b517f2b600e25ec71ef293..fec6d2ee4d90eda1d74912091c8f6bc6e20e3c0b 100644 (file)
@@ -328,7 +328,7 @@ public class FileMoveDetectionStepTest {
 
     assertThat(movedFilesRepository.getComponentsWithOriginal()).containsExactly(file2);
     MovedFilesRepository.OriginalFile originalFile = movedFilesRepository.getOriginalFile(file2).get();
-    assertThat(originalFile.getKey()).isEqualTo(dtos[0].getDbKey());
+    assertThat(originalFile.getKey()).isEqualTo(dtos[0].getKey());
     assertThat(originalFile.getUuid()).isEqualTo(dtos[0].uuid());
     assertThat(addedFileRepository.getComponents()).isEmpty();
     verifyStatistics(context, 1, 1, 1, 1);
@@ -339,8 +339,8 @@ public class FileMoveDetectionStepTest {
     analysisMetadataHolder.setBaseAnalysis(ANALYSIS);
     Component file1 = fileComponent(FILE_1_REF, null);
     Component file2 = fileComponent(FILE_2_REF, LESS_CONTENT1);
-    insertFiles(file1.getDbKey());
-    insertContentOfFileInDb(file1.getDbKey(), CONTENT1);
+    insertFiles(file1.getKey());
+    insertContentOfFileInDb(file1.getKey(), CONTENT1);
     setFilesInReport(file2);
 
     TestComputationStepContext context = new TestComputationStepContext();
@@ -359,8 +359,8 @@ public class FileMoveDetectionStepTest {
     analysisMetadataHolder.setBaseAnalysis(ANALYSIS);
     Component file1 = fileComponent(FILE_1_REF, null);
     Component file2 = fileComponent(FILE_2_REF, CONTENT1);
-    insertFiles(file1.getDbKey());
-    insertContentOfFileInDb(file1.getDbKey(), CONTENT_EMPTY);
+    insertFiles(file1.getKey());
+    insertContentOfFileInDb(file1.getKey(), CONTENT_EMPTY);
     setFilesInReport(file2);
 
     TestComputationStepContext context = new TestComputationStepContext();
@@ -377,8 +377,8 @@ public class FileMoveDetectionStepTest {
     analysisMetadataHolder.setBaseAnalysis(ANALYSIS);
     Component file1 = fileComponent(FILE_1_REF, null);
     Component file2 = fileComponent(FILE_2_REF, CONTENT1);
-    insertFiles(key -> newComponentDto(key).setPath(null), file1.getDbKey());
-    insertContentOfFileInDb(file1.getDbKey(), CONTENT1);
+    insertFiles(key -> newComponentDto(key).setPath(null), file1.getKey());
+    insertContentOfFileInDb(file1.getKey(), CONTENT1);
     setFilesInReport(file2);
 
     TestComputationStepContext context = new TestComputationStepContext();
@@ -395,8 +395,8 @@ public class FileMoveDetectionStepTest {
     analysisMetadataHolder.setBaseAnalysis(ANALYSIS);
     Component file1 = fileComponent(FILE_1_REF, null);
     Component file2 = fileComponent(FILE_2_REF, CONTENT_EMPTY);
-    insertFiles(file1.getDbKey());
-    insertContentOfFileInDb(file1.getDbKey(), CONTENT1);
+    insertFiles(file1.getKey());
+    insertContentOfFileInDb(file1.getKey(), CONTENT1);
     setFilesInReport(file2);
 
     TestComputationStepContext context = new TestComputationStepContext();
@@ -415,8 +415,8 @@ public class FileMoveDetectionStepTest {
     Component file1 = fileComponent(FILE_1_REF, null);
     Component file2 = fileComponent(FILE_2_REF, CONTENT1);
     Component file3 = fileComponent(FILE_3_REF, CONTENT1);
-    insertFiles(file1.getDbKey());
-    insertContentOfFileInDb(file1.getDbKey(), CONTENT1);
+    insertFiles(file1.getKey());
+    insertContentOfFileInDb(file1.getKey(), CONTENT1);
     setFilesInReport(file2, file3);
 
     TestComputationStepContext context = new TestComputationStepContext();
@@ -493,10 +493,10 @@ public class FileMoveDetectionStepTest {
 
     assertThat(movedFilesRepository.getComponentsWithOriginal()).containsOnly(file3, file6);
     MovedFilesRepository.OriginalFile originalFile2 = movedFilesRepository.getOriginalFile(file3).get();
-    assertThat(originalFile2.getKey()).isEqualTo(dtos[0].getDbKey());
+    assertThat(originalFile2.getKey()).isEqualTo(dtos[0].getKey());
     assertThat(originalFile2.getUuid()).isEqualTo(dtos[0].uuid());
     MovedFilesRepository.OriginalFile originalFile5 = movedFilesRepository.getOriginalFile(file6).get();
-    assertThat(originalFile5.getKey()).isEqualTo(dtos[3].getDbKey());
+    assertThat(originalFile5.getKey()).isEqualTo(dtos[3].getKey());
     assertThat(originalFile5.getUuid()).isEqualTo(dtos[3].uuid());
     assertThat(scoreMatrixDumper.scoreMatrix.getMaxScore()).isGreaterThan(MIN_REQUIRED_SCORE);
     assertThat(addedFileRepository.getComponents()).isEmpty();
@@ -510,9 +510,9 @@ public class FileMoveDetectionStepTest {
     Component file2 = fileComponent(FILE_2_REF, null);
     Component file3 = fileComponent(FILE_3_REF, arrayOf(118));
     Component file4 = fileComponent(5, arrayOf(25));
-    insertFiles(file1.getDbKey(), file2.getDbKey());
-    insertContentOfFileInDb(file1.getDbKey(), arrayOf(100));
-    insertContentOfFileInDb(file2.getDbKey(), arrayOf(30));
+    insertFiles(file1.getKey(), file2.getKey());
+    insertContentOfFileInDb(file1.getKey(), arrayOf(100));
+    insertContentOfFileInDb(file2.getKey(), arrayOf(30));
     setFilesInReport(file3, file4);
 
     TestComputationStepContext context = new TestComputationStepContext();
@@ -595,7 +595,7 @@ public class FileMoveDetectionStepTest {
         FileSourceDto fileSourceDto = new FileSourceDto()
           .setUuid(Uuids.createFast())
           .setFileUuid(file.uuid())
-          .setProjectUuid(file.projectUuid())
+          .setProjectUuid(file.branchUuid())
           .setLineHashes(linesHashesComputer.getLineHashes());
         dbTester.getDbClient().fileSourceDao().insert(dbTester.getSession(), fileSourceDto);
         dbTester.commit();
@@ -623,7 +623,7 @@ public class FileMoveDetectionStepTest {
 
   private ComponentDto newComponentDto(String uuid) {
     return ComponentTesting.newFileDto(project)
-      .setDbKey("key_" + uuid)
+      .setKey("key_" + uuid)
       .setUuid(uuid)
       .setPath("path_" + uuid);
   }
index 454a56f4074e425ff96809a9726c9c411dff785a..e4eb4bb9037b8ff1e0579fd7aa64b31fae3dc357 100644 (file)
@@ -334,8 +334,8 @@ public class IntegrateIssuesVisitorTest {
   }
 
   private void addBaseIssue(RuleKey ruleKey) {
-    ComponentDto project = ComponentTesting.newPrivateProjectDto(PROJECT_UUID).setDbKey(PROJECT_KEY);
-    ComponentDto file = ComponentTesting.newFileDto(project, null, FILE_UUID).setDbKey(FILE_KEY);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(PROJECT_UUID).setKey(PROJECT_KEY);
+    ComponentDto file = ComponentTesting.newFileDto(project, null, FILE_UUID).setKey(FILE_KEY);
     dbTester.components().insertComponents(project, file);
 
     RuleDto ruleDto = RuleTesting.newDto(ruleKey);
@@ -351,8 +351,8 @@ public class IntegrateIssuesVisitorTest {
   }
 
   private void addBaseIssueOnBranch(RuleKey ruleKey) {
-    ComponentDto project = ComponentTesting.newPrivateProjectDto(PROJECT_UUID_ON_BRANCH).setDbKey(PROJECT_KEY);
-    ComponentDto file = ComponentTesting.newFileDto(project, null, FILE_UUID_ON_BRANCH).setDbKey(FILE_KEY);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(PROJECT_UUID_ON_BRANCH).setKey(PROJECT_KEY);
+    ComponentDto file = ComponentTesting.newFileDto(project, null, FILE_UUID_ON_BRANCH).setKey(FILE_KEY);
     dbTester.components().insertComponents(project, file);
 
     RuleDto ruleDto = RuleTesting.newDto(ruleKey);
index 15f88d5a3cd2d40195920f54fc4d532f2ad4b29b..80b1ba6e5aee00a9a3bbff3dd84315c8093c7612 100644 (file)
@@ -43,7 +43,6 @@ public class MovedIssueVisitorTest {
   private static final String FILE_UUID = "file uuid";
   private static final Component FILE = ReportComponent.builder(Component.Type.FILE, 1)
     .setKey("key_1")
-    .setPublicKey("public_key_1")
     .setUuid(FILE_UUID)
     .build();
 
index db85e27e3da6d62496d1dae5d68d5e50dbe4ed21..1de550b1323621f87f4accb4c0b0177446873c86 100644 (file)
@@ -76,7 +76,7 @@ public class ProjectTrackerBaseLazyInputTest {
     ruleRepositoryRule.add(rule.getKey());
     rootProjectDto = dbTester.components().insertPublicProject();
     ReportComponent rootProject = ReportComponent.builder(Component.Type.FILE, 1)
-      .setKey(rootProjectDto.getDbKey())
+      .setKey(rootProjectDto.getKey())
       .setUuid(rootProjectDto.uuid()).build();
     reportModulesPath = mock(ReportModulesPath.class);
     underTest = new ProjectTrackerBaseLazyInput(analysisMetadataHolder, mock(ComponentsWithUnprocessedIssues.class), dbClient, new IssueFieldsSetter(), issuesLoader,
@@ -112,7 +112,7 @@ public class ProjectTrackerBaseLazyInputTest {
   @Test
   public void migrate_and_return_module_and_folder_issues_on_module() {
     ComponentDto module = dbTester.components().insertComponent(newModuleDto(rootProjectDto).setPath("moduleAInDb"));
-    when(reportModulesPath.get()).thenReturn(ImmutableMap.of(module.getDbKey(), "moduleAInReport"));
+    when(reportModulesPath.get()).thenReturn(ImmutableMap.of(module.getKey(), "moduleAInReport"));
     ComponentDto folder = dbTester.components().insertComponent(newDirectory(module, "src"));
     ComponentDto file = dbTester.components().insertComponent(newFileDto(module));
     IssueDto openIssueOnProject = dbTester.issues().insert(rule, rootProjectDto, rootProjectDto, i -> i.setStatus("OPEN").setResolution(null));
index 763986106e36d64b4510bf582b27d5085acc2ec9..6de4ad9b5756a678c6ac2a9a38922ed6512921aa 100644 (file)
@@ -88,7 +88,7 @@ public class PullRequestSourceBranchMergerTest {
       issueLifecycle,
       sourceBranchInputFactory);
 
-    ComponentDto projectDto = db.components().insertPublicProject(p -> p.setDbKey(PROJECT_KEY).setUuid(PROJECT_UUID));
+    ComponentDto projectDto = db.components().insertPublicProject(p -> p.setKey(PROJECT_KEY).setUuid(PROJECT_UUID));
     ComponentDto branch1Dto = db.components().insertProjectBranch(projectDto, b -> b.setKey("myBranch1")
       .setBranchType(BranchType.PULL_REQUEST)
       .setMergeBranchUuid(projectDto.uuid()));
@@ -98,9 +98,9 @@ public class PullRequestSourceBranchMergerTest {
     ComponentDto branch3Dto = db.components().insertProjectBranch(projectDto, b -> b.setKey("myBranch3")
       .setBranchType(BranchType.PULL_REQUEST)
       .setMergeBranchUuid(projectDto.uuid()));
-    db.components().insertComponent(newFileDto(branch1Dto).setDbKey(FILE_1_KEY + ":PULL_REQUEST:myBranch1"));
-    db.components().insertComponent(newFileDto(branch2Dto).setDbKey(FILE_1_KEY + ":PULL_REQUEST:myBranch2"));
-    db.components().insertComponent(newFileDto(branch3Dto).setDbKey(FILE_1_KEY + ":PULL_REQUEST:myBranch3"));
+    db.components().insertComponent(newFileDto(branch1Dto).setKey(FILE_1_KEY + ":PULL_REQUEST:myBranch1"));
+    db.components().insertComponent(newFileDto(branch2Dto).setKey(FILE_1_KEY + ":PULL_REQUEST:myBranch2"));
+    db.components().insertComponent(newFileDto(branch3Dto).setKey(FILE_1_KEY + ":PULL_REQUEST:myBranch3"));
     rule = db.rules().insert();
     rawIssue = createIssue("issue1", rule.getKey(), Issue.STATUS_OPEN, new Date());
     rawIssuesInput = new DefaultTrackingInput(singletonList(rawIssue), mock(LineHashSequence.class), mock(BlockHashSequence.class));
index b7d6758719d469c8a1422d139075ec00b8b09fc4..ebd2a0573cf78838f8320597652aec3034ce481f 100644 (file)
@@ -105,7 +105,7 @@ public class SiblingsIssueMergerTest {
     copier = new SiblingsIssueMerger(new SiblingsIssuesLoader(new SiblingComponentsWithOpenIssues(treeRootHolder, metadataHolder, dbClient), dbClient, componentIssuesLoader),
       tracker,
       issueLifecycle);
-    projectDto = db.components().insertPublicProject(p -> p.setDbKey(PROJECT_KEY).setUuid(PROJECT_UUID));
+    projectDto = db.components().insertPublicProject(p -> p.setKey(PROJECT_KEY).setUuid(PROJECT_UUID));
     branch1Dto = db.components().insertProjectBranch(projectDto, b -> b.setKey("myBranch1")
       .setBranchType(BranchType.PULL_REQUEST)
       .setMergeBranchUuid(projectDto.uuid()));
@@ -115,9 +115,9 @@ public class SiblingsIssueMergerTest {
     branch3Dto = db.components().insertProjectBranch(projectDto, b -> b.setKey("myBranch3")
       .setBranchType(BranchType.PULL_REQUEST)
       .setMergeBranchUuid(projectDto.uuid()));
-    fileOnBranch1Dto = db.components().insertComponent(newFileDto(branch1Dto).setDbKey(FILE_1_KEY + ":PULL_REQUEST:myBranch1"));
-    fileOnBranch2Dto = db.components().insertComponent(newFileDto(branch2Dto).setDbKey(FILE_1_KEY + ":PULL_REQUEST:myBranch2"));
-    fileOnBranch3Dto = db.components().insertComponent(newFileDto(branch3Dto).setDbKey(FILE_1_KEY + ":PULL_REQUEST:myBranch3"));
+    fileOnBranch1Dto = db.components().insertComponent(newFileDto(branch1Dto).setKey(FILE_1_KEY + ":PULL_REQUEST:myBranch1"));
+    fileOnBranch2Dto = db.components().insertComponent(newFileDto(branch2Dto).setKey(FILE_1_KEY + ":PULL_REQUEST:myBranch2"));
+    fileOnBranch3Dto = db.components().insertComponent(newFileDto(branch3Dto).setKey(FILE_1_KEY + ":PULL_REQUEST:myBranch3"));
     rule = db.rules().insert();
     when(branch.getReferenceBranchUuid()).thenReturn(projectDto.uuid());
     metadataHolder.setBranch(branch);
index 65f792c7b7ceafbb9cf20c79f40873c1cc40eb8b..79656060e44e9b0de66266b698ed5c8abeff2862 100644 (file)
@@ -79,7 +79,7 @@ public class SourceBranchComponentUuidsTest {
     when(branch.getPullRequestKey()).thenReturn(PR_KEY);
     db.components().insertSnapshot(newAnalysis(branch1));
 
-    assertThat(underTest.getSourceBranchComponentUuid(pr1File.getDbKey())).isEqualTo(branch1File.uuid());
+    assertThat(underTest.getSourceBranchComponentUuid(pr1File.getKey())).isEqualTo(branch1File.uuid());
     assertThat(underTest.hasSourceBranchAnalysis()).isTrue();
   }
 
@@ -108,7 +108,7 @@ public class SourceBranchComponentUuidsTest {
     when(branch.getType()).thenReturn(BranchType.BRANCH);
     when(branch.getName()).thenReturn(BRANCH_KEY);
 
-    assertThat(underTest.getSourceBranchComponentUuid(pr1File.getDbKey())).isNull();
+    assertThat(underTest.getSourceBranchComponentUuid(pr1File.getKey())).isNull();
   }
 
   @Test
@@ -116,6 +116,6 @@ public class SourceBranchComponentUuidsTest {
     when(branch.getType()).thenReturn(BranchType.PULL_REQUEST);
     when(branch.getName()).thenReturn(BRANCH_KEY);
 
-    assertThat(underTest.getSourceBranchComponentUuid(pr1File.getDbKey())).isNull();
+    assertThat(underTest.getSourceBranchComponentUuid(pr1File.getKey())).isNull();
   }
 }
index 81a318693cd711ca253a54be2cf0d9d804f4535b..9271b7f32a02513573bb316f540550c5c2496d7f 100644 (file)
@@ -40,7 +40,7 @@ public class TargetBranchComponentUuidsTest {
   private static final String BRANCH_KEY = "branch1";
   private static final String PR_KEY = "pr1";
 
-  @org.junit.Rule
+  @Rule
   public AnalysisMetadataHolderRule analysisMetadataHolder = new AnalysisMetadataHolderRule();
 
   @Rule
@@ -80,7 +80,7 @@ public class TargetBranchComponentUuidsTest {
     when(branch.getPullRequestKey()).thenReturn(PR_KEY);
     db.components().insertSnapshot(newAnalysis(branch1));
 
-    assertThat(underTest.getTargetBranchComponentUuid(pr1File.getDbKey())).isEqualTo(branch1File.uuid());
+    assertThat(underTest.getTargetBranchComponentUuid(pr1File.getKey())).isEqualTo(branch1File.uuid());
     assertThat(underTest.hasTargetBranchAnalysis()).isTrue();
   }
 
@@ -112,7 +112,7 @@ public class TargetBranchComponentUuidsTest {
     when(branch.getName()).thenReturn("prBranch");
     when(branch.getTargetBranchName()).thenReturn(BRANCH_KEY);
 
-    assertThat(underTest.getTargetBranchComponentUuid(pr1File.getDbKey())).isNull();
+    assertThat(underTest.getTargetBranchComponentUuid(pr1File.getKey())).isNull();
   }
 
   @Test
@@ -121,6 +121,6 @@ public class TargetBranchComponentUuidsTest {
     when(branch.getName()).thenReturn("prBranch");
     when(branch.getTargetBranchName()).thenReturn(BRANCH_KEY);
 
-    assertThat(underTest.getTargetBranchComponentUuid(pr1File.getDbKey())).isNull();
+    assertThat(underTest.getTargetBranchComponentUuid(pr1File.getKey())).isNull();
   }
 }
index 5560ce021bcc4eadfcf680e00a0d2a2d6661362f..3e8dd552d35f348588f7afbc5165a723b3cba5b9 100644 (file)
@@ -60,7 +60,7 @@ public class TrackerReferenceBranchInputFactoryTest {
     db.fileSources().insertFileSource(fileDto, 3);
 
     Component component = mock(Component.class);
-    when(component.getDbKey()).thenReturn(COMPONENT_KEY);
+    when(component.getKey()).thenReturn(COMPONENT_KEY);
     when(component.getType()).thenReturn(Component.Type.FILE);
     Input<DefaultIssue> input = underTest.create(component);
 
@@ -71,7 +71,7 @@ public class TrackerReferenceBranchInputFactoryTest {
   @Test
   public void gets_nothing_when_there_is_no_matching_component() {
     Component component = mock(Component.class);
-    when(component.getDbKey()).thenReturn(COMPONENT_KEY);
+    when(component.getKey()).thenReturn(COMPONENT_KEY);
     when(component.getType()).thenReturn(Component.Type.FILE);
     Input<DefaultIssue> input = underTest.create(component);
 
index ea5b6f3ba4b5ce63b29ade569fbe39e4273e9d27..2ea7feed1d6be2bf7ba6443e10db0d5a86c3f267 100644 (file)
@@ -59,7 +59,7 @@ public class TrackerSourceBranchInputFactoryTest {
     db.fileSources().insertFileSource(fileDto, 3);
 
     Component component = mock(Component.class);
-    when(component.getDbKey()).thenReturn(COMPONENT_KEY);
+    when(component.getKey()).thenReturn(COMPONENT_KEY);
     when(component.getType()).thenReturn(Component.Type.FILE);
     Input<DefaultIssue> input = underTest.createForSourceBranch(component);
 
@@ -76,7 +76,7 @@ public class TrackerSourceBranchInputFactoryTest {
     db.fileSources().insertFileSource(fileDto, 0);
 
     Component component = mock(Component.class);
-    when(component.getDbKey()).thenReturn(COMPONENT_KEY);
+    when(component.getKey()).thenReturn(COMPONENT_KEY);
     when(component.getType()).thenReturn(Component.Type.FILE);
     Input<DefaultIssue> input = underTest.createForSourceBranch(component);
 
@@ -87,7 +87,7 @@ public class TrackerSourceBranchInputFactoryTest {
   @Test
   public void gets_nothing_when_there_is_no_matching_component() {
     Component component = mock(Component.class);
-    when(component.getDbKey()).thenReturn(COMPONENT_KEY);
+    when(component.getKey()).thenReturn(COMPONENT_KEY);
     when(component.getType()).thenReturn(Component.Type.FILE);
     Input<DefaultIssue> input = underTest.createForSourceBranch(component);
 
index 7fa7e8c250fa0ce738864f28ff19c9297f1374e1..5c678fee52a4434559fa2947d9ee193d53ae2467 100644 (file)
@@ -59,7 +59,7 @@ public class TrackerTargetBranchInputFactoryTest {
     db.fileSources().insertFileSource(fileDto, 3);
 
     Component component = mock(Component.class);
-    when(component.getDbKey()).thenReturn(COMPONENT_KEY);
+    when(component.getKey()).thenReturn(COMPONENT_KEY);
     when(component.getType()).thenReturn(Component.Type.FILE);
     Input<DefaultIssue> input = underTest.createForTargetBranch(component);
 
@@ -76,7 +76,7 @@ public class TrackerTargetBranchInputFactoryTest {
     db.fileSources().insertFileSource(fileDto, 0);
 
     Component component = mock(Component.class);
-    when(component.getDbKey()).thenReturn(COMPONENT_KEY);
+    when(component.getKey()).thenReturn(COMPONENT_KEY);
     when(component.getType()).thenReturn(Component.Type.FILE);
     Input<DefaultIssue> input = underTest.createForTargetBranch(component);
 
@@ -87,7 +87,7 @@ public class TrackerTargetBranchInputFactoryTest {
   @Test
   public void gets_nothing_when_there_is_no_matching_component() {
     Component component = mock(Component.class);
-    when(component.getDbKey()).thenReturn(COMPONENT_KEY);
+    when(component.getKey()).thenReturn(COMPONENT_KEY);
     when(component.getType()).thenReturn(Component.Type.FILE);
     Input<DefaultIssue> input = underTest.createForTargetBranch(component);
 
index 51f632821a43a620023eba312bdbff25f1136a95..b5a7a89deea7b968bd89f9493191a98eb91f478c 100644 (file)
@@ -78,7 +78,7 @@ public class NewCodeReferenceBranchComponentUuidsTest {
   public void should_support_db_key_when_looking_for_reference_component() {
     periodHolder.setPeriod(new Period(NewCodePeriodType.REFERENCE_BRANCH.name(), "branch1", null));
     db.components().insertSnapshot(newAnalysis(branch1));
-    assertThat(underTest.getComponentUuid(pr1File.getDbKey())).isEqualTo(branch1File.uuid());
+    assertThat(underTest.getComponentUuid(pr1File.getKey())).isEqualTo(branch1File.uuid());
   }
 
   @Test
@@ -98,19 +98,19 @@ public class NewCodeReferenceBranchComponentUuidsTest {
   @Test
   public void skip_init_if_no_reference_branch_analysis() {
     periodHolder.setPeriod(new Period(NewCodePeriodType.REFERENCE_BRANCH.name(), "branch1", null));
-    assertThat(underTest.getComponentUuid(pr1File.getDbKey())).isNull();
+    assertThat(underTest.getComponentUuid(pr1File.getKey())).isNull();
   }
 
   @Test
   public void skip_init_if_branch_not_found() {
     periodHolder.setPeriod(new Period(NewCodePeriodType.REFERENCE_BRANCH.name(), "unknown", null));
-    assertThat(underTest.getComponentUuid(pr1File.getDbKey())).isNull();
+    assertThat(underTest.getComponentUuid(pr1File.getKey())).isNull();
   }
 
   @Test
   public void throw_ise_if_mode_is_not_reference_branch() {
     periodHolder.setPeriod(new Period(NewCodePeriodType.NUMBER_OF_DAYS.name(), "10", 1000L));
-    assertThatThrownBy(() -> underTest.getComponentUuid(pr1File.getDbKey()))
+    assertThatThrownBy(() -> underTest.getComponentUuid(pr1File.getKey()))
       .isInstanceOf(IllegalStateException.class);
   }
 }
index 12a2ac8948ca2d1300eda65c0a0e0445e93cecc8..d5902805e5b1d00f7ec210b942ca47a308af0bd3 100644 (file)
@@ -112,7 +112,7 @@ public class ScmInfoDbLoaderTest {
     String referenceFileUuid = "referenceFileUuid";
     String hash = computeSourceHash(1);
 
-    when(referenceBranchComponentUuids.getComponentUuid(FILE.getDbKey())).thenReturn(referenceFileUuid);
+    when(referenceBranchComponentUuids.getComponentUuid(FILE.getKey())).thenReturn(referenceFileUuid);
     addFileSourceInDb("henry", DATE_1, "rev-1", hash, referenceFileUuid);
 
     DbScmInfo scmInfo = underTest.getScmInfo(FILE).get();
@@ -131,7 +131,7 @@ public class ScmInfoDbLoaderTest {
     String targetBranchFileUuid = "targetBranchFileUuid";
     String hash = computeSourceHash(1);
 
-    when(referenceBranchComponentUuids.getComponentUuid(FILE.getDbKey())).thenReturn(targetBranchFileUuid);
+    when(referenceBranchComponentUuids.getComponentUuid(FILE.getKey())).thenReturn(targetBranchFileUuid);
     addFileSourceInDb("henry", DATE_1, "rev-1", hash, targetBranchFileUuid);
 
     DbScmInfo scmInfo = underTest.getScmInfo(FILE).get();
@@ -152,7 +152,7 @@ public class ScmInfoDbLoaderTest {
     String targetBranchFileUuid = "targetBranchFileUuid";
     String hash = computeSourceHash(1);
 
-    when(newCodeReferenceBranchComponentUuids.getComponentUuid(FILE.getDbKey())).thenReturn(targetBranchFileUuid);
+    when(newCodeReferenceBranchComponentUuids.getComponentUuid(FILE.getKey())).thenReturn(targetBranchFileUuid);
     addFileSourceInDb("henry", DATE_1, "rev-1", hash, targetBranchFileUuid);
 
     DbScmInfo scmInfo = underTest.getScmInfo(FILE).get();
index e080f565cc1176b21bc51525387d6cb7963698cf..78ed47cfc775341fcf34ffd2de5b21aa9f945a47 100644 (file)
@@ -66,7 +66,7 @@ public class DbLineHashVersionTest {
     assertThat(underTest.hasLineHashesWithSignificantCode(component)).isFalse();
 
     verify(analysisMetadataHolder).isPullRequest();
-    verify(referenceBranchComponentUuids).getComponentUuid(component.getDbKey());
+    verify(referenceBranchComponentUuids).getComponentUuid(component.getKey());
   }
 
   @Test
@@ -81,7 +81,7 @@ public class DbLineHashVersionTest {
     assertThat(underTest.hasLineHashesWithSignificantCode(component)).isFalse();
 
     verify(analysisMetadataHolder).isPullRequest();
-    verify(referenceBranchComponentUuids).getComponentUuid(component.getDbKey());
+    verify(referenceBranchComponentUuids).getComponentUuid(component.getKey());
   }
 
   @Test
@@ -97,7 +97,7 @@ public class DbLineHashVersionTest {
     assertThat(underTest.hasLineHashesWithSignificantCode(component)).isTrue();
 
     verify(analysisMetadataHolder).isPullRequest();
-    verify(referenceBranchComponentUuids).getComponentUuid(component.getDbKey());
+    verify(referenceBranchComponentUuids).getComponentUuid(component.getKey());
   }
 
   @Test
index e6643465dee050cadc1a41184c77a8a0dd55ef14..c6e5069d34ff5de210a963c792814f7af6dbc9e8 100644 (file)
@@ -233,11 +233,11 @@ public class BuildComponentTreeStepTest {
   @Test
   public void return_existing_uuids() {
     setAnalysisMetadataHolder();
-    ComponentDto project = insertComponent(newPrivateProjectDto("ABCD").setDbKey(REPORT_PROJECT_KEY));
+    ComponentDto project = insertComponent(newPrivateProjectDto("ABCD").setKey(REPORT_PROJECT_KEY));
     ComponentDto directory = newDirectory(project, "CDEF", REPORT_DIR_PATH_1);
-    insertComponent(directory.setDbKey(REPORT_PROJECT_KEY + ":" + REPORT_DIR_PATH_1));
+    insertComponent(directory.setKey(REPORT_PROJECT_KEY + ":" + REPORT_DIR_PATH_1));
     insertComponent(newFileDto(project, directory, "DEFG")
-      .setDbKey(REPORT_PROJECT_KEY + ":" + REPORT_FILE_PATH_1)
+      .setKey(REPORT_PROJECT_KEY + ":" + REPORT_FILE_PATH_1)
       .setPath(REPORT_FILE_PATH_1));
 
     // new structure, without modules
@@ -247,7 +247,7 @@ public class BuildComponentTreeStepTest {
     underTest.execute(new TestComputationStepContext());
 
     verifyComponentByRef(ROOT_REF, REPORT_PROJECT_KEY, analysisMetadataHolder.getProject().getName(), "ABCD");
-    verifyComponentByKey(REPORT_PROJECT_KEY + ":" + REPORT_DIR_PATH_1, REPORT_PROJECT_KEY + ":" + REPORT_DIR_PATH_1, REPORT_DIR_PATH_1, "CDEF");
+    verifyComponentByKey(REPORT_PROJECT_KEY + ":" + REPORT_DIR_PATH_1, REPORT_DIR_PATH_1, "CDEF");
     verifyComponentByRef(FILE_1_REF, REPORT_PROJECT_KEY + ":" + REPORT_FILE_PATH_1, REPORT_FILE_NAME_1, "DEFG");
   }
 
@@ -259,7 +259,7 @@ public class BuildComponentTreeStepTest {
     when(branch.generateKey(any(), any())).thenReturn("generated");
     analysisMetadataHolder.setRootComponentRef(ROOT_REF)
       .setAnalysisDate(ANALYSIS_DATE)
-      .setProject(Project.from(newPrivateProjectDto().setDbKey(REPORT_PROJECT_KEY)))
+      .setProject(Project.from(newPrivateProjectDto().setKey(REPORT_PROJECT_KEY)))
       .setBranch(branch);
     BuildComponentTreeStep underTest = new BuildComponentTreeStep(dbClient, reportReader, treeRootHolder, analysisMetadataHolder, reportModulesPath);
     reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, FILE_1_REF));
@@ -267,10 +267,8 @@ public class BuildComponentTreeStepTest {
 
     underTest.execute(new TestComputationStepContext());
 
-    verifyComponentByRef(ROOT_REF, "generated", REPORT_PROJECT_KEY, analysisMetadataHolder.getProject().getName(), null);
-
-    verifyComponentByKey(REPORT_PROJECT_KEY + ":" + REPORT_DIR_PATH_1, "generated", REPORT_DIR_PATH_1);
-    verifyComponentByRef(FILE_1_REF, "generated", REPORT_PROJECT_KEY + ":" + REPORT_FILE_PATH_1, REPORT_FILE_NAME_1, null);
+    verifyComponentByRef(ROOT_REF, "generated", analysisMetadataHolder.getProject().getName(), null);
+    verifyComponentByRef(FILE_1_REF, "generated", REPORT_FILE_NAME_1, null);
   }
 
   @Test
@@ -280,7 +278,7 @@ public class BuildComponentTreeStepTest {
     Branch branch = mock(Branch.class);
     when(branch.getName()).thenReturn(branchDto.getBranch());
     when(branch.isMain()).thenReturn(false);
-    when(branch.generateKey(any(), any())).thenReturn(branchDto.getDbKey());
+    when(branch.generateKey(any(), any())).thenReturn(branchDto.getKey());
     analysisMetadataHolder.setRootComponentRef(ROOT_REF)
       .setAnalysisDate(ANALYSIS_DATE)
       .setProject(Project.from(projectDto))
@@ -290,7 +288,7 @@ public class BuildComponentTreeStepTest {
 
     underTest.execute(new TestComputationStepContext());
 
-    verifyComponentByRef(ROOT_REF, branchDto.getDbKey(), branchDto.getKey(), analysisMetadataHolder.getProject().getName(), branchDto.uuid());
+    verifyComponentByRef(ROOT_REF, branchDto.getKey(), analysisMetadataHolder.getProject().getName(), branchDto.uuid());
   }
 
   @Test
@@ -302,9 +300,9 @@ public class BuildComponentTreeStepTest {
 
     underTest.execute(new TestComputationStepContext());
 
-    verifyComponentByRef(ROOT_REF, REPORT_PROJECT_KEY, REPORT_PROJECT_KEY, analysisMetadataHolder.getProject().getName(), null);
+    verifyComponentByRef(ROOT_REF, REPORT_PROJECT_KEY, analysisMetadataHolder.getProject().getName(), null);
     verifyComponentByKey(REPORT_PROJECT_KEY + ":" + REPORT_DIR_PATH_1, REPORT_DIR_PATH_1);
-    verifyComponentByRef(FILE_1_REF, REPORT_PROJECT_KEY + ":" + REPORT_FILE_PATH_1, REPORT_PROJECT_KEY + ":" + REPORT_FILE_PATH_1, REPORT_FILE_NAME_1, null);
+    verifyComponentByRef(FILE_1_REF, REPORT_PROJECT_KEY + ":" + REPORT_FILE_PATH_1, REPORT_FILE_NAME_1, null);
   }
 
   @Test
@@ -348,7 +346,7 @@ public class BuildComponentTreeStepTest {
   @Test
   public void set_no_base_project_snapshot_when_no_last_snapshot() {
     setAnalysisMetadataHolder();
-    ComponentDto project = insertComponent(newPrivateProjectDto("ABCD").setDbKey(REPORT_PROJECT_KEY));
+    ComponentDto project = insertComponent(newPrivateProjectDto("ABCD").setKey(REPORT_PROJECT_KEY));
     insertSnapshot(newAnalysis(project).setLast(false));
 
     reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY));
@@ -360,7 +358,7 @@ public class BuildComponentTreeStepTest {
   @Test
   public void set_base_project_snapshot_when_last_snapshot_exist() {
     setAnalysisMetadataHolder();
-    ComponentDto project = insertComponent(newPrivateProjectDto("ABCD").setDbKey(REPORT_PROJECT_KEY));
+    ComponentDto project = insertComponent(newPrivateProjectDto("ABCD").setKey(REPORT_PROJECT_KEY));
     insertSnapshot(newAnalysis(project).setLast(true));
 
     reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY));
@@ -383,7 +381,7 @@ public class BuildComponentTreeStepTest {
   @UseDataProvider("oneParameterNullNonNullCombinations")
   public void set_projectVersion_to_previous_analysis_when_not_set(@Nullable String previousAnalysisProjectVersion) {
     setAnalysisMetadataHolder();
-    ComponentDto project = insertComponent(newPrivateProjectDto("ABCD").setDbKey(REPORT_PROJECT_KEY));
+    ComponentDto project = insertComponent(newPrivateProjectDto("ABCD").setKey(REPORT_PROJECT_KEY));
     insertSnapshot(newAnalysis(project).setProjectVersion(previousAnalysisProjectVersion).setLast(true));
     reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY));
 
@@ -416,7 +414,7 @@ public class BuildComponentTreeStepTest {
     String scannerProjectVersion = randomAlphabetic(12);
     setAnalysisMetadataHolder();
     reportReader.setMetadata(createReportMetadata(scannerProjectVersion, NO_SCANNER_BUILD_STRING));
-    ComponentDto project = insertComponent(newPrivateProjectDto("ABCD").setDbKey(REPORT_PROJECT_KEY));
+    ComponentDto project = insertComponent(newPrivateProjectDto("ABCD").setKey(REPORT_PROJECT_KEY));
     insertSnapshot(newAnalysis(project).setProjectVersion(previousAnalysisProjectVersion).setLast(true));
     reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY));
 
@@ -454,27 +452,18 @@ public class BuildComponentTreeStepTest {
   }
 
   private void verifyComponentByRef(int ref, String key, String shortName) {
-    verifyComponentByRef(ref, key, key, shortName, null);
-  }
-
-  private void verifyComponentByRef(int ref, String key, String shortName, @Nullable String uuid) {
-    verifyComponentByRef(ref, key, key, shortName, uuid);
+    verifyComponentByRef(ref, key, shortName, null);
   }
 
-  private void verifyComponentByKey(String publicKey, String shortName) {
-    verifyComponentByKey(publicKey, publicKey, shortName, null);
+  private void verifyComponentByKey(String key, String shortName) {
+    verifyComponentByKey(key, shortName, null);
   }
 
-  private void verifyComponentByKey(String publicKey, String key, String shortName) {
-    verifyComponentByKey(publicKey, key, shortName, null);
-  }
-
-  private void verifyComponentByKey(String publicKey, String key, String shortName, @Nullable String uuid) {
+  private void verifyComponentByKey(String key, String shortName, @Nullable String uuid) {
     Map<String, Component> componentsByKey = indexAllComponentsInTreeByKey(treeRootHolder.getRoot());
-    Component component = componentsByKey.get(publicKey);
-    assertThat(component.getDbKey()).isEqualTo(key);
+    Component component = componentsByKey.get(key);
+    assertThat(component.getKey()).isEqualTo(key);
     assertThat(component.getReportAttributes().getRef()).isNull();
-    assertThat(component.getKey()).isEqualTo(publicKey);
     assertThat(component.getShortName()).isEqualTo(shortName);
     if (uuid != null) {
       assertThat(component.getUuid()).isEqualTo(uuid);
@@ -483,11 +472,10 @@ public class BuildComponentTreeStepTest {
     }
   }
 
-  private void verifyComponentByRef(int ref, String key, String publicKey, String shortName, @Nullable String uuid) {
+  private void verifyComponentByRef(int ref, String key, String shortName, @Nullable String uuid) {
     Map<Integer, Component> componentsByRef = indexAllComponentsInTreeByRef(treeRootHolder.getRoot());
     Component component = componentsByRef.get(ref);
-    assertThat(component.getDbKey()).isEqualTo(key);
-    assertThat(component.getKey()).isEqualTo(publicKey);
+    assertThat(component.getKey()).isEqualTo(key);
     assertThat(component.getShortName()).isEqualTo(shortName);
     if (uuid != null) {
       assertThat(component.getUuid()).isEqualTo(uuid);
@@ -572,7 +560,7 @@ public class BuildComponentTreeStepTest {
     analysisMetadataHolder.setRootComponentRef(ROOT_REF)
       .setAnalysisDate(ANALYSIS_DATE)
       .setBranch(branch)
-      .setProject(Project.from(newPrivateProjectDto().setDbKey(REPORT_PROJECT_KEY).setName(REPORT_PROJECT_KEY)));
+      .setProject(Project.from(newPrivateProjectDto().setKey(REPORT_PROJECT_KEY).setName(REPORT_PROJECT_KEY)));
   }
 
   public static ScannerReport.Metadata createReportMetadata(@Nullable String projectVersion, @Nullable String buildString) {
index ce62cb4792dfda9e1aac1d976337637c1c534aa8..1a8a328a3dec9b6fc663db0d0eac15d2202ae732 100644 (file)
@@ -157,7 +157,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest {
           .build()),
       singletonList(
         new Block.Builder()
-          .setResourceId(otherFile.getDbKey())
+          .setResourceId(otherFile.getKey())
           .setBlockHash(new ByteArray(hash))
           .setIndexInFile(duplicate.getIndexInFile())
           .setLines(duplicate.getStartLine(), duplicate.getEndLine())
@@ -238,14 +238,14 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest {
     Map<Integer, Block> duplicationBlocksByIndex = blocksByIndexInFile(duplicationBlocks.getValue());
     assertThat(duplicationBlocksByIndex.get(0)).isEqualTo(
       new Block.Builder()
-        .setResourceId(otherFile.getDbKey())
+        .setResourceId(otherFile.getKey())
         .setBlockHash(new ByteArray(originBlock1.getHash()))
         .setIndexInFile(duplicate1.getIndexInFile())
         .setLines(duplicate1.getStartLine(), duplicate1.getEndLine())
         .build());
     assertThat(duplicationBlocksByIndex.get(1)).isEqualTo(
       new Block.Builder()
-        .setResourceId(otherFile.getDbKey())
+        .setResourceId(otherFile.getKey())
         .setBlockHash(new ByteArray(originBlock2.getHash()))
         .setIndexInFile(duplicate2.getIndexInFile())
         .setLines(duplicate2.getStartLine(), duplicate2.getEndLine())
@@ -319,7 +319,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest {
   }
 
   private ComponentDto createProject(String projectKey) {
-    ComponentDto project = ComponentTesting.newPrivateProjectDto().setDbKey(projectKey);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto().setKey(projectKey);
     return dbTester.components().insertComponent(project);
   }
 
@@ -332,7 +332,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest {
 
   private ComponentDto createFile(String fileKey, ComponentDto project) {
     ComponentDto file = ComponentTesting.newFileDto(project, null)
-      .setDbKey(fileKey)
+      .setKey(fileKey)
       .setLanguage(XOO_LANGUAGE);
     dbClient.componentDao().insert(dbSession, file);
     dbSession.commit();
index 6339dbfa4a44b67bb76abe7af5722c1de59cbebf..05131c002c9e18e894fe6e8ddd33e1a068532b39 100644 (file)
@@ -76,7 +76,7 @@ public class LoadReportAnalysisMetadataHolderStepTest {
   public void setUp() {
     CeTask defaultOrgCeTask = createCeTask(PROJECT_KEY);
     underTest = createStep(defaultOrgCeTask);
-    project = db.components().insertPublicProject(p -> p.setDbKey(PROJECT_KEY));
+    project = db.components().insertPublicProject(p -> p.setKey(PROJECT_KEY));
   }
 
   @Test
@@ -127,7 +127,7 @@ public class LoadReportAnalysisMetadataHolderStepTest {
 
     Project project = analysisMetadataHolder.getProject();
     assertThat(project.getUuid()).isEqualTo(this.project.uuid());
-    assertThat(project.getKey()).isEqualTo(this.project.getDbKey());
+    assertThat(project.getKey()).isEqualTo(this.project.getKey());
     assertThat(project.getName()).isEqualTo(this.project.name());
     assertThat(project.getDescription()).isEqualTo(this.project.description());
   }
@@ -215,12 +215,12 @@ public class LoadReportAnalysisMetadataHolderStepTest {
     ComponentDto otherProject = db.components().insertPublicProject();
     reportReader.setMetadata(
       ScannerReport.Metadata.newBuilder()
-        .setProjectKey(otherProject.getDbKey())
+        .setProjectKey(otherProject.getKey())
         .build());
 
     assertThatThrownBy(() -> underTest.execute(new TestComputationStepContext()))
       .isInstanceOf(MessageException.class)
-      .hasMessage("ProjectKey in report (" + otherProject.getDbKey() + ") is not consistent with projectKey under which the report has been submitted (" + PROJECT_KEY + ")");
+      .hasMessage("ProjectKey in report (" + otherProject.getKey() + ") is not consistent with projectKey under which the report has been submitted (" + PROJECT_KEY + ")");
 
   }
 
@@ -229,7 +229,7 @@ public class LoadReportAnalysisMetadataHolderStepTest {
     ComponentDto otherProject = db.components().insertPublicProject();
     reportReader.setMetadata(
       ScannerReport.Metadata.newBuilder()
-        .setProjectKey(otherProject.getDbKey())
+        .setProjectKey(otherProject.getKey())
         .build());
 
     try {
@@ -244,7 +244,7 @@ public class LoadReportAnalysisMetadataHolderStepTest {
     ComponentDto otherProject = db.components().insertPublicProject();
     reportReader.setMetadata(
       ScannerReport.Metadata.newBuilder()
-        .setProjectKey(otherProject.getDbKey())
+        .setProjectKey(otherProject.getKey())
         .setAnalysisDate(ANALYSIS_DATE)
         .build());
 
@@ -260,11 +260,11 @@ public class LoadReportAnalysisMetadataHolderStepTest {
     ComponentDto project = db.components().insertPublicProject();
     ScannerReport.Metadata.Builder metadataBuilder = newBatchReportBuilder();
     metadataBuilder
-      .setProjectKey(project.getDbKey());
+      .setProjectKey(project.getKey());
     metadataBuilder.putQprofilesPerLanguage("js", ScannerReport.Metadata.QProfile.newBuilder().setKey("p1").setName("Sonar way").setLanguage("js").build());
     reportReader.setMetadata(metadataBuilder.build());
 
-    ComputationStep underTest = createStep(createCeTask(project.getDbKey()));
+    ComputationStep underTest = createStep(createCeTask(project.getKey()));
 
     underTest.execute(new TestComputationStepContext());
   }
index 92b0c04112cb8a807011045b079dbbc0c15f9530..b20ca1a60886c157a49aebaba1ecd788af06a665 100644 (file)
@@ -51,7 +51,7 @@ public class PersistComponentsStepTest {
     String projectKey = randomAlphabetic(20);
 
     doReturn(component).when(treeRootHolder).getRoot();
-    doReturn(projectKey).when(component).getDbKey();
+    doReturn(projectKey).when(component).getKey();
     doReturn(componentDao).when(dbClient).componentDao();
     doReturn(emptyList()).when(componentDao).selectAllComponentsFromProjectKey(any(DbSession.class), eq(projectKey));
 
index 3b39bdcdc3466ab0c2bf7467634f418e1522f461..e6dabb7a5b96b141522dd9aa6cdc48382be53ce9 100644 (file)
@@ -175,11 +175,11 @@ public class PersistDuplicationDataStepTest extends BaseStepTest {
 
   private ComponentDto insertComponent(String key, String uuid) {
     ComponentDto componentDto = new ComponentDto()
-      .setDbKey(key)
+      .setKey(key)
       .setUuid(uuid)
       .setUuidPath(uuid + ".")
       .setRootUuid(uuid)
-      .setProjectUuid(uuid);
+      .setBranchUuid(uuid);
     db.components().insertComponent(componentDto);
     return componentDto;
   }
index be8adf493fc59ad4ee694a0e96e41453242a55e3..a4a2a343b2b16f3266fc3f6fcaba1e878bacbec8 100644 (file)
@@ -267,7 +267,7 @@ public class PersistLiveMeasuresStepTest extends BaseStepTest {
           .build())
       .build();
     treeRootHolder.setRoot(project);
-    analysisMetadataHolder.setProject(new Project(project.getUuid(), project.getDbKey(), project.getName(), project.getDescription(), emptyList()));
+    analysisMetadataHolder.setProject(new Project(project.getUuid(), project.getKey(), project.getName(), project.getDescription(), emptyList()));
 
     // components as persisted in db
     ComponentDto projectDto = insertComponent("project-key", "project-uuid");
@@ -304,11 +304,11 @@ public class PersistLiveMeasuresStepTest extends BaseStepTest {
 
   private ComponentDto insertComponent(String key, String uuid) {
     ComponentDto componentDto = new ComponentDto()
-      .setDbKey(key)
+      .setKey(key)
       .setUuid(uuid)
       .setUuidPath(uuid + ".")
       .setRootUuid(uuid)
-      .setProjectUuid(uuid);
+      .setBranchUuid(uuid);
     db.components().insertComponent(componentDto);
     return componentDto;
   }
index 83e62f7c60bfbbcd7fb08c5973397a8819babf54..c293d0a453880a16aa399c3c2f60bbd58ffe61b3 100644 (file)
@@ -223,11 +223,11 @@ public class PersistMeasuresStepTest extends BaseStepTest {
 
   private ComponentDto insertComponent(String key, String uuid) {
     ComponentDto componentDto = new ComponentDto()
-      .setDbKey(key)
+      .setKey(key)
       .setUuid(uuid)
       .setUuidPath(uuid + ".")
       .setRootUuid(uuid)
-      .setProjectUuid(uuid);
+      .setBranchUuid(uuid);
     db.components().insertComponent(componentDto);
     return componentDto;
   }
index a68cff2659ac6544d65d42b22f62c861d707c6e2..0ae78766c0750f1fa86fd627403cc8df6db266c5 100644 (file)
@@ -97,7 +97,7 @@ public class QualityGateEventsStepTest {
   public void setUp() {
     when(metricRepository.getByKey(ALERT_STATUS_KEY)).thenReturn(alertStatusMetric);
     analysisMetadataHolder
-      .setProject(new Project(PROJECT_COMPONENT.getUuid(), PROJECT_COMPONENT.getDbKey(), PROJECT_COMPONENT.getName(), PROJECT_COMPONENT.getDescription(), emptyList()));
+      .setProject(new Project(PROJECT_COMPONENT.getUuid(), PROJECT_COMPONENT.getKey(), PROJECT_COMPONENT.getName(), PROJECT_COMPONENT.getDescription(), emptyList()));
     analysisMetadataHolder.setBranch(mock(Branch.class));
     treeRootHolder.setRoot(PROJECT_COMPONENT);
   }
index 06cddbc136d8ea7a7283962ad9fa4f88440afe1e..dd4de426878f924981e4fd5e14af53ad93646c41 100644 (file)
@@ -93,13 +93,13 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
   @Test
   public void persist_analysis() {
     String projectVersion = randomAlphabetic(10);
-    ComponentDto projectDto = ComponentTesting.newPrivateProjectDto("ABCD").setDbKey(PROJECT_KEY).setName("Project");
+    ComponentDto projectDto = ComponentTesting.newPrivateProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project");
     dbTester.components().insertComponent(projectDto);
-    ComponentDto moduleDto = ComponentTesting.newModuleDto("BCDE", projectDto).setDbKey("MODULE_KEY").setName("Module");
+    ComponentDto moduleDto = ComponentTesting.newModuleDto("BCDE", projectDto).setKey("MODULE_KEY").setName("Module");
     dbTester.components().insertComponent(moduleDto);
-    ComponentDto directoryDto = ComponentTesting.newDirectory(moduleDto, "CDEF", "MODULE_KEY:src/main/java/dir").setDbKey("MODULE_KEY:src/main/java/dir");
+    ComponentDto directoryDto = ComponentTesting.newDirectory(moduleDto, "CDEF", "MODULE_KEY:src/main/java/dir").setKey("MODULE_KEY:src/main/java/dir");
     dbTester.components().insertComponent(directoryDto);
-    ComponentDto fileDto = ComponentTesting.newFileDto(moduleDto, directoryDto, "DEFG").setDbKey("MODULE_KEY:src/main/java/dir/Foo.java");
+    ComponentDto fileDto = ComponentTesting.newFileDto(moduleDto, directoryDto, "DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java");
     dbTester.components().insertComponent(fileDto);
     dbTester.getSession().commit();
 
@@ -134,7 +134,7 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
 
   @Test
   public void persist_snapshots_with_new_code_period() {
-    ComponentDto projectDto = ComponentTesting.newPrivateProjectDto("ABCD").setDbKey(PROJECT_KEY).setName("Project");
+    ComponentDto projectDto = ComponentTesting.newPrivateProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project");
     dbTester.components().insertComponent(projectDto);
     SnapshotDto snapshotDto = SnapshotTesting.newAnalysis(projectDto).setCreatedAt(DateUtils.parseDateQuietly("2015-01-01").getTime());
     dbClient.snapshotDao().insert(dbTester.getSession(), snapshotDto);
@@ -156,18 +156,18 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
   public void only_persist_snapshots_with_new_code_period_on_project_and_module() {
     periodsHolder.setPeriod(new Period("PREVIOUS_VERSION", null, analysisDate));
 
-    ComponentDto projectDto = ComponentTesting.newPrivateProjectDto("ABCD").setDbKey(PROJECT_KEY).setName("Project");
+    ComponentDto projectDto = ComponentTesting.newPrivateProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project");
     dbTester.components().insertComponent(projectDto);
     SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(projectDto);
     dbClient.snapshotDao().insert(dbTester.getSession(), projectSnapshot);
 
-    ComponentDto moduleDto = ComponentTesting.newModuleDto("BCDE", projectDto).setDbKey("MODULE_KEY").setName("Module");
+    ComponentDto moduleDto = ComponentTesting.newModuleDto("BCDE", projectDto).setKey("MODULE_KEY").setName("Module");
     dbTester.components().insertComponent(moduleDto);
 
-    ComponentDto directoryDto = ComponentTesting.newDirectory(moduleDto, "CDEF", "MODULE_KEY:src/main/java/dir").setDbKey("MODULE_KEY:src/main/java/dir");
+    ComponentDto directoryDto = ComponentTesting.newDirectory(moduleDto, "CDEF", "MODULE_KEY:src/main/java/dir").setKey("MODULE_KEY:src/main/java/dir");
     dbTester.components().insertComponent(directoryDto);
 
-    ComponentDto fileDto = ComponentTesting.newFileDto(moduleDto, directoryDto, "DEFG").setDbKey("MODULE_KEY:src/main/java/dir/Foo.java");
+    ComponentDto fileDto = ComponentTesting.newFileDto(moduleDto, directoryDto, "DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java");
     dbTester.components().insertComponent(fileDto);
 
     dbTester.getSession().commit();
@@ -185,7 +185,7 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
 
   @Test
   public void set_no_period_on_snapshots_when_no_period() {
-    ComponentDto projectDto = ComponentTesting.newPrivateProjectDto("ABCD").setDbKey(PROJECT_KEY).setName("Project");
+    ComponentDto projectDto = ComponentTesting.newPrivateProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project");
     dbTester.components().insertComponent(projectDto);
     SnapshotDto snapshotDto = SnapshotTesting.newAnalysis(projectDto);
     dbClient.snapshotDao().insert(dbTester.getSession(), snapshotDto);
index efaca113b357b8989c6379740856e343d9dcaad7..18fe21647511c1e8dc47babadbeee17aeba9a831 100644 (file)
@@ -43,8 +43,10 @@ import org.sonar.ce.task.step.ComputationStep;
 import org.sonar.ce.task.step.TestComputationStepContext;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
+import org.sonar.db.component.BranchDto;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.ComponentTesting;
+import org.sonar.db.project.ProjectDto;
 import org.sonar.server.project.Project;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -125,7 +127,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(directoryDto.moduleUuid()).isEqualTo(projectDto.uuid());
     assertThat(directoryDto.moduleUuidPath()).isEqualTo(projectDto.moduleUuidPath());
     assertThat(directoryDto.getMainBranchProjectUuid()).isNull();
-    assertThat(directoryDto.projectUuid()).isEqualTo(projectDto.uuid());
+    assertThat(directoryDto.branchUuid()).isEqualTo(projectDto.uuid());
     assertThat(directoryDto.qualifier()).isEqualTo("DIR");
     assertThat(directoryDto.scope()).isEqualTo("DIR");
     assertThat(directoryDto.getRootUuid()).isEqualTo(projectDto.uuid());
@@ -142,7 +144,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(fileDto.moduleUuid()).isEqualTo(projectDto.uuid());
     assertThat(fileDto.moduleUuidPath()).isEqualTo(projectDto.moduleUuidPath());
     assertThat(fileDto.getMainBranchProjectUuid()).isNull();
-    assertThat(fileDto.projectUuid()).isEqualTo(projectDto.uuid());
+    assertThat(fileDto.branchUuid()).isEqualTo(projectDto.uuid());
     assertThat(fileDto.qualifier()).isEqualTo("FIL");
     assertThat(fileDto.scope()).isEqualTo("FIL");
     assertThat(fileDto.getRootUuid()).isEqualTo(projectDto.uuid());
@@ -151,7 +153,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
 
   @Test
   public void persist_components_of_existing_branch() {
-    ComponentDto project = prepareBranch("feature/foo");
+    ComponentDto branch = prepareBranch("feature/foo");
     Component file = builder(FILE, 4).setUuid("DEFG").setKey("PROJECT_KEY:src/main/java/dir/Foo.java")
       .setName("src/main/java/dir/Foo.java")
       .setShortName("Foo.java")
@@ -163,7 +165,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
       .setShortName("dir")
       .addChildren(file)
       .build();
-    Component treeRoot = asTreeRoot(project)
+    Component treeRoot = asTreeRoot(branch)
       .addChildren(directory)
       .build();
     treeRootHolder.setRoot(treeRoot);
@@ -172,23 +174,23 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
 
     assertThat(db.countRowsOfTable("components")).isEqualTo(3);
 
-    ComponentDto directoryDto = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get();
+    ComponentDto directoryDto = dbClient.componentDao().selectByKeyAndBranch(db.getSession(), "PROJECT_KEY:src/main/java/dir", "feature/foo").get();
     assertThat(directoryDto.name()).isEqualTo("dir");
     assertThat(directoryDto.longName()).isEqualTo("src/main/java/dir");
     assertThat(directoryDto.description()).isNull();
     assertThat(directoryDto.path()).isEqualTo("src/main/java/dir");
     assertThat(directoryDto.uuid()).isEqualTo("CDEF");
-    assertThat(directoryDto.getUuidPath()).isEqualTo(UUID_PATH_SEPARATOR + project.uuid() + UUID_PATH_SEPARATOR);
-    assertThat(directoryDto.moduleUuid()).isEqualTo(project.uuid());
-    assertThat(directoryDto.moduleUuidPath()).isEqualTo(project.moduleUuidPath());
-    assertThat(directoryDto.getMainBranchProjectUuid()).isEqualTo(project.uuid());
-    assertThat(directoryDto.projectUuid()).isEqualTo(project.uuid());
+    assertThat(directoryDto.getUuidPath()).isEqualTo(UUID_PATH_SEPARATOR + branch.uuid() + UUID_PATH_SEPARATOR);
+    assertThat(directoryDto.moduleUuid()).isEqualTo(branch.uuid());
+    assertThat(directoryDto.moduleUuidPath()).isEqualTo(branch.moduleUuidPath());
+    assertThat(directoryDto.getMainBranchProjectUuid()).isEqualTo(branch.uuid());
+    assertThat(directoryDto.branchUuid()).isEqualTo(branch.uuid());
     assertThat(directoryDto.qualifier()).isEqualTo("DIR");
     assertThat(directoryDto.scope()).isEqualTo("DIR");
-    assertThat(directoryDto.getRootUuid()).isEqualTo(project.uuid());
+    assertThat(directoryDto.getRootUuid()).isEqualTo(branch.uuid());
     assertThat(directoryDto.getCreatedAt()).isEqualTo(now);
 
-    ComponentDto fileDto = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java").get();
+    ComponentDto fileDto = dbClient.componentDao().selectByKeyAndBranch(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java", "feature/foo").get();
     assertThat(fileDto.name()).isEqualTo("Foo.java");
     assertThat(fileDto.longName()).isEqualTo("src/main/java/dir/Foo.java");
     assertThat(fileDto.description()).isNull();
@@ -196,13 +198,13 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(fileDto.language()).isEqualTo("java");
     assertThat(fileDto.uuid()).isEqualTo("DEFG");
     assertThat(fileDto.getUuidPath()).isEqualTo(directoryDto.getUuidPath() + directoryDto.uuid() + UUID_PATH_SEPARATOR);
-    assertThat(fileDto.moduleUuid()).isEqualTo(project.uuid());
-    assertThat(fileDto.moduleUuidPath()).isEqualTo(project.moduleUuidPath());
-    assertThat(fileDto.getMainBranchProjectUuid()).isEqualTo(project.uuid());
-    assertThat(fileDto.projectUuid()).isEqualTo(project.uuid());
+    assertThat(fileDto.moduleUuid()).isEqualTo(branch.uuid());
+    assertThat(fileDto.moduleUuidPath()).isEqualTo(branch.moduleUuidPath());
+    assertThat(fileDto.getMainBranchProjectUuid()).isEqualTo(branch.uuid());
+    assertThat(fileDto.branchUuid()).isEqualTo(branch.uuid());
     assertThat(fileDto.qualifier()).isEqualTo("FIL");
     assertThat(fileDto.scope()).isEqualTo("FIL");
-    assertThat(fileDto.getRootUuid()).isEqualTo(project.uuid());
+    assertThat(fileDto.getRootUuid()).isEqualTo(branch.uuid());
     assertThat(fileDto.getCreatedAt()).isEqualTo(now);
   }
 
@@ -212,16 +214,16 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     treeRootHolder.setRoot(
       asTreeRoot(projectDto)
         .addChildren(
-          builder(FILE, 2).setUuid("DEFG").setKey(projectDto.getDbKey() + ":pom.xml")
+          builder(FILE, 2).setUuid("DEFG").setKey(projectDto.getKey() + ":pom.xml")
             .setName("pom.xml")
             .build())
         .build());
 
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(dbClient.componentDao().selectByKey(db.getSession(), projectDto.getDbKey() + ":/")).isNotPresent();
+    assertThat(dbClient.componentDao().selectByKey(db.getSession(), projectDto.getKey() + ":/")).isNotPresent();
 
-    ComponentDto file = dbClient.componentDao().selectByKey(db.getSession(), projectDto.getDbKey() + ":pom.xml").get();
+    ComponentDto file = dbClient.componentDao().selectByKey(db.getSession(), projectDto.getKey() + ":pom.xml").get();
     assertThat(file.name()).isEqualTo("pom.xml");
     assertThat(file.path()).isEqualTo("pom.xml");
   }
@@ -256,9 +258,9 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
   @Test
   public void update_file_to_directory_change_scope() {
     ComponentDto project = prepareProject();
-    ComponentDto directory = ComponentTesting.newDirectory(project, "src").setUuid("CDEF").setDbKey("PROJECT_KEY:src");
+    ComponentDto directory = ComponentTesting.newDirectory(project, "src").setUuid("CDEF").setKey("PROJECT_KEY:src");
     ComponentDto file = ComponentTesting.newFileDto(project, directory, "DEFG").setPath("src/foo").setName("foo")
-      .setDbKey("PROJECT_KEY:src/foo");
+      .setKey("PROJECT_KEY:src/foo");
     dbClient.componentDao().insert(db.getSession(), directory, file);
     db.getSession().commit();
 
@@ -294,7 +296,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
   @Test
   public void update_module_to_directory_change_scope() {
     ComponentDto project = prepareProject();
-    ComponentDto module = ComponentTesting.newModuleDto(project).setUuid("CDEF").setDbKey("MODULE_KEY").setPath("module");
+    ComponentDto module = ComponentTesting.newModuleDto(project).setUuid("CDEF").setKey("MODULE_KEY").setPath("module");
     dbClient.componentDao().insert(db.getSession(), module);
     db.getSession().commit();
 
@@ -330,7 +332,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     db.getSession().commit();
 
     treeRootHolder.setRoot(
-      builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.getDbKey())
+      builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.getKey())
         .setName("Project")
         .addChildren(
           builder(DIRECTORY, 3).setUuid("CDEF").setKey("PROJECT_KEY:src/main/java/dir")
@@ -347,7 +349,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
 
     assertThat(db.countRowsOfTable("components")).isEqualTo(3);
 
-    ComponentDto projectReloaded = dbClient.componentDao().selectByKey(db.getSession(), project.getDbKey()).get();
+    ComponentDto projectReloaded = dbClient.componentDao().selectByKey(db.getSession(), project.getKey()).get();
     assertThat(projectReloaded.uuid()).isEqualTo(project.uuid());
     assertThat(projectReloaded.getUuidPath()).isEqualTo(UUID_PATH_OF_ROOT);
     assertThat(projectReloaded.getMainBranchProjectUuid()).isNull();
@@ -356,7 +358,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(directory.getUuidPath()).isEqualTo(directory.getUuidPath());
     assertThat(directory.moduleUuid()).isEqualTo(project.uuid());
     assertThat(directory.moduleUuidPath()).isEqualTo(project.moduleUuidPath());
-    assertThat(directory.projectUuid()).isEqualTo(project.uuid());
+    assertThat(directory.branchUuid()).isEqualTo(project.uuid());
     assertThat(directory.getRootUuid()).isEqualTo(project.uuid());
     assertThat(directory.getMainBranchProjectUuid()).isNull();
 
@@ -364,7 +366,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(file.getUuidPath()).isEqualTo(file.getUuidPath());
     assertThat(file.moduleUuid()).isEqualTo(project.uuid());
     assertThat(file.moduleUuidPath()).isEqualTo(project.moduleUuidPath());
-    assertThat(file.projectUuid()).isEqualTo(project.uuid());
+    assertThat(file.branchUuid()).isEqualTo(project.uuid());
     assertThat(file.getRootUuid()).isEqualTo(project.uuid());
     assertThat(file.getMainBranchProjectUuid()).isNull();
   }
@@ -372,14 +374,14 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
   @Test
   public void nothing_to_persist() {
     ComponentDto project = prepareProject();
-    ComponentDto directory = ComponentTesting.newDirectory(project, "src/main/java/dir").setUuid("CDEF").setDbKey("PROJECT_KEY:src/main/java/dir");
+    ComponentDto directory = ComponentTesting.newDirectory(project, "src/main/java/dir").setUuid("CDEF").setKey("PROJECT_KEY:src/main/java/dir");
     ComponentDto file = ComponentTesting.newFileDto(project, directory, "DEFG").setPath("src/main/java/dir/Foo.java").setName("Foo.java")
-      .setDbKey("PROJECT_KEY:src/main/java/dir/Foo.java");
+      .setKey("PROJECT_KEY:src/main/java/dir/Foo.java");
     dbClient.componentDao().insert(db.getSession(), directory, file);
     db.getSession().commit();
 
     treeRootHolder.setRoot(
-      builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.getDbKey())
+      builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.getKey())
         .setName("Project")
         .addChildren(
           builder(DIRECTORY, 3).setUuid("CDEF").setKey("PROJECT_KEY:src/main/java/dir")
@@ -394,15 +396,15 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     underTest.execute(new TestComputationStepContext());
 
     assertThat(db.countRowsOfTable("components")).isEqualTo(3);
-    assertThat(dbClient.componentDao().selectByKey(db.getSession(), project.getDbKey()).get().uuid()).isEqualTo(project.uuid());
+    assertThat(dbClient.componentDao().selectByKey(db.getSession(), project.getKey()).get().uuid()).isEqualTo(project.uuid());
     assertThat(dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get().uuid()).isEqualTo(directory.uuid());
     assertThat(dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java").get().uuid()).isEqualTo(file.uuid());
 
-    ComponentDto projectReloaded = dbClient.componentDao().selectByKey(db.getSession(), project.getDbKey()).get();
+    ComponentDto projectReloaded = dbClient.componentDao().selectByKey(db.getSession(), project.getKey()).get();
     assertThat(projectReloaded.uuid()).isEqualTo(project.uuid());
     assertThat(projectReloaded.moduleUuid()).isEqualTo(project.moduleUuid());
     assertThat(projectReloaded.moduleUuidPath()).isEqualTo(project.moduleUuidPath());
-    assertThat(projectReloaded.projectUuid()).isEqualTo(project.projectUuid());
+    assertThat(projectReloaded.branchUuid()).isEqualTo(project.branchUuid());
     assertThat(projectReloaded.getRootUuid()).isEqualTo(project.getRootUuid());
 
     ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get();
@@ -410,7 +412,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(directoryReloaded.getUuidPath()).isEqualTo(directory.getUuidPath());
     assertThat(directoryReloaded.moduleUuid()).isEqualTo(directory.moduleUuid());
     assertThat(directoryReloaded.moduleUuidPath()).isEqualTo(directory.moduleUuidPath());
-    assertThat(directoryReloaded.projectUuid()).isEqualTo(directory.projectUuid());
+    assertThat(directoryReloaded.branchUuid()).isEqualTo(directory.branchUuid());
     assertThat(directoryReloaded.getRootUuid()).isEqualTo(directory.getRootUuid());
     assertThat(directoryReloaded.name()).isEqualTo(directory.name());
     assertThat(directoryReloaded.path()).isEqualTo(directory.path());
@@ -420,7 +422,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(fileReloaded.getUuidPath()).isEqualTo(file.getUuidPath());
     assertThat(fileReloaded.moduleUuid()).isEqualTo(file.moduleUuid());
     assertThat(fileReloaded.moduleUuidPath()).isEqualTo(file.moduleUuidPath());
-    assertThat(fileReloaded.projectUuid()).isEqualTo(file.projectUuid());
+    assertThat(fileReloaded.branchUuid()).isEqualTo(file.branchUuid());
     assertThat(fileReloaded.getRootUuid()).isEqualTo(file.getRootUuid());
     assertThat(fileReloaded.name()).isEqualTo(file.name());
     assertThat(fileReloaded.path()).isEqualTo(file.path());
@@ -429,14 +431,14 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
   @Test
   public void update_module_uuid_when_moving_a_module() {
     ComponentDto project = prepareProject();
-    ComponentDto directory = ComponentTesting.newDirectory(project, "src/main/java/dir").setUuid("CDEF").setDbKey("PROJECT_KEY:src/main/java/dir");
+    ComponentDto directory = ComponentTesting.newDirectory(project, "src/main/java/dir").setUuid("CDEF").setKey("PROJECT_KEY:src/main/java/dir");
     ComponentDto file = ComponentTesting.newFileDto(project, directory, "DEFG").setPath("src/main/java/dir/Foo.java").setName("Foo.java")
-      .setDbKey("PROJECT_KEY:src/main/java/dir/Foo.java");
+      .setKey("PROJECT_KEY:src/main/java/dir/Foo.java");
     dbClient.componentDao().insert(db.getSession(), directory, file);
     db.getSession().commit();
 
     treeRootHolder.setRoot(
-      builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.getDbKey())
+      builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.getKey())
         .setName("Project")
         .addChildren(
           builder(DIRECTORY, 4).setUuid("CDEF").setKey("PROJECT_KEY:src/main/java/dir")
@@ -462,7 +464,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(directoryReloaded.getUuidPath()).isEqualTo(directoryReloaded.getUuidPath());
     assertThat(directoryReloaded.moduleUuid()).isEqualTo(project.uuid());
     assertThat(directoryReloaded.moduleUuidPath()).isEqualTo(project.moduleUuidPath());
-    assertThat(directoryReloaded.projectUuid()).isEqualTo(project.uuid());
+    assertThat(directoryReloaded.branchUuid()).isEqualTo(project.uuid());
     assertThat(directoryReloaded.getRootUuid()).isEqualTo(project.uuid());
 
     ComponentDto fileReloaded = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java").get();
@@ -471,7 +473,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(fileReloaded.getUuidPath()).isEqualTo(fileReloaded.getUuidPath());
     assertThat(fileReloaded.moduleUuid()).isEqualTo(project.uuid());
     assertThat(fileReloaded.moduleUuidPath()).isEqualTo(project.moduleUuidPath());
-    assertThat(fileReloaded.projectUuid()).isEqualTo(project.uuid());
+    assertThat(fileReloaded.branchUuid()).isEqualTo(project.uuid());
     assertThat(fileReloaded.getRootUuid()).isEqualTo(project.uuid());
   }
 
@@ -482,7 +484,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     db.getSession().commit();
 
     treeRootHolder.setRoot(
-      builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.getDbKey())
+      builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.getKey())
         .build());
 
     underTest.execute(new TestComputationStepContext());
@@ -498,19 +500,19 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
       .setLongName("src/main/java/dir")
       .setName("dir")
       .setUuid("CDEF")
-      .setDbKey("PROJECT_KEY:src/main/java/dir")
+      .setKey("PROJECT_KEY:src/main/java/dir")
       .setEnabled(false);
     ComponentDto removedFile = ComponentTesting.newFileDto(project, removedDirectory, "DEFG")
       .setPath("src/main/java/dir/Foo.java")
       .setLongName("src/main/java/dir/Foo.java")
       .setName("Foo.java")
-      .setDbKey("PROJECT_KEY:src/main/java/dir/Foo.java")
+      .setKey("PROJECT_KEY:src/main/java/dir/Foo.java")
       .setEnabled(false);
     dbClient.componentDao().insert(db.getSession(), removedDirectory, removedFile);
     db.getSession().commit();
 
     treeRootHolder.setRoot(
-      builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.getDbKey())
+      builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.getKey())
         .setName("Project")
         .addChildren(
           builder(DIRECTORY, 3).setUuid("CDEF").setKey("PROJECT_KEY:src/main/java/dir")
@@ -527,20 +529,20 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     underTest.execute(new TestComputationStepContext());
 
     assertThat(db.countRowsOfTable("components")).isEqualTo(3);
-    assertThat(dbClient.componentDao().selectByKey(db.getSession(), project.getDbKey()).get().uuid()).isEqualTo(project.uuid());
+    assertThat(dbClient.componentDao().selectByKey(db.getSession(), project.getKey()).get().uuid()).isEqualTo(project.uuid());
     assertThat(dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get().uuid()).isEqualTo(removedDirectory.uuid());
     assertThat(dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java").get().uuid()).isEqualTo(removedFile.uuid());
-    assertExistButDisabled(removedDirectory.getDbKey(), removedFile.getDbKey());
+    assertExistButDisabled(removedDirectory.getKey(), removedFile.getKey());
 
     // commit the functional transaction
     dbClient.componentDao().applyBChangesForRootComponentUuid(db.getSession(), project.uuid());
 
-    ComponentDto projectReloaded = dbClient.componentDao().selectByKey(db.getSession(), project.getDbKey()).get();
+    ComponentDto projectReloaded = dbClient.componentDao().selectByKey(db.getSession(), project.getKey()).get();
     assertThat(projectReloaded.uuid()).isEqualTo(project.uuid());
     assertThat(projectReloaded.getUuidPath()).isEqualTo(project.getUuidPath());
     assertThat(projectReloaded.moduleUuid()).isEqualTo(project.moduleUuid());
     assertThat(projectReloaded.moduleUuidPath()).isEqualTo(project.moduleUuidPath());
-    assertThat(projectReloaded.projectUuid()).isEqualTo(project.projectUuid());
+    assertThat(projectReloaded.branchUuid()).isEqualTo(project.branchUuid());
     assertThat(projectReloaded.getRootUuid()).isEqualTo(project.getRootUuid());
     assertThat(projectReloaded.isEnabled()).isTrue();
 
@@ -549,7 +551,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(directoryReloaded.getUuidPath()).isEqualTo(removedDirectory.getUuidPath());
     assertThat(directoryReloaded.moduleUuid()).isEqualTo(removedDirectory.moduleUuid());
     assertThat(directoryReloaded.moduleUuidPath()).isEqualTo(removedDirectory.moduleUuidPath());
-    assertThat(directoryReloaded.projectUuid()).isEqualTo(removedDirectory.projectUuid());
+    assertThat(directoryReloaded.branchUuid()).isEqualTo(removedDirectory.branchUuid());
     assertThat(directoryReloaded.getRootUuid()).isEqualTo(removedDirectory.getRootUuid());
     assertThat(directoryReloaded.name()).isEqualTo(removedDirectory.name());
     assertThat(directoryReloaded.longName()).isEqualTo(removedDirectory.longName());
@@ -561,7 +563,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(fileReloaded.getUuidPath()).isEqualTo(removedFile.getUuidPath());
     assertThat(fileReloaded.moduleUuid()).isEqualTo(removedFile.moduleUuid());
     assertThat(fileReloaded.moduleUuidPath()).isEqualTo(removedFile.moduleUuidPath());
-    assertThat(fileReloaded.projectUuid()).isEqualTo(removedFile.projectUuid());
+    assertThat(fileReloaded.branchUuid()).isEqualTo(removedFile.branchUuid());
     assertThat(fileReloaded.getRootUuid()).isEqualTo(removedFile.getRootUuid());
     assertThat(fileReloaded.name()).isEqualTo(removedFile.name());
     assertThat(fileReloaded.path()).isEqualTo(removedFile.path());
@@ -580,7 +582,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     ComponentDto project = prepareProject(p -> p.setPrivate(true));
     ComponentDto module = newModuleDto(project).setPrivate(false);
     db.components().insertComponent(module);
-    ComponentDto dir = db.components().insertComponent(newDirectory(module, "DEFG", "Directory").setDbKey("DIR").setPrivate(true));
+    ComponentDto dir = db.components().insertComponent(newDirectory(module, "DEFG", "Directory").setKey("DIR").setPrivate(true));
     treeRootHolder.setRoot(createSampleProjectComponentTree(project));
 
     underTest.execute(new TestComputationStepContext());
@@ -592,7 +594,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
   }
 
   private ReportComponent createSampleProjectComponentTree(ComponentDto project) {
-    return createSampleProjectComponentTree(project.uuid(), project.getDbKey());
+    return createSampleProjectComponentTree(project.uuid(), project.getKey());
   }
 
   private ReportComponent createSampleProjectComponentTree(String projectUuid, String projectKey) {
@@ -610,7 +612,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
   }
 
   private ReportComponent.Builder asTreeRoot(ComponentDto project) {
-    return builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.getDbKey()).setName(project.name());
+    return builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.getKey()).setName(project.name());
   }
 
   private ComponentDto prepareProject() {
@@ -625,14 +627,11 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
   }
 
   private ComponentDto prepareBranch(String branchName) {
-    return prepareBranch(branchName, defaults());
-  }
-
-  private ComponentDto prepareBranch(String branchName, Consumer<ComponentDto> populators) {
-    ComponentDto dto = db.components().insertPrivateProject(populators);
-    analysisMetadataHolder.setProject(Project.from(dto));
+    ComponentDto projectDto = db.components().insertPublicProject();
+    ComponentDto branchDto = db.components().insertProjectBranch(projectDto, b -> b.setKey(branchName));
+    analysisMetadataHolder.setProject(Project.from(projectDto));
     analysisMetadataHolder.setBranch(new TestBranch(branchName));
-    return dto;
+    return branchDto;
   }
 
   private static <T> Consumer<T> defaults() {
index 338d7516a28a496e3ee3311333915acaeee341dc..a0b7c98b26b86c43eb5e10e7ec22e9ecae58b096 100644 (file)
@@ -497,8 +497,8 @@ public class SendIssueNotificationsStepTest extends BaseStepTest {
   @Test
   public void do_not_send_new_issues_notifications_for_hotspot() {
     UserDto user = db.users().insertUser();
-    ComponentDto project = newPrivateProjectDto().setDbKey(PROJECT.getDbKey()).setLongName(PROJECT.getName());
-    ComponentDto file = newFileDto(project).setDbKey(FILE.getDbKey()).setLongName(FILE.getName());
+    ComponentDto project = newPrivateProjectDto().setKey(PROJECT.getKey()).setLongName(PROJECT.getName());
+    ComponentDto file = newFileDto(project).setKey(FILE.getKey()).setLongName(FILE.getName());
     RuleDto ruleDefinitionDto = newRule();
     prepareIssue(ANALYSE_DATE, user, project, file, ruleDefinitionDto, RuleType.SECURITY_HOTSPOT);
     analysisMetadataHolder.setProject(new Project(PROJECT.getUuid(), PROJECT.getKey(), PROJECT.getName(), null, emptyList()));
@@ -519,12 +519,12 @@ public class SendIssueNotificationsStepTest extends BaseStepTest {
 
   private void sendIssueChangeNotification(long issueCreatedAt) {
     UserDto user = db.users().insertUser();
-    ComponentDto project = newPrivateProjectDto().setDbKey(PROJECT.getDbKey()).setLongName(PROJECT.getName());
+    ComponentDto project = newPrivateProjectDto().setKey(PROJECT.getKey()).setLongName(PROJECT.getName());
     analysisMetadataHolder.setProject(Project.from(project));
-    ComponentDto file = newFileDto(project).setDbKey(FILE.getDbKey()).setLongName(FILE.getName());
-    treeRootHolder.setRoot(builder(Type.PROJECT, 2).setKey(project.getDbKey()).setPublicKey(project.getKey()).setName(project.longName()).setUuid(project.uuid())
+    ComponentDto file = newFileDto(project).setKey(FILE.getKey()).setLongName(FILE.getName());
+    treeRootHolder.setRoot(builder(Type.PROJECT, 2).setKey(project.getKey()).setName(project.longName()).setUuid(project.uuid())
       .addChildren(
-        builder(Type.FILE, 11).setKey(file.getDbKey()).setPublicKey(file.getKey()).setName(file.longName()).build())
+        builder(Type.FILE, 11).setKey(file.getKey()).setName(file.longName()).build())
       .build());
     RuleDto ruleDefinitionDto = newRule();
     RuleType randomTypeExceptHotspot = RuleType.values()[nextInt(RuleType.values().length - 1)];
@@ -550,7 +550,7 @@ public class SendIssueNotificationsStepTest extends BaseStepTest {
     DefaultIssue issue = newIssue(ruleDefinitionDto, project, file).setType(type).toDefaultIssue()
       .setNew(false).setChanged(true).setSendNotifications(true).setCreationDate(new Date(issueCreatedAt)).setAssigneeUuid(user.getUuid());
     protoIssueCache.newAppender().append(issue).close();
-    when(notificationService.hasProjectSubscribersForTypes(project.projectUuid(), NOTIF_TYPES)).thenReturn(true);
+    when(notificationService.hasProjectSubscribersForTypes(project.branchUuid(), NOTIF_TYPES)).thenReturn(true);
     return issue;
   }
 
@@ -568,8 +568,8 @@ public class SendIssueNotificationsStepTest extends BaseStepTest {
     ComponentDto project = newPrivateProjectDto();
     ComponentDto branch = newBranchComponent(project, newBranchDto(project).setKey(BRANCH_NAME));
     ComponentDto file = newFileDto(branch);
-    treeRootHolder.setRoot(builder(Type.PROJECT, 2).setKey(branch.getDbKey()).setPublicKey(branch.getKey()).setName(branch.longName()).setUuid(branch.uuid()).addChildren(
-      builder(Type.FILE, 11).setKey(file.getDbKey()).setPublicKey(file.getKey()).setName(file.longName()).build()).build());
+    treeRootHolder.setRoot(builder(Type.PROJECT, 2).setKey(branch.getKey()).setName(branch.longName()).setUuid(branch.uuid()).addChildren(
+      builder(Type.FILE, 11).setKey(file.getKey()).setName(file.longName()).build()).build());
     analysisMetadataHolder.setProject(Project.from(project));
     RuleDto ruleDefinitionDto = newRule();
     RuleType randomTypeExceptHotspot = RuleType.values()[nextInt(RuleType.values().length - 1)];
@@ -599,8 +599,8 @@ public class SendIssueNotificationsStepTest extends BaseStepTest {
   @Test
   public void sends_one_issue_change_notification_every_1000_issues() {
     UserDto user = db.users().insertUser();
-    ComponentDto project = newPrivateProjectDto().setDbKey(PROJECT.getDbKey()).setLongName(PROJECT.getName());
-    ComponentDto file = newFileDto(project).setDbKey(FILE.getDbKey()).setLongName(FILE.getName());
+    ComponentDto project = newPrivateProjectDto().setKey(PROJECT.getKey()).setLongName(PROJECT.getName());
+    ComponentDto file = newFileDto(project).setKey(FILE.getKey()).setLongName(FILE.getName());
     RuleDto ruleDefinitionDto = newRule();
     RuleType randomTypeExceptHotspot = RuleType.values()[nextInt(RuleType.values().length - 1)];
     List<DefaultIssue> issues = IntStream.range(0, 2001 + new Random().nextInt(10))
@@ -700,8 +700,8 @@ public class SendIssueNotificationsStepTest extends BaseStepTest {
   private ComponentDto setUpBranch(ComponentDto project, BranchType branchType) {
     ComponentDto branch = newBranchComponent(project, newBranchDto(project, branchType).setKey(BRANCH_NAME));
     ComponentDto file = newFileDto(branch);
-    treeRootHolder.setRoot(builder(Type.PROJECT, 2).setKey(branch.getDbKey()).setPublicKey(branch.getKey()).setName(branch.longName()).setUuid(branch.uuid()).addChildren(
-      builder(Type.FILE, 11).setKey(file.getDbKey()).setPublicKey(file.getKey()).setName(file.longName()).build()).build());
+    treeRootHolder.setRoot(builder(Type.PROJECT, 2).setKey(branch.getKey()).setName(branch.longName()).setUuid(branch.uuid()).addChildren(
+      builder(Type.FILE, 11).setKey(file.getKey()).setName(file.longName()).build()).build());
     return branch;
   }
 
index 29c2eb8c9f7734d50a3a019906c7fee414edb1eb..e749ab9593b05315b30e505e5bf4afbec643dbe5 100644 (file)
@@ -49,7 +49,7 @@ public class UpdateNeedIssueSyncStepTest {
   @Test
   public void analysis_step_updates_need_issue_sync_flag() {
     ComponentDto project = db.components()
-      .insertPrivateProject(c -> c.setUuid(PROJECT.getUuid()).setDbKey(PROJECT.getDbKey()));
+      .insertPrivateProject(c -> c.setUuid(PROJECT.getUuid()).setKey(PROJECT.getKey()));
     dbClient.branchDao().updateNeedIssueSync(db.getSession(), PROJECT.getUuid(), true);
     db.getSession().commit();
 
index 8f7dfe180bd7664c2920dd0b3662bfae62112e4b..0e36782973a4f387b2c5dee3533c118ec6844f8c 100644 (file)
@@ -80,7 +80,7 @@ public class ValidateProjectStepTest {
 
   @Test
   public void not_fail_if_analysis_date_is_after_last_analysis() {
-    ComponentDto project = ComponentTesting.newPrivateProjectDto("ABCD").setDbKey(PROJECT_KEY);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto("ABCD").setKey(PROJECT_KEY);
     db.components().insertComponent(project);
     dbClient.snapshotDao().insert(db.getSession(), SnapshotTesting.newAnalysis(project).setCreatedAt(PAST_ANALYSIS_TIME));
     db.getSession().commit();
@@ -112,7 +112,7 @@ public class ValidateProjectStepTest {
   public void fail_if_analysis_date_is_before_last_analysis() {
     analysisMetadataHolder.setAnalysisDate(DateUtils.parseDate("2015-01-01"));
 
-    ComponentDto project = ComponentTesting.newPrivateProjectDto("ABCD").setDbKey(PROJECT_KEY);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto("ABCD").setKey(PROJECT_KEY);
     db.components().insertComponent(project);
     dbClient.snapshotDao().insert(db.getSession(), SnapshotTesting.newAnalysis(project).setCreatedAt(1433131200000L)); // 2015-06-01
     db.getSession().commit();
@@ -129,7 +129,7 @@ public class ValidateProjectStepTest {
 
   @Test
   public void fail_when_project_key_is_invalid() {
-    ComponentDto project = db.components().insertPrivateProject(p -> p.setDbKey("inv$lid!"));
+    ComponentDto project = db.components().insertPrivateProject(p -> p.setKey("inv$lid!"));
     db.components().insertSnapshot(project, a -> a.setCreatedAt(PAST_ANALYSIS_TIME));
     treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1)
       .setUuid(project.uuid())
index 8e05800f5edfb439c64534eabef9ac4538552190..c5a8dc8d5cbd31aaf74e25ab02f88658844f3bfe 100644 (file)
@@ -90,7 +90,7 @@ public class ViewsPersistAnalysisStepTest extends BaseStepTest {
 
   @Test
   public void persist_analysis() {
-    ComponentDto viewDto = save(ComponentTesting.newPortfolio("UUID_VIEW").setDbKey("KEY_VIEW"));
+    ComponentDto viewDto = save(ComponentTesting.newPortfolio("UUID_VIEW").setKey("KEY_VIEW"));
     save(ComponentTesting.newSubPortfolio(viewDto, "UUID_SUBVIEW", "KEY_SUBVIEW"));
     save(newPrivateProjectDto("proj"));
     dbTester.getSession().commit();
@@ -116,7 +116,7 @@ public class ViewsPersistAnalysisStepTest extends BaseStepTest {
 
   @Test
   public void persist_snapshots_with_new_code_period() {
-    ComponentDto viewDto = save(ComponentTesting.newPortfolio("UUID_VIEW").setDbKey("KEY_VIEW"));
+    ComponentDto viewDto = save(ComponentTesting.newPortfolio("UUID_VIEW").setKey("KEY_VIEW"));
     ComponentDto subViewDto = save(ComponentTesting.newSubPortfolio(viewDto, "UUID_SUBVIEW", "KEY_SUBVIEW"));
     dbTester.getSession().commit();
 
index 792586ca3266c2be17c0db334627e84980b1454a..0ba046193a39f96069abcdc8fd5da3b027d4a8fa 100644 (file)
@@ -298,7 +298,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
     ComponentDto project = ComponentTesting.newPrivateProjectDto();
     persistComponents(view, project);
     ComponentDto projectView = ComponentTesting.newProjectCopy(PROJECT_VIEW_1_UUID, project, view)
-      .setDbKey(PROJECT_VIEW_1_KEY)
+      .setKey(PROJECT_VIEW_1_KEY)
       .setName("Old name")
       .setCreatedAt(now);
     persistComponents(projectView);
@@ -328,7 +328,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
 
     // Project view in DB is associated to project1
     ComponentDto projectView = ComponentTesting.newProjectCopy(PROJECT_VIEW_1_UUID, project1, view)
-      .setDbKey(PROJECT_VIEW_1_KEY)
+      .setKey(PROJECT_VIEW_1_KEY)
       .setCreatedAt(now);
     persistComponents(projectView);
 
@@ -393,7 +393,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
   public void persists_new_components_with_visibility_of_root_in_db_out_of_functional_transaction() {
     boolean isRootPrivate = new Random().nextBoolean();
     ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto());
-    ComponentDto view = newViewDto().setUuid(VIEW_UUID).setDbKey(VIEW_KEY).setName("View").setPrivate(isRootPrivate);
+    ComponentDto view = newViewDto().setUuid(VIEW_UUID).setKey(VIEW_KEY).setName("View").setPrivate(isRootPrivate);
     dbTester.components().insertComponent(view);
     treeRootHolder.setRoot(
       createViewBuilder(PORTFOLIO)
@@ -416,11 +416,11 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
   public void persists_existing_components_with_visibility_of_root_in_db_out_of_functional_transaction() {
     boolean isRootPrivate = new Random().nextBoolean();
     ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto());
-    ComponentDto view = newViewDto().setUuid(VIEW_UUID).setDbKey(VIEW_KEY).setName("View").setPrivate(isRootPrivate);
+    ComponentDto view = newViewDto().setUuid(VIEW_UUID).setKey(VIEW_KEY).setName("View").setPrivate(isRootPrivate);
     dbTester.components().insertComponent(view);
-    ComponentDto subView = newSubPortfolio(view).setUuid("BCDE").setDbKey("MODULE").setPrivate(!isRootPrivate);
+    ComponentDto subView = newSubPortfolio(view).setUuid("BCDE").setKey("MODULE").setPrivate(!isRootPrivate);
     dbTester.components().insertComponent(subView);
-    dbTester.components().insertComponent(newProjectCopy("DEFG", project, view).setDbKey("DIR").setPrivate(isRootPrivate));
+    dbTester.components().insertComponent(newProjectCopy("DEFG", project, view).setKey("DIR").setPrivate(isRootPrivate));
     treeRootHolder.setRoot(
       createViewBuilder(PORTFOLIO)
         .addChildren(
@@ -459,7 +459,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
       .setUuid(PROJECT_VIEW_1_UUID)
       .setName(PROJECT_VIEW_1_NAME)
       .setDescription("project view description is not persisted")
-      .setProjectViewAttributes(new ProjectViewAttributes(project.uuid(), project.getDbKey(), analysisDate, project.getBranch()));
+      .setProjectViewAttributes(new ProjectViewAttributes(project.uuid(), project.getKey(), analysisDate, project.getBranch()));
   }
 
   private void persistComponents(ComponentDto... componentDtos) {
@@ -480,7 +480,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
 
   private ComponentDto newViewDto() {
     return ComponentTesting.newPortfolio(VIEW_UUID)
-      .setDbKey(VIEW_KEY)
+      .setKey(VIEW_KEY)
       .setName(VIEW_NAME);
   }
 
@@ -498,7 +498,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
     assertThat(dto.description()).isEqualTo(VIEW_DESCRIPTION);
     assertThat(dto.path()).isNull();
     assertThat(dto.uuid()).isEqualTo(VIEW_UUID);
-    assertThat(dto.projectUuid()).isEqualTo(VIEW_UUID);
+    assertThat(dto.branchUuid()).isEqualTo(VIEW_UUID);
     assertThat(dto.getRootUuid()).isEqualTo(VIEW_UUID);
     assertThat(dto.moduleUuid()).isNull();
     assertThat(dto.moduleUuidPath()).isEqualTo("." + dto.uuid() + ".");
@@ -517,7 +517,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
     assertThat(dto.description()).isEqualTo(VIEW_DESCRIPTION);
     assertThat(dto.path()).isNull();
     assertThat(dto.uuid()).isEqualTo(VIEW_UUID);
-    assertThat(dto.projectUuid()).isEqualTo(VIEW_UUID);
+    assertThat(dto.branchUuid()).isEqualTo(VIEW_UUID);
     assertThat(dto.getRootUuid()).isEqualTo(VIEW_UUID);
     assertThat(dto.moduleUuid()).isNull();
     assertThat(dto.moduleUuidPath()).isEqualTo("." + dto.uuid() + ".");
@@ -536,7 +536,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
     assertThat(sv1Dto.description()).isEqualTo(SUBVIEW_1_DESCRIPTION);
     assertThat(sv1Dto.path()).isNull();
     assertThat(sv1Dto.uuid()).isEqualTo(SUBVIEW_1_UUID);
-    assertThat(sv1Dto.projectUuid()).isEqualTo(viewDto.uuid());
+    assertThat(sv1Dto.branchUuid()).isEqualTo(viewDto.uuid());
     assertThat(sv1Dto.getRootUuid()).isEqualTo(viewDto.uuid());
     assertThat(sv1Dto.moduleUuid()).isEqualTo(viewDto.uuid());
     assertThat(sv1Dto.moduleUuidPath()).isEqualTo(viewDto.moduleUuidPath() + sv1Dto.uuid() + ".");
@@ -552,7 +552,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
     assertThat(pv1Dto.description()).isNull();
     assertThat(pv1Dto.path()).isNull();
     assertThat(pv1Dto.uuid()).isEqualTo(PROJECT_VIEW_1_UUID);
-    assertThat(pv1Dto.projectUuid()).isEqualTo(viewDto.uuid());
+    assertThat(pv1Dto.branchUuid()).isEqualTo(viewDto.uuid());
     assertThat(pv1Dto.getRootUuid()).isEqualTo(viewDto.uuid());
     assertThat(pv1Dto.moduleUuid()).isEqualTo(parentViewDto.uuid());
     assertThat(pv1Dto.moduleUuidPath()).isEqualTo(parentViewDto.moduleUuidPath() + pv1Dto.uuid() + ".");
index 552c8cb8488ee69ddbfb688f4203a88847cad43d..4569a9eb7ffaf113889c919aaa6304d07310a433 100644 (file)
@@ -60,7 +60,7 @@ public class ExportAnalysesStepTest {
     // no id yet
     .setScope(Scopes.PROJECT)
     .setQualifier(Qualifiers.PROJECT)
-    .setDbKey("the_project")
+    .setKey("the_project")
     .setName("The Project")
     .setDescription("The project description")
     .setEnabled(true)
@@ -69,7 +69,7 @@ public class ExportAnalysesStepTest {
     .setRootUuid(PROJECT_UUID)
     .setModuleUuid(null)
     .setModuleUuidPath("." + PROJECT_UUID + ".")
-    .setProjectUuid(PROJECT_UUID);
+    .setBranchUuid(PROJECT_UUID);
 
   private static final String MODULE_UUID = "MODULE_UUID";
   private static final String MODULE_UUID_PATH = UUID_PATH_OF_ROOT + UUID_PATH_SEPARATOR + MODULE_UUID;
@@ -77,7 +77,7 @@ public class ExportAnalysesStepTest {
     // no id yet
     .setScope(Scopes.PROJECT)
     .setQualifier(Qualifiers.MODULE)
-    .setDbKey("the_module")
+    .setKey("the_module")
     .setName("The Module")
     .setDescription("description of module")
     .setEnabled(true)
@@ -86,14 +86,14 @@ public class ExportAnalysesStepTest {
     .setRootUuid(MODULE_UUID)
     .setModuleUuid(PROJECT_UUID)
     .setModuleUuidPath("." + PROJECT_UUID + ".MODULE_UUID.")
-    .setProjectUuid(PROJECT_UUID);
+    .setBranchUuid(PROJECT_UUID);
 
   private static final String FILE_UUID = "FILE_UUID";
   private static final ComponentDto FILE = new ComponentDto()
     // no id yet
     .setScope(Scopes.FILE)
     .setQualifier(Qualifiers.FILE)
-    .setDbKey("the_file")
+    .setKey("the_file")
     .setName("The File")
     .setUuid(FILE_UUID)
     .setUuidPath(MODULE_UUID_PATH + UUID_PATH_SEPARATOR + FILE_UUID)
@@ -101,7 +101,7 @@ public class ExportAnalysesStepTest {
     .setEnabled(true)
     .setModuleUuid(MODULE_UUID)
     .setModuleUuidPath("." + PROJECT_UUID + ".MODULE_UUID.")
-    .setProjectUuid(PROJECT_UUID);
+    .setBranchUuid(PROJECT_UUID);
 
   @Rule
   public DbTester dbTester = DbTester.create(System2.INSTANCE);
index cf4d9543828c329a59b5d0b524e87f70c2e0631c..ace1622934d3d05c7df159d74ecb73ba298beb50 100644 (file)
@@ -57,7 +57,7 @@ public class ExportBranchesStepTest {
     // no id yet
     .setScope(Scopes.PROJECT)
     .setQualifier(Qualifiers.PROJECT)
-    .setDbKey("the_project")
+    .setKey("the_project")
     .setName("The Project")
     .setDescription("The project description")
     .setEnabled(true)
@@ -66,7 +66,7 @@ public class ExportBranchesStepTest {
     .setRootUuid(PROJECT_UUID)
     .setModuleUuid(null)
     .setModuleUuidPath("." + PROJECT_UUID + ".")
-    .setProjectUuid(PROJECT_UUID);
+    .setBranchUuid(PROJECT_UUID);
 
   @Rule
   public DbTester dbTester = DbTester.createWithExtensionMappers(System2.INSTANCE, ProjectExportMapper.class);
index 95112cb3587b97a4d10560a96eed55d688d53bd6..256134357afd46195b315c5963f153cec1a42e31 100644 (file)
@@ -53,7 +53,7 @@ public class ExportComponentsStepTest {
     // no id yet
     .setScope(Scopes.PROJECT)
     .setQualifier(Qualifiers.PROJECT)
-    .setDbKey("the_project")
+    .setKey("the_project")
     .setName("The Project")
     .setDescription("The project description")
     .setEnabled(true)
@@ -63,7 +63,7 @@ public class ExportComponentsStepTest {
     .setModuleUuid(null)
     .setModuleUuidPath("." + PROJECT_UUID + ".")
     .setCreatedAt(new Date(1596749115856L))
-    .setProjectUuid(PROJECT_UUID);
+    .setBranchUuid(PROJECT_UUID);
 
   private static final String MODULE_UUID = "MODULE_UUID";
   private static final String MODULE_UUID_PATH = UUID_PATH_OF_ROOT + MODULE_UUID + UUID_PATH_SEPARATOR;
@@ -71,7 +71,7 @@ public class ExportComponentsStepTest {
     // no id yet
     .setScope(Scopes.PROJECT)
     .setQualifier(Qualifiers.MODULE)
-    .setDbKey("the_module")
+    .setKey("the_module")
     .setName("The Module")
     .setDescription("description of module")
     .setEnabled(true)
@@ -81,7 +81,7 @@ public class ExportComponentsStepTest {
     .setModuleUuid(PROJECT_UUID)
     .setModuleUuidPath("." + PROJECT_UUID + ".MODULE_UUID.")
     .setCreatedAt(new Date(1596749132539L))
-    .setProjectUuid(PROJECT_UUID);
+    .setBranchUuid(PROJECT_UUID);
 
   private static final String FILE_UUID = "FILE_UUID";
   private static final String FILE_UUID_PATH = MODULE_UUID_PATH + FILE_UUID + UUID_PATH_SEPARATOR;
@@ -89,7 +89,7 @@ public class ExportComponentsStepTest {
     // no id yet
     .setScope(Scopes.FILE)
     .setQualifier(Qualifiers.FILE)
-    .setDbKey("the_file")
+    .setKey("the_file")
     .setName("The File")
     .setUuid(FILE_UUID)
     .setRootUuid(MODULE_UUID)
@@ -98,7 +98,7 @@ public class ExportComponentsStepTest {
     .setModuleUuid(MODULE_UUID)
     .setModuleUuidPath("." + PROJECT_UUID + ".MODULE_UUID.")
     .setCreatedAt(new Date(1596749148406L))
-    .setProjectUuid(PROJECT_UUID);
+    .setBranchUuid(PROJECT_UUID);
 
   @Rule
   public DbTester dbTester = DbTester.create(System2.INSTANCE);
index 437996f023f0610e97523822c09d8f197ff37d7f..03136fac933a7f8db1c0609019dc4d09b49e9f7d 100644 (file)
@@ -360,7 +360,7 @@ public class ExportIssuesStepTest {
   }
 
   private ProjectDto createProject() {
-    ComponentDto projectDto = dbTester.components().insertPrivateProject(c -> c.setDbKey(PROJECT_KEY).setUuid(SOME_PROJECT_UUID));
+    ComponentDto projectDto = dbTester.components().insertPrivateProject(c -> c.setKey(PROJECT_KEY).setUuid(SOME_PROJECT_UUID));
     dbTester.commit();
     return dbTester.components().getProjectDto(projectDto);
   }
index 60fdd5efc6c2a702e90212162c7c6e5442afce26..dab76d1d2327b652e641a011b2aaa97129d0d2ea 100644 (file)
@@ -61,7 +61,7 @@ public class ExportAdHocRulesStepTest {
     // no id yet
     .setScope(Scopes.PROJECT)
     .setQualifier(Qualifiers.PROJECT)
-    .setDbKey("the_project")
+    .setKey("the_project")
     .setName("The Project")
     .setDescription("The project description")
     .setEnabled(true)
@@ -70,7 +70,7 @@ public class ExportAdHocRulesStepTest {
     .setRootUuid(PROJECT_UUID)
     .setModuleUuid(null)
     .setModuleUuidPath("." + PROJECT_UUID + ".")
-    .setProjectUuid(PROJECT_UUID);
+    .setBranchUuid(PROJECT_UUID);
 
   private static final List<BranchDto> BRANCHES = ImmutableList.of(
     new BranchDto().setBranchType(BranchType.PULL_REQUEST).setProjectUuid(PROJECT_UUID).setKey("pr-1").setUuid("pr-1-uuid").setMergeBranchUuid("master"),
index c81dcebc7a92c46c770c8705339e8b2151bee25c..7206e841b9c6901dfab19631986383a0faaf3a47 100644 (file)
@@ -51,10 +51,10 @@ public class ExportEventsStepTest {
     .setUuid(PROJECT_UUID)
     .setUuidPath(UUID_PATH_OF_ROOT)
     .setRootUuid(PROJECT_UUID)
-    .setProjectUuid(PROJECT_UUID)
+    .setBranchUuid(PROJECT_UUID)
     .setScope(Scopes.PROJECT)
     .setQualifier(Qualifiers.PROJECT)
-    .setDbKey("the_project")
+    .setKey("the_project")
     .setEnabled(true);
 
 
index 4566f46913a629ecdb2dcb47989700bdfdba8e53..5e6248f4eae5c90b61c100a5f84d06a8e686adf7 100644 (file)
@@ -49,7 +49,7 @@ public class ExportLinksStepTest {
     // no id yet
     .setScope(Scopes.PROJECT)
     .setQualifier(Qualifiers.PROJECT)
-    .setDbKey("the_project")
+    .setKey("the_project")
     .setName("The Project")
     .setDescription("The project description")
     .setEnabled(true)
@@ -58,7 +58,7 @@ public class ExportLinksStepTest {
     .setUuidPath(UUID_PATH_OF_ROOT)
     .setModuleUuid(null)
     .setModuleUuidPath("." + PROJECT_UUID + ".")
-    .setProjectUuid(PROJECT_UUID);
+    .setBranchUuid(PROJECT_UUID);
 
   @Rule
   public DbTester db = DbTester.createWithExtensionMappers(System2.INSTANCE, ProjectExportMapper.class);
index e681f8448e5485de6c83c7dfc67c1db5b7037905..faccb9279b32aa9231c28216cf4644684958388c 100644 (file)
@@ -49,24 +49,24 @@ import static org.sonar.db.component.SnapshotDto.STATUS_UNPROCESSED;
 public class ExportMeasuresStepTest {
 
   private static final ComponentDto PROJECT = new ComponentDto()
-    .setDbKey("project_key")
+    .setKey("project_key")
     .setUuid("project_uuid")
     .setRootUuid("project_uuid")
-    .setProjectUuid("project_uuid")
+    .setBranchUuid("project_uuid")
     .setUuidPath(UUID_PATH_OF_ROOT)
     .setEnabled(true);
   private static final ComponentDto FILE = new ComponentDto()
-    .setDbKey("file_key")
+    .setKey("file_key")
     .setUuid("file_uuid")
     .setRootUuid("project_uuid")
-    .setProjectUuid("project_uuid")
+    .setBranchUuid("project_uuid")
     .setUuidPath(UUID_PATH_OF_ROOT + PROJECT.uuid() + UUID_PATH_SEPARATOR)
     .setEnabled(true);
   private static final ComponentDto ANOTHER_PROJECT = new ComponentDto()
-    .setDbKey("another_project_key")
+    .setKey("another_project_key")
     .setUuid("another_project_uuid")
     .setRootUuid("another_project_uuid")
-    .setProjectUuid("another_project_uuid")
+    .setBranchUuid("another_project_uuid")
     .setUuidPath(UUID_PATH_OF_ROOT)
     .setEnabled(true);
 
index ec9393f4f9284ee3222a0fef440e2d6b782cceff..ce87c38f7e04fb7c01d9702b7f19e407d87da09f 100644 (file)
@@ -54,18 +54,18 @@ public class ExportNewCodePeriodsStepTest {
     .setUuid(PROJECT_UUID)
     .setUuidPath(UUID_PATH_OF_ROOT)
     .setRootUuid(PROJECT_UUID)
-    .setProjectUuid(PROJECT_UUID)
+    .setBranchUuid(PROJECT_UUID)
     .setQualifier(Qualifiers.PROJECT)
     .setName("project")
-    .setDbKey("the_project");
+    .setKey("the_project");
   private static final ComponentDto ANOTHER_PROJECT = new ComponentDto()
     .setUuid(ANOTHER_PROJECT_UUID)
     .setUuidPath(UUID_PATH_OF_ROOT)
     .setRootUuid(ANOTHER_PROJECT_UUID)
-    .setProjectUuid(ANOTHER_PROJECT_UUID)
+    .setBranchUuid(ANOTHER_PROJECT_UUID)
     .setQualifier(Qualifiers.PROJECT)
     .setName("another_project")
-    .setDbKey("another_project");
+    .setKey("another_project");
 
   private static final List<BranchDto> PROJECT_BRANCHES = ImmutableList.of(
     new BranchDto().setBranchType(BranchType.PULL_REQUEST).setProjectUuid(PROJECT_UUID).setKey("pr-1").setUuid("pr-uuid-1").setMergeBranchUuid("master"),
index d471a915e7ea4e43a57228d5d9ee4787b557471f..49c11d277ea2a38fbfa25da09103a541d5a2a974 100644 (file)
@@ -48,14 +48,14 @@ public class ExportSettingsStepTest {
     .setUuid("project_uuid")
     .setUuidPath(UUID_PATH_OF_ROOT)
     .setRootUuid("project_uuid")
-    .setProjectUuid("project_uuid")
-    .setDbKey("the_project");
+    .setBranchUuid("project_uuid")
+    .setKey("the_project");
   private static final ComponentDto ANOTHER_PROJECT = new ComponentDto()
     .setUuid("another_project_uuid")
     .setUuidPath(UUID_PATH_OF_ROOT)
     .setRootUuid("another_project_uuid")
-    .setProjectUuid("another_project_uuid")
-    .setDbKey("another_project");
+    .setBranchUuid("another_project_uuid")
+    .setKey("another_project");
 
   @Rule
   public LogTester logTester = new LogTester();
index 466faf4533c69066c74667a0c7c23311c376c259..7d4bd734cafb02e4ec9d83da5fa9c7ece1418f27 100644 (file)
@@ -68,7 +68,7 @@ public class LoadProjectStepTest {
 
   @Test
   public void registers_project_if_valid() {
-    ComponentDto project = dbTester.components().insertPublicProject(c -> c.setDbKey(PROJECT_KEY));
+    ComponentDto project = dbTester.components().insertPublicProject(c -> c.setKey(PROJECT_KEY));
     underTest.execute(new TestComputationStepContext());
     assertThat(definitionHolder.projectDto().getKey()).isEqualTo(project.getKey());
   }
index 5bcbcd9d11cb5190b5266f05e2387ca5cb451e85..c99dc67efb36ec2de99fe6fd4b3d98a1be3014c8 100644 (file)
@@ -40,7 +40,6 @@ public class ReportComponent implements Component {
 
   public static final Component DUMB_PROJECT = builder(Type.PROJECT, 1)
     .setKey("PROJECT_KEY")
-    .setPublicKey("PUBLIC_PROJECT_KEY")
     .setUuid("PROJECT_UUID")
     .setName("Project Name")
     .setProjectVersion("1.0-SNAPSHOT")
@@ -53,7 +52,6 @@ public class ReportComponent implements Component {
   @CheckForNull
   private final String description;
   private final String key;
-  private final String publicKey;
   private final String uuid;
   private final ProjectAttributes projectAttributes;
   private final ReportAttributes reportAttributes;
@@ -64,7 +62,6 @@ public class ReportComponent implements Component {
     this.type = builder.type;
     this.status = builder.status;
     this.key = builder.key;
-    this.publicKey = builder.publicKey;
     this.name = builder.name == null ? String.valueOf(builder.key) : builder.name;
     this.shortName = builder.shortName == null ? this.name : builder.shortName;
     this.description = builder.description;
@@ -97,21 +94,13 @@ public class ReportComponent implements Component {
   }
 
   @Override
-  public String getDbKey() {
+  public String getKey() {
     if (key == null) {
       throw new UnsupportedOperationException(String.format("Component key of ref '%d' has not be fed yet", this.reportAttributes.getRef()));
     }
     return key;
   }
 
-  @Override
-  public String getKey() {
-    if (publicKey == null) {
-      throw new UnsupportedOperationException(String.format("Component key of ref '%d' has not be fed yet", this.reportAttributes.getRef()));
-    }
-    return publicKey;
-  }
-
   @Override
   public String getName() {
     return this.name;
@@ -192,7 +181,7 @@ public class ReportComponent implements Component {
   }
 
   public static Builder builder(Type type, int ref, String key) {
-    return new Builder(type, ref).setKey(key).setPublicKey(key).setUuid("uuid_" + ref).setName("name_" + ref);
+    return new Builder(type, ref).setKey(key).setUuid("uuid_" + ref).setName("name_" + ref);
   }
 
   public static Builder builder(Type type, int ref) {
@@ -205,7 +194,6 @@ public class ReportComponent implements Component {
     private Status status;
     private String uuid;
     private String key;
-    private String publicKey;
     private String name;
     private String shortName;
     private String projectVersion;
@@ -249,11 +237,6 @@ public class ReportComponent implements Component {
       return this;
     }
 
-    public Builder setPublicKey(String publicKey) {
-      this.publicKey = requireNonNull(publicKey);
-      return this;
-    }
-
     public Builder setProjectVersion(@Nullable String s) {
       checkProjectVersion(s);
       this.projectVersion = s;
index 24683fcfe8c5519c6217c2425110a977d6c2baae..38665c353488baa5ede567ab62f9fb7a9ffa61ec 100644 (file)
@@ -34,7 +34,7 @@ public final class TreeComponentProvider extends AbstractComponentProvider {
   }
 
   private static String getRef(Component component) {
-    return component.getType().isReportType() ? String.valueOf(component.getReportAttributes().getRef()) : component.getDbKey();
+    return component.getType().isReportType() ? String.valueOf(component.getReportAttributes().getRef()) : component.getKey();
   }
 
   @Override
index ffe4830db1b0a93bb2c96ab98ae042fcf99a75cb..aeb2ce00f5595bd006c1db4ef6b8e8eb92494192 100644 (file)
@@ -72,7 +72,7 @@ public class TreeRootHolderRule extends ExternalResource implements TreeRootHold
       new TypeAwareVisitorAdapter(CrawlerDepthLimit.LEAVES, POST_ORDER) {
         @Override
         public void visitAny(Component component) {
-          builder.put(component.getDbKey(), component);
+          builder.put(component.getKey(), component);
         }
       }).visit(getRoot());
     this.componentsByKey = builder.build();
index 9597710d0ef46088fa7ad4c8bc40fdddcbbd1182..e6ee9be30cc2bad51ae2f46d890cfc5156ca97ac 100644 (file)
@@ -152,17 +152,12 @@ public class ViewsComponent implements Component {
     return uuid;
   }
 
-  @Override
-  public String getDbKey() {
-    return key;
-  }
-
   /**
    * Views has no branch feature, the public key is the same as the key
    */
   @Override
   public String getKey() {
-    return getDbKey();
+    return this.key;
   }
 
   @Override
index 973f1176d211449bccb58df201c8db7d2bb42001..e68d51fd69e0abbc0b244aadc39e53b3e086dd3a 100644 (file)
@@ -272,30 +272,6 @@ public class MeasureRepositoryRule extends ExternalResource implements MeasureRe
   }
 
   private static String getRef(Component component) {
-    return component.getType().isReportType() ? String.valueOf(component.getReportAttributes().getRef()) : component.getDbKey();
+    return component.getType().isReportType() ? String.valueOf(component.getReportAttributes().getRef()) : component.getKey();
   }
-
-  private static class MatchMetric implements Predicate<Map.Entry<InternalKey, Measure>> {
-    private final Metric metric;
-
-    public MatchMetric(Metric metric) {
-      this.metric = metric;
-    }
-
-    @Override
-    public boolean apply(@Nonnull Map.Entry<InternalKey, Measure> input) {
-      return input.getKey().getMetricKey().equals(metric.getKey());
-    }
-  }
-
-  private enum ToMeasure implements Function<Map.Entry<InternalKey, Measure>, Measure> {
-    INSTANCE;
-
-    @Nullable
-    @Override
-    public Measure apply(@Nonnull Map.Entry<InternalKey, Measure> input) {
-      return input.getValue();
-    }
-  }
-
 }
index 935948712d7ce2a373f80646c8ace5402a2150e0..05b04d9ac2f5dd28c10edc06cc2e5c7d2266cec7 100644 (file)
@@ -351,8 +351,8 @@ public class InternalCeQueueImplTest {
     assertThat(peek).isPresent();
     assertThat(peek.get().getUuid()).isEqualTo(task.getUuid());
     assertThat(peek.get().getType()).isEqualTo(CeTaskTypes.REPORT);
-    assertThat(peek.get().getComponent()).contains(new CeTask.Component(branch.uuid(), branch.getDbKey(), branch.name()));
-    assertThat(peek.get().getMainComponent()).contains(new CeTask.Component(project.uuid(), project.getDbKey(), project.name()));
+    assertThat(peek.get().getComponent()).contains(new CeTask.Component(branch.uuid(), branch.getKey(), branch.name()));
+    assertThat(peek.get().getMainComponent()).contains(new CeTask.Component(project.uuid(), project.getKey(), project.name()));
 
     // no more pending tasks
     peek = underTest.peek(WORKER_UUID_2, true);
@@ -608,7 +608,7 @@ public class InternalCeQueueImplTest {
     if (componentDto != null) {
       CeTask.Component component = task.getComponent().get();
       assertThat(component.getUuid()).isEqualTo(componentDto.uuid());
-      assertThat(component.getKey()).contains(componentDto.getDbKey());
+      assertThat(component.getKey()).contains(componentDto.getKey());
       assertThat(component.getName()).contains(componentDto.name());
     } else if (taskSubmit.getComponent().isPresent()) {
       assertThat(task.getComponent()).contains(new CeTask.Component(taskSubmit.getComponent().get().getUuid(), null, null));
@@ -644,7 +644,7 @@ public class InternalCeQueueImplTest {
   }
 
   private ComponentDto newProjectDto(String uuid) {
-    return ComponentTesting.newPublicProjectDto(uuid).setName("name_" + uuid).setDbKey("key_" + uuid);
+    return ComponentTesting.newPublicProjectDto(uuid).setName("name_" + uuid).setKey("key_" + uuid);
   }
 
   private CeTask submit(String reportType, ComponentDto componentDto) {
index 14da008f50eb956f179bdb6337b737cbb5a33207..515fd70c61a3c425a19b9ae6ac736585be3733a1 100644 (file)
@@ -62,7 +62,7 @@ import org.sonar.db.component.ResourceDto;
 import org.sonar.db.component.ScrapAnalysisPropertyDto;
 import org.sonar.db.component.SnapshotDto;
 import org.sonar.db.component.SnapshotMapper;
-import org.sonar.db.component.UuidWithProjectUuidDto;
+import org.sonar.db.component.UuidWithBranchUuidDto;
 import org.sonar.db.component.ViewsSnapshotDto;
 import org.sonar.db.duplication.DuplicationMapper;
 import org.sonar.db.duplication.DuplicationUnitDto;
@@ -243,7 +243,7 @@ public class MyBatis {
     confBuilder.loadAlias("UserTelemetry", UserTelemetryDto.class);
     confBuilder.loadAlias("UserToken", UserTokenDto.class);
     confBuilder.loadAlias("UserTokenCount", UserTokenCount.class);
-    confBuilder.loadAlias("UuidWithProjectUuid", UuidWithProjectUuidDto.class);
+    confBuilder.loadAlias("UuidWithBranchUuid", UuidWithBranchUuidDto.class);
     confBuilder.loadAlias("ViewsSnapshot", ViewsSnapshotDto.class);
     confExtensions.forEach(ext -> ext.loadAliases(confBuilder::loadAlias));
 
index 38cca4e82014d96ad50fc7fe9f11ee24473fe343..f655c175cfd0bd2bd7edb34f73bf260c1aefd3dd 100644 (file)
@@ -92,7 +92,7 @@ public class BranchDao implements Dao {
   public Collection<BranchDto> selectByComponent(DbSession dbSession, ComponentDto component) {
     String projectUuid = component.getMainBranchProjectUuid();
     if (projectUuid == null) {
-      projectUuid = component.projectUuid();
+      projectUuid = component.branchUuid();
     }
     return mapper(dbSession).selectByProjectUuid(projectUuid);
   }
index b11d2801afdfbebd8285b2792e07e4744f92465c..d843733d1ffa129eb21ab1e1fe4a9347565aaf47 100644 (file)
@@ -23,6 +23,7 @@ import com.google.common.collect.Ordering;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
@@ -32,6 +33,7 @@ import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import javax.annotation.Nullable;
+import org.apache.commons.lang.StringUtils;
 import org.apache.ibatis.session.ResultHandler;
 import org.apache.ibatis.session.RowBounds;
 import org.sonar.api.resources.Qualifiers;
@@ -44,14 +46,10 @@ import org.sonar.db.audit.model.ComponentNewValue;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static java.util.Collections.emptyList;
-import static org.sonar.core.util.stream.MoreCollectors.toList;
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
 import static org.sonar.db.DatabaseUtils.checkThatNotTooManyConditions;
 import static org.sonar.db.DatabaseUtils.executeLargeInputs;
 import static org.sonar.db.DatabaseUtils.executeLargeInputsIntoSet;
 import static org.sonar.db.DatabaseUtils.executeLargeUpdates;
-import static org.sonar.db.component.ComponentDto.generateBranchKey;
-import static org.sonar.db.component.ComponentDto.generatePullRequestKey;
 
 public class ComponentDao implements Dao {
   private final AuditPersister auditPersister;
@@ -85,11 +83,7 @@ public class ComponentDao implements Dao {
   }
 
   public ComponentDto selectOrFailByUuid(DbSession session, String uuid) {
-    Optional<ComponentDto> componentDto = selectByUuid(session, uuid);
-    if (!componentDto.isPresent()) {
-      throw new RowNotFoundException(String.format("Component with uuid '%s' not found", uuid));
-    }
-    return componentDto.get();
+    return selectByUuid(session, uuid).orElseThrow(() -> new RowNotFoundException(String.format("Component with uuid '%s' not found", uuid)));
   }
 
   /**
@@ -156,8 +150,8 @@ public class ComponentDao implements Dao {
     return mapper(session).selectComponentsFromProjectKeyAndScope(projectKey, Scopes.PROJECT, excludeDisabled);
   }
 
-  public int countEnabledModulesByProjectUuid(DbSession session, String projectUuid) {
-    return mapper(session).countEnabledModulesByProjectUuid(projectUuid);
+  public int countEnabledModulesByBranchUuid(DbSession session, String branchUuid) {
+    return mapper(session).countEnabledModulesByBranchUuid(branchUuid);
   }
 
   public List<ComponentDto> selectEnabledModulesFromProjectKey(DbSession session, String projectKey) {
@@ -169,30 +163,45 @@ public class ComponentDao implements Dao {
   }
 
   public List<ComponentDto> selectByKeysAndBranch(DbSession session, Collection<String> keys, String branch) {
-    List<String> dbKeys = keys.stream().map(k -> generateBranchKey(k, branch)).collect(toList());
-    List<String> allKeys = Stream.of(keys, dbKeys).flatMap(Collection::stream).collect(toList());
-    return executeLargeInputs(allKeys, subKeys -> mapper(session).selectByKeysAndBranch(subKeys, branch));
-  }
-
-  /**
-   * Return list of components that will will mix main and branch components.
-   * Please note that a project can only appear once in the list, it's not possible to ask for many branches on same project with this method.
-   */
-  public List<ComponentDto> selectByKeysAndBranches(DbSession session, Map<String, String> branchesByKey) {
-    Set<String> dbKeys = branchesByKey.entrySet().stream()
-      .map(entry -> generateBranchKey(entry.getKey(), entry.getValue()))
-      .collect(toSet());
-    return selectByDbKeys(session, dbKeys);
-  }
-
-  public List<ComponentDto> selectByDbKeys(DbSession session, Set<String> dbKeys) {
-    return executeLargeInputs(dbKeys, subKeys -> mapper(session).selectByDbKeys(subKeys));
+    return executeLargeInputs(keys, subKeys -> mapper(session).selectByKeysAndBranch(subKeys, branch));
   }
 
   public List<ComponentDto> selectByKeysAndPullRequest(DbSession session, Collection<String> keys, String pullRequestId) {
-    List<String> dbKeys = keys.stream().map(k -> generatePullRequestKey(k, pullRequestId)).collect(toList());
-    List<String> allKeys = Stream.of(keys, dbKeys).flatMap(Collection::stream).collect(toList());
-    return executeLargeInputs(allKeys, subKeys -> mapper(session).selectByKeysAndBranch(subKeys, pullRequestId));
+    return executeLargeInputs(keys, subKeys -> mapper(session).selectByKeysAndBranch(subKeys, pullRequestId));
+  }
+
+  public List<ComponentDto> selectByDbKeys(DbSession session, Collection<String> dbKeys) {
+    Map<String, List<String>> keyByBranchKey = new HashMap<>();
+    Map<String, List<String>> keyByPrKey = new HashMap<>();
+    List<String> mainBranchKeys = new LinkedList<>();
+
+    for (String dbKey : dbKeys) {
+      String branchKey = StringUtils.substringAfterLast(dbKey, ComponentDto.BRANCH_KEY_SEPARATOR);
+      if (!StringUtils.isEmpty(branchKey)) {
+        keyByBranchKey.computeIfAbsent(branchKey, b -> new LinkedList<>())
+          .add(StringUtils.substringBeforeLast(dbKey, ComponentDto.BRANCH_KEY_SEPARATOR));
+        continue;
+      }
+
+      String prKey = StringUtils.substringAfterLast(dbKey, ComponentDto.PULL_REQUEST_SEPARATOR);
+      if (!StringUtils.isEmpty(prKey)) {
+        keyByPrKey.computeIfAbsent(prKey, b -> new LinkedList<>())
+          .add(StringUtils.substringBeforeLast(dbKey, ComponentDto.PULL_REQUEST_SEPARATOR));
+        continue;
+      }
+
+      mainBranchKeys.add(dbKey);
+    }
+
+    List<ComponentDto> components = new LinkedList<>();
+    for (Map.Entry<String, List<String>> e : keyByBranchKey.entrySet()) {
+      components.addAll(selectByKeysAndBranch(session, e.getValue(), e.getKey()));
+    }
+    for (Map.Entry<String, List<String>> e : keyByPrKey.entrySet()) {
+      components.addAll(selectByKeysAndPullRequest(session, e.getValue(), e.getKey()));
+    }
+    components.addAll(selectByKeys(session, mainBranchKeys));
+    return components;
   }
 
   /**
@@ -230,11 +239,7 @@ public class ComponentDao implements Dao {
   }
 
   public ComponentDto selectOrFailByKey(DbSession session, String key) {
-    Optional<ComponentDto> component = selectByKey(session, key);
-    if (!component.isPresent()) {
-      throw new RowNotFoundException(String.format("Component key '%s' not found", key));
-    }
-    return component.get();
+    return selectByKey(session, key).orElseThrow(() -> new RowNotFoundException(String.format("Component key '%s' not found", key)));
   }
 
   public Optional<ComponentDto> selectByKey(DbSession session, String key) {
@@ -246,14 +251,14 @@ public class ComponentDao implements Dao {
   }
 
   public Optional<ComponentDto> selectByKeyAndBranch(DbSession session, String key, String branch) {
-    return Optional.ofNullable(mapper(session).selectBranchByKeyAndBranchKey(key, generateBranchKey(key, branch), branch));
+    return Optional.ofNullable(mapper(session).selectByKeyAndBranchKey(key, branch));
   }
 
   public Optional<ComponentDto> selectByKeyAndPullRequest(DbSession session, String key, String pullRequestId) {
-    return Optional.ofNullable(mapper(session).selectPrByKeyAndBranchKey(key, generatePullRequestKey(key, pullRequestId), pullRequestId));
+    return Optional.ofNullable(mapper(session).selectByKeyAndPrKey(key, pullRequestId));
   }
 
-  public List<UuidWithProjectUuidDto> selectAllViewsAndSubViews(DbSession session) {
+  public List<UuidWithBranchUuidDto> selectAllViewsAndSubViews(DbSession session) {
     return mapper(session).selectUuidsForQualifiers(Qualifiers.APP, Qualifiers.VIEW, Qualifiers.SUBVIEW);
   }
 
@@ -295,12 +300,12 @@ public class ComponentDao implements Dao {
   }
 
   /**
-   * Retrieves all components with a specific root project Uuid, no other filtering is done by this method.
+   * Retrieves all components with a specific branch UUID, no other filtering is done by this method.
    * <p>
    * Used by Views plugin
    */
-  public List<ComponentDto> selectByProjectUuid(String projectUuid, DbSession dbSession) {
-    return mapper(dbSession).selectByProjectUuid(projectUuid);
+  public List<ComponentDto> selectByBranchUuid(String branchUuid, DbSession dbSession) {
+    return mapper(dbSession).selectByBranchUuid(branchUuid);
   }
 
   /**
@@ -340,8 +345,8 @@ public class ComponentDao implements Dao {
    * Scroll all <strong>enabled</strong> files of the specified project (same project_uuid) in no specific order with
    * 'SOURCE' source and a non null path.
    */
-  public void scrollAllFilesForFileMove(DbSession session, String projectUuid, ResultHandler<FileMoveRowDto> handler) {
-    mapper(session).scrollAllFilesForFileMove(projectUuid, handler);
+  public void scrollAllFilesForFileMove(DbSession session, String branchUuid, ResultHandler<FileMoveRowDto> handler) {
+    mapper(session).scrollAllFilesForFileMove(branchUuid, handler);
   }
 
   public void insert(DbSession session, ComponentDto item) {
@@ -373,23 +378,23 @@ public class ComponentDao implements Dao {
     executeLargeUpdates(uuids, mapper(session)::updateBEnabledToFalse);
   }
 
-  public void applyBChangesForRootComponentUuid(DbSession session, String projectUuid) {
-    mapper(session).applyBChangesForRootComponentUuid(projectUuid);
+  public void applyBChangesForRootComponentUuid(DbSession session, String branchUuid) {
+    mapper(session).applyBChangesForRootComponentUuid(branchUuid);
   }
 
-  public void resetBChangedForRootComponentUuid(DbSession session, String projectUuid) {
-    mapper(session).resetBChangedForRootComponentUuid(projectUuid);
+  public void resetBChangedForRootComponentUuid(DbSession session, String branchUuid) {
+    mapper(session).resetBChangedForRootComponentUuid(branchUuid);
   }
 
-  public void setPrivateForRootComponentUuidWithoutAudit(DbSession session, String projectUuid, boolean isPrivate) {
-    mapper(session).setPrivateForRootComponentUuid(projectUuid, isPrivate);
+  public void setPrivateForRootComponentUuidWithoutAudit(DbSession session, String branchUuid, boolean isPrivate) {
+    mapper(session).setPrivateForRootComponentUuid(branchUuid, isPrivate);
   }
 
-  public void setPrivateForRootComponentUuid(DbSession session, String projectUuid, boolean isPrivate,
+  public void setPrivateForRootComponentUuid(DbSession session, String branchUuid, boolean isPrivate,
     @Nullable String qualifier, String componentKey, String componentName) {
-    ComponentNewValue componentNewValue = new ComponentNewValue(projectUuid, componentName, componentKey, isPrivate, qualifier);
+    ComponentNewValue componentNewValue = new ComponentNewValue(branchUuid, componentName, componentKey, isPrivate, qualifier);
     auditPersister.updateComponentVisibility(session, componentNewValue);
-    mapper(session).setPrivateForRootComponentUuid(projectUuid, isPrivate);
+    mapper(session).setPrivateForRootComponentUuid(branchUuid, isPrivate);
   }
 
   private static void checkThatNotTooManyComponents(ComponentQuery query) {
index a3818109278ab04f29c9531ab4a82fc9ff6f0928..cb17c2a859e6d0facc2023b3da6925bfbaa6f7e9 100644 (file)
@@ -24,7 +24,6 @@ import com.google.common.base.Strings;
 import java.util.Date;
 import java.util.List;
 import java.util.Objects;
-import java.util.regex.Pattern;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import org.apache.commons.lang.builder.ToStringBuilder;
@@ -47,7 +46,6 @@ public class ComponentDto {
   public static final String BRANCH_KEY_SEPARATOR = ":BRANCH:";
   public static final String PULL_REQUEST_SEPARATOR = ":PULL_REQUEST:";
 
-  private static final Splitter BRANCH_OR_PULL_REQUEST_SPLITTER = Splitter.on(Pattern.compile(BRANCH_KEY_SEPARATOR + "|" + PULL_REQUEST_SEPARATOR));
   private static final Splitter BRANCH_KEY_SPLITTER = Splitter.on(BRANCH_KEY_SEPARATOR);
   private static final Splitter PULL_REQUEST_SPLITTER = Splitter.on(PULL_REQUEST_SEPARATOR);
 
@@ -93,7 +91,7 @@ public class ComponentDto {
    * - on view: UUID="5" PROJECT_UUID="5"
    * - on sub-view: UUID="6" PROJECT_UUID="5"
   */
-  private String projectUuid;
+  private String branchUuid;
 
   /**
    * Badly named, it is not the root !
@@ -177,23 +175,15 @@ public class ComponentDto {
     return UUID_PATH_SPLITTER.splitToList(uuidPath);
   }
 
-  public String getDbKey() {
+  public String getKey() {
     return kee;
   }
 
-  public ComponentDto setDbKey(String key) {
+  public ComponentDto setKey(String key) {
     this.kee = checkComponentKey(key);
     return this;
   }
 
-  /**
-   * The key to be displayed to user, doesn't contain information on branches
-   */
-  public String getKey() {
-    List<String> split = BRANCH_OR_PULL_REQUEST_SPLITTER.splitToList(kee);
-    return split.size() == 2 ? split.get(0) : kee;
-  }
-
   /**
    * @return the key of the branch. It will be null on the main branch and when the component is not on a branch
    */
@@ -233,12 +223,12 @@ public class ComponentDto {
   /**
    * Return the root project uuid. On a root project, return itself
    */
-  public String projectUuid() {
-    return projectUuid;
+  public String branchUuid() {
+    return branchUuid;
   }
 
-  public ComponentDto setProjectUuid(String projectUuid) {
-    this.projectUuid = projectUuid;
+  public ComponentDto setBranchUuid(String branchUuid) {
+    this.branchUuid = branchUuid;
     return this;
   }
 
@@ -320,7 +310,7 @@ public class ComponentDto {
   }
 
   /**
-   * Use {@link #projectUuid()}, {@link #moduleUuid()} or {@link #moduleUuidPath()}
+   * Use {@link #branchUuid()}, {@link #moduleUuid()} or {@link #moduleUuidPath()}
    */
   @Deprecated
   public String getRootUuid() {
@@ -409,7 +399,7 @@ public class ComponentDto {
       .append("kee", kee)
       .append("scope", scope)
       .append("qualifier", qualifier)
-      .append("projectUuid", projectUuid)
+      .append("branchUuid", branchUuid)
       .append("moduleUuid", moduleUuid)
       .append("moduleUuidPath", moduleUuidPath)
       .append("rootUuid", rootUuid)
@@ -426,11 +416,10 @@ public class ComponentDto {
 
   public ComponentDto copy() {
     ComponentDto copy = new ComponentDto();
-    copy.projectUuid = projectUuid;
     copy.kee = kee;
     copy.uuid = uuid;
     copy.uuidPath = uuidPath;
-    copy.projectUuid = projectUuid;
+    copy.branchUuid = branchUuid;
     copy.rootUuid = rootUuid;
     copy.mainBranchProjectUuid = mainBranchProjectUuid;
     copy.moduleUuid = moduleUuid;
index e62a69a23b73f1109eeb0d3ff352089aebd2b918..982972780933b1ec4261a519a34d1eee88cd7dc0 100644 (file)
@@ -37,10 +37,10 @@ public interface ComponentMapper {
   ComponentDto selectByKeyCaseInsensitive(@Param("key") String key);
 
   @CheckForNull
-  ComponentDto selectBranchByKeyAndBranchKey(@Param("key") String key, @Param("dbKey") String dbKey, @Param("branch") String branch);
+  ComponentDto selectByKeyAndBranchKey(@Param("key") String key, @Param("branch") String branch);
 
   @CheckForNull
-  ComponentDto selectPrByKeyAndBranchKey(@Param("key") String key, @Param("dbKey") String dbKey, @Param("branch") String branch);
+  ComponentDto selectByKeyAndPrKey(@Param("key") String key, @Param("pr") String pr);
 
   @CheckForNull
   ComponentDto selectByUuid(@Param("uuid") String uuid);
@@ -52,19 +52,17 @@ public interface ComponentMapper {
 
   List<ComponentDto> selectByKeys(@Param("keys") Collection<String> keys);
 
-  List<ComponentDto> selectByDbKeys(@Param("dbKeys") Collection<String> dbKeys);
-
   List<ComponentDto> selectByKeysAndBranch(@Param("keys") Collection<String> keys, @Param("branch") String branch);
 
   List<ComponentDto> selectByUuids(@Param("uuids") Collection<String> uuids);
 
-  List<ComponentDto> selectByProjectUuid(@Param("projectUuid") String projectUuid);
+  List<ComponentDto> selectByBranchUuid(@Param("branchUuid") String branchUuid);
 
   List<String> selectExistingUuids(@Param("uuids") Collection<String> uuids);
 
   List<ComponentDto> selectComponentsByQualifiers(@Param("qualifiers") Collection<String> qualifiers);
 
-  int countEnabledModulesByProjectUuid(@Param("projectUuid") String projectUuid);
+  int countEnabledModulesByBranchUuid(@Param("branchUuid") String branchUuid);
 
   List<ComponentDto> selectByQuery(@Param("query") ComponentQuery query, RowBounds rowBounds);
 
@@ -103,7 +101,7 @@ public interface ComponentMapper {
    * <p/>
    * It's using a join on snapshots in order to use he indexed columns snapshots.qualifier
    */
-  List<UuidWithProjectUuidDto> selectUuidsForQualifiers(@Param("qualifiers") String... qualifiers);
+  List<UuidWithBranchUuidDto> selectUuidsForQualifiers(@Param("qualifiers") String... qualifiers);
 
   /**
    * Return components of a given scope of a project
@@ -127,7 +125,7 @@ public interface ComponentMapper {
 
   void scrollForIndexing(@Param("projectUuid") @Nullable String projectUuid, ResultHandler<ComponentDto> handler);
 
-  void scrollAllFilesForFileMove(@Param("projectUuid") String projectUuid, ResultHandler<FileMoveRowDto> handler);
+  void scrollAllFilesForFileMove(@Param("branchUuid") String branchUuid, ResultHandler<FileMoveRowDto> handler);
 
   void insert(ComponentDto componentDto);
 
@@ -135,11 +133,11 @@ public interface ComponentMapper {
 
   void updateBEnabledToFalse(@Param("uuids") List<String> uuids);
 
-  void applyBChangesForRootComponentUuid(@Param("projectUuid") String projectUuid);
+  void applyBChangesForRootComponentUuid(@Param("branchUuid") String branchUuid);
 
-  void resetBChangedForRootComponentUuid(@Param("projectUuid") String projectUuid);
+  void resetBChangedForRootComponentUuid(@Param("branchUuid") String branchUuid);
 
-  void setPrivateForRootComponentUuid(@Param("projectUuid") String projectUuid, @Param("isPrivate") boolean isPrivate);
+  void setPrivateForRootComponentUuid(@Param("branchUuid") String branchUuid, @Param("isPrivate") boolean isPrivate);
 
   void delete(String componentUuid);
 
index 90569194c85148eb315211c7635cf6978fac8b45..7268d4b8aad8aca9740157ba1f729ec04a69a22c 100644 (file)
@@ -188,7 +188,7 @@ public class ComponentUpdateDto {
     return new ComponentUpdateDto()
       .setUuid(from.uuid())
       .setBChanged(false)
-      .setBKey(from.getDbKey())
+      .setBKey(from.getKey())
       .setBCopyComponentUuid(from.getCopyComponentUuid())
       .setBDescription(from.description())
       .setBEnabled(from.isEnabled())
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/UuidWithBranchUuidDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/UuidWithBranchUuidDto.java
new file mode 100644 (file)
index 0000000..0794cfc
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.component;
+
+public class UuidWithBranchUuidDto {
+
+  private String uuid;
+  private String branchUuid;
+
+  public String getBranchUuid() {
+    return branchUuid;
+  }
+
+  public UuidWithBranchUuidDto setBranchUuid(String branchUuid) {
+    this.branchUuid = branchUuid;
+    return this;
+  }
+
+  public String getUuid() {
+    return uuid;
+  }
+
+  public UuidWithBranchUuidDto setUuid(String uuid) {
+    this.uuid = uuid;
+    return this;
+  }
+}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/UuidWithProjectUuidDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/UuidWithProjectUuidDto.java
deleted file mode 100644 (file)
index 96c5c19..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2022 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.db.component;
-
-public class UuidWithProjectUuidDto {
-
-  private String uuid;
-  private String projectUuid;
-
-  public String getProjectUuid() {
-    return projectUuid;
-  }
-
-  public UuidWithProjectUuidDto setProjectUuid(String projectUuid) {
-    this.projectUuid = projectUuid;
-    return this;
-  }
-
-  public String getUuid() {
-    return uuid;
-  }
-
-  public UuidWithProjectUuidDto setUuid(String uuid) {
-    this.uuid = uuid;
-    return this;
-  }
-}
index 00a47fe64ee2639edd308f4f8e9eafeec03e1e57..80ccda2b0d7623d4eade92cc1a22f7217e198e8e 100644 (file)
@@ -101,7 +101,7 @@ public class IssueDao implements Dao {
 
   public List<IssueDto> selectNonClosedByModuleOrProjectExcludingExternalsAndSecurityHotspots(DbSession dbSession, ComponentDto module) {
     String likeModuleUuidPath = buildLikeValue(module.moduleUuidPath(), WildcardPosition.AFTER);
-    return mapper(dbSession).selectNonClosedByModuleOrProject(module.projectUuid(), likeModuleUuidPath);
+    return mapper(dbSession).selectNonClosedByModuleOrProject(module.branchUuid(), likeModuleUuidPath);
   }
 
   public List<PrIssueDto> selectOpenByComponentUuids(DbSession dbSession, Collection<String> componentUuids) {
index 7611cff2f3cb11f37e2a004f8e1bb8bbf071d7c9..2e9fa59db6762f4eda8c5a64994db9ddd97569b8 100644 (file)
@@ -206,7 +206,7 @@ public final class IssueDto implements Serializable {
   }
 
   public IssueDto setComponent(ComponentDto component) {
-    this.componentKey = component.getDbKey();
+    this.componentKey = component.getKey();
     this.componentUuid = component.uuid();
     this.moduleUuidPath = component.moduleUuidPath();
     this.filePath = component.path();
@@ -214,7 +214,7 @@ public final class IssueDto implements Serializable {
   }
 
   public IssueDto setProject(ComponentDto project) {
-    this.projectKey = project.getDbKey();
+    this.projectKey = project.getKey();
     this.projectUuid = project.uuid();
     return this;
   }
index 056a1651b2dfc33439fb76d6589501135c348bc6..6addf4b835933ae93dc46253c18a05f6f5067245 100644 (file)
@@ -47,7 +47,7 @@ public class IssueTesting {
 
   public static IssueDto newIssue(RuleDto rule, ComponentDto project, ComponentDto file) {
     checkArgument(project.qualifier().equals(Qualifiers.PROJECT), "Second parameter should be a project");
-    return newIssue(rule, project.uuid(), project.getDbKey(), file);
+    return newIssue(rule, project.uuid(), project.getKey(), file);
   }
 
   public static IssueDto newIssue(RuleDto rule, ProjectDto project, ComponentDto file) {
@@ -55,7 +55,7 @@ public class IssueTesting {
   }
 
   public static IssueDto newIssue(RuleDto rule, String projectUuid, String projectKey, ComponentDto file) {
-    checkArgument(file.projectUuid().equals(projectUuid), "The file doesn't belong to the project");
+    checkArgument(file.branchUuid().equals(projectUuid), "The file doesn't belong to the project");
 
     return new IssueDto()
       .setKee("uuid_" + randomAlphabetic(5))
index cd3f294fcc68a083e3ff8b03380c28fe8618f4ca..1e8687178d47ece081787b552569ca189fc1be0c 100644 (file)
@@ -34,11 +34,11 @@ public interface PurgeMapper {
    */
   List<String> selectRootAndModulesOrSubviewsByProjectUuid(@Param("rootUuid") String rootUuid);
 
-  Set<String> selectDisabledComponentsWithFileSource(@Param("projectUuid") String projectUuid);
+  Set<String> selectDisabledComponentsWithFileSource(@Param("branchUuid") String branchUuid);
 
-  Set<String> selectDisabledComponentsWithUnresolvedIssues(@Param("projectUuid") String projectUuid);
+  Set<String> selectDisabledComponentsWithUnresolvedIssues(@Param("branchUuid") String branchUuid);
 
-  Set<String> selectDisabledComponentsWithLiveMeasures(@Param("projectUuid") String projectUuid);
+  Set<String> selectDisabledComponentsWithLiveMeasures(@Param("branchUuid") String branchUuid);
 
   void deleteAnalyses(@Param("analysisUuids") List<String> analysisUuids);
 
@@ -97,7 +97,7 @@ public interface PurgeMapper {
   @CheckForNull
   String selectSpecificAnalysisNewCodePeriod(@Param("projectUuid") String projectUuid);
 
-  List<String> selectDisabledComponentsWithoutIssues(@Param("projectUuid") String projectUuid);
+  List<String> selectDisabledComponentsWithoutIssues(@Param("branchUuid") String branchUuid);
 
   void deleteIssuesFromKeys(@Param("keys") List<String> keys);
 
index 0cdef645451b06315bb196eacaaaf5e2610e3f57..246dc8bbf43f838aea74225b900da326b668e049 100644 (file)
     select
     case when exists
     (
-    select pb.project_uuid, pb.need_issue_sync from project_branches pb join components c on pb.project_uuid =
-    c.project_uuid
+    select pb.project_uuid, pb.need_issue_sync from project_branches pb join components c on pb.project_uuid = c.branch_uuid
     where c.kee in
     <foreach collection="componentKeys" open="(" close=")" item="componentKey" separator=",">
       #{componentKey,jdbcType=VARCHAR}
index aed19c345e9558757aa5025c7713b2423b5b8052..c25cc05c20bc0c451bb38457758e24cdbdeb6df3 100644 (file)
@@ -5,7 +5,7 @@
   <sql id="componentColumns">
     p.uuid as uuid,
     p.uuid_path as uuidPath,
-    p.project_uuid as projectUuid,
+    p.branch_uuid as branchUuid,
     p.module_uuid as moduleUuid,
     p.module_uuid_path as moduleUuidPath,
     p.main_branch_project_uuid as mainBranchProjectUuid,
@@ -30,6 +30,7 @@
     FROM components p
     where
       p.kee=#{key,jdbcType=VARCHAR}
+      and p.main_branch_project_uuid is null
   </select>
 
   <select id="selectByKeyCaseInsensitive" parameterType="String" resultType="Component">
       lower(p.kee)=lower(#{key,jdbcType=VARCHAR})
   </select>
 
-  <select id="selectBranchByKeyAndBranchKey" parameterType="String" resultType="Component">
+  <select id="selectByKeyAndBranchKey" parameterType="String" resultType="Component">
     select
       <include refid="componentColumns"/>
     from components p
-    inner join project_branches pb on pb.uuid = p.project_uuid
+    inner join project_branches pb on pb.uuid = p.branch_uuid
     where
-      (p.kee=#{dbKey,jdbcType=VARCHAR} OR p.kee=#{key,jdbcType=VARCHAR})
+      p.kee=#{key,jdbcType=VARCHAR}
       and pb.kee=#{branch,jdbcType=VARCHAR}
-      and (pb.branch_type='BRANCH')
+      and pb.branch_type='BRANCH'
   </select>
 
-  <select id="selectPrByKeyAndBranchKey" parameterType="String" resultType="Component">
+  <select id="selectByKeyAndPrKey" parameterType="String" resultType="Component">
     select
       <include refid="componentColumns"/>
     from components p
-    inner join project_branches pb on pb.uuid = p.project_uuid
+    inner join project_branches pb on pb.uuid = p.branch_uuid
     where
-      (p.kee=#{dbKey,jdbcType=VARCHAR} OR p.kee=#{key,jdbcType=VARCHAR})
-      and pb.kee=#{branch,jdbcType=VARCHAR}
+      p.kee=#{key,jdbcType=VARCHAR}
+      and pb.kee=#{pr,jdbcType=VARCHAR}
       and pb.branch_type='PULL_REQUEST'
   </select>
 
       p.uuid=#{uuid,jdbcType=VARCHAR}
   </select>
 
-  <select id="selectByProjectUuid" parameterType="string" resultType="Component">
+  <select id="selectByBranchUuid" parameterType="string" resultType="Component">
     select
     <include refid="componentColumns"/>
     from components root
-    inner join components p on p.project_uuid=root.uuid
+    inner join components p on p.branch_uuid=root.uuid
     where
-      root.uuid=#{projectUuid,jdbcType=VARCHAR}
+      root.uuid=#{branchUuid,jdbcType=VARCHAR}
   </select>
 
   <select id="selectByKeys" parameterType="String" resultType="Component">
       </foreach>
   </select>
 
-  <select id="selectByDbKeys" parameterType="String" resultType="Component">
-    select
-    <include refid="componentColumns"/>
-    from components p
-    where
-    p.enabled=${_true}
-    and p.kee in
-    <foreach collection="dbKeys" open="(" close=")" item="key" separator=",">
-      #{key,jdbcType=VARCHAR}
-    </foreach>
-  </select>
-
   <select id="selectByKeysAndBranch" parameterType="String" resultType="Component">
     SELECT
     <include refid="componentColumns"/>
     FROM components p
-    INNER JOIN project_branches pb on pb.uuid = p.project_uuid
+    INNER JOIN project_branches pb on pb.uuid = p.branch_uuid
     <where>
     p.enabled=${_true}
     AND p.kee IN
 
   <sql id="modulesTreeQuery">
     INNER JOIN components module ON
-      module.project_uuid = p.project_uuid
+      module.branch_uuid = p.branch_uuid
       and module.uuid = #{moduleUuid}
       and module.scope='PRJ' AND module.enabled = ${_true}
     where
       fs.revision
     FROM components root
     INNER JOIN components p on
-      p.project_uuid=root.uuid
+      p.branch_uuid=root.uuid
       and p.enabled=${_true}
       and p.scope='FIL'
     INNER JOIN file_sources fs ON
       </foreach>
   </select>
 
-  <select id="countEnabledModulesByProjectUuid" resultType="int">
+  <select id="countEnabledModulesByBranchUuid" resultType="int">
     select
       count(1)
     from components p
     where
       p.enabled=${_true}
-      and p.project_uuid = #{projectUuid,jdbcType=VARCHAR}
+      and p.branch_uuid = #{branchUuid,jdbcType=VARCHAR}
       and p.qualifier = 'BRC'
   </select>
 
       <include refid="componentColumns"/>
     from components p
     where
-    p.project_uuid = #{branchUuid,jdbcType=VARCHAR}
+    p.branch_uuid = #{branchUuid,jdbcType=VARCHAR}
     and p.uuid_path in
     <foreach collection="uuidPaths" item="uuidPath" open="(" close=")" separator=",">
         #{uuidPath,jdbcType=VARCHAR}
   </select>
 
   <sql id="selectDescendantsJoins">
-    inner join components base on base.project_uuid = p.project_uuid and base.uuid = #{baseUuid}
+    inner join components base on base.branch_uuid = p.branch_uuid and base.uuid = #{baseUuid}
     <choose>
       <when test="query.getStrategy().name() == 'CHILDREN'">
         and p.uuid_path = #{baseUuidPath,jdbcType=VARCHAR}
     </if>
   </sql>
 
-  <select id="selectUuidsForQualifiers" resultType="UuidWithProjectUuid">
-    SELECT p.uuid as "uuid", p.project_uuid as "projectUuid" FROM components p
+  <select id="selectUuidsForQualifiers" resultType="UuidWithBranchUuid">
+    SELECT p.uuid as "uuid", p.branch_uuid as "branchUuid" FROM components p
     where
       <foreach collection="qualifiers" open="(" close=")" item="qualifier" separator="OR ">
         p.qualifier=#{qualifier,jdbcType=VARCHAR}
         <foreach collection="projectUuids" open="(" close=")" item="uuid" separator=",">#{uuid,jdbcType=VARCHAR}</foreach>
     where
       p.enabled = ${_true}
-      and p.uuid = leaf.project_uuid
+      and p.uuid = leaf.branch_uuid
       and p.scope = 'PRJ'
       and p.qualifier in ('VW', 'APP')
   </select>
     from components p
     where
       p.enabled = ${_true}
-      and p.project_uuid = #{projectViewUuid,jdbcType=VARCHAR}
+      and p.branch_uuid = #{projectViewUuid,jdbcType=VARCHAR}
     <choose>
       <when test="_databaseId == 'mssql'">
         and p.module_uuid_path like #{viewUuidLikeQuery,jdbcType=VARCHAR} {escape '\'}
     SELECT
     <include refid="componentColumns"/>
     FROM components p
-    INNER JOIN components root ON root.uuid=p.project_uuid AND root.kee=#{projectKey,jdbcType=VARCHAR}
+    INNER JOIN components root ON root.uuid=p.branch_uuid AND root.kee=#{projectKey,jdbcType=VARCHAR}
     <where>
       <if test="excludeDisabled">
         p.enabled = ${_true}
     FROM
       components p
     INNER JOIN
-      components root ON root.uuid=p.project_uuid AND p.enabled = ${_true} AND root.kee=#{projectKey,jdbcType=VARCHAR}
+      components root ON root.uuid=p.branch_uuid AND p.enabled = ${_true} AND root.kee=#{projectKey,jdbcType=VARCHAR}
   </select>
 
   <select id="selectUuidsByKeyFromProjectKey" parameterType="string" resultType="KeyWithUuid">
     FROM
       components p
     INNER JOIN
-      components root ON root.uuid=p.project_uuid AND root.kee=#{projectKey,jdbcType=VARCHAR}
+      components root ON root.uuid=p.branch_uuid AND root.kee=#{projectKey,jdbcType=VARCHAR}
   </select>
 
   <select id="scrollForIndexing" parameterType="map" resultType="Component" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY">
       and p.scope = 'PRJ'
       and p.qualifier in ('TRK','VW','SVW','APP')
       <if test="projectUuid != null">
-        and p.project_uuid = #{projectUuid,jdbcType=VARCHAR}
+        and p.branch_uuid = #{projectUuid,jdbcType=VARCHAR}
       </if>
   </select>
 
     inner join file_sources fs on
       fs.file_uuid = p.uuid
     where
-      p.project_uuid = #{projectUuid,jdbcType=VARCHAR}
+      p.branch_uuid = #{branchUuid,jdbcType=VARCHAR}
       and p.enabled = ${_true}
       and p.scope = 'FIL'
       and p.qualifier in ('FIL', 'UTS')
       kee,
       uuid,
       uuid_path,
-      project_uuid,
+      branch_uuid,
       module_uuid,
       module_uuid_path,
       main_branch_project_uuid,
     #{kee,jdbcType=VARCHAR},
     #{uuid,jdbcType=VARCHAR},
     #{uuidPath,jdbcType=VARCHAR},
-    #{projectUuid,jdbcType=VARCHAR},
+    #{branchUuid,jdbcType=VARCHAR},
     #{moduleUuid,jdbcType=VARCHAR},
     #{moduleUuidPath,jdbcType=VARCHAR},
     #{mainBranchProjectUuid, jdbcType=VARCHAR},
     b_path = null,
     b_qualifier = null
     where
-    project_uuid = #{projectUuid,jdbcType=VARCHAR} and
+    branch_uuid = #{branchUuid,jdbcType=VARCHAR} and
     b_changed = ${_true}
   </update>
 
     <!-- Component key is normally immutable, but since 7.6 deprecated_kee is used as a b_kee to migrate component keys after the drop of modules -->
     deprecated_kee = kee
     where
-    project_uuid = #{projectUuid,jdbcType=VARCHAR} and
+    branch_uuid = #{branchUuid,jdbcType=VARCHAR} and
     b_changed = ${_true}
   </update>
 
     update components set
       private = #{isPrivate,jdbcType=BOOLEAN}
     where
-      project_uuid = #{projectUuid,jdbcType=VARCHAR}
+      branch_uuid = #{branchUuid,jdbcType=VARCHAR}
       and private &lt;&gt; #{isPrivate,jdbcType=BOOLEAN}
   </update>
 
index 513386f13222b9a7c0f97fe19ca609abf5efa429..575645a72c623011e337a77c0653c60cab50096d 100644 (file)
@@ -38,7 +38,7 @@
   <select id="selectLastSnapshotByComponentUuid" resultType="Snapshot">
     select <include refid="snapshotColumns" />
     from snapshots s
-    inner join components p on s.component_uuid = p.project_uuid
+    inner join components p on s.component_uuid = p.branch_uuid
     where
       s.islast=${_true}
       and p.uuid = #{componentUuid,jdbcType=VARCHAR}
   <select id="selectLastAnalysisDateByProject" resultType="long">
     select max(s.created_at)
     from snapshots s
-    inner join components p on s.component_uuid = p.project_uuid
+    inner join components p on s.component_uuid = p.branch_uuid
     where
       s.islast=${_true}
-      and coalesce(p.main_branch_project_uuid, p.project_uuid) = #{projectUuid,jdbcType=VARCHAR}
+      and coalesce(p.main_branch_project_uuid, p.branch_uuid) = #{projectUuid,jdbcType=VARCHAR}
   </select>
 
   <select id="selectLastAnalysisDateByProjects" resultType="org.sonar.db.component.ProjectLastAnalysisDateDto">
@@ -65,7 +65,7 @@
       from
         snapshots s
       inner join components c on
-        s.component_uuid = c.project_uuid
+        s.component_uuid = c.branch_uuid
       where
         s.islast = ${_true}
         and c.main_branch_project_uuid in
         c.main_branch_project_uuid
     union
       select
-        c.project_uuid as project_uuid,
+        c.branch_uuid as project_uuid,
         max(s.created_at) as last_analysis_date
       from
         snapshots s
       inner join components c on
-        s.component_uuid = c.project_uuid
+        s.component_uuid = c.branch_uuid
       where
         s.islast = ${_true}
         and c.main_branch_project_uuid is null
-        and c.project_uuid in
+        and c.branch_uuid in
       <foreach collection="projectUuids" item="projectUuid" separator="," open="(" close=")">
         #{projectUuid,jdbcType=VARCHAR}
       </foreach>
       group by
-        c.project_uuid
+        c.branch_uuid
     ) result_with_duplicates
     group by
       result_with_duplicates.project_uuid
index 20df7611c2b815d44c07b521314759be6ce98335..db14d3c66467dcfd0a8c265b96ed4a78a187e8af 100644 (file)
@@ -69,7 +69,7 @@
       components p
     where
       (
-        p.project_uuid=#{rootUuid,jdbcType=VARCHAR}
+        p.branch_uuid=#{rootUuid,jdbcType=VARCHAR}
         and p.scope = 'PRJ' and p.qualifier in ('SVW','BRC')
       )
       or (
@@ -85,7 +85,7 @@
     inner join components p on
       p.uuid = fs.file_uuid
       and p.enabled = ${_false}
-      and p.project_uuid=#{projectUuid,jdbcType=VARCHAR}
+      and p.branch_uuid=#{branchUuid,jdbcType=VARCHAR}
   </select>
 
   <select id="selectDisabledComponentsWithUnresolvedIssues" parameterType="map" resultType="String">
@@ -95,7 +95,7 @@
     inner join components p on
       p.uuid = i.component_uuid
       and p.enabled = ${_false}
-      and p.project_uuid=#{projectUuid,jdbcType=VARCHAR}
+      and p.branch_uuid=#{branchUuid,jdbcType=VARCHAR}
     where
       resolution is null
   </select>
     inner join components p on
       p.uuid = lm.component_uuid
       and p.enabled = ${_false}
-      and p.project_uuid=#{projectUuid,jdbcType=VARCHAR}
+      and p.branch_uuid=#{branchUuid,jdbcType=VARCHAR}
   </select>
 
   <delete id="deleteAnalysisMeasures" parameterType="map">
   <delete id="deleteComponentsByProjectUuid" parameterType="map">
     delete from components
     where
-      project_uuid = #{rootUuid,jdbcType=VARCHAR}
+      branch_uuid = #{rootUuid,jdbcType=VARCHAR}
   </delete>
 
     <delete id="deleteComponentsByMainBranchProjectUuid" parameterType="map">
       components p
     WHERE
       p.enabled = ${_false}
-      AND p.project_uuid=#{projectUuid,jdbcType=VARCHAR}
+      AND p.branch_uuid=#{branchUuid,jdbcType=VARCHAR}
       AND NOT EXISTS (SELECT 1 FROM issues i WHERE i.component_uuid = p.uuid)
   </select>
 
index f161a202ff65098368e267894a56b0a55339b305..fae462a9976e784a4ae2f4c146f62156c7ca7f4b 100644 (file)
@@ -215,7 +215,7 @@ CREATE TABLE "COMPONENTS"(
     "COPY_COMPONENT_UUID" CHARACTER VARYING(50),
     "PATH" CHARACTER VARYING(2000),
     "UUID_PATH" CHARACTER VARYING(1500) NOT NULL,
-    "PROJECT_UUID" CHARACTER VARYING(50) NOT NULL,
+    "BRANCH_UUID" CHARACTER VARYING(50) NOT NULL,
     "MODULE_UUID" CHARACTER VARYING(50),
     "MODULE_UUID_PATH" CHARACTER VARYING(1500),
     "MAIN_BRANCH_PROJECT_UUID" CHARACTER VARYING(50),
@@ -233,13 +233,12 @@ CREATE TABLE "COMPONENTS"(
     "B_MODULE_UUID_PATH" CHARACTER VARYING(1500),
     "CREATED_AT" TIMESTAMP
 );
-CREATE UNIQUE INDEX "PROJECTS_KEE" ON "COMPONENTS"("KEE" NULLS FIRST);
 CREATE INDEX "PROJECTS_MODULE_UUID" ON "COMPONENTS"("MODULE_UUID" NULLS FIRST);
-CREATE INDEX "PROJECTS_PROJECT_UUID" ON "COMPONENTS"("PROJECT_UUID" NULLS FIRST);
 CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER" NULLS FIRST);
 CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID" NULLS FIRST);
 CREATE INDEX "IDX_MAIN_BRANCH_PRJ_UUID" ON "COMPONENTS"("MAIN_BRANCH_PROJECT_UUID" NULLS FIRST);
 CREATE UNIQUE INDEX "COMPONENTS_UUID" ON "COMPONENTS"("UUID" NULLS FIRST);
+CREATE INDEX "COMPONENTS_BRANCH_UUID" ON "COMPONENTS"("BRANCH_UUID" NULLS FIRST);
 
 CREATE TABLE "DEFAULT_QPROFILES"(
     "LANGUAGE" CHARACTER VARYING(20) NOT NULL,
index d760751fac27b8590d87956b03d46056e5338269..2eb980d3913c649b1447d46e34c20162c85a6b5e 100644 (file)
@@ -702,12 +702,12 @@ public class CeQueueDaoTest {
   private void insertView(String view_uuid) {
     ComponentDto view = new ComponentDto();
     view.setQualifier("VW");
-    view.setDbKey(view_uuid + "_key");
+    view.setKey(view_uuid + "_key");
     view.setUuid(view_uuid);
     view.setPrivate(false);
     view.setRootUuid(view_uuid);
     view.setUuidPath("uuid_path");
-    view.setProjectUuid(view_uuid);
+    view.setBranchUuid(view_uuid);
     db.components().insertPortfolioAndSnapshot(view);
     db.commit();
   }
@@ -715,12 +715,12 @@ public class CeQueueDaoTest {
   private void insertBranch(String uuid) {
     ComponentDto branch = new ComponentDto();
     branch.setQualifier("TRK");
-    branch.setDbKey(uuid + "_key");
+    branch.setKey(uuid + "_key");
     branch.setUuid(uuid);
     branch.setPrivate(false);
     branch.setRootUuid(uuid);
     branch.setUuidPath("uuid_path");
-    branch.setProjectUuid(uuid);
+    branch.setBranchUuid(uuid);
     db.components().insertComponent(branch);
     db.commit();
   }
index 7e016ddfe3a13cce8a6a88939a60201c86292949..7c8d24a49cc79a2d294ffeecf7184188969fa9e3 100644 (file)
@@ -79,9 +79,9 @@ public class ApplicationProjectsDaoTest {
 
   @Test
   public void select_project_branches_from_application_branch() {
-    var project = db.components().insertPublicProjectDto(p -> p.setDbKey("project"));
+    var project = db.components().insertPublicProjectDto(p -> p.setKey("project"));
     var projectBranch = db.components().insertProjectBranch(project, b -> b.setKey("project-branch"));
-    var app = db.components().insertPrivateApplicationDto(a -> a.setDbKey("app1"));
+    var app = db.components().insertPrivateApplicationDto(a -> a.setKey("app1"));
     var appBranch = db.components().insertProjectBranch(app, b -> b.setKey("app-branch"));
     db.components().addApplicationProject(app, project);
     underTest.addProjectBranchToAppBranch(dbSession, app.getUuid(), appBranch.getUuid(), project.getUuid(), projectBranch.getUuid());
index e58113a3212718f07a28c8bb8ecce80101127b71..5de47d10d246017228cdc818b0e98c8a756bb4c0 100644 (file)
@@ -425,7 +425,7 @@ public class BranchDaoTest {
     featureBranch.setMergeBranchUuid("U3");
     underTest.insert(dbSession, featureBranch);
 
-    ComponentDto component = new ComponentDto().setProjectUuid(mainBranch.getUuid());
+    ComponentDto component = new ComponentDto().setBranchUuid(mainBranch.getUuid());
 
     // select the component
     Collection<BranchDto> branches = underTest.selectByComponent(dbSession, component);
@@ -736,7 +736,7 @@ public class BranchDaoTest {
   @Test
   public void doAnyOfComponentsNeedIssueSync_test_more_than_1000() {
     List<String> componentKeys = IntStream.range(0, 1100).mapToObj(value -> db.components().insertPrivateProject())
-      .map(ComponentDto::getDbKey)
+      .map(ComponentDto::getKey)
       .collect(Collectors.toList());
 
     assertThat(underTest.doAnyOfComponentsNeedIssueSync(dbSession, componentKeys)).isFalse();
@@ -745,7 +745,7 @@ public class BranchDaoTest {
     ProjectDto projectDto = db.components().getProjectDto(project);
     db.components().insertProjectBranch(projectDto, b -> b.setBranchType(BranchType.BRANCH).setNeedIssueSync(true));
 
-    componentKeys.add(project.getDbKey());
+    componentKeys.add(project.getKey());
 
     assertThat(underTest.doAnyOfComponentsNeedIssueSync(dbSession, componentKeys)).isTrue();
   }
index 0996f6a56ff47d132ddd04ce07f9ea69781dd3ef..8104002008b886ebbac9ee76c6e6cc574a0ee6fd 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.db.component;
 
-import com.google.common.collect.ImmutableMap;
 import com.tngtech.java.junit.dataprovider.DataProvider;
 import com.tngtech.java.junit.dataprovider.DataProviderRunner;
 import com.tngtech.java.junit.dataprovider.UseDataProvider;
@@ -130,7 +129,7 @@ public class ComponentDaoTest {
   @Test
   public void get_by_uuid() {
     ComponentDto project = db.components().insertPrivateProject(p -> p
-      .setDbKey("org.struts:struts")
+      .setKey("org.struts:struts")
       .setName("Struts")
       .setLongName("Apache Struts"));
     ComponentDto anotherProject = db.components().insertPrivateProject();
@@ -141,8 +140,8 @@ public class ComponentDaoTest {
     assertThat(result.getUuidPath()).isEqualTo(".");
     assertThat(result.moduleUuid()).isNull();
     assertThat(result.moduleUuidPath()).isEqualTo("." + project.uuid() + ".");
-    assertThat(result.projectUuid()).isEqualTo(project.uuid());
-    assertThat(result.getDbKey()).isEqualTo("org.struts:struts");
+    assertThat(result.branchUuid()).isEqualTo(project.uuid());
+    assertThat(result.getKey()).isEqualTo("org.struts:struts");
     assertThat(result.path()).isNull();
     assertThat(result.name()).isEqualTo("Struts");
     assertThat(result.longName()).isEqualTo("Apache Struts");
@@ -159,7 +158,7 @@ public class ComponentDaoTest {
   public void get_by_uuid_on_technical_project_copy() {
     ComponentDto view = db.components().insertPublicPortfolio();
     ComponentDto project = db.components().insertPublicProject(p -> p
-      .setDbKey("org.struts:struts")
+      .setKey("org.struts:struts")
       .setName("Struts")
       .setLongName("Apache Struts"));
     ComponentDto projectCopy = db.components().insertComponent(newProjectCopy(project, view));
@@ -170,8 +169,8 @@ public class ComponentDaoTest {
     assertThat(result.uuid()).isEqualTo(projectCopy.uuid());
     assertThat(result.moduleUuid()).isEqualTo(view.uuid());
     assertThat(result.moduleUuidPath()).isEqualTo("." + view.uuid() + ".");
-    assertThat(result.projectUuid()).isEqualTo(view.uuid());
-    assertThat(result.getDbKey()).isEqualTo(view.getDbKey() + project.getDbKey());
+    assertThat(result.branchUuid()).isEqualTo(view.uuid());
+    assertThat(result.getKey()).isEqualTo(view.getKey() + project.getKey());
     assertThat(result.path()).isNull();
     assertThat(result.name()).isEqualTo("Struts");
     assertThat(result.longName()).isEqualTo("Apache Struts");
@@ -205,24 +204,24 @@ public class ComponentDaoTest {
     ComponentDto project = db.components().insertPrivateProject();
     ComponentDto directory = db.components().insertComponent(newDirectory(project, "src"));
     ComponentDto file = db.components().insertComponent(newFileDto(project, directory)
-      .setDbKey("org.struts:struts-core:src/org/struts/RequestContext.java")
+      .setKey("org.struts:struts-core:src/org/struts/RequestContext.java")
       .setName("RequestContext.java")
       .setLongName("org.struts.RequestContext")
       .setLanguage("java")
       .setPath("src/RequestContext.java"));
 
-    Optional<ComponentDto> optional = underTest.selectByKey(dbSession, file.getDbKey());
+    Optional<ComponentDto> optional = underTest.selectByKey(dbSession, file.getKey());
 
     ComponentDto result = optional.get();
     assertThat(result.uuid()).isEqualTo(file.uuid());
-    assertThat(result.getDbKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
+    assertThat(result.getKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
     assertThat(result.path()).isEqualTo("src/RequestContext.java");
     assertThat(result.name()).isEqualTo("RequestContext.java");
     assertThat(result.longName()).isEqualTo("org.struts.RequestContext");
     assertThat(result.qualifier()).isEqualTo("FIL");
     assertThat(result.scope()).isEqualTo("FIL");
     assertThat(result.language()).isEqualTo("java");
-    assertThat(result.projectUuid()).isEqualTo(project.uuid());
+    assertThat(result.branchUuid()).isEqualTo(project.uuid());
 
     assertThat(underTest.selectByKey(dbSession, "unknown")).isEmpty();
   }
@@ -250,9 +249,7 @@ public class ComponentDaoTest {
     ComponentDto file = db.components().insertComponent(newFileDto(pullRequest));
 
     assertThat(underTest.selectByKeyAndPullRequest(dbSession, project.getKey(), "my_PR").get().uuid()).isEqualTo(pullRequest.uuid());
-    assertThat(underTest.selectByKeyAndBranch(dbSession, project.getKey(), "master").get().uuid()).isEqualTo(project.uuid());
     assertThat(underTest.selectByKeyAndPullRequest(dbSession, project.getKey(), "master").get().uuid()).isEqualTo(pullRequestNamedAsMainBranch.uuid());
-    assertThat(underTest.selectByKeyAndBranch(dbSession, branch.getKey(), "my_branch").get().uuid()).isEqualTo(branch.uuid());
     assertThat(underTest.selectByKeyAndPullRequest(dbSession, branch.getKey(), "my_branch").get().uuid()).isEqualTo(pullRequestNamedAsBranch.uuid());
     assertThat(underTest.selectByKeyAndPullRequest(dbSession, file.getKey(), "my_PR").get().uuid()).isEqualTo(file.uuid());
     assertThat(underTest.selectByKeyAndPullRequest(dbSession, "unknown", "my_branch")).isNotPresent();
@@ -271,7 +268,7 @@ public class ComponentDaoTest {
   public void get_by_key_on_disabled_component() {
     ComponentDto project = db.components().insertPrivateProject(p -> p.setEnabled(false));
 
-    ComponentDto result = underTest.selectOrFailByKey(dbSession, project.getDbKey());
+    ComponentDto result = underTest.selectOrFailByKey(dbSession, project.getKey());
 
     assertThat(result.isEnabled()).isFalse();
   }
@@ -280,13 +277,13 @@ public class ComponentDaoTest {
   public void get_by_key_on_a_root_project() {
     ComponentDto project = db.components().insertPrivateProject();
 
-    ComponentDto result = underTest.selectOrFailByKey(dbSession, project.getDbKey());
+    ComponentDto result = underTest.selectOrFailByKey(dbSession, project.getKey());
 
-    assertThat(result.getDbKey()).isEqualTo(project.getDbKey());
+    assertThat(result.getKey()).isEqualTo(project.getKey());
     assertThat(result.uuid()).isEqualTo(project.uuid());
     assertThat(result.getUuidPath()).isEqualTo(project.getUuidPath());
     assertThat(result.getRootUuid()).isEqualTo(project.uuid());
-    assertThat(result.projectUuid()).isEqualTo(project.uuid());
+    assertThat(result.branchUuid()).isEqualTo(project.uuid());
   }
 
   @Test
@@ -294,13 +291,13 @@ public class ComponentDaoTest {
     ComponentDto project1 = db.components().insertPrivateProject();
     ComponentDto project2 = db.components().insertPrivateProject();
 
-    List<ComponentDto> results = underTest.selectByKeys(dbSession, asList(project1.getDbKey(), project2.getDbKey()));
+    List<ComponentDto> results = underTest.selectByKeys(dbSession, asList(project1.getKey(), project2.getKey()));
 
     assertThat(results)
-      .extracting(ComponentDto::uuid, ComponentDto::getDbKey)
+      .extracting(ComponentDto::uuid, ComponentDto::getKey)
       .containsExactlyInAnyOrder(
-        tuple(project1.uuid(), project1.getDbKey()),
-        tuple(project2.uuid(), project2.getDbKey()));
+        tuple(project1.uuid(), project1.getKey()),
+        tuple(project2.uuid(), project2.getKey()));
 
     assertThat(underTest.selectByKeys(dbSession, singletonList("unknown"))).isEmpty();
   }
@@ -321,29 +318,7 @@ public class ComponentDaoTest {
     assertThat(underTest.selectByKeysAndBranch(dbSession, singletonList(fileOnAnotherBranch.getKey()), "my_branch")).isEmpty();
     assertThat(underTest.selectByKeysAndBranch(dbSession, singletonList(file1.getKey()), "unknown")).isEmpty();
     assertThat(underTest.selectByKeysAndBranch(dbSession, singletonList("unknown"), "my_branch")).isEmpty();
-    assertThat(underTest.selectByKeysAndBranch(dbSession, singletonList(branch.getKey()), "master")).extracting(ComponentDto::uuid).containsExactlyInAnyOrder(project.uuid());
-  }
-
-  @Test
-  public void select_by_keys_and_branches() {
-    ComponentDto project = db.components().insertPublicProject();
-    ComponentDto projectBranch = db.components().insertProjectBranch(project, b -> b.setKey("my_branch"));
-    ComponentDto application = db.components().insertPublicProject(a -> a.setQualifier(APP));
-    ComponentDto applicationBranch = db.components().insertProjectBranch(application, b -> b.setKey("my_branch"));
-
-    assertThat(underTest.selectByKeysAndBranches(db.getSession(), ImmutableMap.of(
-      projectBranch.getKey(), projectBranch.getBranch(),
-      applicationBranch.getKey(), applicationBranch.getBranch())))
-      .extracting(ComponentDto::getKey, ComponentDto::getBranch)
-      .containsExactlyInAnyOrder(
-        tuple(projectBranch.getKey(), "my_branch"),
-        tuple(applicationBranch.getKey(), "my_branch"));
-    assertThat(underTest.selectByKeysAndBranches(db.getSession(), ImmutableMap.of(
-      projectBranch.getKey(), "unknown",
-      "unknown", projectBranch.getBranch())))
-      .extracting(ComponentDto::getDbKey)
-      .isEmpty();
-    assertThat(underTest.selectByKeysAndBranches(db.getSession(), Collections.emptyMap())).isEmpty();
+    assertThat(underTest.selectByKeysAndBranch(dbSession, singletonList(branch.getKey()), "my_branch")).extracting(ComponentDto::uuid).containsExactlyInAnyOrder(branch.uuid());
   }
 
   @Test
@@ -354,10 +329,10 @@ public class ComponentDaoTest {
     List<ComponentDto> results = underTest.selectByUuids(dbSession, asList(project1.uuid(), project2.uuid()));
 
     assertThat(results)
-      .extracting(ComponentDto::uuid, ComponentDto::getDbKey)
+      .extracting(ComponentDto::uuid, ComponentDto::getKey)
       .containsExactlyInAnyOrder(
-        tuple(project1.uuid(), project1.getDbKey()),
-        tuple(project2.uuid(), project2.getDbKey()));
+        tuple(project1.uuid(), project1.getKey()),
+        tuple(project2.uuid(), project2.getKey()));
 
     assertThat(underTest.selectByUuids(dbSession, singletonList("unknown"))).isEmpty();
   }
@@ -370,10 +345,10 @@ public class ComponentDaoTest {
     List<ComponentDto> results = underTest.selectByUuids(dbSession, asList(project1.uuid(), project2.uuid()));
 
     assertThat(results)
-      .extracting(ComponentDto::getDbKey, ComponentDto::isEnabled)
+      .extracting(ComponentDto::getKey, ComponentDto::isEnabled)
       .containsExactlyInAnyOrder(
-        tuple(project1.getDbKey(), true),
-        tuple(project2.getDbKey(), false));
+        tuple(project1.getKey(), true),
+        tuple(project2.getKey(), false));
   }
 
   @Test
@@ -393,10 +368,10 @@ public class ComponentDaoTest {
     ComponentDto directory = db.components().insertComponent(newDirectory(module, "src"));
     ComponentDto file = db.components().insertComponent(newFileDto(directory));
 
-    assertThat(underTest.selectComponentsByQualifiers(dbSession, newHashSet("TRK"))).extracting(ComponentDto::getDbKey).containsExactlyInAnyOrder(project.getDbKey());
-    assertThat(underTest.selectComponentsByQualifiers(dbSession, newHashSet("BRC"))).extracting(ComponentDto::getDbKey).containsExactlyInAnyOrder(module.getDbKey());
-    assertThat(underTest.selectComponentsByQualifiers(dbSession, newHashSet("DIR"))).extracting(ComponentDto::getDbKey).containsExactlyInAnyOrder(directory.getDbKey());
-    assertThat(underTest.selectComponentsByQualifiers(dbSession, newHashSet("FIL"))).extracting(ComponentDto::getDbKey).containsExactlyInAnyOrder(file.getDbKey());
+    assertThat(underTest.selectComponentsByQualifiers(dbSession, newHashSet("TRK"))).extracting(ComponentDto::getKey).containsExactlyInAnyOrder(project.getKey());
+    assertThat(underTest.selectComponentsByQualifiers(dbSession, newHashSet("BRC"))).extracting(ComponentDto::getKey).containsExactlyInAnyOrder(module.getKey());
+    assertThat(underTest.selectComponentsByQualifiers(dbSession, newHashSet("DIR"))).extracting(ComponentDto::getKey).containsExactlyInAnyOrder(directory.getKey());
+    assertThat(underTest.selectComponentsByQualifiers(dbSession, newHashSet("FIL"))).extracting(ComponentDto::getKey).containsExactlyInAnyOrder(file.getKey());
     assertThat(underTest.selectComponentsByQualifiers(dbSession, newHashSet("unknown"))).isEmpty();
   }
 
@@ -417,7 +392,7 @@ public class ComponentDaoTest {
     subModule2.setEnabled(false);
     db.components().insertComponent(subModule2);
 
-    int result = underTest.countEnabledModulesByProjectUuid(dbSession, project.uuid());
+    int result = underTest.countEnabledModulesByBranchUuid(dbSession, project.uuid());
 
     assertThat(result).isEqualTo(2);
   }
@@ -437,8 +412,8 @@ public class ComponentDaoTest {
 
     // Sub project of a file
     assertThat(underTest.selectSubProjectsByComponentUuids(dbSession, singletonList(file.uuid())))
-      .extracting(ComponentDto::getDbKey)
-      .containsExactlyInAnyOrder(subModule.getDbKey());
+      .extracting(ComponentDto::getKey)
+      .containsExactlyInAnyOrder(subModule.getKey());
 
     // Sub project of a directory
     assertThat(underTest.selectSubProjectsByComponentUuids(dbSession, singletonList(directory.uuid())))
@@ -518,7 +493,7 @@ public class ComponentDaoTest {
     ComponentDto removedFile = db.components().insertComponent(newFileDto(subModule, directory).setEnabled(false));
 
     // From root project
-    assertThat(underTest.selectEnabledComponentsWithModuleUuidFromProjectKey(dbSession, project.getDbKey()))
+    assertThat(underTest.selectEnabledComponentsWithModuleUuidFromProjectKey(dbSession, project.getKey()))
       .extracting(ComponentWithModuleUuidDto::uuid)
       .containsExactlyInAnyOrder(
         project.uuid(),
@@ -636,10 +611,10 @@ public class ComponentDaoTest {
     ComponentDto removedFile = db.components().insertComponent(newFileDto(subModule, directory).setEnabled(false));
 
     // Removed components are included
-    assertThat(underTest.selectAllComponentsFromProjectKey(dbSession, project.getDbKey()))
-      .extracting(ComponentDto::getDbKey)
-      .containsExactlyInAnyOrder(project.getDbKey(), module.getDbKey(), removedModule.getDbKey(), subModule.getDbKey(), removedSubModule.getDbKey(),
-        directory.getDbKey(), removedDirectory.getDbKey(), file.getDbKey(), removedFile.getDbKey());
+    assertThat(underTest.selectAllComponentsFromProjectKey(dbSession, project.getKey()))
+      .extracting(ComponentDto::getKey)
+      .containsExactlyInAnyOrder(project.getKey(), module.getKey(), removedModule.getKey(), subModule.getKey(), removedSubModule.getKey(),
+        directory.getKey(), removedDirectory.getKey(), file.getKey(), removedFile.getKey());
 
     assertThat(underTest.selectAllComponentsFromProjectKey(dbSession, "UNKNOWN")).isEmpty();
   }
@@ -657,19 +632,19 @@ public class ComponentDaoTest {
     ComponentDto file = db.components().insertComponent(newFileDto(subModule, directory));
     ComponentDto removedFile = db.components().insertComponent(newFileDto(subModule, directory).setEnabled(false));
 
-    Map<String, String> uuidsByKey = underTest.selectUuidsByKeyFromProjectKey(dbSession, project.getDbKey())
+    Map<String, String> uuidsByKey = underTest.selectUuidsByKeyFromProjectKey(dbSession, project.getKey())
       .stream().collect(Collectors.toMap(KeyWithUuidDto::key, KeyWithUuidDto::uuid));
 
     assertThat(uuidsByKey).containsOnly(
-      entry(project.getDbKey(), project.uuid()),
-      entry(module.getDbKey(), module.uuid()),
-      entry(removedModule.getDbKey(), removedModule.uuid()),
-      entry(subModule.getDbKey(), subModule.uuid()),
-      entry(removedSubModule.getDbKey(), removedSubModule.uuid()),
-      entry(directory.getDbKey(), directory.uuid()),
-      entry(removedDirectory.getDbKey(), removedDirectory.uuid()),
-      entry(file.getDbKey(), file.uuid()),
-      entry(removedFile.getDbKey(), removedFile.uuid()));
+      entry(project.getKey(), project.uuid()),
+      entry(module.getKey(), module.uuid()),
+      entry(removedModule.getKey(), removedModule.uuid()),
+      entry(subModule.getKey(), subModule.uuid()),
+      entry(removedSubModule.getKey(), removedSubModule.uuid()),
+      entry(directory.getKey(), directory.uuid()),
+      entry(removedDirectory.getKey(), removedDirectory.uuid()),
+      entry(file.getKey(), file.uuid()),
+      entry(removedFile.getKey(), removedFile.uuid()));
   }
 
   @Test
@@ -686,9 +661,9 @@ public class ComponentDaoTest {
     ComponentDto removedFile = db.components().insertComponent(newFileDto(subModule, directory).setEnabled(false));
 
     // Removed modules are not included
-    assertThat(underTest.selectEnabledModulesFromProjectKey(dbSession, project.getDbKey()))
-      .extracting(ComponentDto::getDbKey)
-      .containsExactlyInAnyOrder(project.getDbKey(), module.getDbKey(), subModule.getDbKey());
+    assertThat(underTest.selectEnabledModulesFromProjectKey(dbSession, project.getKey()))
+      .extracting(ComponentDto::getKey)
+      .containsExactlyInAnyOrder(project.getKey(), module.getKey(), subModule.getKey());
 
     assertThat(underTest.selectEnabledModulesFromProjectKey(dbSession, "UNKNOWN")).isEmpty();
   }
@@ -704,10 +679,10 @@ public class ComponentDaoTest {
     db.components().insertSubView(view, dto -> dto.setUuid("FGHI"));
     ComponentDto application = db.components().insertPublicApplication();
 
-    assertThat(underTest.selectAllViewsAndSubViews(dbSession)).extracting(UuidWithProjectUuidDto::getUuid)
+    assertThat(underTest.selectAllViewsAndSubViews(dbSession)).extracting(UuidWithBranchUuidDto::getUuid)
       .containsExactlyInAnyOrder("ABCD", "EFGH", "FGHI", "IJKL", application.uuid());
-    assertThat(underTest.selectAllViewsAndSubViews(dbSession)).extracting(UuidWithProjectUuidDto::getProjectUuid)
-      .containsExactlyInAnyOrder("ABCD", "EFGH", "EFGH", "IJKL", application.projectUuid());
+    assertThat(underTest.selectAllViewsAndSubViews(dbSession)).extracting(UuidWithBranchUuidDto::getBranchUuid)
+      .containsExactlyInAnyOrder("ABCD", "EFGH", "EFGH", "IJKL", application.branchUuid());
   }
 
   @Test
@@ -743,7 +718,7 @@ public class ComponentDaoTest {
 
     Set<String> keys = underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project.uuid()));
 
-    assertThat(keys).containsOnly(view.getDbKey());
+    assertThat(keys).containsOnly(view.getKey());
 
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project.uuid())))
       .isEqualTo(keys);
@@ -762,25 +737,25 @@ public class ComponentDaoTest {
     insertProjectCopy(view2, project3);
 
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project1.uuid())))
-      .containsOnly(view.getDbKey());
+      .containsOnly(view.getKey());
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project1.uuid())))
-      .containsOnly(view.getDbKey());
+      .containsOnly(view.getKey());
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project2.uuid())))
-      .containsOnly(view.getDbKey());
+      .containsOnly(view.getKey());
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project2.uuid())))
-      .containsOnly(view.getDbKey());
+      .containsOnly(view.getKey());
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project3.uuid())))
-      .containsOnly(view2.getDbKey());
+      .containsOnly(view2.getKey());
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project3.uuid())))
-      .containsOnly(view2.getDbKey());
+      .containsOnly(view2.getKey());
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, of(project2.uuid(), project1.uuid())))
-      .containsOnly(view.getDbKey());
+      .containsOnly(view.getKey());
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project2.uuid(), project1.uuid())))
-      .containsOnly(view.getDbKey());
+      .containsOnly(view.getKey());
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, of(project1.uuid(), project3.uuid())))
-      .containsOnly(view.getDbKey(), view2.getDbKey());
+      .containsOnly(view.getKey(), view2.getKey());
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project1.uuid(), project3.uuid())))
-      .containsOnly(view.getDbKey(), view2.getDbKey());
+      .containsOnly(view.getKey(), view2.getKey());
   }
 
   @Test
@@ -795,7 +770,7 @@ public class ComponentDaoTest {
 
     Set<String> keys = underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project2.uuid()));
 
-    assertThat(keys).containsOnly(view2.getDbKey());
+    assertThat(keys).containsOnly(view2.getKey());
 
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project2.uuid())))
       .isEqualTo(keys);
@@ -812,7 +787,7 @@ public class ComponentDaoTest {
 
     Set<String> keys = underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project.uuid()));
 
-    assertThat(keys).containsOnly(view1.getDbKey());
+    assertThat(keys).containsOnly(view1.getKey());
 
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project.uuid())))
       .isEqualTo(keys);
@@ -829,7 +804,7 @@ public class ComponentDaoTest {
 
     Set<String> keys = underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project.uuid()));
 
-    assertThat(keys).containsOnly(view2.getDbKey());
+    assertThat(keys).containsOnly(view2.getKey());
 
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project.uuid())))
       .isEqualTo(keys);
@@ -845,7 +820,7 @@ public class ComponentDaoTest {
 
     Set<String> keys = underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project.uuid()));
 
-    assertThat(keys).containsOnly(view.getDbKey());
+    assertThat(keys).containsOnly(view.getKey());
 
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project.uuid())))
       .isEqualTo(keys);
@@ -866,25 +841,25 @@ public class ComponentDaoTest {
     insertProjectCopy(lowestSubview2, project3);
 
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project1.uuid())))
-      .containsOnly(view1.getDbKey());
+      .containsOnly(view1.getKey());
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project1.uuid())))
-      .containsOnly(view1.getDbKey());
+      .containsOnly(view1.getKey());
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project2.uuid())))
-      .containsOnly(view1.getDbKey());
+      .containsOnly(view1.getKey());
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project2.uuid())))
-      .containsOnly(view1.getDbKey());
+      .containsOnly(view1.getKey());
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project3.uuid())))
-      .containsOnly(view2.getDbKey());
+      .containsOnly(view2.getKey());
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project3.uuid())))
-      .containsOnly(view2.getDbKey());
+      .containsOnly(view2.getKey());
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, of(project2.uuid(), project1.uuid())))
-      .containsOnly(view1.getDbKey());
+      .containsOnly(view1.getKey());
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project2.uuid(), project1.uuid())))
-      .containsOnly(view1.getDbKey());
+      .containsOnly(view1.getKey());
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, of(project1.uuid(), project3.uuid())))
-      .containsOnly(view1.getDbKey(), view2.getDbKey());
+      .containsOnly(view1.getKey(), view2.getKey());
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project1.uuid(), project3.uuid())))
-      .containsOnly(view1.getDbKey(), view2.getDbKey());
+      .containsOnly(view1.getKey(), view2.getKey());
   }
 
   @Test
@@ -901,7 +876,7 @@ public class ComponentDaoTest {
 
     Set<String> keys = underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project2.uuid()));
 
-    assertThat(keys).containsOnly(view2.getDbKey());
+    assertThat(keys).containsOnly(view2.getKey());
 
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project2.uuid())))
       .isEqualTo(keys);
@@ -920,7 +895,7 @@ public class ComponentDaoTest {
 
     Set<String> keys = underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project.uuid()));
 
-    assertThat(keys).containsOnly(view1.getDbKey());
+    assertThat(keys).containsOnly(view1.getKey());
 
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project.uuid())))
       .isEqualTo(keys);
@@ -939,7 +914,7 @@ public class ComponentDaoTest {
 
     Set<String> keys = underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project.uuid()));
 
-    assertThat(keys).containsOnly(view2.getDbKey());
+    assertThat(keys).containsOnly(view2.getKey());
 
     assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project.uuid())))
       .isEqualTo(keys);
@@ -1050,7 +1025,7 @@ public class ComponentDaoTest {
   @Test
   public void selectByQuery_provisioned() {
     ComponentDto provisionedProject = db.components()
-      .insertPrivateProject(p -> p.setDbKey("provisioned.project").setName("Provisioned Project"));
+      .insertPrivateProject(p -> p.setKey("provisioned.project").setName("Provisioned Project"));
     ComponentDto provisionedPortfolio = db.components().insertPrivatePortfolio();
 
     SnapshotDto analyzedProject = db.components().insertProjectAndSnapshot(newPrivateProjectDto());
@@ -1076,7 +1051,7 @@ public class ComponentDaoTest {
       .containsOnly(provisionedProject.uuid(), provisionedPortfolio.uuid());
 
     // match key
-    assertThat(underTest.selectByQuery(dbSession, query.get().setNameOrKeyQuery(provisionedProject.getDbKey()).build(), 0, 10))
+    assertThat(underTest.selectByQuery(dbSession, query.get().setNameOrKeyQuery(provisionedProject.getKey()).build(), 0, 10))
       .extracting(ComponentDto::uuid)
       .containsExactly(provisionedProject.uuid());
     assertThat(underTest.selectByQuery(dbSession, query.get().setNameOrKeyQuery("pROvisiONed.proJEcT").setPartialMatchOnKey(true).build(), 0, 10))
@@ -1188,7 +1163,7 @@ public class ComponentDaoTest {
     ComponentDto file = db.components().insertComponent(newFileDto(subModule, directory));
     ComponentDto removedFile = db.components().insertComponent(newFileDto(subModule, directory).setEnabled(false));
 
-    assertThat(underTest.selectByProjectUuid(project.uuid(), dbSession))
+    assertThat(underTest.selectByBranchUuid(project.uuid(), dbSession))
       .extracting(ComponentDto::uuid)
       .containsExactlyInAnyOrder(project.uuid(), module.uuid(), removedModule.uuid(), subModule.uuid(), removedSubModule.uuid(), directory.uuid(), removedDirectory.uuid(),
         file.uuid(),
@@ -1294,7 +1269,7 @@ public class ComponentDaoTest {
     Map<String, Object> row1 = selectBColumnsForUuid("U1");
     assertThat(row1.get("bChanged")).isIn(true, /* for Oracle */1L, 1);
     assertThat(row1)
-      .containsEntry("bKey", dto1.getDbKey())
+      .containsEntry("bKey", dto1.getKey())
       .containsEntry("bCopyComponentUuid", dto1.getCopyComponentUuid())
       .containsEntry("bDescription", dto1.description());
     assertThat(row1.get("bEnabled")).isIn(false, /* for Oracle */0L, 0);
@@ -1311,7 +1286,7 @@ public class ComponentDaoTest {
     Map<String, Object> row2 = selectBColumnsForUuid("U2");
     assertThat(row2.get("bChanged")).isIn(true, /* for Oracle */1L, 1);
     assertThat(row2)
-      .containsEntry("bKey", dto2.getDbKey())
+      .containsEntry("bKey", dto2.getKey())
       .containsEntry("bCopyComponentUuid", dto2.getCopyComponentUuid())
       .containsEntry("bDescription", dto2.description());
     assertThat(row2.get("bEnabled")).isIn(false, /* for Oracle */0L, 0);
@@ -1412,19 +1387,19 @@ public class ComponentDaoTest {
 
   @Test
   public void selectByQuery_key_with_special_characters() {
-    db.components().insertProjectAndSnapshot(newPrivateProjectDto().setDbKey("project-_%-key"));
-    db.components().insertProjectAndSnapshot(newPrivateProjectDto().setDbKey("project-key-that-does-not-match"));
+    db.components().insertProjectAndSnapshot(newPrivateProjectDto().setKey("project-_%-key"));
+    db.components().insertProjectAndSnapshot(newPrivateProjectDto().setKey("project-key-that-does-not-match"));
 
     ComponentQuery query = ComponentQuery.builder().setNameOrKeyQuery("project-_%-key").setQualifiers(PROJECT).build();
     List<ComponentDto> result = underTest.selectByQuery(dbSession, query, 0, 10);
 
     assertThat(result).hasSize(1);
-    assertThat(result.get(0).getDbKey()).isEqualTo("project-_%-key");
+    assertThat(result.get(0).getKey()).isEqualTo("project-_%-key");
   }
 
   @Test
   public void selectByQuery_on_key_partial_match_case_insensitive() {
-    db.components().insertProjectAndSnapshot(newPrivateProjectDto().setDbKey("project-key"));
+    db.components().insertProjectAndSnapshot(newPrivateProjectDto().setKey("project-key"));
 
     ComponentQuery query = ComponentQuery.builder()
       .setNameOrKeyQuery("JECT-K")
@@ -1433,7 +1408,7 @@ public class ComponentDaoTest {
     List<ComponentDto> result = underTest.selectByQuery(dbSession, query, 0, 10);
 
     assertThat(result).hasSize(1);
-    assertThat(result.get(0).getDbKey()).isEqualTo("project-key");
+    assertThat(result.get(0).getKey()).isEqualTo("project-key");
   }
 
   @Test
@@ -1579,16 +1554,16 @@ public class ComponentDaoTest {
 
   @Test
   public void selectByQuery_filter_on_visibility() {
-    db.components().insertComponent(newPrivateProjectDto().setDbKey("private-key"));
-    db.components().insertComponent(ComponentTesting.newPublicProjectDto().setDbKey("public-key"));
+    db.components().insertComponent(newPrivateProjectDto().setKey("private-key"));
+    db.components().insertComponent(ComponentTesting.newPublicProjectDto().setKey("public-key"));
 
     ComponentQuery privateProjectsQuery = ComponentQuery.builder().setPrivate(true).setQualifiers(PROJECT).build();
     ComponentQuery publicProjectsQuery = ComponentQuery.builder().setPrivate(false).setQualifiers(PROJECT).build();
     ComponentQuery allProjectsQuery = ComponentQuery.builder().setPrivate(null).setQualifiers(PROJECT).build();
 
-    assertThat(underTest.selectByQuery(dbSession, privateProjectsQuery, 0, 10)).extracting(ComponentDto::getDbKey).containsExactly("private-key");
-    assertThat(underTest.selectByQuery(dbSession, publicProjectsQuery, 0, 10)).extracting(ComponentDto::getDbKey).containsExactly("public-key");
-    assertThat(underTest.selectByQuery(dbSession, allProjectsQuery, 0, 10)).extracting(ComponentDto::getDbKey).containsOnly("public-key", "private-key");
+    assertThat(underTest.selectByQuery(dbSession, privateProjectsQuery, 0, 10)).extracting(ComponentDto::getKey).containsExactly("private-key");
+    assertThat(underTest.selectByQuery(dbSession, publicProjectsQuery, 0, 10)).extracting(ComponentDto::getKey).containsExactly("public-key");
+    assertThat(underTest.selectByQuery(dbSession, allProjectsQuery, 0, 10)).extracting(ComponentDto::getKey).containsOnly("public-key", "private-key");
   }
 
   @Test
@@ -1609,13 +1584,13 @@ public class ComponentDaoTest {
     ComponentDto jdk8 = db.components().insertComponent(newPrivateProjectDto());
     ComponentDto cLang = db.components().insertComponent(newPrivateProjectDto());
     ComponentQuery query = ComponentQuery.builder().setQualifiers(PROJECT)
-      .setComponentKeys(newHashSet(sonarqube.getDbKey(), jdk8.getDbKey())).build();
+      .setComponentKeys(newHashSet(sonarqube.getKey(), jdk8.getKey())).build();
 
     List<ComponentDto> result = underTest.selectByQuery(dbSession, query, 0, 10);
 
-    assertThat(result).hasSize(2).extracting(ComponentDto::getDbKey)
-      .containsExactlyInAnyOrder(sonarqube.getDbKey(), jdk8.getDbKey())
-      .doesNotContain(cLang.getDbKey());
+    assertThat(result).hasSize(2).extracting(ComponentDto::getKey)
+      .containsExactlyInAnyOrder(sonarqube.getKey(), jdk8.getKey())
+      .doesNotContain(cLang.getKey());
   }
 
   @Test
@@ -1675,11 +1650,11 @@ public class ComponentDaoTest {
     db.components().insertProjectAndSnapshot(project);
     ComponentDto module = newModuleDto(MODULE_UUID, project);
     db.components().insertComponent(module);
-    ComponentDto fileInProject = newFileDto(project, null, FILE_1_UUID).setDbKey("file-key-1").setName("File One");
+    ComponentDto fileInProject = newFileDto(project, null, FILE_1_UUID).setKey("file-key-1").setName("File One");
     db.components().insertComponent(fileInProject);
-    ComponentDto file1InModule = newFileDto(module, null, FILE_2_UUID).setDbKey("file-key-2").setName("File Two");
+    ComponentDto file1InModule = newFileDto(module, null, FILE_2_UUID).setKey("file-key-2").setName("File Two");
     db.components().insertComponent(file1InModule);
-    ComponentDto file2InModule = newFileDto(module, null, FILE_3_UUID).setDbKey("file-key-3").setName("File Three");
+    ComponentDto file2InModule = newFileDto(module, null, FILE_3_UUID).setKey("file-key-3").setName("File Three");
     db.components().insertComponent(file2InModule);
     db.commit();
 
@@ -1703,11 +1678,11 @@ public class ComponentDaoTest {
     db.components().insertProjectAndSnapshot(project);
     ComponentDto module = newModuleDto(MODULE_UUID, project);
     db.components().insertComponent(module);
-    ComponentDto fileInProject = newFileDto(project, null, FILE_1_UUID).setDbKey("file-key-1").setName("File One");
+    ComponentDto fileInProject = newFileDto(project, null, FILE_1_UUID).setKey("file-key-1").setName("File One");
     db.components().insertComponent(fileInProject);
-    ComponentDto file1InModule = newFileDto(module, null, FILE_2_UUID).setDbKey("file-key-2").setName("File Two");
+    ComponentDto file1InModule = newFileDto(module, null, FILE_2_UUID).setKey("file-key-2").setName("File Two");
     db.components().insertComponent(file1InModule);
-    ComponentDto file2InModule = newFileDto(module, null, FILE_3_UUID).setDbKey("file-key-3").setName("File Three");
+    ComponentDto file2InModule = newFileDto(module, null, FILE_3_UUID).setKey("file-key-3").setName("File Three");
     db.components().insertComponent(file2InModule);
     db.commit();
 
@@ -1818,11 +1793,11 @@ public class ComponentDaoTest {
     String uuid2 = "uuid2";
 
     String[] uuids = {
-      db.components().insertComponent(newPrivateProjectDto().setProjectUuid(uuid1).setPrivate(true)).uuid(),
-      db.components().insertComponent(newPrivateProjectDto().setProjectUuid(uuid1).setPrivate(false)).uuid(),
-      db.components().insertComponent(newPrivateProjectDto().setProjectUuid(uuid2).setPrivate(true)).uuid(),
-      db.components().insertComponent(newPrivateProjectDto().setProjectUuid(uuid2).setPrivate(false)).uuid(),
-      db.components().insertComponent(newPrivateProjectDto().setRootUuid(uuid1).setProjectUuid("foo").setPrivate(false)).uuid(),
+      db.components().insertComponent(newPrivateProjectDto().setBranchUuid(uuid1).setPrivate(true)).uuid(),
+      db.components().insertComponent(newPrivateProjectDto().setBranchUuid(uuid1).setPrivate(false)).uuid(),
+      db.components().insertComponent(newPrivateProjectDto().setBranchUuid(uuid2).setPrivate(true)).uuid(),
+      db.components().insertComponent(newPrivateProjectDto().setBranchUuid(uuid2).setPrivate(false)).uuid(),
+      db.components().insertComponent(newPrivateProjectDto().setRootUuid(uuid1).setBranchUuid("foo").setPrivate(false)).uuid(),
     };
 
     underTest.setPrivateForRootComponentUuidWithoutAudit(db.getSession(), uuid1, true);
index b59c8dee9e152b44a7c0ddd9121d4506def1322b..061dbac8515c24587c6364e2b6d67181310fdd5d 100644 (file)
@@ -30,7 +30,7 @@ public class ComponentDtoTest {
   @Test
   public void setters_and_getters() {
     ComponentDto componentDto = new ComponentDto()
-      .setDbKey("org.struts:struts-core:src/org/struts/RequestContext.java")
+      .setKey("org.struts:struts-core:src/org/struts/RequestContext.java")
       .setName("RequestContext.java")
       .setLongName("org.struts.RequestContext")
       .setQualifier("FIL")
@@ -41,7 +41,7 @@ public class ComponentDtoTest {
       .setCopyComponentUuid("uuid_5")
       .setRootUuid("uuid_3");
 
-    assertThat(componentDto.getDbKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
+    assertThat(componentDto.getKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
     assertThat(componentDto.getBranch()).isNull();
     assertThat(componentDto.name()).isEqualTo("RequestContext.java");
     assertThat(componentDto.longName()).isEqualTo("org.struts.RequestContext");
@@ -109,26 +109,4 @@ public class ComponentDtoTest {
     ComponentDto nonRoot = new ComponentDto().setUuidPath(".12.34.56.");
     assertThat(nonRoot.getUuidPathAsList()).containsExactly("12", "34", "56");
   }
-
-  @Test
-  public void getKey_and_getBranch() {
-    ComponentDto underTest = new ComponentDto().setDbKey("my_key:BRANCH:my_branch");
-    assertThat(underTest.getKey()).isEqualTo("my_key");
-    assertThat(underTest.getBranch()).isEqualTo("my_branch");
-
-    underTest = new ComponentDto().setDbKey("my_key");
-    assertThat(underTest.getKey()).isEqualTo("my_key");
-    assertThat(underTest.getBranch()).isNull();
-  }
-
-  @Test
-  public void getKey_and_getPullRequest() {
-    ComponentDto underTest = new ComponentDto().setDbKey("my_key:PULL_REQUEST:pr-123");
-    assertThat(underTest.getKey()).isEqualTo("my_key");
-    assertThat(underTest.getPullRequest()).isEqualTo("pr-123");
-
-    underTest = new ComponentDto().setDbKey("my_key");
-    assertThat(underTest.getKey()).isEqualTo("my_key");
-    assertThat(underTest.getPullRequest()).isNull();
-  }
 }
index 585f9708ddb4eafb01950ec2c39d5475acdb411a..e77ed5dd4e9b5bd792a2740fa31dc7865176bcab 100644 (file)
@@ -52,8 +52,7 @@ import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 
 public class ComponentKeyUpdaterDaoTest {
-
-
+  
   @Rule
   public DbTester db = DbTester.create(System2.INSTANCE);
   private AuditPersister auditPersister = mock(AuditPersister.class);
@@ -86,13 +85,13 @@ public class ComponentKeyUpdaterDaoTest {
   public void updateKey_updates_disabled_components() {
     ComponentDto project = db.components().insertComponent(
       newPrivateProjectDto("A")
-        .setDbKey("my_project"));
+        .setKey("my_project"));
     ComponentDto directory = db.components().insertComponent(
       newDirectory(project, "B")
-        .setDbKey("my_project:directory"));
-    db.components().insertComponent(newFileDto(project, directory).setDbKey("my_project:directory/file"));
-    ComponentDto inactiveDirectory = db.components().insertComponent(newDirectory(project, "/inactive_directory").setDbKey("my_project:inactive_directory").setEnabled(false));
-    db.components().insertComponent(newFileDto(project, inactiveDirectory).setDbKey("my_project:inactive_directory/file").setEnabled(false));
+        .setKey("my_project:directory"));
+    db.components().insertComponent(newFileDto(project, directory).setKey("my_project:directory/file"));
+    ComponentDto inactiveDirectory = db.components().insertComponent(newDirectory(project, "/inactive_directory").setKey("my_project:inactive_directory").setEnabled(false));
+    db.components().insertComponent(newFileDto(project, inactiveDirectory).setKey("my_project:inactive_directory/file").setEnabled(false));
 
     underTest.updateKey(dbSession, "A", "your_project");
     dbSession.commit();
@@ -100,7 +99,7 @@ public class ComponentKeyUpdaterDaoTest {
     List<ComponentDto> result = dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, "your_project");
     assertThat(result)
       .hasSize(5)
-      .extracting(ComponentDto::getDbKey)
+      .extracting(ComponentDto::getKey)
       .containsOnlyOnce("your_project", "your_project:directory", "your_project:directory/file", "your_project:inactive_directory", "your_project:inactive_directory/file");
   }
 
@@ -109,20 +108,20 @@ public class ComponentKeyUpdaterDaoTest {
     ComponentDto app = db.components().insertPublicProject();
     ComponentDto appBranch = db.components().insertProjectBranch(app);
     ComponentDto appBranchProj1 = appBranch.copy()
-      .setDbKey(appBranch.getDbKey().replace(BRANCH_KEY_SEPARATOR, "") + "appBranchProj1:BRANCH:1").setUuid("appBranchProj1").setScope(Qualifiers.FILE);
+      .setKey(appBranch.getKey().replace(BRANCH_KEY_SEPARATOR, "") + "appBranchProj1").setUuid("appBranchProj1").setScope(Qualifiers.FILE);
     ComponentDto appBranchProj2 = appBranch.copy()
-      .setDbKey(appBranch.getDbKey().replace(BRANCH_KEY_SEPARATOR, "") + "appBranchProj2:BRANCH:2").setUuid("appBranchProj2").setScope(Qualifiers.FILE);
+      .setKey(appBranch.getKey().replace(BRANCH_KEY_SEPARATOR, "") + "appBranchProj2").setUuid("appBranchProj2").setScope(Qualifiers.FILE);
     db.components().insertComponent(appBranchProj1);
     db.components().insertComponent(appBranchProj2);
     int branchComponentCount = 3;
 
-    String oldBranchKey = appBranch.getDbKey();
+    String oldBranchKey = appBranch.getKey();
     assertThat(dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, oldBranchKey)).hasSize(branchComponentCount);
 
     String newBranchName = "newKey";
-    String newAppBranchKey = ComponentDto.generateBranchKey(app.getDbKey(), newBranchName);
-    String newAppBranchFragment = app.getDbKey() + newBranchName;
-    underTest.updateApplicationBranchKey(dbSession, appBranch.uuid(), app.getDbKey(), newBranchName);
+    String newAppBranchKey = ComponentDto.generateBranchKey(app.getKey(), newBranchName);
+    String newAppBranchFragment = app.getKey() + newBranchName;
+    underTest.updateApplicationBranchKey(dbSession, appBranch.uuid(), app.getKey(), newBranchName);
 
     assertThat(dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, oldBranchKey)).isEmpty();
 
@@ -140,9 +139,9 @@ public class ComponentKeyUpdaterDaoTest {
     ComponentDto appBranch = db.components().insertProjectBranch(app);
     db.components().insertProjectBranch(app, b -> b.setKey("newName"));
 
-    assertThatThrownBy(() -> underTest.updateApplicationBranchKey(dbSession, appBranch.uuid(), app.getDbKey(), "newName"))
+    assertThatThrownBy(() -> underTest.updateApplicationBranchKey(dbSession, appBranch.uuid(), app.getKey(), "newName"))
       .isInstanceOf(IllegalArgumentException.class)
-      .hasMessage(String.format("Impossible to update key: a component with key \"%s\" already exists.", generateBranchKey(app.getDbKey(), "newName")));
+      .hasMessage(String.format("Impossible to update key: a component with key \"%s\" already exists.", generateBranchKey(app.getKey(), "newName")));
   }
 
   @Test
@@ -151,7 +150,7 @@ public class ComponentKeyUpdaterDaoTest {
     ComponentDto appBranch = db.components().insertProjectBranch(app);
     db.components().insertProjectBranch(app, b -> b.setKey("newName"));
 
-    underTestWithAuditPersister.updateApplicationBranchKey(dbSession, appBranch.uuid(), app.getDbKey(), "newName2");
+    underTestWithAuditPersister.updateApplicationBranchKey(dbSession, appBranch.uuid(), app.getKey(), "newName2");
 
     verify(auditPersister, times(1))
       .componentKeyBranchUpdate(any(DbSession.class), any(ComponentKeyNewValue.class), anyString());
@@ -168,7 +167,7 @@ public class ComponentKeyUpdaterDaoTest {
     String oldProjectKey = project.getKey();
     assertThat(dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, oldProjectKey)).hasSize(1);
 
-    String oldBranchKey = branch.getDbKey();
+    String oldBranchKey = branch.getKey();
     assertThat(dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, oldBranchKey)).hasSize(branchComponentCount);
 
     String newProjectKey = "newKey";
@@ -195,7 +194,7 @@ public class ComponentKeyUpdaterDaoTest {
     String oldProjectKey = project.getKey();
     assertThat(dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, oldProjectKey)).hasSize(1);
 
-    String oldBranchKey = pullRequest.getDbKey();
+    String oldBranchKey = pullRequest.getKey();
     assertThat(dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, oldBranchKey)).hasSize(branchComponentCount);
 
     String newProjectKey = "newKey";
@@ -212,7 +211,7 @@ public class ComponentKeyUpdaterDaoTest {
   }
 
   private ComponentDto prefixDbKeyWithKey(ComponentDto componentDto, String key) {
-    return componentDto.setDbKey(key + ":" + componentDto.getDbKey());
+    return componentDto.setKey(key + ":" + componentDto.getKey());
   }
 
   @Test
@@ -226,9 +225,9 @@ public class ComponentKeyUpdaterDaoTest {
 
   @Test
   public void updateKey_throws_IAE_when_sub_component_key_is_too_long() {
-    ComponentDto project = newPrivateProjectDto("project-uuid").setDbKey("old-project-key");
+    ComponentDto project = newPrivateProjectDto("project-uuid").setKey("old-project-key");
     db.components().insertComponent(project);
-    db.components().insertComponent(newFileDto(project, null).setDbKey("old-project-key:file"));
+    db.components().insertComponent(newFileDto(project, null).setKey("old-project-key:file"));
     String newLongProjectKey = Strings.repeat("a", 400);
 
     assertThatThrownBy(() -> underTest.updateKey(dbSession, project.uuid(), newLongProjectKey))
@@ -244,7 +243,7 @@ public class ComponentKeyUpdaterDaoTest {
 
   @Test
   public void updateKey_callsAuditPersister() {
-    db.components().insertComponent(newPrivateProjectDto("A").setDbKey("my_project"));
+    db.components().insertComponent(newPrivateProjectDto("A").setKey("my_project"));
 
     underTestWithAuditPersister.updateKey(dbSession, "A", "your_project");
 
@@ -258,13 +257,13 @@ public class ComponentKeyUpdaterDaoTest {
   }
 
   private void populateSomeData() {
-    ComponentDto project1 = db.components().insertPrivateProject(t -> t.setDbKey("org.struts:struts").setUuid("A"));
-    ComponentDto module1 = db.components().insertComponent(newModuleDto(project1).setDbKey("org.struts:struts-core").setUuid("B"));
+    ComponentDto project1 = db.components().insertPrivateProject(t -> t.setKey("org.struts:struts").setUuid("A"));
+    ComponentDto module1 = db.components().insertComponent(newModuleDto(project1).setKey("org.struts:struts-core").setUuid("B"));
     ComponentDto directory1 = db.components().insertComponent(newDirectory(module1, "/src/org/struts").setUuid("C"));
-    db.components().insertComponent(ComponentTesting.newFileDto(module1, directory1).setDbKey("org.struts:struts-core:/src/org/struts/RequestContext.java").setUuid("D"));
-    ComponentDto module2 = db.components().insertComponent(newModuleDto(project1).setDbKey("org.struts:struts-ui").setUuid("E"));
+    db.components().insertComponent(ComponentTesting.newFileDto(module1, directory1).setKey("org.struts:struts-core:/src/org/struts/RequestContext.java").setUuid("D"));
+    ComponentDto module2 = db.components().insertComponent(newModuleDto(project1).setKey("org.struts:struts-ui").setUuid("E"));
     ComponentDto directory2 = db.components().insertComponent(newDirectory(module2, "/src/org/struts").setUuid("F"));
-    db.components().insertComponent(ComponentTesting.newFileDto(module2, directory2).setDbKey("org.struts:struts-ui:/src/org/struts/RequestContext.java").setUuid("G"));
-    ComponentDto project2 = db.components().insertPublicProject(t -> t.setDbKey("foo:struts-core").setUuid("H"));
+    db.components().insertComponent(ComponentTesting.newFileDto(module2, directory2).setKey("org.struts:struts-ui:/src/org/struts/RequestContext.java").setUuid("G"));
+    ComponentDto project2 = db.components().insertPublicProject(t -> t.setKey("foo:struts-core").setUuid("H"));
   }
 }
index 615afb4141f46ac6444ccd1f04541ec45b948d30..868fea8df9580b43d3dbb4d532287a6f1efdfb46 100644 (file)
@@ -125,7 +125,7 @@ public class ScrollForFileMoveComponentDaoTest {
     List<ComponentAndSource> files = IntStream.range(0, 300 + random.nextInt(500))
       .mapToObj(i -> {
         String qualifier = random.nextBoolean() ? FILE : UNIT_TEST_FILE;
-        ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project).setDbKey("f_" + i).setQualifier(qualifier));
+        ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project).setKey("f_" + i).setQualifier(qualifier));
         FileSourceDto fileSource = db.fileSources().insertFileSource(file);
         return new ComponentAndSource(file, fileSource);
       })
@@ -233,7 +233,7 @@ public class ScrollForFileMoveComponentDaoTest {
 
   private static void verifyFileMoveRowDto(RecordingResultHandler resultHander, ComponentAndSource componentAndSource) {
     FileMoveRowDto dto = resultHander.getByUuid(componentAndSource.component.uuid()).get();
-    assertThat(dto.getKey()).isEqualTo(componentAndSource.component.getDbKey());
+    assertThat(dto.getKey()).isEqualTo(componentAndSource.component.getKey());
     assertThat(dto.getUuid()).isEqualTo(componentAndSource.component.uuid());
     assertThat(dto.getPath()).isEqualTo(componentAndSource.component.path());
     assertThat(dto.getLineCount()).isEqualTo(componentAndSource.source.getLineCount());
index 3ebd0e7d7dce88b2526bffa7317c223da166ef3a..598248c39a7687181bca9185fcd80caa335a6fa8 100644 (file)
@@ -639,7 +639,7 @@ public class IssueDaoTest {
     // return module or dir only if has issue with status different from CLOSED
     allModuleOrDirs
       .forEach(moduleOrDir -> {
-        String projectUuid = moduleOrDir.projectUuid();
+        String projectUuid = moduleOrDir.branchUuid();
         // CLOSED issue => not returned
         db.issues().insertIssue(t -> t.setProjectUuid(projectUuid).setComponent(moduleOrDir).setStatus(STATUS_CLOSED));
         assertThat(underTest.selectModuleAndDirComponentUuidsOfOpenIssuesForProjectUuid(db.getSession(), projectUuid))
@@ -663,7 +663,7 @@ public class IssueDaoTest {
     // never return project, view, subview, app or file, whatever the issue status
     Stream.of(project1, file11, application, view, subview, project2, file21)
       .forEach(neitherModuleNorDir -> {
-        String projectUuid = neitherModuleNorDir.projectUuid();
+        String projectUuid = neitherModuleNorDir.branchUuid();
         STATUSES
           .forEach(status -> {
             db.issues().insertIssue(t -> t.setProjectUuid(projectUuid).setComponent(neitherModuleNorDir).setStatus(status));
@@ -675,7 +675,7 @@ public class IssueDaoTest {
     // never return whatever the component if it is disabled
     allcomponents
       .forEach(component -> {
-        String projectUuid = component.projectUuid();
+        String projectUuid = component.branchUuid();
 
         // issues for each status => returned if component is dir or module
         STATUSES
@@ -808,8 +808,8 @@ public class IssueDaoTest {
 
   private static IssueDto newIssueDto(String key) {
     IssueDto dto = new IssueDto();
-    dto.setComponent(new ComponentDto().setDbKey("struts:Action").setUuid("component-uuid"));
-    dto.setProject(new ComponentDto().setDbKey("struts").setUuid("project-uuid"));
+    dto.setComponent(new ComponentDto().setKey("struts:Action").setUuid("component-uuid"));
+    dto.setProject(new ComponentDto().setKey("struts").setUuid("project-uuid"));
     dto.setRule(RuleTesting.newRule(RuleKey.of("java", "S001")).setUuid("uuid-200"));
     dto.setKee(key);
     dto.setType(2);
@@ -834,8 +834,8 @@ public class IssueDaoTest {
 
   private void prepareIssuesComponent() {
     db.rules().insert(RULE.setIsExternal(true));
-    ComponentDto projectDto = db.components().insertPrivateProject(t -> t.setUuid(PROJECT_UUID).setDbKey(PROJECT_KEY));
-    db.components().insertComponent(newFileDto(projectDto).setUuid(FILE_UUID).setDbKey(FILE_KEY));
+    ComponentDto projectDto = db.components().insertPrivateProject(t -> t.setUuid(PROJECT_UUID).setKey(PROJECT_KEY));
+    db.components().insertComponent(newFileDto(projectDto).setUuid(FILE_UUID).setKey(FILE_KEY));
   }
 
   private void prepareTables() {
index f756a75f13e746e06017f0404b2f022b8456e951..c296effa23939d37d814d331b2a3d16fa5809cef 100644 (file)
@@ -486,7 +486,7 @@ public class IssueMapperTest {
       .setRuleUuid(rule.getUuid())
       .setType(rule.getType())
       .setComponentUuid(component.uuid())
-      .setProjectUuid(component.projectUuid())
+      .setProjectUuid(component.branchUuid())
       .setStatus(Issue.STATUS_CLOSED)
       .setIssueCloseTime(issueCloseTime);
     Arrays.asList(consumers).forEach(c -> c.accept(res));
index cfb9d3c6d137ea08062368aa939fe25a5efc02af..ac04aa4b4ae43dd3def8a8868e0f0e8b953bed60 100644 (file)
@@ -721,7 +721,7 @@ public class LiveMeasureDaoTest {
   }
 
   private ComponentDto addProjectWithMeasure(String projectKey, MetricDto metric, double metricValue) {
-    ComponentDto project = db.components().insertPublicProject(p -> p.setDbKey(projectKey));
+    ComponentDto project = db.components().insertPublicProject(p -> p.setKey(projectKey));
     addMeasureToComponent(project, metric, metricValue,true);
     return project;
   }
index 84d9e502cd68f4957ed6bfde83ecb69321fe1251..ce4bbe751320dafa9a516b3af495970637caafa1 100644 (file)
@@ -62,7 +62,7 @@ public class ProjectMeasuresIndexerIteratorTest {
   @Test
   public void return_project_measure() {
     ComponentDto project = dbTester.components().insertPrivateProject(
-      c -> c.setDbKey("Project-Key").setName("Project Name"),
+      c -> c.setKey("Project-Key").setName("Project Name"),
       p -> p.setTags(newArrayList("platform", "java")));
 
     SnapshotDto analysis = dbTester.components().insertSnapshot(project);
@@ -87,7 +87,7 @@ public class ProjectMeasuresIndexerIteratorTest {
 
   @Test
   public void return_application_measure() {
-    ComponentDto project = dbTester.components().insertPrivateApplication(c -> c.setDbKey("App-Key").setName("App Name"));
+    ComponentDto project = dbTester.components().insertPrivateApplication(c -> c.setKey("App-Key").setName("App Name"));
 
     SnapshotDto analysis = dbTester.components().insertSnapshot(project);
     MetricDto metric1 = dbTester.measures().insertMetric(m -> m.setValueType(INT.name()).setKey("ncloc"));
@@ -110,7 +110,7 @@ public class ProjectMeasuresIndexerIteratorTest {
   @Test
   public void return_project_measure_having_leak() {
     ComponentDto project = dbTester.components().insertPrivateProject(
-      c -> c.setDbKey("Project-Key").setName("Project Name"),
+      c -> c.setKey("Project-Key").setName("Project Name"),
       p -> p.setTagsString("platform,java"));
     MetricDto metric = dbTester.measures().insertMetric(m -> m.setValueType(INT.name()).setKey("new_lines"));
     dbTester.measures().insertLiveMeasure(project, metric, m -> m.setVariation(10d));
@@ -269,7 +269,7 @@ public class ProjectMeasuresIndexerIteratorTest {
     ProjectMeasures doc = docsById.get(project1.uuid());
     assertThat(doc).isNotNull();
     assertThat(doc.getProject().getUuid()).isEqualTo(project1.uuid());
-    assertThat(doc.getProject().getKey()).isNotNull().isEqualTo(project1.getDbKey());
+    assertThat(doc.getProject().getKey()).isNotNull().isEqualTo(project1.getKey());
     assertThat(doc.getProject().getName()).isNotNull().isEqualTo(project1.name());
     assertThat(doc.getProject().getAnalysisDate()).isNotNull().isEqualTo(analysis1.getCreatedAt());
   }
index 89f9450d68e637d833f604a986ef7ad040fddbd7..6c8fce59e49b427f71ec07bf9b4dd6832282fba7 100644 (file)
@@ -173,13 +173,13 @@ public class GroupPermissionDaoWithPersisterTest {
 
   private void addGroupPermission() {
     group = db.users().insertGroup(g -> g.setUuid("guuid").setName("gname"));
-    project = db.components().insertPrivateProject(c -> c.setUuid("cuuid").setName("cname").setDbKey("cKey"));
+    project = db.components().insertPrivateProject(c -> c.setUuid("cuuid").setName("cname").setKey("cKey"));
     dto = getGroupPermission(group, project);
     underTest.insert(dbSession, dto, project, null);
   }
 
   private void addGroupPermissionWithoutGroup() {
-    project = db.components().insertPrivateProject(c -> c.setUuid("cuuid").setName("cname").setDbKey("cKey"));
+    project = db.components().insertPrivateProject(c -> c.setUuid("cuuid").setName("cname").setKey("cKey"));
     dto = getGroupPermission(project);
     underTest.insert(dbSession, dto, project, null);
   }
index 72b76e9c4bd530846b6ebc39ecbe006f4b2e0f22..aa1c30d884c9095e438d733ac8f8ac86fa289f13 100644 (file)
@@ -224,7 +224,7 @@ public class PortfolioDaoTest {
     db.components().insertPrivatePortfolioDto("portfolio1");
     db.components().insertPrivatePortfolioDto("portfolio2");
     db.components().insertPrivatePortfolioDto("portfolio3");
-    ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app1"));
+    ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setKey("app1"));
 
     portfolioDao.addReference(session, "portfolio1", "portfolio2");
     portfolioDao.addReference(session, "portfolio2", "portfolio3");
@@ -240,7 +240,7 @@ public class PortfolioDaoTest {
     db.components().insertPrivatePortfolioDto("portfolio1");
     db.components().insertPrivatePortfolioDto("portfolio2");
     db.components().insertPrivatePortfolioDto("portfolio3");
-    ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app1"));
+    ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setKey("app1"));
 
     portfolioDao.addReference(session, "portfolio1", "portfolio2");
     portfolioDao.addReference(session, "portfolio2", "portfolio3");
@@ -259,9 +259,9 @@ public class PortfolioDaoTest {
     var p1 = db.components().insertPrivatePortfolioDto("portfolio1");
     var p2 = db.components().insertPrivatePortfolioDto("portfolio2", p -> p.setRootUuid(p1.getUuid()).setParentUuid(p1.getUuid()));
     var p3 = db.components().insertPrivatePortfolioDto("portfolio3", p -> p.setRootUuid(p1.getUuid()).setParentUuid(p1.getUuid()));
-    ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app1"));
-    ProjectDto app2 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app2"));
-    ProjectDto app3 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app3"));
+    ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setKey("app1"));
+    ProjectDto app2 = db.components().insertPrivateApplicationDto(p -> p.setKey("app2"));
+    ProjectDto app3 = db.components().insertPrivateApplicationDto(p -> p.setKey("app3"));
 
     portfolioDao.addReference(session, "portfolio1", app1.getUuid());
     portfolioDao.addReference(session, "portfolio2", app2.getUuid());
@@ -282,9 +282,9 @@ public class PortfolioDaoTest {
     var p1 = db.components().insertPrivatePortfolioDto("portfolio1");
     var p2 = db.components().insertPrivatePortfolioDto("portfolio2", p -> p.setRootUuid(p1.getUuid()).setParentUuid(p1.getUuid()));
     var p3 = db.components().insertPrivatePortfolioDto("portfolio3", p -> p.setRootUuid(p1.getUuid()).setParentUuid(p1.getUuid()));
-    ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app1"));
-    ProjectDto app2 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app2"));
-    ProjectDto app3 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app3"));
+    ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setKey("app1"));
+    ProjectDto app2 = db.components().insertPrivateApplicationDto(p -> p.setKey("app2"));
+    ProjectDto app3 = db.components().insertPrivateApplicationDto(p -> p.setKey("app3"));
 
     portfolioDao.addReference(session, "portfolio1", app1.getUuid());
     portfolioDao.addReference(session, "portfolio2", app2.getUuid());
@@ -316,10 +316,10 @@ public class PortfolioDaoTest {
   @Test
   public void selectAllApplicationProjectsBelongToTheSamePortfolio() {
     var portfolio = db.components().insertPrivatePortfolioDto("portfolio1");
-    var app1 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app1"));
-    var app2 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app2"));
-    var project1 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:one").setName("Projet Un"));
-    var project2 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:two").setName("Projet Deux"));
+    var app1 = db.components().insertPrivateApplicationDto(p -> p.setKey("app1"));
+    var app2 = db.components().insertPrivateApplicationDto(p -> p.setKey("app2"));
+    var project1 = db.components().insertPrivateProjectDto(p -> p.setKey("project:one").setName("Projet Un"));
+    var project2 = db.components().insertPrivateProjectDto(p -> p.setKey("project:two").setName("Projet Deux"));
 
     db.components().addApplicationProject(app1, project1);
     db.components().addApplicationProject(app2, project2);
@@ -353,7 +353,7 @@ public class PortfolioDaoTest {
   @Test
   public void select_reference_to_app_by_key() {
     PortfolioDto portfolio = db.components().insertPrivatePortfolioDto("portfolio1");
-    ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app1"));
+    ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setKey("app1"));
     db.components().addPortfolioReference(portfolio, app1.getUuid());
 
     assertThat(portfolioDao.selectReferenceToApp(db.getSession(), portfolio.getUuid(), app1.getKey()))
@@ -371,7 +371,7 @@ public class PortfolioDaoTest {
   @Test
   public void select_reference_to_app_with_branches() {
     PortfolioDto portfolio = db.components().insertPrivatePortfolioDto("portfolio1");
-    ProjectDto app = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app").setName("app"));
+    ProjectDto app = db.components().insertPrivateApplicationDto(p -> p.setKey("app").setName("app"));
     BranchDto branch1 = db.components().insertProjectBranch(app, b -> b.setExcludeFromPurge(true));
     BranchDto branch2 = db.components().insertProjectBranch(app, b -> b.setExcludeFromPurge(true));
 
@@ -391,7 +391,7 @@ public class PortfolioDaoTest {
   @Test
   public void select_root_reference_to_app_main_branch() {
     PortfolioDto portfolio1 = db.components().insertPrivatePortfolioDto("portfolio1");
-    ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app1"));
+    ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setKey("app1"));
     db.components().addPortfolioReference(portfolio1, app1.getUuid());
 
     assertThat(portfolioDao.selectRootOfReferencersToMainBranch(db.getSession(), app1.getUuid()))
@@ -399,7 +399,7 @@ public class PortfolioDaoTest {
       .containsExactly(portfolio1.getKey());
 
     PortfolioDto portfolio2 = db.components().insertPrivatePortfolioDto("portfolio2");
-    ProjectDto app2 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app2"));
+    ProjectDto app2 = db.components().insertPrivateApplicationDto(p -> p.setKey("app2"));
     db.components().addPortfolioApplicationBranch(portfolio2.getUuid(), app2.getUuid(), app2.getUuid());
 
     assertThat(portfolioDao.selectRootOfReferencersToMainBranch(db.getSession(), app2.getUuid()))
@@ -410,7 +410,7 @@ public class PortfolioDaoTest {
   @Test
   public void select_root_reference_to_app_with_branches() {
     PortfolioDto portfolio = db.components().insertPrivatePortfolioDto("portfolio1");
-    ProjectDto app = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app").setName("app"));
+    ProjectDto app = db.components().insertPrivateApplicationDto(p -> p.setKey("app").setName("app"));
     BranchDto branch = db.components().insertProjectBranch(app, b -> b.setExcludeFromPurge(true));
 
     db.components().addPortfolioApplicationBranch(portfolio.getUuid(), app.getUuid(), branch.getUuid());
@@ -530,7 +530,7 @@ public class PortfolioDaoTest {
   @Test
   public void deleteReferenceBranch() {
     PortfolioDto portfolio = db.components().insertPrivatePortfolioDto("portfolio1");
-    ProjectDto app = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app").setName("app"));
+    ProjectDto app = db.components().insertPrivateApplicationDto(p -> p.setKey("app").setName("app"));
     BranchDto branch1 = db.components().insertProjectBranch(app, b -> b.setExcludeFromPurge(true));
     BranchDto branch2 = db.components().insertProjectBranch(app, b -> b.setExcludeFromPurge(true));
 
index e0ec8ed5a5765548660658ab1e8f1edd0c331414..dd53c201b9767170124bba36559a50f8a93ed684 100644 (file)
@@ -176,7 +176,7 @@ public class InternalComponentPropertiesDaoTest {
     underTest.insertOrUpdate(dbSession, portfolio2.uuid(), SOME_KEY, "bar");
     underTest.insertOrUpdate(dbSession, portfolio3.uuid(), "foo", SOME_VALUE);
 
-    assertThat(underTest.selectDbKeys(dbSession, SOME_KEY, SOME_VALUE)).containsOnly(portfolio1.getDbKey());
+    assertThat(underTest.selectDbKeys(dbSession, SOME_KEY, SOME_VALUE)).containsOnly(portfolio1.getKey());
   }
 
   private InternalComponentPropertyDto saveDto() {
index 8f812c2f8ba92149551caeff1766eb435bb6462f..40cf19f892a7004331db5515c501361bacbe0797 100644 (file)
@@ -529,7 +529,7 @@ public class PropertiesDaoTest {
     insertProperty("project.one", "Pone", projectUuid, null, null, projectDto.getKey(), projectDto.name());
     insertProperty("project.two", "Ptwo", projectUuid, null, null, projectDto.getKey(), projectDto.name());
 
-    List<PropertyDto> dtos = underTest.selectProjectProperties(projectDto.getDbKey());
+    List<PropertyDto> dtos = underTest.selectProjectProperties(projectDto.getKey());
     assertThat(dtos)
       .hasSize(2);
     assertThat(findByKey(dtos, "project.one"))
@@ -547,7 +547,7 @@ public class PropertiesDaoTest {
     ComponentDto projectDto = insertPrivateProject("A");
     insertProperty("project.one", dbValue, projectDto.uuid(), null, null, projectDto.getKey(), projectDto.name());
 
-    List<PropertyDto> dtos = underTest.selectProjectProperties(projectDto.getDbKey());
+    List<PropertyDto> dtos = underTest.selectProjectProperties(projectDto.getKey());
     assertThat(dtos).hasSize(1);
 
     assertThat(dtos.iterator().next())
@@ -1316,7 +1316,7 @@ public class PropertiesDaoTest {
   }
 
   private ComponentDto insertPrivateProject(String projectKey) {
-    return db.components().insertPrivateProject(t -> t.setDbKey(projectKey));
+    return db.components().insertPrivateProject(t -> t.setKey(projectKey));
   }
 
   private static Consumer<UserDto> withEmail(String login) {
index 5700ff9b35649dd24164e3f2d006fc4f7e10603a..3be16525ec8f90a37fc24a89625b14918ac301aa 100644 (file)
@@ -210,7 +210,7 @@ public class PurgeCommandsTest {
   @Test
   public void deleteProjects() {
     ComponentDto project = dbTester.components().insertPrivateProject();
-    ProjectDto projectDto = dbTester.getDbClient().projectDao().selectProjectByKey(dbTester.getSession(), project.getDbKey()).get();
+    ProjectDto projectDto = dbTester.getDbClient().projectDao().selectProjectByKey(dbTester.getSession(), project.getKey()).get();
     ComponentDto file = dbTester.components().insertComponent(newFileDto(project));
     SnapshotDto analysis = dbTester.components().insertSnapshot(project);
     dbTester.events().insertEvent(analysis);
@@ -754,7 +754,7 @@ public class PurgeCommandsTest {
   }
 
   private int countComponentOfRoot(ComponentDto projectOrView) {
-    return dbTester.countSql("select count(1) from components where project_uuid='" + projectOrView.uuid() + "'");
+    return dbTester.countSql("select count(1) from components where branch_uuid='" + projectOrView.uuid() + "'");
   }
 
   private void insertDuplication(ComponentDto project, SnapshotDto analysis) {
index a8bbfc379c6515f706aa95ba12b38c07866cf99c..00826d4dbb50aad88981fca9681538ef40a1c57c 100644 (file)
@@ -1165,7 +1165,7 @@ public class PurgeDaoTest {
       newConfigurationWith30Days(System2.INSTANCE, project.uuid(), project.uuid(), disabledComponentUuids),
       purgeListener, new PurgeProfiler());
 
-    assertThat(db.getDbClient().componentDao().selectByProjectUuid(project.uuid(), dbSession))
+    assertThat(db.getDbClient().componentDao().selectByBranchUuid(project.uuid(), dbSession))
       .extracting("uuid")
       .containsOnly(project.uuid(), enabledFileWithIssues.uuid(), disabledFileWithIssues.uuid(),
         enabledFileWithoutIssues.uuid());
index bdd73a6f3ee0194ff344304686b9c7bf54073cab..89f6b619d5e616a7021d86a3614c78b78f97fa3a 100644 (file)
@@ -65,9 +65,9 @@ public class ProjectQgateAssociationDaoTest {
   @Test
   public void select_all_projects_by_query_should_have_deterministic_order() {
     QualityGateDto qualityGate1 = db.qualityGates().insertQualityGate();
-    ComponentDto project1 = db.components().insertPrivateProject(d -> d.setName("p1").setDbKey("key1"));
-    ComponentDto project2 = db.components().insertPrivateProject(d -> d.setName("p1").setDbKey("key2"));
-    ComponentDto project3 = db.components().insertPrivateProject(d -> d.setName("p2").setDbKey("key3"));
+    ComponentDto project1 = db.components().insertPrivateProject(d -> d.setName("p1").setKey("key1"));
+    ComponentDto project2 = db.components().insertPrivateProject(d -> d.setName("p1").setKey("key2"));
+    ComponentDto project3 = db.components().insertPrivateProject(d -> d.setName("p2").setKey("key3"));
     db.qualityGates().associateProjectToQualityGate(db.components().getProjectDto(project1), qualityGate1);
     db.qualityGates().associateProjectToQualityGate(db.components().getProjectDto(project2), qualityGate1);
     db.qualityGates().associateProjectToQualityGate(db.components().getProjectDto(project3), qualityGate1);
index dee8e09339f526a555418f1b8cc073c3f6d8c0ba..0631c5d3fc3a46de71f8acf5c7155b5e057ad66d 100644 (file)
@@ -771,8 +771,8 @@ public class QualityProfileDaoTest {
     assertThat(underTest.selectSelectedProjects(dbSession, profile1, null))
       .extracting("projectUuid", "projectKey", "projectName", "profileKey")
       .containsOnly(
-        tuple(project1.uuid(), project1.getDbKey(), project1.name(), profile1.getKee()),
-        tuple(project2.uuid(), project2.getDbKey(), project2.name(), profile1.getKee()));
+        tuple(project1.uuid(), project1.getKey(), project1.name(), profile1.getKee()),
+        tuple(project2.uuid(), project2.getKey(), project2.name(), profile1.getKee()));
 
     assertThat(underTest.selectSelectedProjects(dbSession, profile1, "ect1")).hasSize(1);
     assertThat(underTest.selectSelectedProjects(dbSession, profile3, null)).isEmpty();
@@ -796,8 +796,8 @@ public class QualityProfileDaoTest {
     assertThat(underTest.selectDeselectedProjects(dbSession, profile1, null))
       .extracting("projectUuid", "projectKey", "projectName", "profileKey")
       .containsExactly(
-        tuple(project2.uuid(), project2.getDbKey(), project2.name(), null),
-        tuple(project3.uuid(), project3.getDbKey(), project3.name(), null));
+        tuple(project2.uuid(), project2.getKey(), project2.name(), null),
+        tuple(project3.uuid(), project3.getKey(), project3.name(), null));
 
     assertThat(underTest.selectDeselectedProjects(dbSession, profile1, "ect2")).hasSize(1);
     assertThat(underTest.selectDeselectedProjects(dbSession, profile3, null)).hasSize(3);
@@ -822,9 +822,9 @@ public class QualityProfileDaoTest {
     assertThat(underTest.selectProjectAssociations(dbSession, profile1, null))
       .extracting("projectUuid", "projectKey", "projectName", "profileKey")
       .containsOnly(
-        tuple(project1.uuid(), project1.getDbKey(), project1.name(), profile1.getKee()),
-        tuple(project2.uuid(), project2.getDbKey(), project2.name(), null),
-        tuple(project3.uuid(), project3.getDbKey(), project3.name(), null));
+        tuple(project1.uuid(), project1.getKey(), project1.name(), profile1.getKee()),
+        tuple(project2.uuid(), project2.getKey(), project2.name(), null),
+        tuple(project3.uuid(), project3.getKey(), project3.name(), null));
 
     assertThat(underTest.selectProjectAssociations(dbSession, profile1, "ect2")).hasSize(1);
     assertThat(underTest.selectProjectAssociations(dbSession, profile3, null)).hasSize(3);
index 30b3152793f22851cb52bf8627618a7f3b987b4a..5a04f76f638b73c1ed217d7001c590de7ca9b75c 100644 (file)
@@ -56,8 +56,8 @@ public class RegulatoryReportDaoTest {
   public void prepare() {
     rule = db.rules().insertRule();
     hotspotRule = db.rules().insertHotspotRule();
-    project = db.components().insertPrivateProject(t -> t.setProjectUuid(PROJECT_UUID).setUuid(PROJECT_UUID).setDbKey(PROJECT_KEY));
-    file = db.components().insertComponent(newFileDto(project).setUuid(FILE_UUID).setDbKey(FILE_KEY));
+    project = db.components().insertPrivateProject(t -> t.setBranchUuid(PROJECT_UUID).setUuid(PROJECT_UUID).setKey(PROJECT_KEY));
+    file = db.components().insertComponent(newFileDto(project).setUuid(FILE_UUID).setKey(FILE_KEY));
   }
 
   @Test
index 885ed6d3bdead3b2eaae18bb5dce06dcc5aed345..e1b6f37fb6eb44551a74a2acfff61673ce5c1a0f 100644 (file)
@@ -245,7 +245,7 @@ public class FileSourceDaoTest {
       .collect(Collectors.toList());
 
     Map<String, FileHashesDto> fileSourcesByUuid = new HashMap<>();
-    underTest.scrollFileHashesByProjectUuid(dbSession, project.projectUuid(), result -> fileSourcesByUuid.put(result.getResultObject().getFileUuid(), result.getResultObject()));
+    underTest.scrollFileHashesByProjectUuid(dbSession, project.branchUuid(), result -> fileSourcesByUuid.put(result.getResultObject().getFileUuid(), result.getResultObject()));
 
     assertThat(fileSourcesByUuid).hasSize(files.size());
     files.forEach(t -> assertThat(fileSourcesByUuid).containsKey(t.uuid()));
@@ -258,7 +258,7 @@ public class FileSourceDaoTest {
     FileSourceDto inserted = dbTester.fileSources().insertFileSource(file);
 
     List<FileHashesDto> fileSources = new ArrayList<>(1);
-    underTest.scrollFileHashesByProjectUuid(dbSession, project.projectUuid(), result -> fileSources.add(result.getResultObject()));
+    underTest.scrollFileHashesByProjectUuid(dbSession, project.branchUuid(), result -> fileSources.add(result.getResultObject()));
 
     assertThat(fileSources).hasSize(1);
     FileHashesDto fileSource = fileSources.iterator().next();
index de5d12ba329909211512eefb50940604a970adb3..78d4bec46a46889734a8f64545d6c9d99f8e1838 100644 (file)
@@ -69,7 +69,7 @@ public class UserTokenDaoTest {
   @Test
   public void insert_project_analysis_token() {
     UserTokenDto projectAnalysisToken = newProjectAnalysisToken();
-    ComponentDto project = db.components().insertPublicProject(p -> p.setDbKey(projectAnalysisToken.getProjectKey()));
+    ComponentDto project = db.components().insertPublicProject(p -> p.setKey(projectAnalysisToken.getProjectKey()));
     underTest.insert(db.getSession(), projectAnalysisToken, "login");
 
     UserTokenDto projectAnalysisTokenFromDb = underTest.selectByTokenHash(db.getSession(), projectAnalysisToken.getTokenHash());
index 16145d3685074c93f070d761cb999eb9c2b2039d..527ed614192a016fa9c3290eaf52b556adff9298 100644 (file)
@@ -159,7 +159,7 @@ public class WebhookDaoWithPersisterTest {
   @Test
   public void deleteProjectWebhooksIsPersisted() {
     ProjectDto projectDto = componentDbTester.insertPrivateProjectDto(p ->
-      p.setUuid("puuid").setName("pname").setDbKey("pkey"));
+      p.setUuid("puuid").setName("pname").setKey("pkey"));
     webhookDbTester.insertWebhook(projectDto);
 
     underTest.deleteByProject(dbSession, projectDto);
index db56cf6c597a09891746bba7e8f176ef02cdb651..be729322f027d69e2ec200268b4146d71d545d8b 100644 (file)
@@ -478,7 +478,7 @@ public class ComponentDbTester {
   @SafeVarargs
   public final ComponentDto insertProjectBranch(ComponentDto project, Consumer<BranchDto>... dtoPopulators) {
     // MainBranchProjectUuid will be null if it's a main branch
-    BranchDto branchDto = ComponentTesting.newBranchDto(firstNonNull(project.getMainBranchProjectUuid(), project.projectUuid()), BRANCH);
+    BranchDto branchDto = ComponentTesting.newBranchDto(firstNonNull(project.getMainBranchProjectUuid(), project.branchUuid()), BRANCH);
     Arrays.stream(dtoPopulators).forEach(dtoPopulator -> dtoPopulator.accept(branchDto));
     return insertProjectBranch(project, branchDto);
   }
@@ -502,7 +502,7 @@ public class ComponentDbTester {
 
   public final ComponentDto insertProjectBranch(ComponentDto project, BranchDto branchDto) {
     // MainBranchProjectUuid will be null if it's a main branch
-    checkArgument(branchDto.getProjectUuid().equals(firstNonNull(project.getMainBranchProjectUuid(), project.projectUuid())));
+    checkArgument(branchDto.getProjectUuid().equals(firstNonNull(project.getMainBranchProjectUuid(), project.branchUuid())));
     ComponentDto branch = ComponentTesting.newBranchComponent(project, branchDto);
     insertComponent(branch);
     dbClient.branchDao().insert(dbSession, branchDto);
@@ -518,7 +518,7 @@ public class ComponentDbTester {
   public static ProjectDto toProjectDto(ComponentDto componentDto, long createTime) {
     return new ProjectDto()
       .setUuid(componentDto.uuid())
-      .setKey(componentDto.getDbKey())
+      .setKey(componentDto.getKey())
       .setQualifier(componentDto.qualifier() != null ? componentDto.qualifier() : Qualifiers.PROJECT)
       .setCreatedAt(createTime)
       .setUpdatedAt(createTime)
@@ -530,8 +530,8 @@ public class ComponentDbTester {
   public static PortfolioDto toPortfolioDto(ComponentDto componentDto, long createTime) {
     return new PortfolioDto()
       .setUuid(componentDto.uuid())
-      .setKey(componentDto.getDbKey())
-      .setRootUuid(componentDto.projectUuid())
+      .setKey(componentDto.getKey())
+      .setRootUuid(componentDto.branchUuid())
       .setSelectionMode(NONE.name())
       .setCreatedAt(createTime)
       .setUpdatedAt(createTime)
index 741fe1ed192625883a2d9da6e9b8da736f64020a..b32970caf9a22af046ce214fccd668608effdd44 100644 (file)
@@ -34,8 +34,6 @@ import static org.sonar.db.component.ComponentDto.PULL_REQUEST_SEPARATOR;
 import static org.sonar.db.component.ComponentDto.UUID_PATH_OF_ROOT;
 import static org.sonar.db.component.ComponentDto.UUID_PATH_SEPARATOR;
 import static org.sonar.db.component.ComponentDto.formatUuidPathFromParent;
-import static org.sonar.db.component.ComponentDto.generateBranchKey;
-import static org.sonar.db.component.ComponentDto.generatePullRequestKey;
 
 public class ComponentTesting {
 
@@ -51,7 +49,7 @@ public class ComponentTesting {
     String filename = "NAME_" + fileUuid;
     String path = directory != null ? directory.path() + "/" + filename : module.path() + "/" + filename;
     return newChildComponent(fileUuid, module, directory == null ? module : directory)
-      .setDbKey(generateKey("FILE_KEY_" + fileUuid, module))
+      .setKey("FILE_KEY_" + fileUuid)
       .setName(filename)
       .setLongName(path)
       .setScope(Scopes.FILE)
@@ -68,7 +66,7 @@ public class ComponentTesting {
   public static ComponentDto newDirectory(ComponentDto module, String uuid, String path) {
     String key = !path.equals("/") ? module.getKey() + ":" + path : module.getKey() + ":/";
     return newChildComponent(uuid, module, module)
-      .setDbKey(generateKey(key, module))
+      .setKey(key)
       .setName(path)
       .setLongName(path)
       .setPath(path)
@@ -78,7 +76,7 @@ public class ComponentTesting {
 
   public static ComponentDto newSubPortfolio(ComponentDto portfolioOrSubPortfolio, String uuid, String key) {
     return newModuleDto(uuid, portfolioOrSubPortfolio)
-      .setDbKey(key)
+      .setKey(key)
       .setName(key)
       .setLongName(key)
       .setScope(Scopes.PROJECT)
@@ -94,7 +92,7 @@ public class ComponentTesting {
   public static ComponentDto newModuleDto(String uuid, ComponentDto parentModuleOrProject) {
     return newChildComponent(uuid, parentModuleOrProject, parentModuleOrProject)
       .setModuleUuidPath(parentModuleOrProject.moduleUuidPath() + uuid + UUID_PATH_SEPARATOR)
-      .setDbKey(generateKey("MODULE_KEY_" + uuid, parentModuleOrProject))
+      .setKey("MODULE_KEY_" + uuid)
       .setName("NAME_" + uuid)
       .setLongName("LONG_NAME_" + uuid)
       .setPath("module")
@@ -103,19 +101,6 @@ public class ComponentTesting {
       .setLanguage(null);
   }
 
-  private static String generateKey(String key, ComponentDto parentModuleOrProject) {
-    String branch = parentModuleOrProject.getBranch();
-    if (branch != null) {
-      return generateBranchKey(key, branch);
-    }
-    String pullRequest = parentModuleOrProject.getPullRequest();
-    if (pullRequest != null) {
-      return generatePullRequestKey(key, pullRequest);
-    }
-
-    return key;
-  }
-
   public static ComponentDto newModuleDto(ComponentDto subProjectOrProject) {
     return newModuleDto(Uuids.createFast(), subProjectOrProject);
   }
@@ -140,10 +125,10 @@ public class ComponentTesting {
     return new ComponentDto()
       .setUuid(uuid)
       .setUuidPath(UUID_PATH_OF_ROOT)
-      .setProjectUuid(uuid)
+      .setBranchUuid(uuid)
       .setModuleUuidPath(UUID_PATH_SEPARATOR + uuid + UUID_PATH_SEPARATOR)
       .setRootUuid(uuid)
-      .setDbKey("KEY_" + uuid)
+      .setKey("KEY_" + uuid)
       .setName("NAME_" + uuid)
       .setLongName("LONG_NAME_" + uuid)
       .setDescription("DESCRIPTION_" + uuid)
@@ -177,7 +162,7 @@ public class ComponentTesting {
 
   public static ComponentDto newProjectCopy(String uuid, ComponentDto project, ComponentDto view) {
     return newChildComponent(uuid, view, view)
-      .setDbKey(view.getDbKey() + project.getDbKey())
+      .setKey(view.getKey() + project.getKey())
       .setName(project.name())
       .setLongName(project.longName())
       .setCopyComponentUuid(project.uuid())
@@ -194,8 +179,8 @@ public class ComponentTesting {
     return new ComponentDto()
       .setUuid(uuid)
       .setUuidPath(formatUuidPathFromParent(parent))
-      .setDbKey(uuid)
-      .setProjectUuid(moduleOrProject.projectUuid())
+      .setKey(uuid)
+      .setBranchUuid(moduleOrProject.branchUuid())
       .setRootUuid(moduleOrProject.uuid())
       .setModuleUuid(moduleOrProject.uuid())
       .setModuleUuidPath(moduleOrProject.moduleUuidPath())
@@ -216,7 +201,7 @@ public class ComponentTesting {
   }
 
   public static BranchDto newBranchDto(ComponentDto project) {
-    return newBranchDto(project.projectUuid(), BranchType.BRANCH);
+    return newBranchDto(project.branchUuid(), BranchType.BRANCH);
   }
 
   public static BranchDto newBranchDto(ComponentDto branchComponent, BranchType branchType) {
@@ -238,11 +223,11 @@ public class ComponentTesting {
     return new ComponentDto()
       .setUuid(uuid)
       .setUuidPath(UUID_PATH_OF_ROOT)
-      .setProjectUuid(uuid)
+      .setBranchUuid(uuid)
       .setModuleUuidPath(UUID_PATH_SEPARATOR + uuid + UUID_PATH_SEPARATOR)
       .setRootUuid(uuid)
       // name of the branch is not mandatory on the main branch
-      .setDbKey(branchName != null ? project.getKey() + branchSeparator + branchName : project.getKey())
+      .setKey(branchName != null ? project.getKey() + branchSeparator + branchName : project.getKey())
       .setMainBranchProjectUuid(project.getUuid())
       .setName(project.getName())
       .setLongName(project.getName())
@@ -259,16 +244,14 @@ public class ComponentTesting {
     checkArgument(project.qualifier().equals(Qualifiers.PROJECT) || project.qualifier().equals(Qualifiers.APP));
     checkArgument(project.getMainBranchProjectUuid() == null);
     String branchName = branchDto.getKey();
-    String branchSeparator = branchDto.getBranchType() == PULL_REQUEST ? PULL_REQUEST_SEPARATOR : BRANCH_KEY_SEPARATOR;
     String uuid = branchDto.getUuid();
     return new ComponentDto()
       .setUuid(uuid)
       .setUuidPath(UUID_PATH_OF_ROOT)
-      .setProjectUuid(uuid)
+      .setBranchUuid(uuid)
       .setModuleUuidPath(UUID_PATH_SEPARATOR + uuid + UUID_PATH_SEPARATOR)
       .setRootUuid(uuid)
-      // name of the branch is not mandatory on the main branch
-      .setDbKey(branchName != null ? project.getDbKey() + branchSeparator + branchName : project.getKey())
+      .setKey(project.getKey())
       .setMainBranchProjectUuid(project.uuid())
       .setName(project.name())
       .setLongName(project.longName())
index ae451bacac668d363929584fc453fffc07ebf175..5de13132e633c84d91e58f3c6f8ebaa2f010f13b 100644 (file)
@@ -32,7 +32,7 @@ public class SnapshotTesting {
 
   public static SnapshotDto newAnalysis(ComponentDto rootComponent) {
     checkNotNull(rootComponent.uuid(), "Project UUID must be set");
-    checkArgument(rootComponent.uuid().equals(rootComponent.projectUuid()), "Component is not a tree root");
+    checkArgument(rootComponent.uuid().equals(rootComponent.branchUuid()), "Component is not a tree root");
     return newAnalysis(rootComponent.uuid());
   }
 
index a39dee2a830f64bf17e07126ab941f80f8420a8c..330f6cbb9e8ab09c9303107fba37dd24fb74621e 100644 (file)
@@ -70,7 +70,7 @@ public class MeasureTesting {
     return new LiveMeasureDto()
       .setMetricUuid(metric.getUuid())
       .setComponentUuid(component.uuid())
-      .setProjectUuid(component.projectUuid())
+      .setProjectUuid(component.branchUuid())
       .setData(String.valueOf(cursor++))
       .setValue((double) cursor++)
       .setVariation((double) cursor++);
index 4206dfdfce0302c2964a4a729d60c024d07e7ea7..9175c4ab8f138568b950621e1ca5ecd2bb5f599c 100644 (file)
@@ -45,7 +45,7 @@ public class FileSourceTester {
   public final FileSourceDto insertFileSource(ComponentDto file, Consumer<FileSourceDto>... dtoPopulators) {
     FileSourceDto dto = new FileSourceDto()
       .setUuid(Uuids.createFast())
-      .setProjectUuid(file.projectUuid())
+      .setProjectUuid(file.branchUuid())
       .setFileUuid(file.uuid())
       .setSrcHash(randomAlphanumeric(50))
       .setDataHash(randomAlphanumeric(50))
@@ -65,7 +65,7 @@ public class FileSourceTester {
   public final FileSourceDto insertFileSource(ComponentDto file, int numLines, Consumer<FileSourceDto>... dtoPopulators) {
     FileSourceDto dto = new FileSourceDto()
       .setUuid(Uuids.createFast())
-      .setProjectUuid(file.projectUuid())
+      .setProjectUuid(file.branchUuid())
       .setFileUuid(file.uuid())
       .setSrcHash(randomAlphanumeric(50))
       .setDataHash(randomAlphanumeric(50))
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/CreateIndexForComponentsBranchUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/CreateIndexForComponentsBranchUuid.java
new file mode 100644 (file)
index 0000000..4640177
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v97;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.DatabaseUtils;
+import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class CreateIndexForComponentsBranchUuid extends DdlChange {
+  private static final String INDEX_NAME = "components_branch_uuid";
+  private static final String TABLE = "components";
+  private static final String COLUMN_NAME = "branch_uuid";
+
+  public CreateIndexForComponentsBranchUuid(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    try (Connection connection = getDatabase().getDataSource().getConnection()) {
+      createComponentsBranchUuidIndex(context, connection);
+    }
+  }
+
+  private static void createComponentsBranchUuidIndex(Context context, Connection connection) {
+    if (!DatabaseUtils.indexExistsIgnoreCase(TABLE, INDEX_NAME, connection)) {
+      context.execute(new CreateIndexBuilder()
+        .setTable(TABLE)
+        .setName(INDEX_NAME)
+        .addColumn(COLUMN_NAME)
+        .setUnique(false)
+        .build());
+    }
+  }
+
+}
index 0234783e802fa9f7545a10187c765647da06c490..8cfd5e7b247bb69b0209fa1a93b0f22ec4bb8b6b 100644 (file)
@@ -29,6 +29,12 @@ public class DbVersion97 implements DbVersion {
       .add(6600, "Add column 'webhook_secret' to 'alm_settings'", AddWebhookSecretToAlmSettingsTable.class)
       .add(6601, "Drop non unique index on 'uuid' in 'components'", DropNonUniqueIndexForComponentsUuid.class)
       .add(6602, "Add unique index on 'uuid' in 'components'", CreateUniqueIndexForComponentsUuid.class)
+
+      .add(6603, "Drop index for 'project_uuid' in 'components'", DropIndexForComponentsProjectUuid.class)
+      .add(6604, "Rename column 'project_uuid' to 'branch_uuid' in 'components'", RenameProjectUuidToBranchUuidInComponents.class)
+      .add(6605, "Create index for 'branch_uuid' in 'components'", CreateIndexForComponentsBranchUuid.class)
+      
+      .add(6606, "Drop index for 'kee' in 'components'", DropIndexForComponentsKey.class)
     ;
   }
 }
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/DropIndexForComponentsKey.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/DropIndexForComponentsKey.java
new file mode 100644 (file)
index 0000000..fa97abd
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v97;
+
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DropIndexChange;
+
+public class DropIndexForComponentsKey extends DropIndexChange {
+  public DropIndexForComponentsKey(Database db) {
+    super(db, "projects_kee", "components");
+  }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/DropIndexForComponentsProjectUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/DropIndexForComponentsProjectUuid.java
new file mode 100644 (file)
index 0000000..b6d594c
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v97;
+
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DropIndexChange;
+
+public class DropIndexForComponentsProjectUuid extends DropIndexChange {
+  public DropIndexForComponentsProjectUuid(Database db) {
+    super(db, "projects_project_uuid", "components");
+  }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/RenameProjectUuidToBranchUuidInComponents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/RenameProjectUuidToBranchUuidInComponents.java
new file mode 100644 (file)
index 0000000..00b92dc
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v97;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.DatabaseUtils;
+import org.sonar.server.platform.db.migration.def.VarcharColumnDef;
+import org.sonar.server.platform.db.migration.sql.RenameColumnsBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class RenameProjectUuidToBranchUuidInComponents extends DdlChange {
+  private static final String TABLE_NAME = "components";
+
+  private static final VarcharColumnDef columnDefinition = newVarcharColumnDefBuilder()
+    .setColumnName("branch_uuid")
+    .setIsNullable(false)
+    .setLimit(50)
+    .build();
+
+  public RenameProjectUuidToBranchUuidInComponents(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    try (Connection connection = getDatabase().getDataSource().getConnection()) {
+      if (!DatabaseUtils.tableColumnExists(connection, TABLE_NAME, "branch_uuid") && DatabaseUtils.tableColumnExists(connection, TABLE_NAME, "project_uuid")) {
+        context.execute(new RenameColumnsBuilder(getDialect(), TABLE_NAME)
+          .renameColumn("project_uuid", columnDefinition)
+          .build());
+      }
+    }
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v97/CreateIndexForComponentsBranchUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v97/CreateIndexForComponentsBranchUuidTest.java
new file mode 100644 (file)
index 0000000..28fdc9a
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v97;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+public class CreateIndexForComponentsBranchUuidTest {
+  static final String INDEX_NAME = "components_branch_uuid";
+  static final String TABLE = "components";
+  static final String COLUMN_NAME = "branch_uuid";
+
+  @Rule
+  public final CoreDbTester db = CoreDbTester.createForSchema(CreateIndexForComponentsBranchUuidTest.class, "schema.sql");
+
+  private final CreateIndexForComponentsBranchUuid underTest = new CreateIndexForComponentsBranchUuid(db.database());
+
+  @Test
+  public void migration_should_create_index() throws SQLException {
+    db.assertIndexDoesNotExist(TABLE, INDEX_NAME);
+
+    underTest.execute();
+
+    db.assertIndex(TABLE, INDEX_NAME, COLUMN_NAME);
+  }
+
+  @Test
+  public void migration_should_be_reentrant() throws SQLException {
+    underTest.execute();
+    underTest.execute();
+
+    db.assertIndex(TABLE, INDEX_NAME, COLUMN_NAME);
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v97/DropIndexForComponentsProjectUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v97/DropIndexForComponentsProjectUuidTest.java
new file mode 100644 (file)
index 0000000..35e6768
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v97;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+import static org.sonar.db.CoreDbTester.createForSchema;
+
+public class DropIndexForComponentsProjectUuidTest {
+  private static final String TABLE = "components";
+  private static final String INDEX = "projects_project_uuid";
+
+  @Rule
+  public final CoreDbTester db = createForSchema(DropIndexForComponentsProjectUuidTest.class, "schema.sql");
+
+  private final DropIndexForComponentsProjectUuid dropIndexForRuleDescSection = new DropIndexForComponentsProjectUuid(db.database());
+
+  @Test
+  public void migration_should_drop_unique_index() throws SQLException {
+    db.assertIndex(TABLE, INDEX, "project_uuid");
+
+    dropIndexForRuleDescSection.execute();
+
+    db.assertIndexDoesNotExist(TABLE, INDEX);
+  }
+
+  @Test
+  public void migration_should_be_reentrant() throws SQLException {
+    dropIndexForRuleDescSection.execute();
+    dropIndexForRuleDescSection.execute();
+
+    db.assertIndexDoesNotExist(TABLE, INDEX);
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v97/RenameProjectUuidToBranchUuidInComponentsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v97/RenameProjectUuidToBranchUuidInComponentsTest.java
new file mode 100644 (file)
index 0000000..f25fa0d
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v97;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+import static java.sql.Types.VARCHAR;
+
+public class RenameProjectUuidToBranchUuidInComponentsTest {
+  private static final String TABLE_NAME = "components";
+
+  @Rule
+  public final CoreDbTester db = CoreDbTester.createForSchema(RenameProjectUuidToBranchUuidInComponentsTest.class, "schema.sql");
+
+  private final RenameProjectUuidToBranchUuidInComponents underTest = new RenameProjectUuidToBranchUuidInComponents(db.database());
+
+  @Test
+  public void type_column_is_not_null() throws SQLException {
+    underTest.execute();
+
+    db.assertColumnDefinition(TABLE_NAME, "branch_uuid", VARCHAR, 50, false);
+  }
+
+  @Test
+  public void migration_is_reentrant() throws SQLException {
+    underTest.execute();
+    underTest.execute();
+
+    db.assertColumnDefinition(TABLE_NAME, "branch_uuid", VARCHAR, 50, false);
+  }
+}
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v97/CreateIndexForComponentsBranchUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v97/CreateIndexForComponentsBranchUuidTest/schema.sql
new file mode 100644 (file)
index 0000000..4f56aea
--- /dev/null
@@ -0,0 +1,41 @@
+
+CREATE TABLE "COMPONENTS"(
+    "UUID" CHARACTER VARYING(50) NOT NULL,
+    "KEE" CHARACTER VARYING(1000),
+    "DEPRECATED_KEE" CHARACTER VARYING(400),
+    "NAME" CHARACTER VARYING(2000),
+    "LONG_NAME" CHARACTER VARYING(2000),
+    "DESCRIPTION" CHARACTER VARYING(2000),
+    "ENABLED" BOOLEAN DEFAULT TRUE NOT NULL,
+    "SCOPE" CHARACTER VARYING(3),
+    "QUALIFIER" CHARACTER VARYING(10),
+    "PRIVATE" BOOLEAN NOT NULL,
+    "ROOT_UUID" CHARACTER VARYING(50) NOT NULL,
+    "LANGUAGE" CHARACTER VARYING(20),
+    "COPY_COMPONENT_UUID" CHARACTER VARYING(50),
+    "PATH" CHARACTER VARYING(2000),
+    "UUID_PATH" CHARACTER VARYING(1500) NOT NULL,
+    "BRANCH_UUID" CHARACTER VARYING(50) NOT NULL,
+    "MODULE_UUID" CHARACTER VARYING(50),
+    "MODULE_UUID_PATH" CHARACTER VARYING(1500),
+    "MAIN_BRANCH_PROJECT_UUID" CHARACTER VARYING(50),
+    "B_CHANGED" BOOLEAN,
+    "B_NAME" CHARACTER VARYING(500),
+    "B_LONG_NAME" CHARACTER VARYING(500),
+    "B_DESCRIPTION" CHARACTER VARYING(2000),
+    "B_ENABLED" BOOLEAN,
+    "B_QUALIFIER" CHARACTER VARYING(10),
+    "B_LANGUAGE" CHARACTER VARYING(20),
+    "B_COPY_COMPONENT_UUID" CHARACTER VARYING(50),
+    "B_PATH" CHARACTER VARYING(2000),
+    "B_UUID_PATH" CHARACTER VARYING(1500),
+    "B_MODULE_UUID" CHARACTER VARYING(50),
+    "B_MODULE_UUID_PATH" CHARACTER VARYING(1500),
+    "CREATED_AT" TIMESTAMP
+);
+CREATE UNIQUE INDEX "PROJECTS_KEE" ON "COMPONENTS"("KEE" NULLS FIRST);
+CREATE INDEX "PROJECTS_MODULE_UUID" ON "COMPONENTS"("MODULE_UUID" NULLS FIRST);
+CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER" NULLS FIRST);
+CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID" NULLS FIRST);
+CREATE INDEX "PROJECTS_UUID" ON "COMPONENTS"("UUID" NULLS FIRST);
+CREATE INDEX "IDX_MAIN_BRANCH_PRJ_UUID" ON "COMPONENTS"("MAIN_BRANCH_PROJECT_UUID" NULLS FIRST);
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v97/DropIndexForComponentsProjectUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v97/DropIndexForComponentsProjectUuidTest/schema.sql
new file mode 100644 (file)
index 0000000..fc8a4a7
--- /dev/null
@@ -0,0 +1,41 @@
+CREATE TABLE "COMPONENTS"(
+    "UUID" CHARACTER VARYING(50) NOT NULL,
+    "KEE" CHARACTER VARYING(1000),
+    "DEPRECATED_KEE" CHARACTER VARYING(400),
+    "NAME" CHARACTER VARYING(2000),
+    "LONG_NAME" CHARACTER VARYING(2000),
+    "DESCRIPTION" CHARACTER VARYING(2000),
+    "ENABLED" BOOLEAN DEFAULT TRUE NOT NULL,
+    "SCOPE" CHARACTER VARYING(3),
+    "QUALIFIER" CHARACTER VARYING(10),
+    "PRIVATE" BOOLEAN NOT NULL,
+    "ROOT_UUID" CHARACTER VARYING(50) NOT NULL,
+    "LANGUAGE" CHARACTER VARYING(20),
+    "COPY_COMPONENT_UUID" CHARACTER VARYING(50),
+    "PATH" CHARACTER VARYING(2000),
+    "UUID_PATH" CHARACTER VARYING(1500) NOT NULL,
+    "PROJECT_UUID" CHARACTER VARYING(50) NOT NULL,
+    "MODULE_UUID" CHARACTER VARYING(50),
+    "MODULE_UUID_PATH" CHARACTER VARYING(1500),
+    "MAIN_BRANCH_PROJECT_UUID" CHARACTER VARYING(50),
+    "B_CHANGED" BOOLEAN,
+    "B_NAME" CHARACTER VARYING(500),
+    "B_LONG_NAME" CHARACTER VARYING(500),
+    "B_DESCRIPTION" CHARACTER VARYING(2000),
+    "B_ENABLED" BOOLEAN,
+    "B_QUALIFIER" CHARACTER VARYING(10),
+    "B_LANGUAGE" CHARACTER VARYING(20),
+    "B_COPY_COMPONENT_UUID" CHARACTER VARYING(50),
+    "B_PATH" CHARACTER VARYING(2000),
+    "B_UUID_PATH" CHARACTER VARYING(1500),
+    "B_MODULE_UUID" CHARACTER VARYING(50),
+    "B_MODULE_UUID_PATH" CHARACTER VARYING(1500),
+    "CREATED_AT" TIMESTAMP
+);
+CREATE UNIQUE INDEX "PROJECTS_KEE" ON "COMPONENTS"("KEE" NULLS FIRST);
+CREATE INDEX "PROJECTS_MODULE_UUID" ON "COMPONENTS"("MODULE_UUID" NULLS FIRST);
+CREATE INDEX "PROJECTS_PROJECT_UUID" ON "COMPONENTS"("PROJECT_UUID" NULLS FIRST);
+CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER" NULLS FIRST);
+CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID" NULLS FIRST);
+CREATE INDEX "PROJECTS_UUID" ON "COMPONENTS"("UUID" NULLS FIRST);
+CREATE INDEX "IDX_MAIN_BRANCH_PRJ_UUID" ON "COMPONENTS"("MAIN_BRANCH_PROJECT_UUID" NULLS FIRST);
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v97/RenameProjectUuidToBranchUuidInComponentsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v97/RenameProjectUuidToBranchUuidInComponentsTest/schema.sql
new file mode 100644 (file)
index 0000000..8373917
--- /dev/null
@@ -0,0 +1,41 @@
+
+CREATE TABLE "COMPONENTS"(
+    "UUID" CHARACTER VARYING(50) NOT NULL,
+    "KEE" CHARACTER VARYING(1000),
+    "DEPRECATED_KEE" CHARACTER VARYING(400),
+    "NAME" CHARACTER VARYING(2000),
+    "LONG_NAME" CHARACTER VARYING(2000),
+    "DESCRIPTION" CHARACTER VARYING(2000),
+    "ENABLED" BOOLEAN DEFAULT TRUE NOT NULL,
+    "SCOPE" CHARACTER VARYING(3),
+    "QUALIFIER" CHARACTER VARYING(10),
+    "PRIVATE" BOOLEAN NOT NULL,
+    "ROOT_UUID" CHARACTER VARYING(50) NOT NULL,
+    "LANGUAGE" CHARACTER VARYING(20),
+    "COPY_COMPONENT_UUID" CHARACTER VARYING(50),
+    "PATH" CHARACTER VARYING(2000),
+    "UUID_PATH" CHARACTER VARYING(1500) NOT NULL,
+    "PROJECT_UUID" CHARACTER VARYING(50) NOT NULL,
+    "MODULE_UUID" CHARACTER VARYING(50),
+    "MODULE_UUID_PATH" CHARACTER VARYING(1500),
+    "MAIN_BRANCH_PROJECT_UUID" CHARACTER VARYING(50),
+    "B_CHANGED" BOOLEAN,
+    "B_NAME" CHARACTER VARYING(500),
+    "B_LONG_NAME" CHARACTER VARYING(500),
+    "B_DESCRIPTION" CHARACTER VARYING(2000),
+    "B_ENABLED" BOOLEAN,
+    "B_QUALIFIER" CHARACTER VARYING(10),
+    "B_LANGUAGE" CHARACTER VARYING(20),
+    "B_COPY_COMPONENT_UUID" CHARACTER VARYING(50),
+    "B_PATH" CHARACTER VARYING(2000),
+    "B_UUID_PATH" CHARACTER VARYING(1500),
+    "B_MODULE_UUID" CHARACTER VARYING(50),
+    "B_MODULE_UUID_PATH" CHARACTER VARYING(1500),
+    "CREATED_AT" TIMESTAMP
+);
+CREATE UNIQUE INDEX "PROJECTS_KEE" ON "COMPONENTS"("KEE" NULLS FIRST);
+CREATE INDEX "PROJECTS_MODULE_UUID" ON "COMPONENTS"("MODULE_UUID" NULLS FIRST);
+CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER" NULLS FIRST);
+CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID" NULLS FIRST);
+CREATE INDEX "PROJECTS_UUID" ON "COMPONENTS"("UUID" NULLS FIRST);
+CREATE INDEX "IDX_MAIN_BRANCH_PRJ_UUID" ON "COMPONENTS"("MAIN_BRANCH_PROJECT_UUID" NULLS FIRST);
index 2d1c7a26cf4d249c4674715762b480a87c5ffbb0..94054fde77371750c81b791e27cfbcbd0068703b 100644 (file)
@@ -127,7 +127,7 @@ public class ComponentIndexer implements ProjectIndexer, NeedAuthorizationIndexe
       dbClient.componentDao().scrollForIndexing(dbSession, branchUuid, context -> {
         ComponentDto dto = context.getResultObject();
         bulkIndexer.add(toDocument(dto).toIndexRequest());
-        remaining.remove(dto.projectUuid());
+        remaining.remove(dto.branchUuid());
       });
     }
 
@@ -185,8 +185,8 @@ public class ComponentIndexer implements ProjectIndexer, NeedAuthorizationIndexe
     return new ComponentDoc()
       .setId(component.uuid())
       .setName(component.name())
-      .setKey(component.getDbKey())
-      .setProjectUuid(component.projectUuid())
+      .setKey(component.getKey())
+      .setProjectUuid(component.branchUuid())
       .setQualifier(component.qualifier());
   }
 }
index ee832cd2e137bbacc9eaffcbebab40e71bb5e984..e19163b9e07d41e5520d8b9ca23bcbe7bbec2f01 100644 (file)
@@ -46,7 +46,7 @@ public interface ProjectIndexers {
 
   default void commitAndIndexComponents(DbSession dbSession, Collection<ComponentDto> projects, ProjectIndexer.Cause cause) {
     Collection<String> projectUuids = projects.stream()
-      .map(ComponentDto::projectUuid)
+      .map(ComponentDto::branchUuid)
       .collect(MoreCollectors.toSet(projects.size()));
     commitAndIndexByProjectUuids(dbSession, projectUuids, cause);
   }
index eb9ee198e5ebae64cebbef156edca4a362f38b45..2e27ce531f5a7998177f658f8689f1b705b8b4ac 100644 (file)
@@ -51,7 +51,7 @@ public class FavoriteUpdater {
       .setUserUuid(userUuid)
       .setComponentUuid(componentDto.uuid())
       .build(), dbSession);
-    checkArgument(existingFavoriteOnComponent.isEmpty(), "Component '%s' is already a favorite", componentDto.getDbKey());
+    checkArgument(existingFavoriteOnComponent.isEmpty(), "Component '%s' is already a favorite", componentDto.getKey());
 
     List<PropertyDto> existingFavorites = dbClient.propertiesDao().selectByKeyAndUserUuidAndComponentQualifier(dbSession, PROP_FAVORITE_KEY, userUuid, componentDto.qualifier());
     if (existingFavorites.size() >= 100) {
@@ -81,6 +81,6 @@ public class FavoriteUpdater {
         .setComponentUuid(component.uuid())
         .setUserUuid(userUuid),
       userLogin, component.getKey(), component.name(), component.qualifier());
-    checkArgument(result == 1, "Component '%s' is not a favorite", component.getDbKey());
+    checkArgument(result == 1, "Component '%s' is not a favorite", component.getKey());
   }
 }
index f636672025f09fb35a8f3258d845fc0e2401cf22..308f6a21d970308451081812ebf74224756a7066 100644 (file)
@@ -111,7 +111,7 @@ public class IssueIndexer implements ProjectIndexer, NeedAuthorizationIndexer {
 
   @Override
   public void indexOnAnalysis(String branchUuid) {
-    try (IssueIterator issues = issueIteratorFactory.createForProject(branchUuid)) {
+    try (IssueIterator issues = issueIteratorFactory.createForBranch(branchUuid)) {
       doIndex(issues, Size.REGULAR, IndexingListener.FAIL_ON_ERROR);
     }
   }
@@ -217,7 +217,7 @@ public class IssueIndexer implements ProjectIndexer, NeedAuthorizationIndexer {
 
     for (String projectUuid : itemsByProjectUuid.keySet()) {
       // TODO support loading of multiple projects in a single SQL request
-      try (IssueIterator issues = issueIteratorFactory.createForProject(projectUuid)) {
+      try (IssueIterator issues = issueIteratorFactory.createForBranch(projectUuid)) {
         if (issues.hasNext()) {
           do {
             IssueDoc doc = issues.next();
index 446972d8b8e1c100a308c93de94dc94bf0856fdf..a1ebd01b1257df7f0aea8bef2bec1498642ac2ed 100644 (file)
@@ -32,11 +32,11 @@ public class IssueIteratorFactory {
   }
 
   public IssueIterator createForAll() {
-    return createForProject(null);
+    return createForBranch(null);
   }
 
-  public IssueIterator createForProject(@Nullable String projectUuid) {
-    return new IssueIteratorForSingleChunk(dbClient, projectUuid, null);
+  public IssueIterator createForBranch(@Nullable String branchUuid) {
+    return new IssueIteratorForSingleChunk(dbClient, branchUuid, null);
   }
 
   public IssueIterator createForIssueKeys(Collection<String> issueKeys) {
index d2b3715304d9d3b6453c88f370935c73e4ab4f57..0427d887552e07ee7ac32fa0ae73b39dbd7ff017 100644 (file)
@@ -74,7 +74,7 @@ class IssueIteratorForSingleChunk implements IssueIterator {
     "c.module_uuid_path",
     "c.path",
     "c.scope",
-    "c.project_uuid",
+    "c.branch_uuid",
     "c.main_branch_project_uuid",
 
     // column 21
@@ -91,17 +91,16 @@ class IssueIteratorForSingleChunk implements IssueIterator {
 
   private static final String SQL_NEW_CODE_JOIN = "left join new_code_reference_issues n on n.issue_key = i.kee ";
 
-  private static final String PROJECT_FILTER = " and c.project_uuid = ? and i.project_uuid = ? ";
+  private static final String BRANCH_FILTER = " and c.branch_uuid = ? and i.project_uuid = ? ";
   private static final String ISSUE_KEY_FILTER_PREFIX = " and i.kee in (";
   private static final String ISSUE_KEY_FILTER_SUFFIX = ") ";
 
   static final Splitter TAGS_SPLITTER = Splitter.on(',').trimResults().omitEmptyStrings();
-  static final Splitter MODULE_PATH_SPLITTER = Splitter.on('.').trimResults().omitEmptyStrings();
 
   private final DbSession session;
 
   @CheckForNull
-  private final String projectUuid;
+  private final String branchUuid;
 
   @CheckForNull
   private final Collection<String> issueKeys;
@@ -109,10 +108,10 @@ class IssueIteratorForSingleChunk implements IssueIterator {
   private final PreparedStatement stmt;
   private final ResultSetIterator<IssueDoc> iterator;
 
-  IssueIteratorForSingleChunk(DbClient dbClient, @Nullable String projectUuid, @Nullable Collection<String> issueKeys) {
+  IssueIteratorForSingleChunk(DbClient dbClient, @Nullable String branchUuid, @Nullable Collection<String> issueKeys) {
     checkArgument(issueKeys == null || issueKeys.size() <= DatabaseUtils.PARTITION_SIZE_FOR_ORACLE,
       "Cannot search for more than " + DatabaseUtils.PARTITION_SIZE_FOR_ORACLE + " issue keys at once. Please provide the keys in smaller chunks.");
-    this.projectUuid = projectUuid;
+    this.branchUuid = branchUuid;
     this.issueKeys = issueKeys;
     this.session = dbClient.openSession(false);
 
@@ -148,7 +147,7 @@ class IssueIteratorForSingleChunk implements IssueIterator {
 
   private String createSql() {
     String sql = SQL_ALL;
-    sql += projectUuid == null ? "" : PROJECT_FILTER;
+    sql += branchUuid == null ? "" : BRANCH_FILTER;
     if (issueKeys != null && !issueKeys.isEmpty()) {
       sql += ISSUE_KEY_FILTER_PREFIX;
       sql += IntStream.range(0, issueKeys.size()).mapToObj(i -> "?").collect(Collectors.joining(","));
@@ -160,10 +159,10 @@ class IssueIteratorForSingleChunk implements IssueIterator {
 
   private void setParameters(PreparedStatement stmt) throws SQLException {
     int index = 1;
-    if (projectUuid != null) {
-      stmt.setString(index, projectUuid);
+    if (branchUuid != null) {
+      stmt.setString(index, branchUuid);
       index++;
-      stmt.setString(index, projectUuid);
+      stmt.setString(index, branchUuid);
       index++;
     }
     if (issueKeys != null) {
index 8470d57f03506727904f5c95f93e708874d88eec..fc7c5b17148587b2cb8ab689e8e5cb78f6a2e678 100644 (file)
@@ -48,13 +48,13 @@ public class ProjectConfigurationLoaderImpl implements ProjectConfigurationLoade
     Map<String, ChildSettings> mainBranchSettingsByDbKey = loadMainBranchConfigurations(dbSession, mainBranchDbKeys);
     return projects.stream()
       .collect(uniqueIndex(ComponentDto::uuid, component -> {
-        if (component.getDbKey().equals(component.getKey())) {
+        if (component.getKey().equals(component.getKey())) {
           return mainBranchSettingsByDbKey.get(component.getKey()).asConfiguration();
         }
 
         ChildSettings settings = new ChildSettings(mainBranchSettingsByDbKey.get(component.getKey()));
         dbClient.propertiesDao()
-            .selectProjectProperties(dbSession, component.getDbKey())
+            .selectProjectProperties(dbSession, component.getKey())
           .forEach(property -> settings.setProperty(property.getKey(), property.getValue()));
         return settings.asConfiguration();
       }));
index d3a895cc99cf7d16d4720d6ab6d75e088e489ab7..fd7cce98adf120491c830210a369e75ee48b44c2 100644 (file)
@@ -30,7 +30,7 @@ import org.sonar.core.util.stream.MoreCollectors;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.ComponentDto;
-import org.sonar.db.component.UuidWithProjectUuidDto;
+import org.sonar.db.component.UuidWithBranchUuidDto;
 import org.sonar.db.es.EsQueueDto;
 import org.sonar.server.es.BulkIndexer;
 import org.sonar.server.es.BulkIndexer.Size;
@@ -71,8 +71,8 @@ public class ViewIndexer implements ResilientIndexer {
   private void indexAll(Size bulkSize) {
     try (DbSession dbSession = dbClient.openSession(false)) {
       Map<String, String> viewAndProjectViewUuidMap = new HashMap<>();
-      for (UuidWithProjectUuidDto uuidWithProjectUuidDto : dbClient.componentDao().selectAllViewsAndSubViews(dbSession)) {
-        viewAndProjectViewUuidMap.put(uuidWithProjectUuidDto.getUuid(), uuidWithProjectUuidDto.getProjectUuid());
+      for (UuidWithBranchUuidDto uuidWithBranchUuidDto : dbClient.componentDao().selectAllViewsAndSubViews(dbSession)) {
+        viewAndProjectViewUuidMap.put(uuidWithBranchUuidDto.getUuid(), uuidWithBranchUuidDto.getBranchUuid());
       }
       index(dbSession, viewAndProjectViewUuidMap, false, bulkSize);
     }
@@ -88,7 +88,7 @@ public class ViewIndexer implements ResilientIndexer {
     try (DbSession dbSession = dbClient.openSession(false)) {
       Map<String, String> viewAndProjectViewUuidMap = new HashMap<>();
       for (ComponentDto viewOrSubView : dbClient.componentDao().selectEnabledDescendantModules(dbSession, rootViewUuid)) {
-        viewAndProjectViewUuidMap.put(viewOrSubView.uuid(), viewOrSubView.projectUuid());
+        viewAndProjectViewUuidMap.put(viewOrSubView.uuid(), viewOrSubView.branchUuid());
       }
       index(dbSession, viewAndProjectViewUuidMap, true, Size.REGULAR);
     }
index faa055d37671e65589465893eb7bda2972e1330e..34fe87ab95d466f09bc95a5611a2b282bacdffbb 100644 (file)
@@ -102,8 +102,8 @@ public class ComponentIndexerTest {
     assertThatIndexContainsOnly(project);
     ComponentDoc doc = es.getDocuments(TYPE_COMPONENT, ComponentDoc.class).get(0);
     assertThat(doc.getId()).isEqualTo(project.uuid());
-    assertThat(doc.getKey()).isEqualTo(project.getDbKey());
-    assertThat(doc.getProjectUuid()).isEqualTo(project.projectUuid());
+    assertThat(doc.getKey()).isEqualTo(project.getKey());
+    assertThat(doc.getProjectUuid()).isEqualTo(project.branchUuid());
     assertThat(doc.getName()).isEqualTo(project.name());
   }
 
index c3fc3cf0b7baf4b90caec86c7e6dd1a020c95b1b..f77fa99816dca55847177aa850b1c3cf845e325b 100644 (file)
@@ -85,7 +85,7 @@ public class IssueIteratorFactoryTest {
     assertThat(issue.line()).isEqualTo(444);
     assertThat(issue.ruleUuid()).isEqualTo(rule.getUuid());
     assertThat(issue.componentUuid()).isEqualTo(file.uuid());
-    assertThat(issue.projectUuid()).isEqualTo(file.projectUuid());
+    assertThat(issue.projectUuid()).isEqualTo(file.branchUuid());
     assertThat(issue.modulePath()).isEqualTo(file.moduleUuidPath());
     assertThat(issue.directoryPath()).isEqualTo("src/main/java");
     assertThat(issue.filePath()).isEqualTo("src/main/java/Action.java");
@@ -142,11 +142,11 @@ public class IssueIteratorFactoryTest {
       .map(project2Component -> dbTester.issues().insert(rule, project2, project2Component).getKey())
       .toArray(String[]::new);
 
-    assertThat(issuesByKey(factory -> factory.createForProject(project1.uuid())).keySet())
+    assertThat(issuesByKey(factory -> factory.createForBranch(project1.uuid())).keySet())
       .containsOnly(project1IssueKeys);
-    assertThat(issuesByKey(factory -> factory.createForProject(project2.uuid())).keySet())
+    assertThat(issuesByKey(factory -> factory.createForBranch(project2.uuid())).keySet())
       .containsOnly(project2IssueKeys);
-    assertThat(issuesByKey(factory -> factory.createForProject("does not exist")))
+    assertThat(issuesByKey(factory -> factory.createForBranch("does not exist")))
       .isEmpty();
   }
 
index bac6649e5c8c080d0c7e3921965f24bb1f954117..359a03dc2995b16ea0dc60ea9efe90b96740676d 100644 (file)
@@ -182,7 +182,7 @@ public class ProjectConfigurationLoaderImplTest {
   }
 
   private ComponentDto newComponentDto(String componentDbKey, String componentUuid) {
-    return new ComponentDto().setDbKey(componentDbKey).setUuid(componentUuid);
+    return new ComponentDto().setKey(componentDbKey).setUuid(componentUuid);
   }
 
   private PropertyDto newPropertyDto(String projectKey1, String projectValue1) {
index e1ac645ec306035d19715c27e97ee105e0d60c25..301369b93bb083f669361f1e840e057bd807ebf8 100644 (file)
@@ -189,14 +189,14 @@ public class ViewIndexerTest {
 
   @Test
   public void index_application_branch() {
-    ComponentDto application = db.components().insertPublicProject(c -> c.setQualifier(APP).setDbKey("app"));
+    ComponentDto application = db.components().insertPublicProject(c -> c.setQualifier(APP).setKey("app"));
     ComponentDto applicationBranch1 = db.components().insertProjectBranch(application, a -> a.setKey("app-branch1"));
     ComponentDto applicationBranch2 = db.components().insertProjectBranch(application, a -> a.setKey("app-branch2"));
-    ComponentDto project1 = db.components().insertPrivateProject(p -> p.setDbKey("prj1"));
+    ComponentDto project1 = db.components().insertPrivateProject(p -> p.setKey("prj1"));
     ComponentDto project1Branch = db.components().insertProjectBranch(project1);
-    ComponentDto project2 = db.components().insertPrivateProject(p -> p.setDbKey("prj2"));
+    ComponentDto project2 = db.components().insertPrivateProject(p -> p.setKey("prj2"));
     ComponentDto project2Branch = db.components().insertProjectBranch(project2);
-    ComponentDto project3 = db.components().insertPrivateProject(p -> p.setDbKey("prj3"));
+    ComponentDto project3 = db.components().insertPrivateProject(p -> p.setKey("prj3"));
     ComponentDto project3Branch = db.components().insertProjectBranch(project3);
     db.components().insertComponent(newProjectCopy(project1Branch, applicationBranch1));
     db.components().insertComponent(newProjectCopy(project2Branch, applicationBranch1));
index d67cd23a41c3852f3e17f824db9d8f96457c5de4..8c5144937d97205b7fb38edaeab31bb99ff2ecd0 100644 (file)
@@ -45,10 +45,10 @@ public class IssueDocTesting {
     String mainBranchProjectUuid = componentDto.getMainBranchProjectUuid();
     return newDoc()
       .setKey(key)
-      .setBranchUuid(componentDto.projectUuid())
+      .setBranchUuid(componentDto.branchUuid())
       .setComponentUuid(componentDto.uuid())
       .setModuleUuidPath(componentDto.moduleUuidPath())
-      .setProjectUuid(mainBranchProjectUuid == null ? componentDto.projectUuid() : mainBranchProjectUuid)
+      .setProjectUuid(mainBranchProjectUuid == null ? componentDto.branchUuid() : mainBranchProjectUuid)
       // File path make no sens on modules and projects
       .setFilePath(!componentDto.scope().equals(Scopes.PROJECT) ? componentDto.path() : null)
       .setIsMainBranch(mainBranchProjectUuid == null)
index 58702dac6e88220debe0a45a8400e75b007755a7..503ac3a7ad1fa8aa14f99ff46d369eca9218daa8 100644 (file)
@@ -89,7 +89,7 @@ public abstract class AbstractUserSession implements UserSession {
 
   @Override
   public final boolean hasComponentPermission(String permission, ComponentDto component) {
-    String projectUuid = defaultString(component.getMainBranchProjectUuid(), component.projectUuid());
+    String projectUuid = defaultString(component.getMainBranchProjectUuid(), component.branchUuid());
     return hasProjectUuidPermission(permission, projectUuid);
   }
 
@@ -105,7 +105,7 @@ public abstract class AbstractUserSession implements UserSession {
 
   @Override
   public final boolean hasChildProjectsPermission(String permission, ComponentDto component) {
-    String applicationUuid = defaultString(component.getMainBranchProjectUuid(), component.projectUuid());
+    String applicationUuid = defaultString(component.getMainBranchProjectUuid(), component.branchUuid());
     return hasChildProjectsPermission(permission, applicationUuid);
   }
 
index 80ec73f625715162b31c0c31fddb73746aa889f4..a826f6fdda083b8d5fd9a4a3249731ff94a90264 100644 (file)
@@ -152,7 +152,7 @@ public class ServerUserSession extends AbstractUserSession {
       }
       // if component is part of a branch, then permissions must be
       // checked on the project (represented by its main branch)
-      projectUuid = defaultIfEmpty(component.get().getMainBranchProjectUuid(), component.get().projectUuid());
+      projectUuid = defaultIfEmpty(component.get().getMainBranchProjectUuid(), component.get().branchUuid());
       projectUuidByComponentUuid.put(componentUuid, projectUuid);
       return of(projectUuid);
     }
@@ -294,14 +294,14 @@ public class ServerUserSession extends AbstractUserSession {
   protected List<ComponentDto> doKeepAuthorizedComponents(String permission, Collection<ComponentDto> components) {
     try (DbSession dbSession = dbClient.openSession(false)) {
       Set<String> projectUuids = components.stream()
-        .map(c -> defaultIfEmpty(c.getMainBranchProjectUuid(), c.projectUuid()))
+        .map(c -> defaultIfEmpty(c.getMainBranchProjectUuid(), c.branchUuid()))
         .collect(MoreCollectors.toSet(components.size()));
 
       Map<String, ComponentDto> originalComponents = findComponentsByCopyComponentUuid(components,
           dbSession);
 
       Set<String> originalComponentsProjectUuids = originalComponents.values().stream()
-          .map(c -> defaultIfEmpty(c.getMainBranchProjectUuid(), c.projectUuid()))
+          .map(c -> defaultIfEmpty(c.getMainBranchProjectUuid(), c.branchUuid()))
           .collect(MoreCollectors.toSet(components.size()));
 
       Set<String> allProjectUuids = new HashSet<>(projectUuids);
@@ -313,10 +313,10 @@ public class ServerUserSession extends AbstractUserSession {
         .filter(c -> {
           if (c.getCopyComponentUuid() != null) {
             var componentDto = originalComponents.get(c.getCopyComponentUuid());
-            return componentDto != null && authorizedProjectUuids.contains(defaultIfEmpty(componentDto.getMainBranchProjectUuid(), componentDto.projectUuid()));
+            return componentDto != null && authorizedProjectUuids.contains(defaultIfEmpty(componentDto.getMainBranchProjectUuid(), componentDto.branchUuid()));
           }
 
-          return authorizedProjectUuids.contains(c.projectUuid()) || authorizedProjectUuids.contains(
+          return authorizedProjectUuids.contains(c.branchUuid()) || authorizedProjectUuids.contains(
               c.getMainBranchProjectUuid());
         })
         .collect(MoreCollectors.toList(components.size()));
index f1fc01c2a3c42fc8e7817e3b0b771b5365c1563a..b7fe10de148c153641a46d5db4e399dcd0a7e398 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.user;
 
-import java.util.Arrays;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -125,7 +124,7 @@ public class ThreadLocalUserSessionTest {
       .setGroups(group);
 
     ProjectDto subProjectDto = new ProjectDto().setQualifier(Qualifiers.PROJECT).setUuid("subproject-uuid");
-    ComponentDto applicationAsComponentDto = new ComponentDto().setQualifier(Qualifiers.APP).setUuid("application-component-uuid").setProjectUuid("application-project-uuid");
+    ComponentDto applicationAsComponentDto = new ComponentDto().setQualifier(Qualifiers.APP).setUuid("application-component-uuid").setBranchUuid("application-project-uuid");
     ProjectDto applicationAsProjectDto = new ProjectDto().setQualifier(Qualifiers.APP).setUuid("application-project-uuid");
 
     expected.registerProjects(subProjectDto);
index 43c1b3946485c42810e373b8b74d92a47f4b83ed..c8f3a890239c64b619ce68952e8808fcf08e9159 100644 (file)
@@ -68,8 +68,8 @@ public class TokenUserSessionTest {
 
     TokenUserSession userSession = mockTokenUserSession(user);
 
-    assertThat(userSession.hasProjectUuidPermission(SCAN, project1.projectUuid())).isTrue();
-    assertThat(userSession.hasProjectUuidPermission(SCAN, project2.projectUuid())).isFalse();
+    assertThat(userSession.hasProjectUuidPermission(SCAN, project1.branchUuid())).isTrue();
+    assertThat(userSession.hasProjectUuidPermission(SCAN, project2.branchUuid())).isFalse();
   }
 
   @Test
@@ -84,8 +84,8 @@ public class TokenUserSessionTest {
 
     TokenUserSession userSession = mockProjectAnalysisTokenUserSession(user,project1);
 
-    assertThat(userSession.hasProjectUuidPermission(SCAN, project1.projectUuid())).isTrue();
-    assertThat(userSession.hasProjectUuidPermission(SCAN, project2.projectUuid())).isFalse();
+    assertThat(userSession.hasProjectUuidPermission(SCAN, project1.branchUuid())).isTrue();
+    assertThat(userSession.hasProjectUuidPermission(SCAN, project2.branchUuid())).isFalse();
   }
 
   @Test
@@ -99,8 +99,8 @@ public class TokenUserSessionTest {
 
     TokenUserSession userSession = mockProjectAnalysisTokenUserSession(user,project1);
 
-    assertThat(userSession.hasProjectUuidPermission(SCAN, project1.projectUuid())).isTrue();
-    assertThat(userSession.hasProjectUuidPermission(SCAN, project2.projectUuid())).isFalse();
+    assertThat(userSession.hasProjectUuidPermission(SCAN, project1.branchUuid())).isTrue();
+    assertThat(userSession.hasProjectUuidPermission(SCAN, project2.branchUuid())).isFalse();
   }
 
   @Test
@@ -140,7 +140,7 @@ public class TokenUserSessionTest {
 
     TokenUserSession userSession = mockGlobalAnalysisTokenUserSession(user);
 
-    assertThat(userSession.hasProjectUuidPermission(SCAN, project1.projectUuid())).isFalse();
+    assertThat(userSession.hasProjectUuidPermission(SCAN, project1.branchUuid())).isFalse();
     assertThat(userSession.hasPermission(GlobalPermission.SCAN)).isTrue();
   }
 
@@ -205,7 +205,7 @@ public class TokenUserSessionTest {
     userTokenDto.setUserUuid("userUid");
     userTokenDto.setProjectKey(componentDto.getKey());
     userTokenDto.setProjectName(componentDto.name());
-    userTokenDto.setProjectUuid(componentDto.projectUuid());
+    userTokenDto.setProjectUuid(componentDto.branchUuid());
     return userTokenDto;
   }
 
index ed2cf0c2ac1e6181dfaf79cdb2588392da742d5a..c4ae33eb236a959635e879bac5c7818a90353d41 100644 (file)
@@ -71,13 +71,13 @@ public abstract class AbstractMockUserSession<T extends AbstractMockUserSession>
   public T registerComponents(ComponentDto... components) {
     Arrays.stream(components)
       .forEach(component -> {
-        if (component.projectUuid().equals(component.uuid()) && !component.isPrivate()) {
+        if (component.branchUuid().equals(component.uuid()) && !component.isPrivate()) {
           this.projectUuidByPermission.put(UserRole.USER, component.uuid());
           this.projectUuidByPermission.put(UserRole.CODEVIEWER, component.uuid());
           this.projectPermissions.add(UserRole.USER);
           this.projectPermissions.add(UserRole.CODEVIEWER);
         }
-        this.projectUuidByComponentUuid.put(component.uuid(), component.projectUuid());
+        this.projectUuidByComponentUuid.put(component.uuid(), component.branchUuid());
       });
     return clazz.cast(this);
   }
@@ -156,7 +156,7 @@ public abstract class AbstractMockUserSession<T extends AbstractMockUserSession>
     registerComponents(components);
     this.projectPermissions.add(permission);
     Arrays.stream(components)
-      .forEach(component -> this.projectUuidByPermission.put(permission, component.projectUuid()));
+      .forEach(component -> this.projectUuidByPermission.put(permission, component.branchUuid()));
     return clazz.cast(this);
   }
 
index f85417da4eacee53c675ec0631195a6b016d1e60..debbba64ed17c3e1754a4a173fd4889ce3de075d 100644 (file)
@@ -137,7 +137,7 @@ public class ProjectQGChangeEventListenerTest {
     ComponentDto projectComponentDto = new ComponentDto();
     projectComponentDto.setQualifier("TRK");
     projectComponentDto.setUuid("uuid");
-    when(componentDao.selectByProjectUuid(anyString(), any())).thenReturn(List.of(projectComponentDto));
+    when(componentDao.selectByBranchUuid(anyString(), any())).thenReturn(List.of(projectComponentDto));
 
     underTest.onIssueChanges(qualityGateEvent, Set.of());
 
index 7c8e6d0743ead5a0d1f748f905a1746ce057931a..e1f6d21285edcbef848879388072108305cd1410 100644 (file)
@@ -100,7 +100,7 @@ public class IssueQueryFactory {
     .filter(t -> t != RuleType.SECURITY_HOTSPOT)
     .map(Enum::name)
     .collect(MoreCollectors.toSet(RuleType.values().length - 1));
-  private static final ComponentDto UNKNOWN_COMPONENT = new ComponentDto().setUuid(UNKNOWN).setProjectUuid(UNKNOWN);
+  private static final ComponentDto UNKNOWN_COMPONENT = new ComponentDto().setUuid(UNKNOWN).setBranchUuid(UNKNOWN);
   private static final Set<String> QUALIFIERS_WITHOUT_LEAK_PERIOD = new HashSet<>(Arrays.asList(Qualifiers.APP, Qualifiers.VIEW, Qualifiers.SUBVIEW));
   private final DbClient dbClient;
   private final Clock clock;
@@ -443,11 +443,11 @@ public class IssueQueryFactory {
 
   private static String toProjectUuid(ComponentDto componentDto) {
     String mainBranchProjectUuid = componentDto.getMainBranchProjectUuid();
-    return mainBranchProjectUuid == null ? componentDto.projectUuid() : mainBranchProjectUuid;
+    return mainBranchProjectUuid == null ? componentDto.branchUuid() : mainBranchProjectUuid;
   }
 
   private static void setBranch(IssueQuery.Builder builder, ComponentDto component, @Nullable String branch, @Nullable String pullRequest) {
-    builder.branchUuid(branch == null && pullRequest == null ? null : component.projectUuid());
+    builder.branchUuid(branch == null && pullRequest == null ? null : component.branchUuid());
     builder.mainBranch(UNKNOWN_COMPONENT.equals(component)
       || (branch == null && pullRequest == null)
       || (branch != null && !branch.equals(component.getBranch()))
index 7b9a964a8eef07d36024818dba1fa4fc160771e6..cff63f8fc1a753b2984bbbe2bc82e37d149e5c92 100644 (file)
@@ -46,14 +46,14 @@ public class ComponentIndexFeatureFavoriteTest extends ComponentIndexTest {
     SuggestionQuery query1 = SuggestionQuery.builder()
       .setQuery("SonarQube")
       .setQualifiers(singletonList(PROJECT))
-      .setFavoriteKeys(of(project1.getDbKey()))
+      .setFavoriteKeys(of(project1.getKey()))
       .build();
     assertSearch(query1).containsExactly(uuids(project1, project2));
 
     SuggestionQuery query2 = SuggestionQuery.builder()
       .setQuery("SonarQube")
       .setQualifiers(singletonList(PROJECT))
-      .setFavoriteKeys(of(project2.getDbKey()))
+      .setFavoriteKeys(of(project2.getKey()))
       .build();
     assertSearch(query2).containsExactly(uuids(project2, project1));
   }
@@ -66,7 +66,7 @@ public class ComponentIndexFeatureFavoriteTest extends ComponentIndexTest {
     SuggestionQuery query1 = SuggestionQuery.builder()
       .setQuery("bar")
       .setQualifiers(singletonList(PROJECT))
-      .setFavoriteKeys(of(project1.getDbKey()))
+      .setFavoriteKeys(of(project1.getKey()))
       .build();
     assertSearch(query1).isEmpty();
   }
index d83901560b63caf467ce9fda8226140d351394fe..40567a496b28264afaf1b465f380e0ce35a0ed7c 100644 (file)
@@ -44,14 +44,14 @@ public class ComponentIndexFeatureRecentlyBrowsedTest extends ComponentIndexTest
     SuggestionQuery query1 = SuggestionQuery.builder()
       .setQuery("SonarQube")
       .setQualifiers(Collections.singletonList(PROJECT))
-      .setRecentlyBrowsedKeys(of(project1.getDbKey()))
+      .setRecentlyBrowsedKeys(of(project1.getKey()))
       .build();
     assertSearch(query1).containsExactly(uuids(project1, project2));
 
     SuggestionQuery query2 = SuggestionQuery.builder()
       .setQuery("SonarQube")
       .setQualifiers(Collections.singletonList(PROJECT))
-      .setRecentlyBrowsedKeys(of(project2.getDbKey()))
+      .setRecentlyBrowsedKeys(of(project2.getKey()))
       .build();
     assertSearch(query2).containsExactly(uuids(project2, project1));
   }
index 3fbf4f34622748a00a6c7886fe568f74e088990a..145a4eab0c450a3bb17e4aabba62271a182a5227 100644 (file)
@@ -122,15 +122,15 @@ public class ComponentIndexScoreTest extends ComponentIndexTest {
     assertSearch(SuggestionQuery.builder()
       .setQuery("File")
       .setQualifiers(asList(PROJECT, MODULE, FILE))
-      .setRecentlyBrowsedKeys(ImmutableSet.of(file1.getDbKey()))
-      .setFavoriteKeys(ImmutableSet.of(file2.getDbKey()))
+      .setRecentlyBrowsedKeys(ImmutableSet.of(file1.getKey()))
+      .setFavoriteKeys(ImmutableSet.of(file2.getKey()))
       .build()).containsExactly(uuids(file2, file1));
 
     assertSearch(SuggestionQuery.builder()
       .setQuery("File")
       .setQualifiers(asList(PROJECT, MODULE, FILE))
-      .setRecentlyBrowsedKeys(ImmutableSet.of(file2.getDbKey()))
-      .setFavoriteKeys(ImmutableSet.of(file1.getDbKey()))
+      .setRecentlyBrowsedKeys(ImmutableSet.of(file2.getKey()))
+      .setFavoriteKeys(ImmutableSet.of(file1.getKey()))
       .build()).containsExactly(uuids(file1, file2));
   }
 
@@ -161,12 +161,12 @@ public class ComponentIndexScoreTest extends ComponentIndexTest {
 
     index(ComponentTesting.newFileDto(project)
       .setName("DbTester.java")
-      .setDbKey("java/org/example/DbTester.java")
+      .setKey("java/org/example/DbTester.java")
       .setUuid("UUID-DbTester"));
 
     index(ComponentTesting.newFileDto(project)
       .setName("WebhookDbTesting.java")
-      .setDbKey("java/org/example/WebhookDbTesting.java")
+      .setKey("java/org/example/WebhookDbTesting.java")
       .setUuid("UUID-WebhookDbTesting"));
 
     assertSearch("dbt").containsExactly(
index 9d15fe3a1565990d09b661552927b0e3a4b9d3b0..97ff35bad87565e5167e55259091effbfa439142 100644 (file)
@@ -67,9 +67,9 @@ public class ComponentIndexSearchTest {
 
   @Test
   public void filter_by_key_with_exact_match() {
-    ComponentDto ignoredProject = db.components().insertPrivateProject(p -> p.setDbKey("ignored-project"));
-    ComponentDto project = db.components().insertPrivateProject(p -> p.setDbKey("shiny-project"));
-    db.components().insertPrivateProject(p -> p.setDbKey("another-shiny-project"));
+    ComponentDto ignoredProject = db.components().insertPrivateProject(p -> p.setKey("ignored-project"));
+    ComponentDto project = db.components().insertPrivateProject(p -> p.setKey("shiny-project"));
+    db.components().insertPrivateProject(p -> p.setKey("another-shiny-project"));
     index(ignoredProject, project);
 
     SearchIdResult<String> result = underTest.search(ComponentQuery.builder().setQuery("shiny-project").build(), new SearchOptions());
index a1fac9fd57451d9ed89c5870d830393ee4be20bf..15681c4da4bed076119b0a496d28033602b97bfd 100644 (file)
@@ -65,7 +65,7 @@ public class ComponentIndexSearchWindowExceededTest {
       .setId(componentDoc.uuid())
       .setKey(componentDoc.getKey())
       .setName(componentDoc.name())
-      .setProjectUuid(componentDoc.projectUuid())
+      .setProjectUuid(componentDoc.branchUuid())
       .setQualifier(componentDoc.qualifier());
   }
 }
index c9ab8e5a55c8b96fed892aabe007d11e1213a855..06d683bd1b5f2b304aeebe82336e1cb200c2b07b 100644 (file)
@@ -114,13 +114,13 @@ public abstract class ComponentIndexTest {
   protected ComponentDto indexProject(String key, String name) {
     return index(
       ComponentTesting.newPrivateProjectDto("UUID_" + key)
-        .setDbKey(key)
+        .setKey(key)
         .setName(name));
   }
 
   protected ComponentDto newProject(String key, String name) {
     return ComponentTesting.newPrivateProjectDto("UUID_" + key)
-      .setDbKey(key)
+      .setKey(key)
       .setName(name);
   }
 
@@ -132,7 +132,7 @@ public abstract class ComponentIndexTest {
   protected ComponentDto indexFile(ComponentDto project, String fileKey, String fileName) {
     return index(
       ComponentTesting.newFileDto(project)
-        .setDbKey(fileKey)
+        .setKey(fileKey)
         .setName(fileName));
   }
 
index 9ec67e24fb9bf4270f3f3b7ea2579a725ff78bc7..0a2f76b18c5aa4f6c588138f7f770306306e3455 100644 (file)
@@ -330,14 +330,14 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon {
 
   @Test
   public void filter_by_application_branch_having_project_branches() {
-    ComponentDto application = db.components().insertPublicProject(c -> c.setQualifier(APP).setDbKey("app"));
+    ComponentDto application = db.components().insertPublicProject(c -> c.setQualifier(APP).setKey("app"));
     ComponentDto applicationBranch1 = db.components().insertProjectBranch(application, a -> a.setKey("app-branch1"));
     ComponentDto applicationBranch2 = db.components().insertProjectBranch(application, a -> a.setKey("app-branch2"));
-    ComponentDto project1 = db.components().insertPrivateProject(p -> p.setDbKey("prj1"));
+    ComponentDto project1 = db.components().insertPrivateProject(p -> p.setKey("prj1"));
     ComponentDto project1Branch1 = db.components().insertProjectBranch(project1);
     ComponentDto fileOnProject1Branch1 = db.components().insertComponent(newFileDto(project1Branch1));
     ComponentDto project1Branch2 = db.components().insertProjectBranch(project1);
-    ComponentDto project2 = db.components().insertPrivateProject(p -> p.setDbKey("prj2"));
+    ComponentDto project2 = db.components().insertPrivateProject(p -> p.setKey("prj2"));
     indexView(applicationBranch1.uuid(), asList(project1Branch1.uuid(), project2.uuid()));
     indexView(applicationBranch2.uuid(), singletonList(project1Branch2.uuid()));
 
index 1bbc1bcc053c71f3bf14f1b5f32c54748af64d71..aa60a57c2b9d780fcc3369ab412e1ecbd0928668 100644 (file)
@@ -262,7 +262,7 @@ public class IssueIndexSyncProgressCheckerTest {
     ComponentDto subview = db.components().insertSubView(view);
 
     DbSession session = db.getSession();
-    List<String> appViewOrSubviewKeys = Arrays.asList(projectDto1.getKey(), app.getDbKey(), view.getDbKey(), subview.getDbKey());
+    List<String> appViewOrSubviewKeys = Arrays.asList(projectDto1.getKey(), app.getKey(), view.getKey(), subview.getKey());
 
     // throws if flag set to TRUE
     assertThatThrownBy(() -> underTest.checkIfAnyComponentsNeedIssueSync(session,
index e62a4b6352862999eda43dc9806e72dabbe0735f..4d26ed316be46dc6369d36bc9313e18bae301df6 100644 (file)
@@ -218,7 +218,7 @@ public class IssueIndexTest extends IssueIndexTestCommon {
 
     userSessionRule.logIn(user1);
     assertThatSearchReturnsOnly(IssueQuery.builder(), "I1");
-    assertThatSearchReturnsEmpty(IssueQuery.builder().projectUuids(singletonList(project3.getDbKey())));
+    assertThatSearchReturnsEmpty(IssueQuery.builder().projectUuids(singletonList(project3.getKey())));
 
     userSessionRule.logIn(user2);
     assertThatSearchReturnsOnly(IssueQuery.builder(), "I2");
index 772d49480d137b1957dd255f058245c506eebff2..3bb7a74ca8a2faa9a1b21d9f37ac3bd038d34d96 100644 (file)
@@ -92,7 +92,7 @@ public class IssueQueryFactoryTest {
       .setStatuses(asList("CLOSED"))
       .setResolutions(asList("FALSE-POSITIVE"))
       .setResolved(true)
-      .setProjects(asList(project.getDbKey()))
+      .setProjects(asList(project.getKey()))
       .setDirectories(asList("aDirPath"))
       .setFiles(asList(file.uuid()))
       .setAssigneesUuid(asList(user.getUuid()))
@@ -479,7 +479,7 @@ public class IssueQueryFactoryTest {
   public void onComponentOnly_restricts_search_to_specified_componentKeys() {
     ComponentDto project = db.components().insertPrivateProject();
     SearchRequest request = new SearchRequest()
-      .setComponents(asList(project.getDbKey()))
+      .setComponents(asList(project.getKey()))
       .setOnComponentOnly(true);
 
     IssueQuery query = underTest.create(request);
@@ -633,14 +633,14 @@ public class IssueQueryFactoryTest {
 
   @Test
   public void search_by_application_key_and_branch() {
-    ComponentDto application = db.components().insertPublicProject(c -> c.setQualifier(APP).setDbKey("app"));
+    ComponentDto application = db.components().insertPublicProject(c -> c.setQualifier(APP).setKey("app"));
     ComponentDto applicationBranch1 = db.components().insertProjectBranch(application, a -> a.setKey("app-branch1"));
     ComponentDto applicationBranch2 = db.components().insertProjectBranch(application, a -> a.setKey("app-branch2"));
-    ComponentDto project1 = db.components().insertPrivateProject(p -> p.setDbKey("prj1"));
+    ComponentDto project1 = db.components().insertPrivateProject(p -> p.setKey("prj1"));
     ComponentDto project1Branch1 = db.components().insertProjectBranch(project1);
     ComponentDto fileOnProject1Branch1 = db.components().insertComponent(newFileDto(project1Branch1));
     ComponentDto project1Branch2 = db.components().insertProjectBranch(project1);
-    ComponentDto project2 = db.components().insertPrivateProject(p -> p.setDbKey("prj2"));
+    ComponentDto project2 = db.components().insertPrivateProject(p -> p.setKey("prj2"));
     db.components().insertComponents(newProjectCopy(project1Branch1, applicationBranch1));
     db.components().insertComponents(newProjectCopy(project2, applicationBranch1));
     db.components().insertComponents(newProjectCopy(project1Branch2, applicationBranch2));
index 29c231ab8a35b9cb0251450bd572a04ae75c2c42..cc5497e54ab736c32fed88f2cfe0c30557cbd6c4 100644 (file)
@@ -93,12 +93,12 @@ public class ProjectMeasuresIndexTest {
   private static final String NEW_LINES = "new_lines";
   private static final String LANGUAGES = "languages";
 
-  private static final ComponentDto PROJECT1 = ComponentTesting.newPrivateProjectDto().setUuid("Project-1").setName("Project 1").setDbKey("key-1");
-  private static final ComponentDto PROJECT2 = ComponentTesting.newPrivateProjectDto().setUuid("Project-2").setName("Project 2").setDbKey("key-2");
-  private static final ComponentDto PROJECT3 = ComponentTesting.newPrivateProjectDto().setUuid("Project-3").setName("Project 3").setDbKey("key-3");
-  private static final ComponentDto APP1 = ComponentTesting.newApplication().setUuid("App-1").setName("App 1").setDbKey("app-key-1");
-  private static final ComponentDto APP2 = ComponentTesting.newApplication().setUuid("App-2").setName("App 2").setDbKey("app-key-2");
-  private static final ComponentDto APP3 = ComponentTesting.newApplication().setUuid("App-3").setName("App 3").setDbKey("app-key-3");
+  private static final ComponentDto PROJECT1 = ComponentTesting.newPrivateProjectDto().setUuid("Project-1").setName("Project 1").setKey("key-1");
+  private static final ComponentDto PROJECT2 = ComponentTesting.newPrivateProjectDto().setUuid("Project-2").setName("Project 2").setKey("key-2");
+  private static final ComponentDto PROJECT3 = ComponentTesting.newPrivateProjectDto().setUuid("Project-3").setName("Project 3").setKey("key-3");
+  private static final ComponentDto APP1 = ComponentTesting.newApplication().setUuid("App-1").setName("App 1").setKey("app-key-1");
+  private static final ComponentDto APP2 = ComponentTesting.newApplication().setUuid("App-2").setName("App 2").setKey("app-key-2");
+  private static final ComponentDto APP3 = ComponentTesting.newApplication().setUuid("App-3").setName("App 3").setKey("app-key-3");
   private static final UserDto USER1 = newUserDto();
   private static final UserDto USER2 = newUserDto();
   private static final GroupDto GROUP1 = newGroupDto();
@@ -126,10 +126,10 @@ public class ProjectMeasuresIndexTest {
 
   @Test
   public void default_sort_is_by_ascending_case_insensitive_name_then_by_key() {
-    ComponentDto windows = ComponentTesting.newPrivateProjectDto().setUuid("windows").setName("Windows").setDbKey("project1");
-    ComponentDto apachee = ComponentTesting.newPrivateProjectDto().setUuid("apachee").setName("apachee").setDbKey("project2");
-    ComponentDto apache1 = ComponentTesting.newPrivateProjectDto().setUuid("apache-1").setName("Apache").setDbKey("project3");
-    ComponentDto apache2 = ComponentTesting.newPrivateProjectDto().setUuid("apache-2").setName("Apache").setDbKey("project4");
+    ComponentDto windows = ComponentTesting.newPrivateProjectDto().setUuid("windows").setName("Windows").setKey("project1");
+    ComponentDto apachee = ComponentTesting.newPrivateProjectDto().setUuid("apachee").setName("apachee").setKey("project2");
+    ComponentDto apache1 = ComponentTesting.newPrivateProjectDto().setUuid("apache-1").setName("Apache").setKey("project3");
+    ComponentDto apache2 = ComponentTesting.newPrivateProjectDto().setUuid("apache-2").setName("Apache").setKey("project4");
     index(newDoc(windows), newDoc(apachee), newDoc(apache1), newDoc(apache2));
 
     assertResults(new ProjectMeasuresQuery(), apache1, apache2, apachee, windows);
@@ -159,10 +159,10 @@ public class ProjectMeasuresIndexTest {
 
   @Test
   public void sort_by_a_metric_then_by_name_then_by_key() {
-    ComponentDto windows = ComponentTesting.newPrivateProjectDto().setUuid("windows").setName("Windows").setDbKey("project1");
-    ComponentDto apachee = ComponentTesting.newPrivateProjectDto().setUuid("apachee").setName("apachee").setDbKey("project2");
-    ComponentDto apache1 = ComponentTesting.newPrivateProjectDto().setUuid("apache-1").setName("Apache").setDbKey("project3");
-    ComponentDto apache2 = ComponentTesting.newPrivateProjectDto().setUuid("apache-2").setName("Apache").setDbKey("project4");
+    ComponentDto windows = ComponentTesting.newPrivateProjectDto().setUuid("windows").setName("Windows").setKey("project1");
+    ComponentDto apachee = ComponentTesting.newPrivateProjectDto().setUuid("apachee").setName("apachee").setKey("project2");
+    ComponentDto apache1 = ComponentTesting.newPrivateProjectDto().setUuid("apache-1").setName("Apache").setKey("project3");
+    ComponentDto apache2 = ComponentTesting.newPrivateProjectDto().setUuid("apache-2").setName("Apache").setKey("project4");
     index(
       newDoc(windows, NCLOC, 10_000d),
       newDoc(apachee, NCLOC, 5_000d),
@@ -175,7 +175,7 @@ public class ProjectMeasuresIndexTest {
 
   @Test
   public void sort_by_quality_gate_status() {
-    ComponentDto project4 = ComponentTesting.newPrivateProjectDto().setUuid("Project-4").setName("Project 4").setDbKey("key-4");
+    ComponentDto project4 = ComponentTesting.newPrivateProjectDto().setUuid("Project-4").setName("Project 4").setKey("key-4");
     index(
       newDoc(PROJECT1).setQualityGateStatus(OK.name()),
       newDoc(PROJECT2).setQualityGateStatus(ERROR.name()),
@@ -187,10 +187,10 @@ public class ProjectMeasuresIndexTest {
 
   @Test
   public void sort_by_quality_gate_status_then_by_name_then_by_key() {
-    ComponentDto windows = ComponentTesting.newPrivateProjectDto().setUuid("windows").setName("Windows").setDbKey("project1");
-    ComponentDto apachee = ComponentTesting.newPrivateProjectDto().setUuid("apachee").setName("apachee").setDbKey("project2");
-    ComponentDto apache1 = ComponentTesting.newPrivateProjectDto().setUuid("apache-1").setName("Apache").setDbKey("project3");
-    ComponentDto apache2 = ComponentTesting.newPrivateProjectDto().setUuid("apache-2").setName("Apache").setDbKey("project4");
+    ComponentDto windows = ComponentTesting.newPrivateProjectDto().setUuid("windows").setName("Windows").setKey("project1");
+    ComponentDto apachee = ComponentTesting.newPrivateProjectDto().setUuid("apachee").setName("apachee").setKey("project2");
+    ComponentDto apache1 = ComponentTesting.newPrivateProjectDto().setUuid("apache-1").setName("Apache").setKey("project3");
+    ComponentDto apache2 = ComponentTesting.newPrivateProjectDto().setUuid("apache-2").setName("Apache").setKey("project4");
     index(
       newDoc(windows).setQualityGateStatus(ERROR.name()),
       newDoc(apachee).setQualityGateStatus(OK.name()),
@@ -422,7 +422,7 @@ public class ProjectMeasuresIndexTest {
 
   @Test
   public void filter_on_languages() {
-    ComponentDto project4 = ComponentTesting.newPrivateProjectDto().setUuid("Project-4").setName("Project 4").setDbKey("key-4");
+    ComponentDto project4 = ComponentTesting.newPrivateProjectDto().setUuid("Project-4").setName("Project 4").setKey("key-4");
     index(
       newDoc(PROJECT1).setLanguages(singletonList("java")),
       newDoc(PROJECT2).setLanguages(singletonList("xoo")),
@@ -436,10 +436,10 @@ public class ProjectMeasuresIndexTest {
 
   @Test
   public void filter_on_query_text() {
-    ComponentDto windows = ComponentTesting.newPrivateProjectDto().setUuid("windows").setName("Windows").setDbKey("project1");
-    ComponentDto apachee = ComponentTesting.newPrivateProjectDto().setUuid("apachee").setName("apachee").setDbKey("project2");
-    ComponentDto apache1 = ComponentTesting.newPrivateProjectDto().setUuid("apache-1").setName("Apache").setDbKey("project3");
-    ComponentDto apache2 = ComponentTesting.newPrivateProjectDto().setUuid("apache-2").setName("Apache").setDbKey("project4");
+    ComponentDto windows = ComponentTesting.newPrivateProjectDto().setUuid("windows").setName("Windows").setKey("project1");
+    ComponentDto apachee = ComponentTesting.newPrivateProjectDto().setUuid("apachee").setName("apachee").setKey("project2");
+    ComponentDto apache1 = ComponentTesting.newPrivateProjectDto().setUuid("apache-1").setName("Apache").setKey("project3");
+    ComponentDto apache2 = ComponentTesting.newPrivateProjectDto().setUuid("apache-2").setName("Apache").setKey("project4");
     index(newDoc(windows), newDoc(apachee), newDoc(apache1), newDoc(apache2));
 
     assertResults(new ProjectMeasuresQuery().setQueryText("windows"), windows);
@@ -1736,7 +1736,7 @@ public class ProjectMeasuresIndexTest {
   private static ProjectMeasuresDoc newDoc(ComponentDto project) {
     return new ProjectMeasuresDoc()
       .setId(project.uuid())
-      .setKey(project.getDbKey())
+      .setKey(project.getKey())
       .setName(project.name())
       .setQualifier(project.qualifier());
   }
index 56d1732dec60a514242b2c82a0f12b578103b860..b8885dcf6d158c15c118dc0e3cd6c5bc76593029 100644 (file)
@@ -63,8 +63,8 @@ public class ProjectMeasuresIndexTextSearchTest {
   @Test
   public void search_partial_text_from_project_key() {
     index(
-      newDoc(newPrivateProjectDto().setUuid("struts").setName("Apache Struts").setDbKey("org.apache.commons.structs")),
-      newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setDbKey("org.sonar.sonarqube")));
+      newDoc(newPrivateProjectDto().setUuid("struts").setName("Apache Struts").setKey("org.apache.commons.structs")),
+      newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setKey("org.sonar.sonarqube")));
 
     assertTextQueryResults("apache", "struts");
     assertTextQueryResults("apache.comm", "struts");
@@ -196,8 +196,8 @@ public class ProjectMeasuresIndexTextSearchTest {
   @Test
   public void match_exact_case_insensitive_key() {
     index(
-      newDoc(newPrivateProjectDto().setUuid("project1").setName("Windows").setDbKey("project1")),
-      newDoc(newPrivateProjectDto().setUuid("project2").setName("apachee").setDbKey("project2")));
+      newDoc(newPrivateProjectDto().setUuid("project1").setName("Windows").setKey("project1")),
+      newDoc(newPrivateProjectDto().setUuid("project2").setName("apachee").setKey("project2")));
 
     assertTextQueryResults("project1", "project1");
     assertTextQueryResults("PROJECT1", "project1");
@@ -207,8 +207,8 @@ public class ProjectMeasuresIndexTextSearchTest {
   @Test
   public void match_key_with_dot() {
     index(
-      newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setDbKey("org.sonarqube")),
-      newDoc(newPrivateProjectDto().setUuid("sq").setName("SQ").setDbKey("sonarqube")));
+      newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setKey("org.sonarqube")),
+      newDoc(newPrivateProjectDto().setUuid("sq").setName("SQ").setKey("sonarqube")));
 
     assertTextQueryResults("org.sonarqube", "sonarqube");
     assertNoResults("orgsonarqube");
@@ -220,8 +220,8 @@ public class ProjectMeasuresIndexTextSearchTest {
   @Test
   public void match_key_with_dash() {
     index(
-      newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setDbKey("org-sonarqube")),
-      newDoc(newPrivateProjectDto().setUuid("sq").setName("SQ").setDbKey("sonarqube")));
+      newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setKey("org-sonarqube")),
+      newDoc(newPrivateProjectDto().setUuid("sq").setName("SQ").setKey("sonarqube")));
 
     assertTextQueryResults("org-sonarqube", "sonarqube");
     assertNoResults("orgsonarqube");
@@ -233,8 +233,8 @@ public class ProjectMeasuresIndexTextSearchTest {
   @Test
   public void match_key_with_colon() {
     index(
-      newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setDbKey("org:sonarqube")),
-      newDoc(newPrivateProjectDto().setUuid("sq").setName("SQ").setDbKey("sonarqube")));
+      newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setKey("org:sonarqube")),
+      newDoc(newPrivateProjectDto().setUuid("sq").setName("SQ").setKey("sonarqube")));
 
     assertTextQueryResults("org:sonarqube", "sonarqube");
     assertNoResults("orgsonarqube");
@@ -245,7 +245,7 @@ public class ProjectMeasuresIndexTextSearchTest {
 
   @Test
   public void match_key_having_all_special_characters() {
-    index(newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setDbKey("org.sonarqube:sonar-sérvèr_ç")));
+    index(newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setKey("org.sonarqube:sonar-sérvèr_ç")));
 
     assertTextQueryResults("org.sonarqube:sonar-sérvèr_ç", "sonarqube");
   }
@@ -254,12 +254,12 @@ public class ProjectMeasuresIndexTextSearchTest {
   public void facets_take_into_account_text_search() {
     index(
       // docs with ncloc<1K
-      newDoc(newPrivateProjectDto().setName("Windows").setDbKey("project1"), NCLOC, 0d),
-      newDoc(newPrivateProjectDto().setName("apachee").setDbKey("project2"), NCLOC, 999d),
+      newDoc(newPrivateProjectDto().setName("Windows").setKey("project1"), NCLOC, 0d),
+      newDoc(newPrivateProjectDto().setName("apachee").setKey("project2"), NCLOC, 999d),
       // docs with ncloc>=1K and ncloc<10K
-      newDoc(newPrivateProjectDto().setName("Apache").setDbKey("project3"), NCLOC, 1_000d),
+      newDoc(newPrivateProjectDto().setName("Apache").setKey("project3"), NCLOC, 1_000d),
       // docs with ncloc>=100K and ncloc<500K
-      newDoc(newPrivateProjectDto().setName("Apache Foundation").setDbKey("project4"), NCLOC, 100_000d));
+      newDoc(newPrivateProjectDto().setName("Apache Foundation").setKey("project4"), NCLOC, 100_000d));
 
     assertNclocFacet(new ProjectMeasuresQuery().setQueryText("apache"), 1L, 1L, 0L, 1L, 0L);
     assertNclocFacet(new ProjectMeasuresQuery().setQueryText("PAch"), 1L, 1L, 0L, 1L, 0L);
@@ -271,10 +271,10 @@ public class ProjectMeasuresIndexTextSearchTest {
   @Test
   public void filter_by_metric_take_into_account_text_search() {
     index(
-      newDoc(newPrivateProjectDto().setUuid("project1").setName("Windows").setDbKey("project1"), NCLOC, 30_000d),
-      newDoc(newPrivateProjectDto().setUuid("project2").setName("apachee").setDbKey("project2"), NCLOC, 40_000d),
-      newDoc(newPrivateProjectDto().setUuid("project3").setName("Apache").setDbKey("project3"), NCLOC, 50_000d),
-      newDoc(newPrivateProjectDto().setUuid("project4").setName("Apache").setDbKey("project4"), NCLOC, 60_000d));
+      newDoc(newPrivateProjectDto().setUuid("project1").setName("Windows").setKey("project1"), NCLOC, 30_000d),
+      newDoc(newPrivateProjectDto().setUuid("project2").setName("apachee").setKey("project2"), NCLOC, 40_000d),
+      newDoc(newPrivateProjectDto().setUuid("project3").setName("Apache").setKey("project3"), NCLOC, 50_000d),
+      newDoc(newPrivateProjectDto().setUuid("project4").setName("Apache").setKey("project4"), NCLOC, 60_000d));
 
     assertResults(new ProjectMeasuresQuery().setQueryText("apache").addMetricCriterion(MetricCriterion.create(NCLOC, GT, 20_000d)), "project3", "project4", "project2");
     assertResults(new ProjectMeasuresQuery().setQueryText("apache").addMetricCriterion(MetricCriterion.create(NCLOC, LT, 55_000d)), "project3", "project2");
@@ -291,7 +291,7 @@ public class ProjectMeasuresIndexTextSearchTest {
   private static ProjectMeasuresDoc newDoc(ComponentDto project) {
     return new ProjectMeasuresDoc()
       .setId(project.uuid())
-      .setKey(project.getDbKey())
+      .setKey(project.getKey())
       .setName(project.name())
       .setQualifier(project.qualifier());
   }
index 5530f3e8a33e0fd81a066b3f5b7a9dc9249f24cc..bfcee9972ad631a3e767a48211c2e7890a0fb44e 100644 (file)
@@ -54,7 +54,7 @@ public class RecentTasksDurationTaskTest {
     when(dbClient.ceActivityDao()).thenReturn(ceActivityDao);
     when(dbClient.componentDao()).thenReturn(componentDao);
     ComponentDto componentDto = new ComponentDto();
-    componentDto.setDbKey("key");
+    componentDto.setKey("key");
   }
 
   @Test
@@ -116,7 +116,7 @@ public class RecentTasksDurationTaskTest {
     for(int i=0; i<5; i++) {
       ComponentDto component = new ComponentDto();
       component.setUuid(i + "");
-      component.setDbKey(i + "");
+      component.setKey(i + "");
       componentDtos.add(component);
     }
     return componentDtos;
index 2e0e7f9b2236c08111d76a65b69ad55221a989f4..b73efa13e763d79e651bba946c59aad1b8aa4094 100644 (file)
@@ -106,7 +106,7 @@ public class IssueChangeEventServiceImpl implements IssueChangeEventService {
       IssueChangedEvent event = getIssueChangedEvent(projectKey, issuesInProject, issueChanges);
 
       if (event != null) {
-        persistEvent(event, entry.getValue().projectUuid());
+        persistEvent(event, entry.getValue().branchUuid());
       }
     }
   }
index 4fd9b9626d27605d69f3514b917287b429085cc8..e171ae1c4f028595269ca9e23bc0ec4a86e15bb9 100644 (file)
@@ -143,13 +143,13 @@ public class IssueChangeEventServiceImplTest {
 
     Set<DefaultIssue> issues = Set.of(defaultIssue1, defaultIssue2, issue3.toDefaultIssue());
     Map<String, ComponentDto> projectsByUuid = new HashMap<>();
-    projectsByUuid.put(componentDto1.projectUuid(), componentDto1);
-    projectsByUuid.put(componentDto2.projectUuid(), componentDto2);
-    projectsByUuid.put(componentDto3.projectUuid(), componentDto3);
+    projectsByUuid.put(componentDto1.branchUuid(), componentDto1);
+    projectsByUuid.put(componentDto2.branchUuid(), componentDto2);
+    projectsByUuid.put(componentDto3.branchUuid(), componentDto3);
     Map<String, BranchDto> branchesByProjectUuid = new HashMap<>();
-    branchesByProjectUuid.put(componentDto1.projectUuid(), branch1);
-    branchesByProjectUuid.put(componentDto2.projectUuid(), branch2);
-    branchesByProjectUuid.put(componentDto3.projectUuid(), branch3);
+    branchesByProjectUuid.put(componentDto1.branchUuid(), branch1);
+    branchesByProjectUuid.put(componentDto2.branchUuid(), branch2);
+    branchesByProjectUuid.put(componentDto3.branchUuid(), branch3);
 
     underTest.distributeIssueChangeEvent(issues, projectsByUuid, branchesByProjectUuid);
 
@@ -203,9 +203,9 @@ public class IssueChangeEventServiceImplTest {
 
     Set<DefaultIssue> issues = Set.of(defaultIssue1);
     Map<String, ComponentDto> projectsByUuid = new HashMap<>();
-    projectsByUuid.put(project.projectUuid(), project);
+    projectsByUuid.put(project.branchUuid(), project);
     Map<String, BranchDto> branchesByProjectUuid = new HashMap<>();
-    branchesByProjectUuid.put(project.projectUuid(), branch1);
+    branchesByProjectUuid.put(project.branchUuid(), branch1);
 
     underTest.distributeIssueChangeEvent(issues, projectsByUuid, branchesByProjectUuid);
 
index 3d37158da910a55126e1afc5469a9078508864a8..e5f979e7ee1cbc129e865a778c37fea5ac44c599 100644 (file)
@@ -66,7 +66,7 @@ public class ImportHelper {
   public static CreateWsResponse toCreateResponse(ComponentDto componentDto) {
     return newBuilder()
       .setProject(Project.newBuilder()
-        .setKey(componentDto.getDbKey())
+        .setKey(componentDto.getKey())
         .setName(componentDto.name())
         .setQualifier(componentDto.qualifier())
         .setVisibility(Visibility.getLabel(componentDto.isPrivate())))
index 138ecb89723a79ab40997ce82ed135f2b9b70a4b..3e702a0d74cdf1b58d1d5c9e98df12846d4d1531 100644 (file)
@@ -123,7 +123,7 @@ public class ImportGitLabProjectAction implements AlmIntegrationsWsAction {
 
   private void populateMRSetting(DbSession dbSession, Long gitlabProjectId, ComponentDto componentDto, AlmSettingDto almSettingDto) {
     dbClient.projectAlmSettingDao().insertOrUpdate(dbSession, new ProjectAlmSettingDto()
-        .setProjectUuid(componentDto.projectUuid())
+        .setProjectUuid(componentDto.branchUuid())
         .setAlmSettingUuid(almSettingDto.getUuid())
         .setAlmRepo(gitlabProjectId.toString())
         .setAlmSlug(null)
index af8e1b3e547005bf15f71781bb0c0f51e062bef1..9a98d40e96864742842d996b92f0bd43ba0ce288 100644 (file)
@@ -47,7 +47,7 @@ public class BranchSupport {
 
   ComponentKey createComponentKey(String projectKey, Map<String, String> characteristics) {
     if (characteristics.isEmpty()) {
-      return new ComponentKeyImpl(projectKey, projectKey);
+      return new ComponentKeyImpl(projectKey);
     } else {
       checkState(delegate != null, "Current edition does not support branch feature");
     }
@@ -55,8 +55,7 @@ public class BranchSupport {
     return delegate.createComponentKey(projectKey, characteristics);
   }
 
-  ComponentDto createBranchComponent(DbSession dbSession, ComponentKey componentKey,
-    ComponentDto mainComponentDto, BranchDto mainComponentBranchDto) {
+  ComponentDto createBranchComponent(DbSession dbSession, ComponentKey componentKey, ComponentDto mainComponentDto, BranchDto mainComponentBranchDto) {
     checkState(delegate != null, "Current edition does not support branch feature");
 
     return delegate.createBranchComponent(dbSession, componentKey, mainComponentDto, mainComponentBranchDto);
@@ -65,8 +64,6 @@ public class BranchSupport {
   public abstract static class ComponentKey {
     public abstract String getKey();
 
-    public abstract String getDbKey();
-
     public abstract Optional<String> getBranchName();
 
     public abstract Optional<String> getPullRequestKey();
@@ -74,20 +71,13 @@ public class BranchSupport {
     public final boolean isMainBranch() {
       return !getBranchName().isPresent() && !getPullRequestKey().isPresent();
     }
-
-    /**
-     * @return the {@link ComponentKey} of the main branch for this component.
-     */
-    public abstract ComponentKey getMainBranchComponentKey();
   }
 
   private static final class ComponentKeyImpl extends ComponentKey {
     private final String key;
-    private final String dbKey;
 
-    public ComponentKeyImpl(String key, String dbKey) {
+    public ComponentKeyImpl(String key) {
       this.key = key;
-      this.dbKey = dbKey;
     }
 
     @Override
@@ -95,11 +85,6 @@ public class BranchSupport {
       return key;
     }
 
-    @Override
-    public String getDbKey() {
-      return dbKey;
-    }
-
     @Override
     public Optional<String> getBranchName() {
       return Optional.empty();
@@ -110,11 +95,6 @@ public class BranchSupport {
       return Optional.empty();
     }
 
-    @Override
-    public ComponentKey getMainBranchComponentKey() {
-      return this;
-    }
-
     @Override
     public boolean equals(Object o) {
       if (this == o) {
@@ -124,13 +104,12 @@ public class BranchSupport {
         return false;
       }
       ComponentKeyImpl that = (ComponentKeyImpl) o;
-      return Objects.equals(key, that.key) &&
-        Objects.equals(dbKey, that.dbKey);
+      return Objects.equals(key, that.key);
     }
 
     @Override
     public int hashCode() {
-      return Objects.hash(key, dbKey);
+      return Objects.hash(key);
     }
   }
 }
index 8e43f7fd803a396d9442034744313a6f0c64c06b..7e42450ec13c3b04e3ac2669956a76f85e0e8672 100644 (file)
@@ -63,8 +63,7 @@ public class ReportSubmitter {
   private final ProjectDefaultVisibility projectDefaultVisibility;
 
   public ReportSubmitter(CeQueue queue, UserSession userSession, ComponentUpdater componentUpdater,
-    PermissionTemplateService permissionTemplateService, DbClient dbClient, BranchSupport branchSupport,
-    ProjectDefaultVisibility projectDefaultVisibility) {
+    PermissionTemplateService permissionTemplateService, DbClient dbClient, BranchSupport branchSupport, ProjectDefaultVisibility projectDefaultVisibility) {
     this.queue = queue;
     this.userSession = userSession;
     this.componentUpdater = componentUpdater;
@@ -87,17 +86,17 @@ public class ReportSubmitter {
         mainBranchComponent = mainBranchComponentOpt.get();
         validateProject(dbSession, mainBranchComponent, projectKey);
       } else {
-        mainBranchComponent = createProject(dbSession, componentKey.getMainBranchComponentKey(), projectName);
+        mainBranchComponent = createProject(dbSession, componentKey.getKey(), projectName);
         projectCreated = true;
       }
 
-      BranchDto mainBranch = dbClient.branchDao().selectByUuid(dbSession, mainBranchComponent.projectUuid())
+      BranchDto mainBranch = dbClient.branchDao().selectByUuid(dbSession, mainBranchComponent.branchUuid())
         .orElseThrow(() -> new IllegalStateException("Couldn't find the main branch of the project"));
       ComponentDto branchComponent;
       if (isMainBranch(componentKey, mainBranch)) {
         branchComponent = mainBranchComponent;
       } else {
-        branchComponent = dbClient.componentDao().selectByKey(dbSession, componentKey.getDbKey())
+        branchComponent = dbClient.componentDao().selectByKey(dbSession, componentKey.getKey())
           .orElseGet(() -> branchSupport.createBranchComponent(dbSession, componentKey, mainBranchComponent, mainBranch));
       }
 
@@ -137,9 +136,9 @@ public class ReportSubmitter {
     if (!Qualifiers.PROJECT.equals(component.qualifier()) || !Scopes.PROJECT.equals(component.scope())) {
       errors.add(format("Component '%s' is not a project", rawProjectKey));
     }
-    if (!component.projectUuid().equals(component.uuid())) {
+    if (!component.branchUuid().equals(component.uuid())) {
       // Project key is already used as a module of another project
-      ComponentDto anotherBaseProject = dbClient.componentDao().selectOrFailByUuid(dbSession, component.projectUuid());
+      ComponentDto anotherBaseProject = dbClient.componentDao().selectOrFailByUuid(dbSession, component.branchUuid());
       errors.add(format("The project '%s' is already defined in SonarQube but as a module of project '%s'. "
         + "If you really want to stop directly analysing project '%s', please first delete it from SonarQube and then relaunch the analysis of project '%s'.",
         rawProjectKey, anotherBaseProject.getKey(), anotherBaseProject.getKey(), rawProjectKey));
@@ -149,20 +148,19 @@ public class ReportSubmitter {
     }
   }
 
-  private ComponentDto createProject(DbSession dbSession, BranchSupport.ComponentKey componentKey, @Nullable String projectName) {
+  private ComponentDto createProject(DbSession dbSession, String projectKey, @Nullable String projectName) {
     userSession.checkPermission(GlobalPermission.PROVISION_PROJECTS);
     String userUuid = userSession.getUuid();
     String userName = userSession.getLogin();
 
-    boolean wouldCurrentUserHaveScanPermission = permissionTemplateService.wouldUserHaveScanPermissionWithDefaultTemplate(
-      dbSession, userUuid, componentKey.getDbKey());
+    boolean wouldCurrentUserHaveScanPermission = permissionTemplateService.wouldUserHaveScanPermissionWithDefaultTemplate(dbSession, userUuid, projectKey);
     if (!wouldCurrentUserHaveScanPermission) {
       throw insufficientPrivilegesException();
     }
 
     NewComponent newProject = newComponentBuilder()
-      .setKey(componentKey.getKey())
-      .setName(defaultIfBlank(projectName, componentKey.getKey()))
+      .setKey(projectKey)
+      .setName(defaultIfBlank(projectName, projectKey))
       .setQualifier(Qualifiers.PROJECT)
       .setPrivate(getDefaultVisibility(dbSession).isPrivate())
       .build();
index 5a26580fdbbaef2b8c9e24c88ea40eba6f041817..b3daf2cb87d7abab7562559ea852ce808d0c90af 100644 (file)
@@ -108,8 +108,7 @@ public class ComponentFinder {
     return getBranchOrPullRequest(dbSession, project.getUuid(), project.getKey(), branchKey, pullRequestKey);
   }
 
-  public BranchDto getBranchOrPullRequest(DbSession dbSession, String projectUuid, String projectKey,
-    @Nullable String branchKey, @Nullable String pullRequestKey) {
+  public BranchDto getBranchOrPullRequest(DbSession dbSession, String projectUuid, String projectKey, @Nullable String branchKey, @Nullable String pullRequestKey) {
     if (branchKey != null) {
       return dbClient.branchDao().selectByBranchKey(dbSession, projectUuid, branchKey)
         .orElseThrow(() -> new NotFoundException(String.format("Branch '%s' in project '%s' not found", branchKey, projectKey)));
@@ -171,7 +170,7 @@ public class ComponentFinder {
     checkRequest(component.scope().equals(Scopes.PROJECT) && rootQualifiers.contains(component.qualifier()),
       format(
         "Component '%s' (id: %s) must be a project%s.",
-        component.getDbKey(), component.uuid(),
+        component.getKey(), component.uuid(),
         rootQualifiers.contains(Qualifiers.VIEW) ? " or a view" : ""));
 
     return component;
index 55c76cf9789fc81dad1ed341b5b1d8446f1383e9..a03e6848c620457e7105692904acdf812cb5e164 100644 (file)
@@ -143,8 +143,8 @@ public class ComponentUpdater {
       .setRootUuid(uuid)
       .setModuleUuid(null)
       .setModuleUuidPath(ComponentDto.UUID_PATH_SEPARATOR + uuid + ComponentDto.UUID_PATH_SEPARATOR)
-      .setProjectUuid(uuid)
-      .setDbKey(newComponent.key())
+      .setBranchUuid(uuid)
+      .setKey(newComponent.key())
       .setName(newComponent.name())
       .setDescription(newComponent.description())
       .setLongName(newComponent.name())
@@ -184,7 +184,7 @@ public class ComponentUpdater {
   private static PortfolioDto toPortfolioDto(ComponentDto component, long now) {
     return new PortfolioDto()
       .setUuid(component.uuid())
-      .setRootUuid(component.projectUuid())
+      .setRootUuid(component.branchUuid())
       .setKey(component.getKey())
       .setName(component.name())
       .setPrivate(component.isPrivate())
index 6e39d8c4221dca82d1ba8f7b601cf2bd1548d28d..dd3cc2629b0acbe5eed01c7fdd0deda18acf3a15 100644 (file)
@@ -70,7 +70,7 @@ public class ComponentViewerJsonWriter {
     json.prop("longName", component.longName());
     json.prop("q", component.qualifier());
 
-    ComponentDto project = dbClient.componentDao().selectOrFailByUuid(session, component.projectUuid());
+    ComponentDto project = dbClient.componentDao().selectOrFailByUuid(session, component.branchUuid());
 
     json.prop("project", project.getKey());
     json.prop("projectName", project.longName());
index 5b8cb0dfa53100cb6abdc60b686019e04dc5ca69..5320cd1f0e4f6bb60fb1073d6e314703f8316419 100644 (file)
@@ -129,14 +129,14 @@ public class SearchAction implements ComponentsWsAction {
 
   private Map<String, String> searchProjectsKeysByUuids(DbSession dbSession, List<ComponentDto> components) {
     Set<String> projectUuidsToSearch = components.stream()
-      .map(ComponentDto::projectUuid)
+      .map(ComponentDto::branchUuid)
       .collect(toHashSet());
     List<ComponentDto> projects = dbClient.componentDao()
       .selectByUuids(dbSession, projectUuidsToSearch)
       .stream()
       .filter(c -> !c.qualifier().equals(Qualifiers.MODULE))
       .collect(Collectors.toList());
-    return projects.stream().collect(toMap(ComponentDto::uuid, ComponentDto::getDbKey));
+    return projects.stream().collect(toMap(ComponentDto::uuid, ComponentDto::getKey));
   }
 
   private static ComponentQuery buildEsQuery(SearchRequest request) {
@@ -155,7 +155,7 @@ public class SearchAction implements ComponentsWsAction {
       .build();
 
     components.stream()
-      .map(dto -> dtoToComponent(dto, projectKeysByUuids.get(dto.projectUuid())))
+      .map(dto -> dtoToComponent(dto, projectKeysByUuids.get(dto.branchUuid())))
       .forEach(responseBuilder::addComponents);
 
     return responseBuilder.build();
@@ -163,7 +163,7 @@ public class SearchAction implements ComponentsWsAction {
 
   private static Components.Component dtoToComponent(ComponentDto dto, String projectKey) {
     Components.Component.Builder builder = Components.Component.newBuilder()
-      .setKey(dto.getDbKey())
+      .setKey(dto.getKey())
       .setProject(projectKey)
       .setName(dto.name())
       .setQualifier(dto.qualifier());
index 9e42366a4ebdae19f9287939e50da392906184d2..86f340835e058692015bc12b2cfcb6e38eb20334 100644 (file)
@@ -110,7 +110,7 @@ public class ShowAction implements ComponentsWsAction {
     try (DbSession dbSession = dbClient.openSession(false)) {
       ComponentDto component = loadComponent(dbSession, request);
       userSession.checkComponentPermission(UserRole.USER, component);
-      Optional<SnapshotDto> lastAnalysis = dbClient.snapshotDao().selectLastAnalysisByComponentUuid(dbSession, component.projectUuid());
+      Optional<SnapshotDto> lastAnalysis = dbClient.snapshotDao().selectLastAnalysisByComponentUuid(dbSession, component.branchUuid());
       List<ComponentDto> ancestors = dbClient.componentDao().selectAncestors(dbSession, component);
       return buildResponse(dbSession, component, ancestors, lastAnalysis.orElse(null));
     }
@@ -149,7 +149,7 @@ public class ShowAction implements ComponentsWsAction {
         .setNeedIssueSync(needIssueSync);
     } else {
       Optional<ProjectDto> parentProject = dbClient.projectDao().selectByUuid(dbSession,
-        ofNullable(component.getMainBranchProjectUuid()).orElse(component.projectUuid()));
+        ofNullable(component.getMainBranchProjectUuid()).orElse(component.branchUuid()));
       boolean needIssueSync = needIssueSync(dbSession, component, parentProject.orElse(null));
       return componentDtoToWsComponent(component, parentProject.orElse(null), lastAnalysis)
         .setNeedIssueSync(needIssueSync);
index 114c385eaed988d362ebaac42f6bd78ee3d500c4..400e85f255733e5c023ac95442378de92a6da06d 100644 (file)
@@ -215,7 +215,7 @@ public class SuggestionsAction implements ComponentsWsAction {
     }
 
     List<ComponentDto> favorites = favoriteFinder.list();
-    Set<String> favoriteKeys = favorites.stream().map(ComponentDto::getDbKey).collect(MoreCollectors.toSet(favorites.size()));
+    Set<String> favoriteKeys = favorites.stream().map(ComponentDto::getKey).collect(MoreCollectors.toSet(favorites.size()));
     SuggestionQuery.Builder queryBuilder = SuggestionQuery.builder()
       .setQuery(query)
       .setRecentlyBrowsedKeys(recentlyBrowsedKeys)
@@ -283,7 +283,7 @@ public class SuggestionsAction implements ComponentsWsAction {
   private Map<String, ComponentDto> loadProjects(DbSession dbSession, Collection<ComponentDto> components) {
     Set<String> projectUuids = components.stream()
       .filter(c -> QUALIFIERS_FOR_WHICH_TO_RETURN_PROJECT.contains(c.qualifier()))
-      .map(ComponentDto::projectUuid)
+      .map(ComponentDto::branchUuid)
       .collect(MoreCollectors.toSet());
     return dbClient.componentDao().selectByUuids(dbSession, projectUuids).stream()
       .collect(MoreCollectors.uniqueIndex(ComponentDto::uuid));
@@ -330,17 +330,17 @@ public class SuggestionsAction implements ComponentsWsAction {
     ComponentDto result = componentsByUuids.get(hit.getUuid());
     if (result == null
       // SONAR-11419 this has happened in production while code does not really allow it. An inconsistency in DB may be the cause.
-      || (QUALIFIERS_FOR_WHICH_TO_RETURN_PROJECT.contains(result.qualifier()) && projectsByUuids.get(result.projectUuid()) == null)) {
+      || (QUALIFIERS_FOR_WHICH_TO_RETURN_PROJECT.contains(result.qualifier()) && projectsByUuids.get(result.branchUuid()) == null)) {
       return null;
     }
     Suggestion.Builder builder = Suggestion.newBuilder()
-      .setKey(result.getDbKey())
+      .setKey(result.getKey())
       .setName(result.name())
       .setMatch(hit.getHighlightedText().orElse(HtmlEscapers.htmlEscaper().escape(result.name())))
-      .setIsRecentlyBrowsed(recentlyBrowsedKeys.contains(result.getDbKey()))
+      .setIsRecentlyBrowsed(recentlyBrowsedKeys.contains(result.getKey()))
       .setIsFavorite(favoriteUuids.contains(result.uuid()));
     if (QUALIFIERS_FOR_WHICH_TO_RETURN_PROJECT.contains(result.qualifier())) {
-      builder.setProject(projectsByUuids.get(result.projectUuid()).getDbKey());
+      builder.setProject(projectsByUuids.get(result.branchUuid()).getKey());
     }
     return builder.build();
   }
@@ -348,7 +348,7 @@ public class SuggestionsAction implements ComponentsWsAction {
   private static List<Project> toProjects(Map<String, ComponentDto> projectsByUuids) {
     return projectsByUuids.values().stream()
       .map(p -> Project.newBuilder()
-        .setKey(p.getDbKey())
+        .setKey(p.getKey())
         .setName(p.longName())
         .build())
       .collect(Collectors.toList());
index 5c37c378a1cd3579a02016bf324988240e0ad8f6..5fd5e5de2a1917a2da38484335659d15b5280dbf 100644 (file)
@@ -245,7 +245,7 @@ public class TreeAction implements ComponentsWsAction {
       wsComponent = projectOrAppToWsComponent(projectDto, null);
     } else {
       Optional<ProjectDto> parentProject = dbClient.projectDao().selectByUuid(dbSession,
-        ofNullable(component.getMainBranchProjectUuid()).orElse(component.projectUuid()));
+        ofNullable(component.getMainBranchProjectUuid()).orElse(component.branchUuid()));
       wsComponent = componentDtoToWsComponent(component, parentProject.orElse(null), null);
     }
 
index d9fd4e55a8d03320b76cf4d35ace458173c07592..ee557d8bcc485edfa107b6f869eb68927e2f5ae6 100644 (file)
@@ -229,7 +229,7 @@ public class SearchEventsAction implements DevelopersWsAction {
     Map<String, Long> fromDatesByProjectKey = IntStream.range(0, projectKeys.size()).boxed()
       .collect(uniqueIndex(projectKeys::get, fromDates::get));
     return authorizedProjects.stream()
-      .map(dto -> new UuidFromPair(dto.uuid(), fromDatesByProjectKey.get(dto.getDbKey())))
+      .map(dto -> new UuidFromPair(dto.uuid(), fromDatesByProjectKey.get(dto.getKey())))
       .collect(toList(authorizedProjects.size()));
   }
 
index df8c327f22054cef6cd6cf1f84b2ca3fdcf3313b..ea309f789cc01c818a8ed1a305b320c9d1cd826b 100644 (file)
@@ -47,7 +47,7 @@ public class Duplication {
   }
 
   static Duplication newComponent(ComponentDto componentDto, Integer from, Integer size) {
-    return new Duplication(componentDto, componentDto.getDbKey(), from, size, false);
+    return new Duplication(componentDto, componentDto.getKey(), from, size, false);
   }
 
   String componentDbKey() {
index ed9ec0499610ad1e43e31b119738fcb8a42d9ece..01adf616c0ba848bc5a455730362d1029aca0af5 100644 (file)
@@ -56,7 +56,7 @@ public class DuplicationsParser {
       return blocks;
     }
 
-    DuplicationComparator duplicationComparator = new DuplicationComparator(component.uuid(), component.projectUuid());
+    DuplicationComparator duplicationComparator = new DuplicationComparator(component.uuid(), component.branchUuid());
 
     try {
       SMInputFactory inputFactory = initStax();
@@ -123,7 +123,7 @@ public class DuplicationsParser {
   }
 
   private static String convertToKey(String dbKey) {
-    return new ComponentDto().setDbKey(dbKey).getKey();
+    return new ComponentDto().setKey(dbKey).getKey();
   }
 
   private static SMInputFactory initStax() {
@@ -191,7 +191,7 @@ public class DuplicationsParser {
     }
 
     private boolean sameProject(@Nullable ComponentDto otherDto) {
-      return otherDto == null || StringUtils.equals(otherDto.projectUuid(), projectUuid);
+      return otherDto == null || StringUtils.equals(otherDto.branchUuid(), projectUuid);
     }
   }
 
index 46f698e65fbae5ca93ef1b442f3da901d00e35c4..899372371a548fefe4bb70da688ef124a8126a11 100644 (file)
@@ -98,7 +98,7 @@ public class ShowResponseBuilder {
       ComponentDto file = ref.getDto();
 
       if (file != null) {
-        ComponentDto project = getProject(file.projectUuid(), projectsByUuid, session);
+        ComponentDto project = getProject(file.branchUuid(), projectsByUuid, session);
         response.putFiles(ref.getId(), toWsFile(file, project, branch, pullRequest));
       } else {
         response.putFiles(ref.getId(), toWsFile(ref.getComponentKey(), branch, pullRequest));
index b67a34e0039ee75face03d4e64ba5f0c784128a8..eb16083bb55c9c16511cbb45f8192643e1c2bf4c 100644 (file)
@@ -127,7 +127,7 @@ public class SearchAction implements FavoritesWsAction {
   private static Favorite toWsFavorite(Favorite.Builder builder, ComponentDto componentDto) {
     builder
       .clear()
-      .setKey(componentDto.getDbKey());
+      .setKey(componentDto.getKey());
     ofNullable(componentDto.name()).ifPresent(builder::setName);
     ofNullable(componentDto.qualifier()).ifPresent(builder::setQualifier);
     return builder.build();
index 2f2232868b863453d3932555024df03ac5ec7011..5c3490d17d0ec1f772228ca8f956d47176369f32 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.server.hotspot.ws;
 
+import javax.annotation.Nullable;
 import org.sonar.db.component.ComponentDto;
 import org.sonarqube.ws.Hotspots;
 
@@ -30,15 +31,15 @@ public class HotspotWsResponseFormatter {
     // nothing to do here
   }
 
-  Hotspots.Component formatComponent(Hotspots.Component.Builder builder, ComponentDto component) {
+  Hotspots.Component formatComponent(Hotspots.Component.Builder builder, ComponentDto component, @Nullable String branch, @Nullable String pr) {
     builder
       .clear()
       .setKey(component.getKey())
       .setQualifier(component.qualifier())
       .setName(component.name())
       .setLongName(component.longName());
-    ofNullable(component.getBranch()).ifPresent(builder::setBranch);
-    ofNullable(component.getPullRequest()).ifPresent(builder::setPullRequest);
+    ofNullable(branch).ifPresent(builder::setBranch);
+    ofNullable(pr).ifPresent(builder::setPullRequest);
     ofNullable(component.path()).ifPresent(builder::setPath);
     return builder.build();
   }
index ac4146c29660131481ea537e2d6ffd6e7d0be4f6..b913d82127b89375d3e605617e53864f7a10577b 100644 (file)
@@ -32,6 +32,7 @@ import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
+import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import org.apache.lucene.search.TotalHits;
 import org.elasticsearch.action.search.SearchResponse;
@@ -56,6 +57,7 @@ import org.sonar.db.issue.IssueDto;
 import org.sonar.db.project.ProjectDto;
 import org.sonar.db.protobuf.DbIssues;
 import org.sonar.db.rule.RuleDto;
+import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.es.SearchOptions;
 import org.sonar.server.exceptions.NotFoundException;
 import org.sonar.server.issue.TextRangeResponseFormatter;
@@ -131,9 +133,8 @@ public class SearchAction implements HotspotsWsAction {
   private final TextRangeResponseFormatter textRangeFormatter;
   private final System2 system2;
 
-  public SearchAction(DbClient dbClient, UserSession userSession, IssueIndex issueIndex,
-    IssueIndexSyncProgressChecker issueIndexSyncProgressChecker, HotspotWsResponseFormatter responseFormatter,
-    TextRangeResponseFormatter textRangeFormatter, System2 system2) {
+  public SearchAction(DbClient dbClient, UserSession userSession, IssueIndex issueIndex, IssueIndexSyncProgressChecker issueIndexSyncProgressChecker,
+    HotspotWsResponseFormatter responseFormatter, TextRangeResponseFormatter textRangeFormatter, System2 system2) {
     this.dbClient = dbClient;
     this.userSession = userSession;
     this.issueIndex = issueIndex;
@@ -347,7 +348,7 @@ public class SearchAction implements HotspotsWsAction {
     List<IssueDto> hotspots = toIssueDtos(dbSession, issueKeys);
 
     Paging paging = forPageIndex(wsRequest.getPage()).withPageSize(wsRequest.getIndex()).andTotal((int) getTotalHits(result).value);
-    return new SearchResponseData(paging, hotspots);
+    return new SearchResponseData(paging, hotspots, wsRequest.getBranch().orElse(null), wsRequest.getPullRequest().orElse(null));
   }
 
   private static TotalHits getTotalHits(SearchResponse response) {
@@ -635,7 +636,7 @@ public class SearchAction implements HotspotsWsAction {
 
     Hotspots.Component.Builder builder = Hotspots.Component.newBuilder();
     for (ComponentDto component : components) {
-      responseBuilder.addComponents(responseFormatter.formatComponent(builder, component));
+      responseBuilder.addComponents(responseFormatter.formatComponent(builder, component, searchResponseData.getBranch(), searchResponseData.getPullRequest()));
     }
   }
 
@@ -660,8 +661,7 @@ public class SearchAction implements HotspotsWsAction {
     private final Set<String> sonarsourceSecurity;
     private final Set<String> cwe;
     private final Set<String> files;
-
-
+    
     private WsRequest(int page, int index,
       @Nullable String projectKey, @Nullable String branch, @Nullable String pullRequest, Set<String> hotspotKeys,
       @Nullable String status, @Nullable String resolution, @Nullable Boolean inNewCodePeriod, @Nullable Boolean onlyMine,
@@ -774,12 +774,26 @@ public class SearchAction implements HotspotsWsAction {
   private static final class SearchResponseData {
     private final Paging paging;
     private final List<IssueDto> orderedHotspots;
+    private final String branch;
+    private final String pullRequest;
     private final Map<String, ComponentDto> componentsByUuid = new HashMap<>();
     private final Map<RuleKey, RuleDto> rulesByRuleKey = new HashMap<>();
 
-    private SearchResponseData(Paging paging, List<IssueDto> orderedHotspots) {
+    private SearchResponseData(Paging paging, List<IssueDto> orderedHotspots, @Nullable String branch, @Nullable String pullRequest) {
       this.paging = paging;
       this.orderedHotspots = orderedHotspots;
+      this.branch = branch;
+      this.pullRequest = pullRequest;
+    }
+
+    @CheckForNull
+    public String getBranch() {
+      return branch;
+    }
+
+    @CheckForNull
+    public String getPullRequest() {
+      return pullRequest;
     }
 
     boolean isEmpty() {
index 39d3a514d8c47fcde59a9b15852d85e08823a8f3..7a55dcb953062cbe887bf61523389849860a6d4a 100644 (file)
@@ -38,6 +38,8 @@ import org.sonar.api.web.UserRole;
 import org.sonar.core.util.Uuids;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
+import org.sonar.db.component.BranchDto;
+import org.sonar.db.component.BranchType;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.issue.IssueDto;
 import org.sonar.db.protobuf.DbIssues;
@@ -169,8 +171,8 @@ public class ShowAction implements HotspotsWsAction {
 
   private void formatComponents(Components components, ShowWsResponse.Builder responseBuilder) {
     responseBuilder
-      .setProject(responseFormatter.formatComponent(Hotspots.Component.newBuilder(), components.getProject()))
-      .setComponent(responseFormatter.formatComponent(Hotspots.Component.newBuilder(), components.getComponent()));
+      .setProject(responseFormatter.formatComponent(Hotspots.Component.newBuilder(), components.getProject(), components.getBranch(), components.getPullRequest()))
+      .setComponent(responseFormatter.formatComponent(Hotspots.Component.newBuilder(), components.getComponent(), components.getBranch(), components.getPullRequest()));
     responseBuilder.setCanChangeStatus(hotspotWsSupport.canChangeStatus(components.getProject()));
   }
 
@@ -292,6 +294,7 @@ public class ShowAction implements HotspotsWsAction {
     String componentUuid = hotspot.getComponentUuid();
 
     ComponentDto project = hotspotWsSupport.loadAndCheckProject(dbSession, hotspot, UserRole.USER);
+    BranchDto branch = dbClient.branchDao().selectByUuid(dbSession, project.branchUuid()).orElseThrow(() -> new IllegalStateException("Can't find branch " + project.branchUuid()));
 
     checkArgument(componentUuid != null, "Hotspot '%s' has no component", hotspot.getKee());
     boolean hotspotOnProject = Objects.equals(project.uuid(), componentUuid);
@@ -299,16 +302,38 @@ public class ShowAction implements HotspotsWsAction {
       : dbClient.componentDao().selectByUuid(dbSession, componentUuid)
       .orElseThrow(() -> new NotFoundException(format("Component with uuid '%s' does not exist", componentUuid)));
 
-    return new Components(project, component);
+    return new Components(project, component, branch);
   }
 
   private static final class Components {
     private final ComponentDto project;
     private final ComponentDto component;
+    private final String branch;
+    private final String pullRequest;
 
-    private Components(ComponentDto project, ComponentDto component) {
+    private Components(ComponentDto project, ComponentDto component, BranchDto branch) {
       this.project = project;
       this.component = component;
+      if (branch.isMain()) {
+        this.branch = null;
+        this.pullRequest = null;
+      } else if (branch.getBranchType() == BranchType.BRANCH) {
+        this.branch = branch.getKey();
+        this.pullRequest = null;
+      } else {
+        this.branch = null;
+        this.pullRequest = branch.getKey();
+      }
+    }
+
+    @CheckForNull
+    public String getBranch() {
+      return branch;
+    }
+
+    @CheckForNull
+    public String getPullRequest() {
+      return pullRequest;
     }
 
     public ComponentDto getProject() {
index aa4ac9909c65c50de87bd2bd3f9907ec09c522a6..3eab766fcd1eb1ea4b5562dba6c8efa986a42558 100644 (file)
@@ -153,9 +153,9 @@ public class SearchResponseLoader {
   private void loadProjects(Collector collector, DbSession dbSession, SearchResponseData result) {
     Collection<ComponentDto> loadedComponents = result.getComponents();
     for (ComponentDto component : loadedComponents) {
-      collector.addProjectUuid(component.projectUuid());
+      collector.addProjectUuid(component.branchUuid());
     }
-    Set<String> loadedProjectUuids = loadedComponents.stream().filter(cpt -> cpt.uuid().equals(cpt.projectUuid())).map(ComponentDto::uuid).collect(MoreCollectors.toSet());
+    Set<String> loadedProjectUuids = loadedComponents.stream().filter(cpt -> cpt.uuid().equals(cpt.branchUuid())).map(ComponentDto::uuid).collect(MoreCollectors.toSet());
     Set<String> projectUuidsToLoad = copyOf(difference(collector.getProjectUuids(), loadedProjectUuids));
     if (!projectUuidsToLoad.isEmpty()) {
       List<ComponentDto> projects = dbClient.componentDao().selectByUuids(dbSession, collector.getProjectUuids());
@@ -208,7 +208,7 @@ public class SearchResponseLoader {
       Map<String, ComponentDto> componentsByProjectUuid = result.getComponents()
         .stream()
         .filter(ComponentDto::isRootProject)
-        .collect(MoreCollectors.uniqueIndex(ComponentDto::projectUuid));
+        .collect(MoreCollectors.uniqueIndex(ComponentDto::branchUuid));
       for (IssueDto issueDto : result.getIssues()) {
         // so that IssueDto can be used.
         if (fields.contains(ACTIONS)) {
index 957cfbf0705dcb0fbc174771ed139231e8bf6f60..42f74247d77385f1e31bad73e437752c1e438b39 100644 (file)
@@ -80,7 +80,7 @@ public class LiveMeasureComputerImpl implements LiveMeasureComputer {
     }
 
     List<QGChangeEvent> result = new ArrayList<>();
-    Map<String, List<ComponentDto>> componentsByProjectUuid = components.stream().collect(groupingBy(ComponentDto::projectUuid));
+    Map<String, List<ComponentDto>> componentsByProjectUuid = components.stream().collect(groupingBy(ComponentDto::branchUuid));
     for (List<ComponentDto> groupedComponents : componentsByProjectUuid.values()) {
       Optional<QGChangeEvent> qgChangeEvent = refreshComponentsOnSameProject(dbSession, groupedComponents);
       qgChangeEvent.ifPresent(result::add);
index 58a850337573c9a5964bd86235c709b403998e19..35e910cfba7251a2f5875faa0bdbd40fa0a98a4a 100644 (file)
@@ -78,7 +78,7 @@ public class LiveMeasureTreeUpdaterImpl implements LiveMeasureTreeUpdater {
           try {
             formula.computeHierarchy(context);
           } catch (RuntimeException e) {
-            throw new IllegalStateException("Fail to compute " + formula.getMetric().getKey() + " on " + context.getComponent().getDbKey(), e);
+            throw new IllegalStateException("Fail to compute " + formula.getMetric().getKey() + " on " + context.getComponent().getKey(), e);
           }
         }
       }
@@ -98,7 +98,7 @@ public class LiveMeasureTreeUpdaterImpl implements LiveMeasureTreeUpdater {
           try {
             formula.compute(context, issueCounter);
           } catch (RuntimeException e) {
-            throw new IllegalStateException("Fail to compute " + formula.getMetric().getKey() + " on " + context.getComponent().getDbKey(), e);
+            throw new IllegalStateException("Fail to compute " + formula.getMetric().getKey() + " on " + context.getComponent().getKey(), e);
           }
         }
       }
index 62d4e80649c88ec69f596673bba81e5db5b76932..88ddbdbc186accdc2c769ef1eeff75048c2ca295 100644 (file)
@@ -122,7 +122,7 @@ class MeasureMatrix {
     if (cell == null) {
       LiveMeasureDto measure = new LiveMeasureDto()
         .setComponentUuid(component.uuid())
-        .setProjectUuid(component.projectUuid())
+        .setProjectUuid(component.branchUuid())
         .setMetricUuid(metricsByKeys.get(metricKey).getUuid());
       cell = new MeasureCell(measure);
       table.put(component.uuid(), metricKey, cell);
index 0aa9dff22a0a8c19520bd132459a51f1acf4fdad..da046ad021161f68544397e4d05c16a7d93620c4 100644 (file)
@@ -138,7 +138,7 @@ public class ComponentAction implements MeasuresWsAction {
       String pullRequest = request.getPullRequest();
       ComponentDto component = loadComponent(dbSession, request, branch, pullRequest);
       checkPermissions(component);
-      SnapshotDto analysis = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(dbSession, component.projectUuid()).orElse(null);
+      SnapshotDto analysis = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(dbSession, component.branchUuid()).orElse(null);
 
       boolean isPR = isPR(pullRequest);
 
index af0c153024ea83e06481c51c3d5e643f908e75e7..77ee6758c950f0db29210a88ec6bb751c93473cf 100644 (file)
@@ -39,7 +39,7 @@ class ComponentDtoToWsComponent {
 
     ComponentDto referenceComponent = referenceComponentsByUuid.get(component.getCopyComponentUuid());
     if (referenceComponent != null) {
-      wsComponent.setRefKey(referenceComponent.getDbKey());
+      wsComponent.setRefKey(referenceComponent.getKey());
     }
 
     Measures.Measure.Builder measureBuilder = Measures.Measure.newBuilder();
index 50f26aca4bb4bd130fcfd978affd4304c9e098d0..64f179e535037745a026140779288ae937b692c7 100644 (file)
@@ -405,7 +405,7 @@ public class ComponentTreeAction implements MeasuresWsAction {
     try (DbSession dbSession = dbClient.openSession(false)) {
       ComponentDto baseComponent = loadComponent(dbSession, wsRequest);
       checkPermissions(baseComponent);
-      Optional<SnapshotDto> baseSnapshot = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(dbSession, baseComponent.projectUuid());
+      Optional<SnapshotDto> baseSnapshot = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(dbSession, baseComponent.branchUuid());
       if (baseSnapshot.isEmpty()) {
         return ComponentTreeData.builder()
           .setBaseComponent(baseComponent)
index 179a4eaea506f33d3c140e8b81dff18fa204b51c..2bf7d5975effa47fb3a6b0ecff74e2b1374bee2a 100644 (file)
@@ -180,7 +180,7 @@ public class SearchAction implements MeasuresWsAction {
 
     private List<Measure> buildWsMeasures() {
       Map<String, ComponentDto> componentsByUuid = projects.stream().collect(toMap(ComponentDto::uuid, Function.identity()));
-      Map<String, String> componentNamesByKey = projects.stream().collect(toMap(ComponentDto::getDbKey, ComponentDto::name));
+      Map<String, String> componentNamesByKey = projects.stream().collect(toMap(ComponentDto::getKey, ComponentDto::name));
       Map<String, MetricDto> metricsByUuid = metrics.stream().collect(toMap(MetricDto::getUuid, identity()));
 
       Function<LiveMeasureDto, MetricDto> dbMeasureToDbMetric = dbMeasure -> metricsByUuid.get(dbMeasure.getMetricUuid());
@@ -191,7 +191,7 @@ public class SearchAction implements MeasuresWsAction {
       return measures.stream()
         .map(dbMeasure -> {
           updateMeasureBuilder(measureBuilder, dbMeasureToDbMetric.apply(dbMeasure), dbMeasure);
-          measureBuilder.setComponent(componentsByUuid.get(dbMeasure.getComponentUuid()).getDbKey());
+          measureBuilder.setComponent(componentsByUuid.get(dbMeasure.getComponentUuid()).getKey());
           Measure measure = measureBuilder.build();
           measureBuilder.clear();
           return measure;
index aa3abaf9fd2fd9800753dad1cefafaf2e41aee6c..7a956ba2f4b8c810a4e9f19311e7b27e12568547 100644 (file)
@@ -191,7 +191,7 @@ public class SearchHistoryAction implements MeasuresWsAction {
 
   private List<SnapshotDto> searchAnalyses(DbSession dbSession, SearchHistoryRequest request, ComponentDto component) {
     SnapshotQuery dbQuery = new SnapshotQuery()
-      .setComponentUuid(component.projectUuid())
+      .setComponentUuid(component.branchUuid())
       .setStatus(STATUS_PROCESSED)
       .setSort(SORT_FIELD.BY_DATE, SORT_ORDER.ASC);
     ofNullable(request.getFrom()).ifPresent(from -> dbQuery.setCreatedAfter(parseStartingDateOrDateTime(from).getTime()));
index c9b3d8a809c6802e7d3bc45f5ab63bf50e74c0bc..51076d2ac6eb95a6f231bdaf9927b2b1cf17609c 100644 (file)
@@ -182,7 +182,7 @@ public class ListAction implements NotificationsWsAction {
     Map<String, ComponentDto> projectsByUuid) {
     ComponentDto project = projectsByUuid.get(componentUuid);
     notification
-      .setProject(project.getDbKey())
+      .setProject(project.getKey())
       .setProjectName(project.name());
   }
 
index be02376bcf1db0af8fb3c1439d0b7377472879a0..5be67203ebcac9eaccb78199db6422edbbae7231 100644 (file)
@@ -80,7 +80,7 @@ public class PermissionTemplateService {
       return true;
     }
 
-    ComponentDto dto = new ComponentDto().setDbKey(projectKey).setQualifier(Qualifiers.PROJECT);
+    ComponentDto dto = new ComponentDto().setKey(projectKey).setQualifier(Qualifiers.PROJECT);
     PermissionTemplateDto template = findTemplate(dbSession, dto);
     if (template == null) {
       return false;
@@ -195,11 +195,11 @@ public class PermissionTemplateService {
     List<PermissionTemplateDto> matchingTemplates = new ArrayList<>();
     for (PermissionTemplateDto permissionTemplateDto : allPermissionTemplates) {
       String keyPattern = permissionTemplateDto.getKeyPattern();
-      if (StringUtils.isNotBlank(keyPattern) && component.getDbKey().matches(keyPattern)) {
+      if (StringUtils.isNotBlank(keyPattern) && component.getKey().matches(keyPattern)) {
         matchingTemplates.add(permissionTemplateDto);
       }
     }
-    checkAtMostOneMatchForComponentKey(component.getDbKey(), matchingTemplates);
+    checkAtMostOneMatchForComponentKey(component.getKey(), matchingTemplates);
     if (matchingTemplates.size() == 1) {
       return matchingTemplates.get(0);
     }
index f61420ec984c1b0e5f331dafb4eed5abab448ddd..8d22d286e815c4d2734dd70047fbbc0f23e3e66d 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.project.ws;
 
-import java.util.Set;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import org.sonar.api.server.ws.Change;
@@ -100,18 +99,9 @@ public class CreateAction implements ProjectsWsAction {
   @Override
   public void handle(Request request, Response response) throws Exception {
     CreateRequest createRequest = toCreateRequest(request);
-    validate(createRequest);
     writeProtobuf(doHandle(createRequest), request, response);
   }
 
-  private static void validate(CreateRequest createRequest) {
-    Set<String> forbiddenNamePhrases = Set.of(":BRANCH:", ":PULLREQUEST:");
-    if (forbiddenNamePhrases.stream().anyMatch(createRequest.getProjectKey()::contains)) {
-      throw new IllegalArgumentException(String.format("Invalid project key. Project key must not contain following phrases [%s]",
-        String.join(", ", forbiddenNamePhrases)));
-    }
-  }
-
   private CreateWsResponse doHandle(CreateRequest request) {
     try (DbSession dbSession = dbClient.openSession(false)) {
       userSession.checkPermission(PROVISION_PROJECTS);
@@ -119,11 +109,11 @@ public class CreateAction implements ProjectsWsAction {
       boolean changeToPrivate = visibility == null ? projectDefaultVisibility.get(dbSession).isPrivate() : "private".equals(visibility);
 
       ComponentDto componentDto = componentUpdater.create(dbSession, newComponentBuilder()
-        .setKey(request.getProjectKey())
-        .setName(request.getName())
-        .setPrivate(changeToPrivate)
-        .setQualifier(PROJECT)
-        .build(),
+          .setKey(request.getProjectKey())
+          .setName(request.getName())
+          .setPrivate(changeToPrivate)
+          .setQualifier(PROJECT)
+          .build(),
         userSession.isLoggedIn() ? userSession.getUuid() : null,
         userSession.isLoggedIn() ? userSession.getLogin() : null);
       return toCreateResponse(componentDto);
@@ -141,7 +131,7 @@ public class CreateAction implements ProjectsWsAction {
   private static CreateWsResponse toCreateResponse(ComponentDto componentDto) {
     return CreateWsResponse.newBuilder()
       .setProject(CreateWsResponse.Project.newBuilder()
-        .setKey(componentDto.getDbKey())
+        .setKey(componentDto.getKey())
         .setName(componentDto.name())
         .setQualifier(componentDto.qualifier())
         .setVisibility(Visibility.getLabel(componentDto.isPrivate())))
index 075515131f16d1a152948b8920bbb31edfc3c86d..7631fcdb3d9a55ba0b009d31c2ce0148e3958276 100644 (file)
@@ -210,7 +210,7 @@ public class SearchAction implements ProjectsWsAction {
 
   private static Component dtoToProject(ComponentDto dto, @Nullable SnapshotDto snapshot, @Nullable Long lastAnalysisDate) {
     Component.Builder builder = Component.newBuilder()
-      .setKey(dto.getDbKey())
+      .setKey(dto.getKey())
       .setName(dto.name())
       .setQualifier(dto.qualifier())
       .setVisibility(dto.isPrivate() ? PRIVATE.getLabel() : PUBLIC.getLabel());
index 2b6a9edd8cd5a3d8233cfe76d74130439ac17eff..00272da7f01edbad3445813fcd0037be463de745 100644 (file)
@@ -132,7 +132,7 @@ public class SearchMyProjectsAction implements ProjectsWsAction {
     public Project apply(ComponentDto dto) {
       Project.Builder project = Project.newBuilder();
       project
-        .setKey(dto.getDbKey())
+        .setKey(dto.getKey())
         .setName(dto.name());
       data.lastSnapshot(dto.uuid()).ifPresent(s -> {
         project.setLastAnalysisDate(formatDateTime(s.getCreatedAt()));
@@ -172,7 +172,7 @@ public class SearchMyProjectsAction implements ProjectsWsAction {
     SearchMyProjectsData.Builder data = builder();
     ProjectsResult searchResult = searchProjects(dbSession, request);
     List<ComponentDto> projects = searchResult.projects;
-    List<String> projectUuids = Lists.transform(projects, ComponentDto::projectUuid);
+    List<String> projectUuids = Lists.transform(projects, ComponentDto::branchUuid);
     List<ProjectLinkDto> projectLinks = dbClient.projectLinkDao().selectByProjectUuids(dbSession, projectUuids);
     List<SnapshotDto> snapshots = dbClient.snapshotDao().selectLastAnalysesByRootComponentUuids(dbSession, projectUuids);
     List<LiveMeasureDto> qualityGates = dbClient.liveMeasureDao()
index 6ad6f2f91721ee08c4048a3e8c48d3cb86e15fdc..d341ef6a1e4f75dadc8f864ff5a4c585f8fcd225 100644 (file)
@@ -121,7 +121,7 @@ public class IssueSnippetsAction implements SourcesWsAction {
     }
 
     Supplier<Optional<Long>> periodDateSupplier = () -> dbClient.snapshotDao()
-      .selectLastAnalysisByComponentUuid(dbSession, fileDto.projectUuid())
+      .selectLastAnalysisByComponentUuid(dbSession, fileDto.branchUuid())
       .map(SnapshotDto::getPeriodDate);
 
     Iterable<DbFileSources.Line> lineSources = lineSourcesOpt.get();
index c15a9cfc4db0e9c5925b20eeae43c272b02acc5b..109205b4b7f39fabde458907973b2fecc01b668c 100644 (file)
@@ -139,14 +139,14 @@ public class LinesAction implements SourcesWsAction {
     try (DbSession dbSession = dbClient.openSession(false)) {
       ComponentDto file = loadComponent(dbSession, request);
       Supplier<Optional<Long>> periodDateSupplier = () -> dbClient.snapshotDao()
-        .selectLastAnalysisByComponentUuid(dbSession, file.projectUuid())
+        .selectLastAnalysisByComponentUuid(dbSession, file.branchUuid())
         .map(SnapshotDto::getPeriodDate);
 
       userSession.checkComponentPermission(UserRole.CODEVIEWER, file);
       int from = request.mandatoryParamAsInt(PARAM_FROM);
       int to = MoreObjects.firstNonNull(request.paramAsInt(PARAM_TO), Integer.MAX_VALUE);
 
-      Iterable<DbFileSources.Line> lines = checkFoundWithOptional(sourceService.getLines(dbSession, file.uuid(), from, to), "No source found for file '%s'", file.getDbKey());
+      Iterable<DbFileSources.Line> lines = checkFoundWithOptional(sourceService.getLines(dbSession, file.uuid(), from, to), "No source found for file '%s'", file.getKey());
       try (JsonWriter json = response.newJsonWriter()) {
         json.beginObject();
         linesJsonWriter.writeSource(lines, json, periodDateSupplier);
index c3005e1c79b59b659467a43209817193f4b2a0a3..d49d0cefbb8f28c2519acb0e547e405adec48923 100644 (file)
@@ -156,7 +156,7 @@ public class ComponentAction implements NavigationWsAction {
         !userSession.isSystemAdministrator()) {
         throw insufficientPrivilegesException();
       }
-      Optional<SnapshotDto> analysis = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(session, component.projectUuid());
+      Optional<SnapshotDto> analysis = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(session, component.branchUuid());
 
       try (JsonWriter json = response.newJsonWriter()) {
         json.beginObject();
@@ -181,7 +181,7 @@ public class ComponentAction implements NavigationWsAction {
 
   private ComponentDto getRootProjectOrBranch(ComponentDto component, DbSession session) {
     if (!component.isRootProject()) {
-      return dbClient.componentDao().selectOrFailByUuid(session, component.projectUuid());
+      return dbClient.componentDao().selectOrFailByUuid(session, component.branchUuid());
     } else {
       return component;
     }
@@ -245,7 +245,7 @@ public class ComponentAction implements NavigationWsAction {
   }
 
   private void writeProfiles(JsonWriter json, DbSession dbSession, ComponentDto component) {
-    Set<QualityProfile> qualityProfiles = dbClient.liveMeasureDao().selectMeasure(dbSession, component.projectUuid(), QUALITY_PROFILES_KEY)
+    Set<QualityProfile> qualityProfiles = dbClient.liveMeasureDao().selectMeasure(dbSession, component.branchUuid(), QUALITY_PROFILES_KEY)
       .map(LiveMeasureDto::getDataAsString)
       .map(data -> QPMeasureData.fromJson(data).getProfiles())
       .orElse(emptySortedSet());
index 828be41dc10b1a9674f16bd4b4347ab4d59fc4de..c4bb879a6941f05798e5a4016bf0e47451239484 100644 (file)
@@ -85,6 +85,6 @@ public class ImportHelperTest {
 
     assertThat(project).extracting(CreateWsResponse.Project::getKey, CreateWsResponse.Project::getName,
         CreateWsResponse.Project::getQualifier)
-      .containsExactly(componentDto.getDbKey(), componentDto.name(), componentDto.qualifier());
+      .containsExactly(componentDto.getKey(), componentDto.name(), componentDto.qualifier());
   }
 }
index ca76ed7b740b8c1bf2019f9a2aa695c0692415b2..246f703a7bf6a90d881fb954f7ab456a7a503b49 100644 (file)
@@ -243,7 +243,7 @@ public class ImportAzureProjectActionTest {
       dto.setUserUuid(user.getUuid());
     });
     GsonAzureRepo repo = getGsonAzureRepo();
-    db.components().insertPublicProject(p -> p.setDbKey(GENERATED_PROJECT_KEY));
+    db.components().insertPublicProject(p -> p.setKey(GENERATED_PROJECT_KEY));
 
     when(azureDevOpsHttpClient.getRepo(almSetting.getUrl(), almSetting.getDecryptedPersonalAccessToken(encryption),
       "project-name", "repo-name")).thenReturn(repo);
index 574859d8c9fcea7b3fc6a22640aef8ca30fa960a..b771a3a7514b5ed0ebc8789dbb4b385fbbd6d5a8 100644 (file)
@@ -138,7 +138,7 @@ public class ImportBitbucketCloudRepoActionTest {
       dto.setUserUuid(user.getUuid());
     });
     Repository repo = getGsonBBCRepo();
-    db.components().insertPublicProject(p -> p.setDbKey(GENERATED_PROJECT_KEY));
+    db.components().insertPublicProject(p -> p.setKey(GENERATED_PROJECT_KEY));
 
     when(bitbucketCloudRestClient.getRepo(any(), any(), any())).thenReturn(repo);
 
index 40063d4020db5d22ac41235cf27facb6ef7f29bf..aa3c09debec68147e706aac8af290fa9213aff1f 100644 (file)
@@ -105,8 +105,8 @@ public class SearchBitbucketCloudReposActionTest {
       dto.setAlmSettingUuid(almSetting.getUuid());
       dto.setUserUuid(user.getUuid());
     });
-    ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setDbKey("B"));
-    ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setDbKey("A"));
+    ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setKey("B"));
+    ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setKey("A"));
     db.almSettings().insertBitbucketProjectAlmSetting(almSetting, project1, s -> s.setAlmRepo("repo-slug-2"));
     db.almSettings().insertBitbucketProjectAlmSetting(almSetting, project2, s -> s.setAlmRepo("repo-slug-2"));
 
index 97aa314537044d9976ab9189823c3874855814a8..4541a89c1d8ee93c67a25abaa9049f4a67dfc141 100644 (file)
@@ -149,7 +149,7 @@ public class ImportBitbucketServerProjectActionTest {
     });
     Project project = getGsonBBSProject();
     Repository repo = getGsonBBSRepo(project);
-    db.components().insertPublicProject(p -> p.setDbKey(GENERATED_PROJECT_KEY));
+    db.components().insertPublicProject(p -> p.setKey(GENERATED_PROJECT_KEY));
 
     assertThatThrownBy(() -> {
       when(bitbucketServerRestClient.getRepo(any(), any(), any(), any())).thenReturn(repo);
index 3717cfd716729ddbb248cd4c7ecc0bbd3ed0a36d..6869ee0e6ae1eef8ac34a42e88bedee5e654dec6 100644 (file)
@@ -161,8 +161,8 @@ public class SearchBitbucketServerReposActionTest {
       dto.setAlmSettingUuid(almSetting.getUuid());
       dto.setUserUuid(user.getUuid());
     });
-    ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setDbKey("B"));
-    ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setDbKey("A"));
+    ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setKey("B"));
+    ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setKey("A"));
     db.almSettings().insertBitbucketProjectAlmSetting(almSetting, project1, s -> s.setAlmRepo("projectKey2"), s -> s.setAlmSlug("repo-slug-2"));
     db.almSettings().insertBitbucketProjectAlmSetting(almSetting, project2, s -> s.setAlmRepo("projectKey2"), s -> s.setAlmSlug("repo-slug-2"));
 
index df54db59f9ca156051b19caaa0844d4450d9af6c..080436c2f36bbfcc1088bb1e4d8d8165d125cd5c 100644 (file)
@@ -120,7 +120,7 @@ public class ImportGithubProjectActionTest {
   public void importProject_ifProjectWithSameNameAlreadyExists_importSucceed() {
     AlmSettingDto githubAlmSetting = setupAlm();
     db.almPats().insert(p -> p.setAlmSettingUuid(githubAlmSetting.getUuid()).setUserUuid(userSession.getUuid()));
-    db.components().insertPublicProject(p -> p.setDbKey("Hello-World"));
+    db.components().insertPublicProject(p -> p.setKey("Hello-World"));
 
     GithubApplicationClient.Repository repository = new GithubApplicationClient.Repository(1L, "Hello-World", false, "Hello-World",
       "https://github.sonarsource.com/api/v3/repos/octocat/Hello-World", "main");
index 552b1fa798a9cda5a39dc56bc7f6b7a19a22bf43..31b74ebcb663dedfee84acb4c0c16dd074439708 100644 (file)
@@ -114,10 +114,10 @@ public class ListGithubRepositoriesActionTest {
               "https://github-enterprise.sonarqube.com/api/v3/github/HelloWorld", "main"))
             .collect(Collectors.toList())));
 
-    ProjectDto project = db.components().insertPrivateProjectDto(componentDto -> componentDto.setDbKey("github_HelloWorld"));
+    ProjectDto project = db.components().insertPrivateProjectDto(componentDto -> componentDto.setKey("github_HelloWorld"));
     db.almSettings().insertGitHubProjectAlmSetting(githubAlmSettings, project, projectAlmSettingDto -> projectAlmSettingDto.setAlmRepo("github/HelloWorld"));
 
-    ProjectDto project2 = db.components().insertPrivateProjectDto(componentDto -> componentDto.setDbKey("github_HelloWorld2"));
+    ProjectDto project2 = db.components().insertPrivateProjectDto(componentDto -> componentDto.setKey("github_HelloWorld2"));
     db.almSettings().insertGitHubProjectAlmSetting(githubAlmSettings, project2, projectAlmSettingDto -> projectAlmSettingDto.setAlmRepo("github/HelloWorld"));
 
     ListGithubRepositoriesWsResponse response = ws.newRequest()
index 59eb17c30ceadcfda9ff850c3d1c0b3da2daa99e..1826d43fd8954e8ce6f79debc68b0f621bffc920 100644 (file)
@@ -180,10 +180,10 @@ public class ProjectDataLoaderTest {
         .setUuid(uuid)
         .setUuidPath(uuid + ".")
         .setRootUuid(uuid)
-        .setProjectUuid(uuid)
+        .setBranchUuid(uuid)
         .setScope(scope)
         .setModuleUuid(moduleUuid)
-        .setDbKey(key));
+        .setKey(key));
       dbSession.commit();
 
       try {
@@ -209,7 +209,7 @@ public class ProjectDataLoaderTest {
     return new FileSourceDto()
       .setUuid(Uuids.createFast())
       .setFileUuid(file.uuid())
-      .setProjectUuid(file.projectUuid())
+      .setProjectUuid(file.branchUuid())
       .setDataHash("0263047cd758c68c27683625f072f010")
       .setLineHashes(of("8d7b3d6b83c0a517eac07e1aac94b773"))
       .setCreatedAt(System.currentTimeMillis())
index b96071a878e2d16bd07d6465a558b8aff994235d..ae64da13e3e42d84fa67f995ed4b42d96f3b4392 100644 (file)
@@ -106,7 +106,7 @@ public class DeleteActionTest {
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
 
     assertThatThrownBy(() -> tester.newRequest()
-      .setParam("project", project.getDbKey())
+      .setParam("project", project.getKey())
       .setParam("branch", "branch1")
       .execute())
       .isInstanceOf(NotFoundException.class)
index fbc38e4560182166b9ea8351bd9f3886857c3862..aecd1c82c95e36763c09f2578e54c7a0519020b4 100644 (file)
@@ -96,7 +96,7 @@ public class ListActionTest {
 
   @Test
   public void test_example() {
-    ComponentDto project = db.components().insertPrivateProject(p -> p.setDbKey("sonarqube"));
+    ComponentDto project = db.components().insertPrivateProject(p -> p.setKey("sonarqube"));
     db.getDbClient().snapshotDao().insert(db.getSession(),
       newAnalysis(project).setLast(true).setCreatedAt(parseDateTime("2017-04-01T01:15:42+0100").getTime()));
     db.measures().insertLiveMeasure(project, qualityGateStatus, m -> m.setData("ERROR"));
@@ -115,7 +115,7 @@ public class ListActionTest {
     userSession.logIn().addProjectPermission(USER, project);
 
     String json = ws.newRequest()
-      .setParam("project", project.getDbKey())
+      .setParam("project", project.getKey())
       .execute()
       .getInput();
 
@@ -125,7 +125,7 @@ public class ListActionTest {
 
   @Test
   public void test_with_SCAN_EXCUTION_permission() {
-    ComponentDto project = db.components().insertPrivateProject(p -> p.setDbKey("sonarqube"));
+    ComponentDto project = db.components().insertPrivateProject(p -> p.setKey("sonarqube"));
     db.getDbClient().snapshotDao().insert(db.getSession(),
       newAnalysis(project).setLast(true).setCreatedAt(parseDateTime("2017-04-01T01:15:42+0100").getTime()));
     db.measures().insertLiveMeasure(project, qualityGateStatus, m -> m.setData("ERROR"));
@@ -143,7 +143,7 @@ public class ListActionTest {
     userSession.logIn().addProjectPermission(SCAN_EXECUTION, project);
 
     String json = ws.newRequest()
-      .setParam("project", project.getDbKey())
+      .setParam("project", project.getKey())
       .execute()
       .getInput();
 
@@ -156,7 +156,7 @@ public class ListActionTest {
     userSession.logIn().addProjectPermission(USER, project);
 
     ListWsResponse response = ws.newRequest()
-      .setParam("project", project.getDbKey())
+      .setParam("project", project.getKey())
       .executeProtobuf(ListWsResponse.class);
 
     assertThat(response.getBranchesList())
@@ -188,7 +188,7 @@ public class ListActionTest {
     userSession.logIn().addProjectPermission(USER, project);
 
     ListWsResponse response = ws.newRequest()
-      .setParam("project", project.getDbKey())
+      .setParam("project", project.getKey())
       .executeProtobuf(ListWsResponse.class);
 
     assertThat(response.getBranchesList())
@@ -252,7 +252,7 @@ public class ListActionTest {
     userSession.logIn().addProjectPermission(USER, application);
 
     ListWsResponse response = ws.newRequest()
-      .setParam("project", application.getDbKey())
+      .setParam("project", application.getKey())
       .executeProtobuf(ListWsResponse.class);
 
     assertThat(response.getBranchesList())
@@ -270,10 +270,10 @@ public class ListActionTest {
     ComponentDto branch = db.components().insertProjectBranch(project);
 
     assertThatThrownBy(() -> ws.newRequest()
-      .setParam("project", branch.getDbKey())
+      .setParam("project", branch.getKey())
       .execute())
       .isInstanceOf(NotFoundException.class)
-      .hasMessageContaining(format("Project '%s' not found", branch.getDbKey()));
+      .hasMessageContaining(format("Project '%s' not found", branch.getKey()));
   }
 
   @Test
@@ -289,9 +289,9 @@ public class ListActionTest {
     ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project));
     userSession.logIn().addProjectPermission(USER, project);
 
-    assertThatThrownBy(() -> ws.newRequest().setParam("project", file.getDbKey()).execute())
+    assertThatThrownBy(() -> ws.newRequest().setParam("project", file.getKey()).execute())
       .isInstanceOf(NotFoundException.class)
-      .hasMessageContaining("Project '" + file.getDbKey() + "' not found");
+      .hasMessageContaining("Project '" + file.getKey() + "' not found");
   }
 
   @Test
index e637c84154d9b0429e3a1754a3bc847e45cd0253..5041764425ef1796b4d26e8bfcbbfa9136c34d4f 100644 (file)
@@ -112,7 +112,7 @@ public class BranchReportSubmitterTest {
     mockSuccessfulPrepareSubmitCall();
     InputStream reportInput = IOUtils.toInputStream("{binary}", StandardCharsets.UTF_8);
 
-    underTest.submit(project.getDbKey(), project.name(), emptyMap(), reportInput);
+    underTest.submit(project.getKey(), project.name(), emptyMap(), reportInput);
 
     verifyNoInteractions(branchSupportDelegate);
   }
@@ -125,17 +125,17 @@ public class BranchReportSubmitterTest {
     userSession.logIn(user).addProjectPermission(SCAN_EXECUTION, project);
     Map<String, String> randomCharacteristics = randomNonEmptyMap();
     BranchSupport.ComponentKey componentKey = createComponentKeyOfBranch(branch);
-    when(branchSupportDelegate.createComponentKey(project.getDbKey(), randomCharacteristics))
+    when(branchSupportDelegate.createComponentKey(project.getKey(), randomCharacteristics))
       .thenReturn(componentKey);
     InputStream reportInput = IOUtils.toInputStream("{binary}", StandardCharsets.UTF_8);
     String taskUuid = mockSuccessfulPrepareSubmitCall();
 
-    underTest.submit(project.getDbKey(), project.name(), randomCharacteristics, reportInput);
+    underTest.submit(project.getKey(), project.name(), randomCharacteristics, reportInput);
 
     verifyNoInteractions(permissionTemplateService);
     verifyNoInteractions(favoriteUpdater);
     verify(branchSupport, times(0)).createBranchComponent(any(), any(), any(), any());
-    verify(branchSupportDelegate).createComponentKey(project.getDbKey(), randomCharacteristics);
+    verify(branchSupportDelegate).createComponentKey(project.getKey(), randomCharacteristics);
     verify(branchSupportDelegate, times(0)).createBranchComponent(any(), any(), any(), any());
     verifyNoMoreInteractions(branchSupportDelegate);
     verifyQueueSubmit(project, branch, user, randomCharacteristics, taskUuid);
@@ -150,19 +150,19 @@ public class BranchReportSubmitterTest {
     Map<String, String> randomCharacteristics = randomNonEmptyMap();
     ComponentDto createdBranch = createButDoNotInsertBranch(existingProject);
     BranchSupport.ComponentKey componentKey = createComponentKeyOfBranch(createdBranch);
-    when(branchSupportDelegate.createComponentKey(existingProject.getDbKey(), randomCharacteristics))
+    when(branchSupportDelegate.createComponentKey(existingProject.getKey(), randomCharacteristics))
       .thenReturn(componentKey);
     when(branchSupportDelegate.createBranchComponent(any(DbSession.class), same(componentKey), eq(existingProject), eq(exitingProjectMainBranch)))
       .thenReturn(createdBranch);
     InputStream reportInput = IOUtils.toInputStream("{binary}", StandardCharsets.UTF_8);
     String taskUuid = mockSuccessfulPrepareSubmitCall();
 
-    underTest.submit(existingProject.getDbKey(), existingProject.name(), randomCharacteristics, reportInput);
+    underTest.submit(existingProject.getKey(), existingProject.name(), randomCharacteristics, reportInput);
 
     verifyNoInteractions(permissionTemplateService);
     verifyNoInteractions(favoriteUpdater);
     verify(branchSupport).createBranchComponent(any(DbSession.class), same(componentKey), eq(existingProject), eq(exitingProjectMainBranch));
-    verify(branchSupportDelegate).createComponentKey(existingProject.getDbKey(), randomCharacteristics);
+    verify(branchSupportDelegate).createComponentKey(existingProject.getKey(), randomCharacteristics);
     verify(branchSupportDelegate).createBranchComponent(any(DbSession.class), same(componentKey), eq(existingProject),
       eq(exitingProjectMainBranch));
     verifyNoMoreInteractions(branchSupportDelegate);
@@ -181,7 +181,7 @@ public class BranchReportSubmitterTest {
     Map<String, String> randomCharacteristics = randomNonEmptyMap();
     ComponentDto createdBranch = createButDoNotInsertBranch(nonExistingProject);
     BranchSupport.ComponentKey componentKey = createComponentKeyOfBranch(createdBranch);
-    when(branchSupportDelegate.createComponentKey(nonExistingProject.getDbKey(), randomCharacteristics))
+    when(branchSupportDelegate.createComponentKey(nonExistingProject.getKey(), randomCharacteristics))
       .thenReturn(componentKey);
     when(componentUpdater.createWithoutCommit(any(), any(), eq(user.getUuid()), eq(user.getLogin()), any()))
       .thenAnswer((Answer<ComponentDto>) invocation -> db.components().insertPrivateProject(nonExistingProject));
@@ -192,11 +192,11 @@ public class BranchReportSubmitterTest {
     String taskUuid = mockSuccessfulPrepareSubmitCall();
     InputStream reportInput = IOUtils.toInputStream("{binary}", StandardCharsets.UTF_8);
 
-    underTest.submit(nonExistingProject.getDbKey(), nonExistingProject.name(), randomCharacteristics, reportInput);
+    underTest.submit(nonExistingProject.getKey(), nonExistingProject.name(), randomCharacteristics, reportInput);
 
     BranchDto exitingProjectMainBranch = db.getDbClient().branchDao().selectByUuid(db.getSession(), nonExistingProject.uuid()).get();
     verify(branchSupport).createBranchComponent(any(DbSession.class), same(componentKey), eq(nonExistingProject), eq(exitingProjectMainBranch));
-    verify(branchSupportDelegate).createComponentKey(nonExistingProject.getDbKey(), randomCharacteristics);
+    verify(branchSupportDelegate).createComponentKey(nonExistingProject.getKey(), randomCharacteristics);
     verify(branchSupportDelegate).createBranchComponent(any(DbSession.class), same(componentKey), eq(nonExistingProject),
       eq(exitingProjectMainBranch));
     verifyNoMoreInteractions(branchSupportDelegate);
@@ -215,7 +215,7 @@ public class BranchReportSubmitterTest {
     when(branchSupportDelegate.createComponentKey(any(), any())).thenThrow(expected);
 
     try {
-      underTest.submit(project.getDbKey(), project.name(), randomCharacteristics, reportInput);
+      underTest.submit(project.getKey(), project.name(), randomCharacteristics, reportInput);
       fail("exception should have been thrown");
     } catch (Exception e) {
       assertThat(e).isSameAs(expected);
@@ -230,7 +230,7 @@ public class BranchReportSubmitterTest {
     Map<String, String> randomCharacteristics = randomNonEmptyMap();
     ComponentDto createdBranch = createButDoNotInsertBranch(nonExistingProject);
     BranchSupport.ComponentKey componentKey = createComponentKeyOfBranch(createdBranch);
-    String nonExistingProjectDbKey = nonExistingProject.getDbKey();
+    String nonExistingProjectDbKey = nonExistingProject.getKey();
     when(branchSupportDelegate.createComponentKey(nonExistingProjectDbKey, randomCharacteristics))
       .thenReturn(componentKey);
     when(branchSupportDelegate.createBranchComponent(any(DbSession.class), same(componentKey), eq(nonExistingProject), any()))
@@ -245,7 +245,7 @@ public class BranchReportSubmitterTest {
 
   private static ComponentDto createButDoNotInsertBranch(ComponentDto project) {
     BranchType randomBranchType = BranchType.values()[new Random().nextInt(BranchType.values().length)];
-    BranchDto branchDto = newBranchDto(project.projectUuid(), randomBranchType);
+    BranchDto branchDto = newBranchDto(project.branchUuid(), randomBranchType);
     return ComponentTesting.newBranchComponent(project, branchDto);
   }
 
@@ -264,20 +264,14 @@ public class BranchReportSubmitterTest {
   }
 
   private static BranchSupport.ComponentKey createComponentKeyOfBranch(ComponentDto branch) {
-    BranchSupport.ComponentKey mainComponentKey = mockComponentKey(branch.getKey(), branch.getKey());
-    when(mainComponentKey.getMainBranchComponentKey()).thenReturn(mainComponentKey);
-
-    BranchSupport.ComponentKey componentKey = mockComponentKey(branch.getKey(), branch.getDbKey());
+    BranchSupport.ComponentKey componentKey = mockComponentKey(branch.getKey());
     when(componentKey.getBranchName()).thenReturn(Optional.of(branch).map(ComponentDto::name));
-    when(componentKey.getMainBranchComponentKey()).thenReturn(mainComponentKey);
-
     return componentKey;
   }
 
-  private static BranchSupport.ComponentKey mockComponentKey(String key, String dbKey) {
+  private static BranchSupport.ComponentKey mockComponentKey(String key) {
     BranchSupport.ComponentKey componentKey = mock(BranchSupport.ComponentKey.class);
     when(componentKey.getKey()).thenReturn(key);
-    when(componentKey.getDbKey()).thenReturn(dbKey);
     return componentKey;
   }
 
index 67b4cecdf88b65647d21bbf6b8cd3edced9dbe84..61a55cab2022634528b1746b53cf82314e16061b 100644 (file)
@@ -57,8 +57,6 @@ public class BranchSupportTest {
     assertThat(componentKey)
       .isEqualTo(underTestWithBranch.createComponentKey(projectKey, NO_CHARACTERISTICS));
     assertThat(componentKey.getKey()).isEqualTo(projectKey);
-    assertThat(componentKey.getDbKey()).isEqualTo(projectKey);
-    assertThat(componentKey.getMainBranchComponentKey()).isSameAs(componentKey);
     assertThat(componentKey.getBranchName()).isEmpty();
     assertThat(componentKey.getPullRequestKey()).isEmpty();
   }
index 937a7072b80f7129a0f6267e8a285157aea9e2cf..6c87dca07a39a1f7250e303450e0d635cf21478e 100644 (file)
@@ -138,7 +138,7 @@ public class ReportSubmitterTest {
     userSession.logIn(user).addProjectPermission(SCAN_EXECUTION, project);
     mockSuccessfulPrepareSubmitCall();
 
-    underTest.submit(project.getDbKey(), project.name(), emptyMap(), IOUtils.toInputStream("{binary}", StandardCharsets.UTF_8));
+    underTest.submit(project.getKey(), project.name(), emptyMap(), IOUtils.toInputStream("{binary}", StandardCharsets.UTF_8));
 
     verifyReportIsPersisted(TASK_UUID);
     verifyNoInteractions(permissionTemplateService);
@@ -237,7 +237,7 @@ public class ReportSubmitterTest {
     userSession.addPermission(SCAN);
     mockSuccessfulPrepareSubmitCall();
 
-    underTest.submit(project.getDbKey(), project.name(), emptyMap(), IOUtils.toInputStream("{binary}"));
+    underTest.submit(project.getKey(), project.name(), emptyMap(), IOUtils.toInputStream("{binary}"));
 
     verify(queue).submit(any(CeTaskSubmit.class));
   }
@@ -248,7 +248,7 @@ public class ReportSubmitterTest {
     userSession.addProjectPermission(SCAN_EXECUTION, project);
     mockSuccessfulPrepareSubmitCall();
 
-    underTest.submit(project.getDbKey(), project.name(), emptyMap(), IOUtils.toInputStream("{binary}"));
+    underTest.submit(project.getKey(), project.name(), emptyMap(), IOUtils.toInputStream("{binary}"));
 
     verify(queue).submit(any(CeTaskSubmit.class));
   }
@@ -259,7 +259,7 @@ public class ReportSubmitterTest {
     userSession.logIn().addProjectPermission(SCAN_EXECUTION, component);
     mockSuccessfulPrepareSubmitCall();
 
-    String dbKey = component.getDbKey();
+    String dbKey = component.getKey();
     String name = component.name();
     Map<String, String> emptyMap = emptyMap();
     InputStream stream = IOUtils.toInputStream("{binary}", UTF_8);
@@ -275,7 +275,7 @@ public class ReportSubmitterTest {
     userSession.logIn().addProjectPermission(SCAN_EXECUTION, project);
     mockSuccessfulPrepareSubmitCall();
 
-    String moduleDbKey = module.getDbKey();
+    String moduleDbKey = module.getKey();
     String name = module.name();
     Map<String, String> emptyMap = emptyMap();
     InputStream inputStream = IOUtils.toInputStream("{binary}", UTF_8);
index 97e4bbb792b371ef8add68adc755ddfa4ecceba7..2af87ecd1bcc70a3c08e23c027ee55649a20657b 100644 (file)
@@ -294,7 +294,7 @@ public class ActivityActionTest {
     insertActivity("T1", project1, SUCCESS);
     insertActivity("T2", project2, FAILED);
 
-    ActivityResponse activityResponse = call(ws.newRequest().setParam("component", project1.getDbKey()));
+    ActivityResponse activityResponse = call(ws.newRequest().setParam("component", project1.getKey()));
 
     assertThat(activityResponse.getTasksCount()).isOne();
     assertThat(activityResponse.getTasks(0).getId()).isEqualTo("T1");
index 57417501bc5f47ead4805e5d5ec65de1edae2a68..6c2afc4a455775b5df8ee9c0751a40ce5f6f89da 100644 (file)
@@ -91,10 +91,10 @@ public class ActivityStatusActionTest {
   public void status_for_a_project_as_project_admin() {
     String projectKey = "project-key";
     String anotherProjectKey = "another-project-key";
-    ComponentDto project = newPrivateProjectDto().setDbKey(projectKey);
-    ComponentDto anotherProject = newPrivateProjectDto().setDbKey(anotherProjectKey);
+    ComponentDto project = newPrivateProjectDto().setKey(projectKey);
+    ComponentDto anotherProject = newPrivateProjectDto().setKey(anotherProjectKey);
     db.components().insertComponent(project);
-    db.components().insertComponent(newPrivateProjectDto().setDbKey(anotherProjectKey));
+    db.components().insertComponent(newPrivateProjectDto().setKey(anotherProjectKey));
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
     // pending tasks returned
     insertInQueue(CeQueueDto.Status.PENDING, project);
@@ -119,7 +119,7 @@ public class ActivityStatusActionTest {
   @Test
   public void add_pending_time() {
     String projectKey = "project-key";
-    ComponentDto project = newPrivateProjectDto().setDbKey(projectKey);
+    ComponentDto project = newPrivateProjectDto().setKey(projectKey);
     db.components().insertComponent(project);
 
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
@@ -160,7 +160,7 @@ public class ActivityStatusActionTest {
     userSession.logIn();
     ComponentDto project = db.components().insertPrivateProject();
 
-    String dbKey = project.getDbKey();
+    String dbKey = project.getKey();
     assertThatThrownBy(() -> callByComponentKey(dbKey))
       .isInstanceOf(ForbiddenException.class)
       .hasMessage("Insufficient privileges");
index 1592cc4a70538da4547bc3c2f935fb371de1a821..8288322c1af91c3b242fe86fa2b7e6cef42740a4 100644 (file)
@@ -293,7 +293,7 @@ public class AnalysisStatusActionTest {
 
   @Test
   public void json_example() {
-    ComponentDto project = db.components().insertPrivateProject(p -> p.setDbKey("com.github.kevinsawicki:http-request-parent")
+    ComponentDto project = db.components().insertPrivateProject(p -> p.setKey("com.github.kevinsawicki:http-request-parent")
       .setName("HttpRequest"));
     SnapshotDto analysis = db.components().insertSnapshot(project);
     CeActivityDto activity = insertActivity("task-uuid" + counter++, project, SUCCESS, analysis, REPORT);
index 187040078bfcb729a1d14d481fe0e6f2f1ca96a9..057c44514bfcef216ee4a9e4c736eb7e7caa7b1d 100644 (file)
@@ -169,7 +169,7 @@ public class CancelActionTest {
   }
 
   private static ComponentDto nonExistentComponentDot() {
-    return new ComponentDto().setUuid("does_not_exist").setProjectUuid("unknown");
+    return new ComponentDto().setUuid("does_not_exist").setBranchUuid("unknown");
   }
 
   private void logInAsSystemAdministrator() {
index 87dafeab83876d0b059a7bdcc2aac88c31ab0e48..a08844c3293e17cb848a2e6c31e4c692252fe553 100644 (file)
@@ -118,7 +118,7 @@ public class ComponentActionTest {
     insertActivity("T1", project, CeActivityDto.Status.SUCCESS, analysis);
 
     Ce.ComponentResponse response = ws.newRequest()
-      .setParam(PARAM_COMPONENT, project.getDbKey())
+      .setParam(PARAM_COMPONENT, project.getKey())
       .executeProtobuf(Ce.ComponentResponse.class);
     assertThat(response.hasCurrent()).isTrue();
     Ce.Task current = response.getCurrent();
index e5dcca0070bb0b8411d86b93e49157614754b950..13d79e5507e124064ede1c96131cdae103e3e7da 100644 (file)
@@ -104,7 +104,7 @@ public class TaskActionTest {
     assertThat(taskResponse.getTask().getStatus()).isEqualTo(Ce.TaskStatus.PENDING);
     assertThat(taskResponse.getTask().getSubmitterLogin()).isEqualTo(user.getLogin());
     assertThat(taskResponse.getTask().getComponentId()).isEqualTo(privateProject.uuid());
-    assertThat(taskResponse.getTask().getComponentKey()).isEqualTo(privateProject.getDbKey());
+    assertThat(taskResponse.getTask().getComponentKey()).isEqualTo(privateProject.getKey());
     assertThat(taskResponse.getTask().getComponentName()).isEqualTo(privateProject.name());
     assertThat(taskResponse.getTask().hasExecutionTimeMs()).isFalse();
     assertThat(taskResponse.getTask().getWarningCount()).isZero();
@@ -149,7 +149,7 @@ public class TaskActionTest {
     assertThat(task.getId()).isEqualTo(SOME_TASK_UUID);
     assertThat(task.getStatus()).isEqualTo(Ce.TaskStatus.FAILED);
     assertThat(task.getComponentId()).isEqualTo(privateProject.uuid());
-    assertThat(task.getComponentKey()).isEqualTo(privateProject.getDbKey());
+    assertThat(task.getComponentKey()).isEqualTo(privateProject.getKey());
     assertThat(task.getComponentName()).isEqualTo(privateProject.name());
     assertThat(task.getAnalysisId()).isEqualTo(activityDto.getAnalysisUuid());
     assertThat(task.getExecutionTimeMs()).isEqualTo(500L);
index c2e6ec453917e6eab3d0e7324dec9f638fab840c..e59f4b394bcc2959f5b21cb92b5dca1744253ab3 100644 (file)
@@ -86,7 +86,7 @@ public class TaskFormatterTest {
   @Test
   public void formatQueue_with_component_and_other_fields() {
     String uuid = "COMPONENT_UUID";
-    db.components().insertPrivateProject((t) -> t.setUuid(uuid).setDbKey("COMPONENT_KEY").setName("Component Name"));
+    db.components().insertPrivateProject((t) -> t.setUuid(uuid).setKey("COMPONENT_KEY").setName("Component Name"));
     UserDto user = db.users().insertUser();
 
     CeQueueDto dto = new CeQueueDto();
index 7ed73540c0ab98c4d1175ab535edde30aef5f87a..db813338c1e71b23833b546248cbcec393a8f069 100644 (file)
@@ -103,10 +103,10 @@ public class ComponentFinderTest {
     ComponentDto project = db.components().insertPublicProject();
     ComponentDto branch = db.components().insertProjectBranch(project);
 
-    String branchDbKey = branch.getDbKey();
+    String branchDbKey = branch.getKey();
     assertThatThrownBy(() -> underTest.getByUuidOrKey(dbSession, null, branchDbKey, ID_AND_KEY))
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Component key '%s' not found", branch.getDbKey()));
+      .hasMessage(format("Component key '%s' not found", branch.getKey()));
   }
 
   @Test
@@ -133,7 +133,7 @@ public class ComponentFinderTest {
   @Test
   public void fail_when_component_key_is_removed() {
     ComponentDto project = db.components().insertComponent(newPrivateProjectDto());
-    db.components().insertComponent(newFileDto(project).setDbKey("file-key").setEnabled(false));
+    db.components().insertComponent(newFileDto(project).setKey("file-key").setEnabled(false));
 
     assertThatThrownBy(() -> underTest.getByKey(dbSession, "file-key"))
       .isInstanceOf(NotFoundException.class)
@@ -145,7 +145,7 @@ public class ComponentFinderTest {
     ComponentDto project = db.components().insertPublicProject();
     ComponentDto branch = db.components().insertProjectBranch(project);
 
-    String branchDbKey = branch.getDbKey();
+    String branchDbKey = branch.getKey();
     assertThatThrownBy(() -> underTest.getByKey(dbSession, branchDbKey))
       .isInstanceOf(NotFoundException.class)
       .hasMessage(format("Component key '%s' not found", branchDbKey));
@@ -162,11 +162,11 @@ public class ComponentFinderTest {
 
   @Test
   public void get_component_by_key() {
-    db.components().insertComponent(newPrivateProjectDto().setDbKey("project-key"));
+    db.components().insertComponent(newPrivateProjectDto().setKey("project-key"));
 
     ComponentDto component = underTest.getByUuidOrKey(dbSession, null, "project-key", ID_AND_KEY);
 
-    assertThat(component.getDbKey()).isEqualTo("project-key");
+    assertThat(component.getKey()).isEqualTo("project-key");
   }
 
   @Test
index 5c4d384f0f16e922a3f7e9ff675f666f9ac20b0c..2011ad12c262ed50c906d0260afbc446c9b7550c 100644 (file)
@@ -64,8 +64,8 @@ public class ComponentServiceUpdateKeyTest {
   @Test
   public void update_project_key() {
     ComponentDto project = insertSampleProject();
-    ComponentDto file = componentDb.insertComponent(ComponentTesting.newFileDto(project, null).setDbKey("sample:root:src/File.xoo"));
-    ComponentDto inactiveFile = componentDb.insertComponent(ComponentTesting.newFileDto(project, null).setDbKey("sample:root:src/InactiveFile.xoo").setEnabled(false));
+    ComponentDto file = componentDb.insertComponent(ComponentTesting.newFileDto(project, null).setKey("sample:root:src/File.xoo"));
+    ComponentDto inactiveFile = componentDb.insertComponent(ComponentTesting.newFileDto(project, null).setKey("sample:root:src/InactiveFile.xoo").setEnabled(false));
 
     dbSession.commit();
 
@@ -74,15 +74,15 @@ public class ComponentServiceUpdateKeyTest {
     dbSession.commit();
 
     // Check project key has been updated
-    assertThat(db.getDbClient().componentDao().selectByKey(dbSession, project.getDbKey())).isEmpty();
+    assertThat(db.getDbClient().componentDao().selectByKey(dbSession, project.getKey())).isEmpty();
     assertThat(db.getDbClient().componentDao().selectByKey(dbSession, "sample2:root")).isNotNull();
 
     // Check file key has been updated
-    assertThat(db.getDbClient().componentDao().selectByKey(dbSession, file.getDbKey())).isEmpty();
+    assertThat(db.getDbClient().componentDao().selectByKey(dbSession, file.getKey())).isEmpty();
     assertThat(db.getDbClient().componentDao().selectByKey(dbSession, "sample2:root:src/File.xoo")).isNotNull();
     assertThat(db.getDbClient().componentDao().selectByKey(dbSession, "sample2:root:src/InactiveFile.xoo")).isNotNull();
 
-    assertThat(dbClient.componentDao().selectByKey(dbSession, inactiveFile.getDbKey())).isEmpty();
+    assertThat(dbClient.componentDao().selectByKey(dbSession, inactiveFile.getKey())).isEmpty();
 
     assertThat(projectIndexers.hasBeenCalled(project.uuid(), ProjectIndexer.Cause.PROJECT_KEY_UPDATE)).isTrue();
 
@@ -108,7 +108,7 @@ public class ComponentServiceUpdateKeyTest {
     underTest.updateKey(dbSession, componentDb.getProjectDto(provisionedProject), "provisionedProject2");
     dbSession.commit();
 
-    assertComponentKeyHasBeenUpdated(provisionedProject.getDbKey(), "provisionedProject2");
+    assertComponentKeyHasBeenUpdated(provisionedProject.getKey(), "provisionedProject2");
     assertThat(projectIndexers.hasBeenCalled(provisionedProject.uuid(), ProjectIndexer.Cause.PROJECT_KEY_UPDATE)).isTrue();
   }
 
@@ -129,7 +129,7 @@ public class ComponentServiceUpdateKeyTest {
     logInAsProjectAdministrator(project);
 
     ProjectDto projectDto = componentDb.getProjectDto(project);
-    String anotherProjectDbKey = anotherProject.getDbKey();
+    String anotherProjectDbKey = anotherProject.getKey();
     assertThatThrownBy(() -> underTest.updateKey(dbSession, projectDto,
       anotherProjectDbKey))
       .isInstanceOf(IllegalArgumentException.class)
@@ -163,7 +163,7 @@ public class ComponentServiceUpdateKeyTest {
   }
 
   private ComponentDto insertProject(String key) {
-    return componentDb.insertPrivateProject(c -> c.setDbKey(key));
+    return componentDb.insertPrivateProject(c -> c.setKey(key));
   }
 
   private void assertComponentKeyHasBeenUpdated(String oldKey, String newKey) {
index 35b27f35e0298c57ccb54cb7fcc16d4c81ebbed3..fee559a446e994261ba8547bfb57d73b9fbbcd12 100644 (file)
@@ -81,13 +81,13 @@ public class ComponentUpdaterTest {
     ComponentDto returned = underTest.create(db.getSession(), project, null, null);
 
     ComponentDto loaded = db.getDbClient().componentDao().selectOrFailByUuid(db.getSession(), returned.uuid());
-    assertThat(loaded.getDbKey()).isEqualTo(DEFAULT_PROJECT_KEY);
+    assertThat(loaded.getKey()).isEqualTo(DEFAULT_PROJECT_KEY);
     assertThat(loaded.name()).isEqualTo(DEFAULT_PROJECT_NAME);
     assertThat(loaded.longName()).isEqualTo(DEFAULT_PROJECT_NAME);
     assertThat(loaded.qualifier()).isEqualTo(Qualifiers.PROJECT);
     assertThat(loaded.scope()).isEqualTo(Scopes.PROJECT);
     assertThat(loaded.uuid()).isNotNull();
-    assertThat(loaded.projectUuid()).isEqualTo(loaded.uuid());
+    assertThat(loaded.branchUuid()).isEqualTo(loaded.uuid());
     assertThat(loaded.moduleUuid()).isNull();
     assertThat(loaded.moduleUuidPath()).isEqualTo("." + loaded.uuid() + ".");
     assertThat(loaded.isPrivate()).isEqualTo(project.isPrivate());
@@ -140,7 +140,7 @@ public class ComponentUpdaterTest {
     ComponentDto returned = underTest.create(db.getSession(), view, null, null);
 
     ComponentDto loaded = db.getDbClient().componentDao().selectOrFailByUuid(db.getSession(), returned.uuid());
-    assertThat(loaded.getDbKey()).isEqualTo("view-key");
+    assertThat(loaded.getKey()).isEqualTo("view-key");
     assertThat(loaded.name()).isEqualTo("view-name");
     assertThat(loaded.qualifier()).isEqualTo("VW");
     assertThat(projectIndexers.hasBeenCalled(loaded.uuid(), ProjectIndexer.Cause.PROJECT_CREATION)).isTrue();
@@ -159,7 +159,7 @@ public class ComponentUpdaterTest {
     ComponentDto returned = underTest.create(db.getSession(), application, null, null);
 
     ComponentDto loaded = db.getDbClient().componentDao().selectOrFailByUuid(db.getSession(), returned.uuid());
-    assertThat(loaded.getDbKey()).isEqualTo("app-key");
+    assertThat(loaded.getKey()).isEqualTo("app-key");
     assertThat(loaded.name()).isEqualTo("app-name");
     assertThat(loaded.qualifier()).isEqualTo("APP");
     assertThat(projectIndexers.hasBeenCalled(loaded.uuid(), ProjectIndexer.Cause.PROJECT_CREATION)).isTrue();
@@ -248,12 +248,12 @@ public class ComponentUpdaterTest {
 
     DbSession session = db.getSession();
     NewComponent newComponent = NewComponent.newComponentBuilder()
-      .setKey(existing.getDbKey())
+      .setKey(existing.getKey())
       .setName(DEFAULT_PROJECT_NAME)
       .build();
     assertThatThrownBy(() -> underTest.create(session, newComponent, null, null))
       .isInstanceOf(BadRequestException.class)
-      .hasMessage("Could not create Project with key: \"%s\". A similar key already exists: \"%s\"", existing.getDbKey(), existing.getDbKey());
+      .hasMessage("Could not create Project, key already exists: " + existing.getKey());
   }
 
   @Test
@@ -283,7 +283,7 @@ public class ComponentUpdaterTest {
   @Test
   public void create_shouldFail_whenCreatingProjectWithExistingKeyButDifferentCase() {
     String existingKey = randomAlphabetic(5).toUpperCase();
-    db.components().insertPrivateProject(component -> component.setDbKey(existingKey));
+    db.components().insertPrivateProject(component -> component.setKey(existingKey));
     String newKey = existingKey.toLowerCase();
 
     NewComponent newComponent = NewComponent.newComponentBuilder()
index 7a5aa84dcc76ace6fc7a03ae816c02e3326d4c78..2b7e5c30c4280a0942bf5c8342da2ca4ed66543b 100644 (file)
@@ -174,7 +174,7 @@ public class AppActionTest {
     userSession.logIn("john").addProjectPermission(USER, project);
 
     String result = ws.newRequest()
-      .setParam("component", file.getDbKey())
+      .setParam("component", file.getKey())
       .execute()
       .getInput();
 
@@ -299,7 +299,7 @@ public class AppActionTest {
     ComponentDto file = db.components().insertComponent(newFileDto(branch));
 
     String result = ws.newRequest()
-      .setParam("component", file.getDbKey())
+      .setParam("component", file.getKey())
       .setParam("branch", file.getBranch())
       .execute()
       .getInput();
@@ -328,7 +328,7 @@ public class AppActionTest {
     ComponentDto file = db.components().insertComponent(newFileDto(branch));
 
     String result = ws.newRequest()
-      .setParam("component", file.getDbKey())
+      .setParam("component", file.getKey())
       .setParam("pullRequest", file.getPullRequest())
       .execute()
       .getInput();
@@ -357,7 +357,7 @@ public class AppActionTest {
     ComponentDto file = db.components().insertComponent(newFileDto(branch));
 
     TestRequest request = ws.newRequest()
-      .setParam("component", file.getDbKey())
+      .setParam("component", file.getKey())
       .setParam("branch", "unknown_branch")
       .setParam("pullRequest", "unknown_component");
     assertThatThrownBy(request::execute)
index 3a3d074f79342fd7b9b14e87619607800ecc142c..771f7f0ac4ac6788a8b5509a99e8680f25fa4020 100644 (file)
@@ -125,8 +125,8 @@ public class SearchActionTest {
   @Test
   public void search_by_key_query() {
     insertProjectsAuthorizedForUser(
-      ComponentTesting.newPrivateProjectDto().setDbKey("project-_%-key"),
-      ComponentTesting.newPrivateProjectDto().setDbKey("project-key-without-escaped-characters"));
+      ComponentTesting.newPrivateProjectDto().setKey("project-_%-key"),
+      ComponentTesting.newPrivateProjectDto().setKey("project-key-without-escaped-characters"));
 
     SearchWsResponse response = call(new SearchRequest().setQuery("project-_%-key").setQualifiers(singletonList(PROJECT)));
 
@@ -137,7 +137,7 @@ public class SearchActionTest {
   public void search_with_pagination() {
     List<ComponentDto> componentDtoList = new ArrayList<>();
     for (int i = 1; i <= 9; i++) {
-      componentDtoList.add(newPrivateProjectDto("project-uuid-" + i).setDbKey("project-key-" + i).setName("Project Name " + i));
+      componentDtoList.add(newPrivateProjectDto("project-uuid-" + i).setKey("project-key-" + i).setName("Project Name " + i));
     }
     insertProjectsAuthorizedForUser(componentDtoList.toArray(new ComponentDto[] {}));
 
@@ -158,7 +158,7 @@ public class SearchActionTest {
     SearchWsResponse response = call(new SearchRequest().setQualifiers(singletonList(PROJECT)));
 
     assertThat(response.getComponentsList()).extracting(Component::getKey)
-      .containsExactlyInAnyOrder(project1.getDbKey());
+      .containsExactlyInAnyOrder(project1.getKey());
     assertThat(response.getPaging().getTotal()).isOne();
   }
 
@@ -166,16 +166,16 @@ public class SearchActionTest {
   public void return_project_key() {
     ComponentDto project = ComponentTesting.newPublicProjectDto();
     ComponentDto module = ComponentTesting.newModuleDto(project);
-    ComponentDto dir1 = newDirectory(module, "dir1").setDbKey("dir1");
-    ComponentDto dir2 = newDirectory(module, "dir2").setDbKey("dir2");
-    ComponentDto dir3 = newDirectory(project, "dir3").setDbKey("dir3");
+    ComponentDto dir1 = newDirectory(module, "dir1").setKey("dir1");
+    ComponentDto dir2 = newDirectory(module, "dir2").setKey("dir2");
+    ComponentDto dir3 = newDirectory(project, "dir3").setKey("dir3");
     db.components().insertComponents(project, module, dir1, dir2, dir3);
     setBrowsePermissionOnUserAndIndex(project);
 
     SearchWsResponse response = call(new SearchRequest().setQualifiers(asList(PROJECT, APP)));
 
     assertThat(response.getComponentsList()).extracting(Component::getKey, Component::getProject)
-      .containsOnly(tuple(project.getDbKey(), project.getDbKey()));
+      .containsOnly(tuple(project.getKey(), project.getKey()));
   }
 
   @Test
@@ -187,7 +187,7 @@ public class SearchActionTest {
     SearchWsResponse response = call(new SearchRequest().setQualifiers(asList(PROJECT)));
 
     assertThat(response.getComponentsList()).extracting(Component::getKey)
-      .containsOnly(project.getDbKey());
+      .containsOnly(project.getKey());
   }
 
   @Test
@@ -209,9 +209,9 @@ public class SearchActionTest {
   @Test
   public void test_json_example() {
     db.components().insertComponent(newPortfolio());
-    ComponentDto project = newPrivateProjectDto("project-uuid").setName("Project Name").setDbKey("project-key");
-    ComponentDto module = newModuleDto("module-uuid", project).setName("Module Name").setDbKey("module-key");
-    ComponentDto directory = newDirectory(module, "path/to/directoy").setUuid("directory-uuid").setDbKey("directory-key").setName("Directory Name");
+    ComponentDto project = newPrivateProjectDto("project-uuid").setName("Project Name").setKey("project-key");
+    ComponentDto module = newModuleDto("module-uuid", project).setName("Module Name").setKey("module-key");
+    ComponentDto directory = newDirectory(module, "path/to/directoy").setUuid("directory-uuid").setKey("directory-key").setName("Directory Name");
     ComponentDto view = newPortfolio();
     db.components().insertComponents(project, module, directory, view);
     setBrowsePermissionOnUserAndIndex(project);
index 83ba890ff27a176005539b3664b88c83527b3866..03bbabbe88f70fd9d2979f3b8002e82bb76542e6 100644 (file)
@@ -236,17 +236,17 @@ public class SearchProjectsActionTest {
     userSession.logIn();
     MetricDto coverage = db.measures().insertMetric(c -> c.setKey(COVERAGE).setValueType("PERCENT"));
     ComponentDto project1 = insertProject(
-      c -> c.setDbKey(KEY_PROJECT_EXAMPLE_001).setName("My Project 1"),
+      c -> c.setKey(KEY_PROJECT_EXAMPLE_001).setName("My Project 1"),
       p -> p.setTagsString("finance, java"),
       new Measure(coverage, c -> c.setValue(80d)));
 
     db.components().insertProjectBranch(db.components().getProjectDto(project1), branchDto -> branchDto.setNeedIssueSync(true));
 
     ComponentDto project2 = insertProject(
-      c -> c.setDbKey(KEY_PROJECT_EXAMPLE_002).setName("My Project 2"),
+      c -> c.setKey(KEY_PROJECT_EXAMPLE_002).setName("My Project 2"),
       new Measure(coverage, c -> c.setValue(90d)));
     ComponentDto project3 = insertProject(
-      c -> c.setDbKey(KEY_PROJECT_EXAMPLE_003).setName("My Project 3"),
+      c -> c.setKey(KEY_PROJECT_EXAMPLE_003).setName("My Project 3"),
       p -> p.setTagsString("sales, offshore, java"),
       new Measure(coverage, c -> c.setValue(20d)));
     addFavourite(project1);
@@ -265,7 +265,7 @@ public class SearchProjectsActionTest {
       .executeProtobuf(SearchProjectsWsResponse.class);
 
     assertThat(protobufResult.getComponentsList()).extracting(Component::getKey)
-      .containsExactly(project1.getDbKey(), project2.getDbKey(), project3.getDbKey());
+      .containsExactly(project1.getKey(), project2.getKey(), project3.getKey());
   }
 
   @Test
@@ -330,7 +330,7 @@ public class SearchProjectsActionTest {
 
     SearchProjectsWsResponse result = call(request.setFilter("coverage <= 80 and ncloc <= 10000"));
 
-    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(project2.getDbKey());
+    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(project2.getKey());
   }
 
   @Test
@@ -346,7 +346,7 @@ public class SearchProjectsActionTest {
 
     assertThat(result.getComponentsList())
       .extracting(Component::getKey)
-      .containsExactlyInAnyOrder(project1.getDbKey(), project2.getDbKey());
+      .containsExactlyInAnyOrder(project1.getKey(), project2.getKey());
   }
 
   @Test
@@ -366,7 +366,7 @@ public class SearchProjectsActionTest {
 
     SearchProjectsWsResponse result = call(request.setFilter("languages IN (java, js, <null>)"));
 
-    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project2.getDbKey(), project4.getDbKey());
+    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getKey(), project2.getKey(), project4.getKey());
   }
 
   @Test
@@ -381,7 +381,7 @@ public class SearchProjectsActionTest {
 
     SearchProjectsWsResponse result = call(request.setFilter(metricKey + " = 2"));
 
-    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(project2.getDbKey());
+    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(project2.getKey());
   }
 
   @Test
@@ -396,7 +396,7 @@ public class SearchProjectsActionTest {
 
     SearchProjectsWsResponse result = call(request.setFilter(newMetricKey + " = 2"));
 
-    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(project2.getDbKey());
+    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(project2.getKey());
   }
 
   @Test
@@ -409,7 +409,7 @@ public class SearchProjectsActionTest {
 
     SearchProjectsWsResponse result = call(request.setFilter("tags in (finance, offshore)"));
 
-    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project3.getDbKey());
+    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getKey(), project3.getKey());
   }
 
   @Test
@@ -423,7 +423,7 @@ public class SearchProjectsActionTest {
 
     SearchProjectsWsResponse result = call(request.setFilter("coverage <= 80"));
 
-    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project3.getDbKey());
+    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getKey(), project3.getKey());
   }
 
   @Test
@@ -437,7 +437,7 @@ public class SearchProjectsActionTest {
 
     SearchProjectsWsResponse result = call(request.setFilter("new_coverage <= 80"));
 
-    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project3.getDbKey());
+    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getKey(), project3.getKey());
   }
 
   @Test
@@ -451,7 +451,7 @@ public class SearchProjectsActionTest {
 
     SearchProjectsWsResponse result = call(request.setFilter("duplicated_lines_density <= 80"));
 
-    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project3.getDbKey());
+    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getKey(), project3.getKey());
   }
 
   @Test
@@ -466,7 +466,7 @@ public class SearchProjectsActionTest {
 
     SearchProjectsWsResponse result = call(request.setFilter("duplicated_lines_density = NO_DATA"));
 
-    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey());
+    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getKey());
   }
 
   @Test
@@ -493,7 +493,7 @@ public class SearchProjectsActionTest {
 
     SearchProjectsWsResponse result = call(request.setFilter("new_duplicated_lines_density <= 80"));
 
-    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project3.getDbKey());
+    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getKey(), project3.getKey());
   }
 
   @Test
@@ -507,7 +507,7 @@ public class SearchProjectsActionTest {
 
     SearchProjectsWsResponse result = call(request.setFilter("ncloc <= 80"));
 
-    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project3.getDbKey());
+    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getKey(), project3.getKey());
   }
 
   @Test
@@ -521,16 +521,16 @@ public class SearchProjectsActionTest {
 
     SearchProjectsWsResponse result = call(request.setFilter("new_lines <= 80"));
 
-    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project3.getDbKey());
+    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getKey(), project3.getKey());
   }
 
   @Test
   public void filter_projects_by_text_query() {
     userSession.logIn();
-    insertProject(c -> c.setDbKey("sonar-java").setName("Sonar Java"));
-    insertProject(c -> c.setDbKey("sonar-groovy").setName("Sonar Groovy"));
-    insertProject(c -> c.setDbKey("sonar-markdown").setName("Sonar Markdown"));
-    insertProject(c -> c.setDbKey("sonarqube").setName("Sonar Qube"));
+    insertProject(c -> c.setKey("sonar-java").setName("Sonar Java"));
+    insertProject(c -> c.setKey("sonar-groovy").setName("Sonar Groovy"));
+    insertProject(c -> c.setKey("sonar-markdown").setName("Sonar Markdown"));
+    insertProject(c -> c.setKey("sonarqube").setName("Sonar Qube"));
     index();
 
     assertThat(call(request.setFilter("query = \"Groovy\"")).getComponentsList()).extracting(Component::getName).containsOnly("Sonar Groovy");
@@ -551,7 +551,7 @@ public class SearchProjectsActionTest {
     SearchProjectsWsResponse result = call(request.setFilter("isFavorite"));
 
     assertThat(result.getComponentsCount()).isEqualTo(2);
-    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(javaProject.getDbKey(), markDownProject.getDbKey());
+    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(javaProject.getKey(), markDownProject.getKey());
   }
 
   @Test
@@ -568,7 +568,7 @@ public class SearchProjectsActionTest {
     SearchProjectsWsResponse result = call(request.setFilter("isFavorite"));
 
     assertThat(result.getComponentsCount()).isEqualTo(2);
-    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(javaProject.getDbKey(), markDownProject.getDbKey());
+    assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(javaProject.getKey(), markDownProject.getKey());
   }
 
   @Test
@@ -613,7 +613,7 @@ public class SearchProjectsActionTest {
       .containsExactly(
         Stream.of(application1, application2, application3, project1, project2, project3)
           .filter(c -> Stream.of(qualifiers).anyMatch(s -> s.equals(c.qualifier())))
-          .map(ComponentDto::getDbKey)
+          .map(ComponentDto::getKey)
           .toArray(String[]::new));
   }
 
@@ -639,7 +639,7 @@ public class SearchProjectsActionTest {
     assertThat(result.getComponentsCount()).isEqualTo(3);
 
     assertThat(result.getComponentsList()).extracting(Component::getKey)
-      .containsExactly(Stream.of(project1, project2, project3).map(ComponentDto::getDbKey).toArray(String[]::new));
+      .containsExactly(Stream.of(project1, project2, project3).map(ComponentDto::getKey).toArray(String[]::new));
   }
 
   @Test
@@ -664,7 +664,7 @@ public class SearchProjectsActionTest {
     assertThat(result.getComponentsList()).extracting(Component::getKey)
       .containsExactly(
         Stream.of(application1, application2, application3)
-          .map(ComponentDto::getDbKey)
+          .map(ComponentDto::getKey)
           .toArray(String[]::new));
   }
 
@@ -691,7 +691,7 @@ public class SearchProjectsActionTest {
     assertThat(result.getComponentsList()).extracting(Component::getKey)
       .containsExactly(
         Stream.of(project1, project2, project3)
-          .map(ComponentDto::getDbKey)
+          .map(ComponentDto::getKey)
           .toArray(String[]::new));
   }
 
@@ -1160,9 +1160,9 @@ public class SearchProjectsActionTest {
     index();
 
     assertThat(call(request.setSort(COVERAGE).setAsc(true)).getComponentsList()).extracting(Component::getKey)
-      .containsExactly(project3.getDbKey(), project4.getDbKey(), project2.getDbKey(), project1.getDbKey());
+      .containsExactly(project3.getKey(), project4.getKey(), project2.getKey(), project1.getKey());
     assertThat(call(request.setSort(COVERAGE).setAsc(false)).getComponentsList()).extracting(Component::getKey)
-      .containsExactly(project2.getDbKey(), project1.getDbKey(), project3.getDbKey(), project4.getDbKey());
+      .containsExactly(project2.getKey(), project1.getKey(), project3.getKey(), project4.getKey());
   }
 
   @Test
@@ -1176,33 +1176,33 @@ public class SearchProjectsActionTest {
     index();
 
     assertThat(call(request.setSort(QUALITY_GATE_STATUS).setAsc(true)).getComponentsList()).extracting(Component::getKey)
-      .containsExactly(project3.getDbKey(), project4.getDbKey(), project2.getDbKey(), project1.getDbKey());
+      .containsExactly(project3.getKey(), project4.getKey(), project2.getKey(), project1.getKey());
     assertThat(call(request.setSort(QUALITY_GATE_STATUS).setAsc(false)).getComponentsList()).extracting(Component::getKey)
-      .containsExactly(project2.getDbKey(), project1.getDbKey(), project3.getDbKey(), project4.getDbKey());
+      .containsExactly(project2.getKey(), project1.getKey(), project3.getKey(), project4.getKey());
   }
 
   @Test
   public void sort_by_last_analysis_date() {
     userSession.logIn();
-    ComponentDto project1 = db.components().insertPublicProject(p -> p.setDbKey("project1"));
+    ComponentDto project1 = db.components().insertPublicProject(p -> p.setKey("project1"));
     authorizationIndexerTester.allowOnlyAnyone(project1);
-    ComponentDto project2 = db.components().insertPublicProject(p -> p.setDbKey("project2"));
+    ComponentDto project2 = db.components().insertPublicProject(p -> p.setKey("project2"));
     db.components().insertSnapshot(project2, snapshot -> snapshot.setCreatedAt(40_000_000_000L).setLast(true));
     authorizationIndexerTester.allowOnlyAnyone(project2);
-    ComponentDto project3 = db.components().insertPublicProject(p -> p.setDbKey("project3"));
+    ComponentDto project3 = db.components().insertPublicProject(p -> p.setKey("project3"));
     db.components().insertSnapshot(project3, snapshot -> snapshot.setCreatedAt(20_000_000_000L).setLast(true));
     authorizationIndexerTester.allowOnlyAnyone(project3);
-    ComponentDto project4 = db.components().insertPublicProject(p -> p.setDbKey("project4"));
+    ComponentDto project4 = db.components().insertPublicProject(p -> p.setKey("project4"));
     db.components().insertSnapshot(project4, snapshot -> snapshot.setCreatedAt(10_000_000_000L).setLast(false));
     db.components().insertSnapshot(project4, snapshot -> snapshot.setCreatedAt(30_000_000_000L).setLast(true));
     authorizationIndexerTester.allowOnlyAnyone(project4);
     index();
 
     assertThat(call(request.setSort(ANALYSIS_DATE).setAsc(true)).getComponentsList()).extracting(Component::getKey)
-      .containsExactly(project3.getDbKey(), project4.getDbKey(), project2.getDbKey(), project1.getDbKey());
+      .containsExactly(project3.getKey(), project4.getKey(), project2.getKey(), project1.getKey());
 
     assertThat(call(request.setSort(ANALYSIS_DATE).setAsc(false)).getComponentsList()).extracting(Component::getKey)
-      .containsExactly(project2.getDbKey(), project4.getDbKey(), project3.getDbKey(), project1.getDbKey());
+      .containsExactly(project2.getKey(), project4.getKey(), project3.getKey(), project1.getKey());
   }
 
   @Test
@@ -1224,9 +1224,9 @@ public class SearchProjectsActionTest {
 
     assertThat(result.getComponentsList()).extracting(Component::getKey, Component::hasAnalysisDate, Component::getAnalysisDate)
       .containsOnly(
-        tuple(project1.getDbKey(), true, formatDateTime(new Date(20_000_000_000L))),
-        tuple(project2.getDbKey(), true, formatDateTime(new Date(30_000_000_000L))),
-        tuple(project3.getDbKey(), false, ""));
+        tuple(project1.getKey(), true, formatDateTime(new Date(20_000_000_000L))),
+        tuple(project2.getKey(), true, formatDateTime(new Date(30_000_000_000L))),
+        tuple(project3.getKey(), false, ""));
   }
 
   @Test
@@ -1256,10 +1256,10 @@ public class SearchProjectsActionTest {
 
     assertThat(result.getComponentsList()).extracting(Component::getKey, Component::hasLeakPeriodDate, Component::getLeakPeriodDate)
       .containsOnly(
-        tuple(project1.getDbKey(), true, formatDateTime(new Date(10_000_000_000L))),
-        tuple(project2.getDbKey(), false, ""),
-        tuple(project3.getDbKey(), false, ""),
-        tuple(application1.getDbKey(), true, formatDateTime(new Date(10_000_000_000L))));
+        tuple(project1.getKey(), true, formatDateTime(new Date(10_000_000_000L))),
+        tuple(project2.getKey(), false, ""),
+        tuple(project3.getKey(), false, ""),
+        tuple(application1.getKey(), true, formatDateTime(new Date(10_000_000_000L))));
   }
 
   @Test
@@ -1275,8 +1275,8 @@ public class SearchProjectsActionTest {
 
     assertThat(result.getComponentsList()).extracting(Component::getKey, Component::getVisibility)
       .containsExactly(
-        tuple(privateProject.getDbKey(), privateProject.isPrivate() ? "private" : "public"),
-        tuple(publicProject.getDbKey(), publicProject.isPrivate() ? "private" : "public"));
+        tuple(privateProject.getKey(), privateProject.isPrivate() ? "private" : "public"),
+        tuple(publicProject.getKey(), publicProject.isPrivate() ? "private" : "public"));
   }
 
   @Test
@@ -1289,7 +1289,7 @@ public class SearchProjectsActionTest {
     SearchProjectsWsResponse result = call(request);
 
     assertThat(result.getComponentsList()).extracting(Component::getKey)
-      .containsExactlyInAnyOrder(project.getDbKey());
+      .containsExactlyInAnyOrder(project.getKey());
   }
 
   @Test
index 169ceccf252dfb403bee0b6b794eb3f2eff7263f..6603f2a01971671ffedf1efc4a0b79aa553a0185 100644 (file)
@@ -125,9 +125,9 @@ public class ShowActionTest {
     db.components().insertProjectAndSnapshot(project);
     userSession.addProjectPermission(USER, project);
 
-    ShowWsResponse response = newRequest(project.getDbKey());
+    ShowWsResponse response = newRequest(project.getKey());
 
-    assertThat(response.getComponent().getKey()).isEqualTo(project.getDbKey());
+    assertThat(response.getComponent().getKey()).isEqualTo(project.getKey());
   }
 
   @Test
@@ -138,10 +138,10 @@ public class ShowActionTest {
     ComponentDto file = db.components().insertComponent(newFileDto(directory));
     userSession.addProjectPermission(USER, project);
 
-    ShowWsResponse response = newRequest(file.getDbKey());
+    ShowWsResponse response = newRequest(file.getKey());
 
-    assertThat(response.getComponent().getKey()).isEqualTo(file.getDbKey());
-    assertThat(response.getAncestorsList()).extracting(Component::getKey).containsOnly(directory.getDbKey(), module.getDbKey(), project.getDbKey());
+    assertThat(response.getComponent().getKey()).isEqualTo(file.getKey());
+    assertThat(response.getAncestorsList()).extracting(Component::getKey).containsOnly(directory.getKey(), module.getKey(), project.getKey());
   }
 
   @Test
@@ -150,9 +150,9 @@ public class ShowActionTest {
     db.components().insertComponent(newModuleDto(project));
     userSession.addProjectPermission(USER, project);
 
-    ShowWsResponse response = newRequest(project.getDbKey());
+    ShowWsResponse response = newRequest(project.getKey());
 
-    assertThat(response.getComponent().getKey()).isEqualTo(project.getDbKey());
+    assertThat(response.getComponent().getKey()).isEqualTo(project.getKey());
     assertThat(response.getAncestorsList()).isEmpty();
   }
 
@@ -165,7 +165,7 @@ public class ShowActionTest {
       newAnalysis(project).setCreatedAt(3_000_000_000L).setLast(true));
     userSession.addProjectPermission(USER, project);
 
-    ShowWsResponse response = newRequest(project.getDbKey());
+    ShowWsResponse response = newRequest(project.getKey());
 
     assertThat(response.getComponent().getAnalysisDate()).isNotEmpty().isEqualTo(formatDateTime(new Date(3_000_000_000L)));
   }
@@ -180,7 +180,7 @@ public class ShowActionTest {
 
     userSession.addProjectPermission(USER, project);
 
-    ShowWsResponse response = newRequest(project.getDbKey());
+    ShowWsResponse response = newRequest(project.getKey());
 
     assertThat(response.getComponent().getLeakPeriodDate()).isNotEmpty().isEqualTo(formatDateTime(new Date(3_000_000_000L)));
   }
@@ -194,7 +194,7 @@ public class ShowActionTest {
     ComponentDto file = db.components().insertComponent(newFileDto(directory));
     userSession.addProjectPermission(USER, project);
 
-    ShowWsResponse response = newRequest(file.getDbKey());
+    ShowWsResponse response = newRequest(file.getKey());
 
     String expectedDate = formatDateTime(new Date(3_000_000_000L));
     assertThat(response.getAncestorsList()).extracting(Component::getAnalysisDate)
@@ -206,7 +206,7 @@ public class ShowActionTest {
     ComponentDto privateProject = db.components().insertPrivateProject();
     userSession.addProjectPermission(USER, privateProject);
 
-    ShowWsResponse result = newRequest(privateProject.getDbKey());
+    ShowWsResponse result = newRequest(privateProject.getKey());
     assertThat(result.getComponent().hasVisibility()).isTrue();
     assertThat(result.getComponent().getVisibility()).isEqualTo("private");
   }
@@ -216,7 +216,7 @@ public class ShowActionTest {
     ComponentDto publicProject = db.components().insertPublicProject();
     userSession.registerComponents(publicProject);
 
-    ShowWsResponse result = newRequest(publicProject.getDbKey());
+    ShowWsResponse result = newRequest(publicProject.getKey());
     assertThat(result.getComponent().hasVisibility()).isTrue();
     assertThat(result.getComponent().getVisibility()).isEqualTo("public");
   }
@@ -226,7 +226,7 @@ public class ShowActionTest {
     ComponentDto view = db.components().insertPrivatePortfolio();
     userSession.addProjectPermission(USER, view);
 
-    ShowWsResponse result = newRequest(view.getDbKey());
+    ShowWsResponse result = newRequest(view.getKey());
     assertThat(result.getComponent().hasVisibility()).isTrue();
   }
 
@@ -236,7 +236,7 @@ public class ShowActionTest {
     userSession.addProjectPermission(USER, privateProject);
     ComponentDto module = db.components().insertComponent(newModuleDto(privateProject));
 
-    ShowWsResponse result = newRequest(module.getDbKey());
+    ShowWsResponse result = newRequest(module.getKey());
     assertThat(result.getComponent().hasVisibility()).isFalse();
   }
 
@@ -249,7 +249,7 @@ public class ShowActionTest {
     db.components().insertSnapshot(project, s -> s.setProjectVersion("1.1"));
     userSession.addProjectPermission(USER, project);
 
-    ShowWsResponse response = newRequest(file.getDbKey());
+    ShowWsResponse response = newRequest(file.getKey());
 
     assertThat(response.getComponent().getVersion()).isEqualTo("1.1");
     assertThat(response.getAncestorsList())
@@ -379,7 +379,7 @@ public class ShowActionTest {
     ComponentDto componentDto = newPrivateProjectDto("project-uuid");
     db.components().insertProjectAndSnapshot(componentDto);
 
-    String componentDtoDbKey = componentDto.getDbKey();
+    String componentDtoDbKey = componentDto.getKey();
     assertThatThrownBy(() -> newRequest(componentDtoDbKey))
       .isInstanceOf(ForbiddenException.class);
   }
@@ -396,7 +396,7 @@ public class ShowActionTest {
     ComponentDto privateProjectDto = newPrivateProjectDto();
     ComponentDto project = db.components().insertComponent(privateProjectDto);
     userSession.addProjectPermission(USER, project);
-    db.components().insertComponent(newFileDto(project).setDbKey("file-key").setEnabled(false));
+    db.components().insertComponent(newFileDto(project).setKey("file-key").setEnabled(false));
 
     assertThatThrownBy(() -> newRequest("file-key"))
       .isInstanceOf(NotFoundException.class)
@@ -426,10 +426,10 @@ public class ShowActionTest {
     ComponentDto branch = db.components().insertProjectBranch(project);
 
     TestRequest request = ws.newRequest()
-      .setParam(PARAM_COMPONENT, branch.getDbKey());
+      .setParam(PARAM_COMPONENT, branch.getKey());
     assertThatThrownBy(() -> request.executeProtobuf(ShowWsResponse.class))
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(String.format("Component key '%s' not found", branch.getDbKey()));
+      .hasMessage(String.format("Component key '%s' not found", branch.getKey()));
   }
 
   private ShowWsResponse newRequest(@Nullable String key) {
@@ -442,8 +442,8 @@ public class ShowActionTest {
 
   private void insertJsonExampleComponentsAndSnapshots() {
     ComponentDto project = db.components().insertPrivateProject(c -> c.setUuid("AVIF98jgA3Ax6PH2efOW")
-      .setProjectUuid("AVIF98jgA3Ax6PH2efOW")
-      .setDbKey("com.sonarsource:java-markdown")
+      .setBranchUuid("AVIF98jgA3Ax6PH2efOW")
+      .setKey("com.sonarsource:java-markdown")
       .setName("Java Markdown")
       .setDescription("Java Markdown Project")
       .setQualifier(Qualifiers.PROJECT),
@@ -454,13 +454,13 @@ public class ShowActionTest {
       .setCreatedAt(parseDateTime("2017-03-01T11:39:03+0100").getTime())
       .setPeriodDate(parseDateTime("2017-01-01T11:39:03+0100").getTime()));
     ComponentDto directory = newDirectory(project, "AVIF-FfgA3Ax6PH2efPF", "src/main/java/com/sonarsource/markdown/impl")
-      .setDbKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl")
+      .setKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl")
       .setName("src/main/java/com/sonarsource/markdown/impl")
       .setQualifier(Qualifiers.DIRECTORY);
     db.components().insertComponent(directory);
     db.components().insertComponent(
       newFileDto(directory, directory, "AVIF-FffA3Ax6PH2efPD")
-        .setDbKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl/Rule.java")
+        .setKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl/Rule.java")
         .setName("Rule.java")
         .setPath("src/main/java/com/sonarsource/markdown/impl/Rule.java")
         .setLanguage("java")
index 862404efcf6b5eb15dab78a7bcfb083e2b3944e5..7f14288969d488aad43d1b6d11cfcfa59fa9ff74 100644 (file)
@@ -132,15 +132,15 @@ public class SuggestionsActionTest {
 
   @Test
   public void test_example_json_response() {
-    ComponentDto project1 = db.components().insertPublicProject(p -> p.setDbKey("org.sonarsource:sonarqube").setName("SonarSource :: SonarQube"));
-    ComponentDto project2 = db.components().insertPublicProject(p -> p.setDbKey("org.sonarsource:sonarlint").setName("SonarSource :: SonarLint"));
+    ComponentDto project1 = db.components().insertPublicProject(p -> p.setKey("org.sonarsource:sonarqube").setName("SonarSource :: SonarQube"));
+    ComponentDto project2 = db.components().insertPublicProject(p -> p.setKey("org.sonarsource:sonarlint").setName("SonarSource :: SonarLint"));
     componentIndexer.indexAll();
     authorizationIndexerTester.allowOnlyAnyone(project1);
     authorizationIndexerTester.allowOnlyAnyone(project2);
 
     TestResponse wsResponse = ws.newRequest()
       .setParam(PARAM_QUERY, "Sonar")
-      .setParam(PARAM_RECENTLY_BROWSED, project1.getDbKey())
+      .setParam(PARAM_RECENTLY_BROWSED, project1.getKey())
       .setMethod("POST")
       .setMediaType(MediaTypes.JSON)
       .execute();
@@ -157,7 +157,7 @@ public class SuggestionsActionTest {
 
     SuggestionsWsResponse response = ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_RECENTLY_BROWSED, project.getDbKey())
+      .setParam(PARAM_RECENTLY_BROWSED, project.getKey())
       .executeProtobuf(SuggestionsWsResponse.class);
 
     // assert match in qualifier "TRK"
@@ -170,7 +170,7 @@ public class SuggestionsActionTest {
     assertThat(response.getResultsList())
       .flatExtracting(Category::getItemsList)
       .extracting(Suggestion::getKey, Suggestion::getIsRecentlyBrowsed)
-      .containsExactly(tuple(project.getDbKey(), true));
+      .containsExactly(tuple(project.getKey(), true));
   }
 
   @Test
@@ -181,7 +181,7 @@ public class SuggestionsActionTest {
 
     SuggestionsWsResponse response = ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_RECENTLY_BROWSED, project.getDbKey())
+      .setParam(PARAM_RECENTLY_BROWSED, project.getKey())
       .executeProtobuf(SuggestionsWsResponse.class);
 
     // assert match in qualifier "TRK"
@@ -194,7 +194,7 @@ public class SuggestionsActionTest {
     assertThat(response.getResultsList())
       .flatExtracting(Category::getItemsList)
       .extracting(Suggestion::getKey, Suggestion::getIsRecentlyBrowsed)
-      .containsExactly(tuple(project.getDbKey(), true));
+      .containsExactly(tuple(project.getKey(), true));
   }
 
   @Test
@@ -205,7 +205,7 @@ public class SuggestionsActionTest {
 
     SuggestionsWsResponse response = ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_RECENTLY_BROWSED, project.getDbKey())
+      .setParam(PARAM_RECENTLY_BROWSED, project.getKey())
       .executeProtobuf(SuggestionsWsResponse.class);
 
     assertThat(response.getResultsList())
@@ -235,7 +235,7 @@ public class SuggestionsActionTest {
     assertThat(response.getResultsList())
       .flatExtracting(Category::getItemsList)
       .extracting(Suggestion::getKey, Suggestion::getIsFavorite)
-      .containsExactly(tuple(project.getDbKey(), true));
+      .containsExactly(tuple(project.getKey(), true));
   }
 
   @Test
@@ -264,7 +264,7 @@ public class SuggestionsActionTest {
 
     SuggestionsWsResponse response = ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_RECENTLY_BROWSED, project.getDbKey())
+      .setParam(PARAM_RECENTLY_BROWSED, project.getKey())
       .executeProtobuf(SuggestionsWsResponse.class);
 
     // assert match in qualifier "TRK"
@@ -277,7 +277,7 @@ public class SuggestionsActionTest {
     assertThat(response.getResultsList())
       .flatExtracting(Category::getItemsList)
       .extracting(Suggestion::getKey, Suggestion::getIsFavorite, Suggestion::getIsRecentlyBrowsed)
-      .containsExactly(tuple(project.getDbKey(), true, true));
+      .containsExactly(tuple(project.getKey(), true, true));
   }
 
   @Test
@@ -314,7 +314,7 @@ public class SuggestionsActionTest {
 
     SuggestionsWsResponse response = ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_RECENTLY_BROWSED, Stream.of(project3, project1).map(ComponentDto::getDbKey).collect(joining(",")))
+      .setParam(PARAM_RECENTLY_BROWSED, Stream.of(project3, project1).map(ComponentDto::getKey).collect(joining(",")))
       .executeProtobuf(SuggestionsWsResponse.class);
 
     // assert order of keys
@@ -331,12 +331,12 @@ public class SuggestionsActionTest {
   @Test
   public void suggestions_without_query_should_return_empty_qualifiers() {
     ComponentDto project = db.components().insertComponent(newPrivateProjectDto());
-    componentIndexer.indexOnAnalysis(project.projectUuid());
+    componentIndexer.indexOnAnalysis(project.branchUuid());
     userSessionRule.addProjectPermission(USER, project);
 
     SuggestionsWsResponse response = ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_RECENTLY_BROWSED, project.getDbKey())
+      .setParam(PARAM_RECENTLY_BROWSED, project.getKey())
       .executeProtobuf(SuggestionsWsResponse.class);
 
     assertThat(response.getResultsList())
@@ -349,12 +349,12 @@ public class SuggestionsActionTest {
   public void suggestions_should_filter_allowed_qualifiers() {
     resourceTypes.setAllQualifiers(PROJECT, MODULE, FILE, UNIT_TEST_FILE);
     ComponentDto project = db.components().insertComponent(newPrivateProjectDto());
-    componentIndexer.indexOnAnalysis(project.projectUuid());
+    componentIndexer.indexOnAnalysis(project.branchUuid());
     userSessionRule.addProjectPermission(USER, project);
 
     SuggestionsWsResponse response = ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_RECENTLY_BROWSED, project.getDbKey())
+      .setParam(PARAM_RECENTLY_BROWSED, project.getKey())
       .executeProtobuf(SuggestionsWsResponse.class);
 
     assertThat(response.getResultsList())
@@ -371,7 +371,7 @@ public class SuggestionsActionTest {
 
     SuggestionsWsResponse response = ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_QUERY, project.getDbKey())
+      .setParam(PARAM_QUERY, project.getKey())
       .executeProtobuf(SuggestionsWsResponse.class);
 
     // assert match in qualifier "TRK"
@@ -384,7 +384,7 @@ public class SuggestionsActionTest {
     assertThat(response.getResultsList())
       .flatExtracting(Category::getItemsList)
       .extracting(Suggestion::getKey)
-      .containsExactly(project.getDbKey());
+      .containsExactly(project.getKey());
   }
 
   @Test
@@ -399,7 +399,7 @@ public class SuggestionsActionTest {
 
     SuggestionsWsResponse response = ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_QUERY, project.getDbKey())
+      .setParam(PARAM_QUERY, project.getKey())
       .executeProtobuf(SuggestionsWsResponse.class);
 
     // assert match in qualifier "TRK"
@@ -449,14 +449,14 @@ public class SuggestionsActionTest {
     assertThat(response.getResultsList())
       .flatExtracting(Category::getItemsList)
       .extracting(Suggestion::getKey)
-      .contains(project.getDbKey());
+      .contains(project.getKey());
     assertThat(response.getWarning()).contains(SHORT_INPUT_WARNING);
   }
 
   @Test
   public void should_contain_component_names() {
     ComponentDto project1 = db.components().insertComponent(newPrivateProjectDto().setName("Project1"));
-    componentIndexer.indexOnAnalysis(project1.projectUuid());
+    componentIndexer.indexOnAnalysis(project1.branchUuid());
     authorizationIndexerTester.allowOnlyAnyone(project1);
 
     SuggestionsWsResponse response = ws.newRequest()
@@ -467,7 +467,7 @@ public class SuggestionsActionTest {
     assertThat(response.getResultsList())
       .flatExtracting(Category::getItemsList)
       .extracting(Suggestion::getKey, Suggestion::getName)
-      .containsExactlyInAnyOrder(tuple(project1.getDbKey(), project1.name()));
+      .containsExactlyInAnyOrder(tuple(project1.getKey(), project1.name()));
   }
 
   @Test
@@ -475,7 +475,7 @@ public class SuggestionsActionTest {
     ComponentDto project = db.components().insertComponent(newPrivateProjectDto().setName("ProjectWithModules"));
     db.components().insertComponent(newModuleDto(project).setName("Module1"));
     db.components().insertComponent(newModuleDto(project).setName("Module2"));
-    componentIndexer.indexOnAnalysis(project.projectUuid());
+    componentIndexer.indexOnAnalysis(project.branchUuid());
     authorizationIndexerTester.allowOnlyAnyone(project);
 
     SuggestionsWsResponse response = ws.newRequest()
@@ -486,7 +486,7 @@ public class SuggestionsActionTest {
     assertThat(response.getResultsList())
       .flatExtracting(Category::getItemsList)
       .extracting(Suggestion::getKey)
-      .containsOnly(project.getDbKey());
+      .containsOnly(project.getKey());
   }
 
   @Test
@@ -496,13 +496,13 @@ public class SuggestionsActionTest {
     db.components().insertComponent(module1);
     ComponentDto module2 = newModuleDto(project).setName("Module2");
     db.components().insertComponent(module2);
-    componentIndexer.indexOnAnalysis(project.projectUuid());
+    componentIndexer.indexOnAnalysis(project.branchUuid());
     authorizationIndexerTester.allowOnlyAnyone(project);
 
     SuggestionsWsResponse response = ws.newRequest()
       .setMethod("POST")
       .setParam(PARAM_QUERY, "Module")
-      .setParam(PARAM_RECENTLY_BROWSED, Stream.of(module1.getDbKey(), project.getDbKey()).collect(joining(",")))
+      .setParam(PARAM_RECENTLY_BROWSED, Stream.of(module1.getKey(), project.getKey()).collect(joining(",")))
       .executeProtobuf(SuggestionsWsResponse.class);
 
     assertThat(response.getResultsList())
@@ -517,8 +517,8 @@ public class SuggestionsActionTest {
     ComponentDto nonFavouriteProject = db.components().insertComponent(newPublicProjectDto().setName("Project2"));
 
     doReturn(singletonList(favouriteProject)).when(favoriteFinder).list();
-    componentIndexer.indexOnAnalysis(favouriteProject.projectUuid());
-    componentIndexer.indexOnAnalysis(nonFavouriteProject.projectUuid());
+    componentIndexer.indexOnAnalysis(favouriteProject.branchUuid());
+    componentIndexer.indexOnAnalysis(nonFavouriteProject.branchUuid());
     authorizationIndexerTester.allowOnlyAnyone(favouriteProject, nonFavouriteProject);
 
     SuggestionsWsResponse response = ws.newRequest()
@@ -529,13 +529,13 @@ public class SuggestionsActionTest {
     assertThat(response.getResultsList())
       .flatExtracting(Category::getItemsList)
       .extracting(Suggestion::getKey, Suggestion::getIsFavorite)
-      .containsExactly(tuple(favouriteProject.getDbKey(), true), tuple(nonFavouriteProject.getDbKey(), false));
+      .containsExactly(tuple(favouriteProject.getKey(), true), tuple(nonFavouriteProject.getKey(), false));
   }
 
   @Test
   public void should_return_empty_qualifiers() {
     ComponentDto project = db.components().insertComponent(newPrivateProjectDto());
-    componentIndexer.indexOnAnalysis(project.projectUuid());
+    componentIndexer.indexOnAnalysis(project.branchUuid());
     authorizationIndexerTester.allowOnlyAnyone(project);
 
     SuggestionsWsResponse response = ws.newRequest()
index cc893a5aaf50b88a7c924cbea32b0d015d2d5c2e..3124ef11c26b6eb8566a252338551a50a05693ff 100644 (file)
@@ -118,7 +118,7 @@ public class TreeActionTest {
     logInWithBrowsePermission(project);
 
     String response = ws.newRequest()
-      .setParam(PARAM_COMPONENT, project.getDbKey())
+      .setParam(PARAM_COMPONENT, project.getKey())
       .execute()
       .getInput();
 
@@ -145,7 +145,7 @@ public class TreeActionTest {
 
     TreeWsResponse response = ws.newRequest()
       .setParam(PARAM_STRATEGY, "children")
-      .setParam(PARAM_COMPONENT, module.getDbKey())
+      .setParam(PARAM_COMPONENT, module.getKey())
       .setParam(Param.PAGE, "2")
       .setParam(Param.PAGE_SIZE, "3")
       .setParam(Param.TEXT_QUERY, "file-name")
@@ -175,7 +175,7 @@ public class TreeActionTest {
 
     TreeWsResponse response = ws.newRequest()
       .setParam(PARAM_STRATEGY, "all")
-      .setParam(PARAM_COMPONENT, module.getDbKey())
+      .setParam(PARAM_COMPONENT, module.getKey())
       .setParam(Param.PAGE, "2")
       .setParam(Param.PAGE_SIZE, "3")
       .setParam(Param.TEXT_QUERY, "file-name")
@@ -200,7 +200,7 @@ public class TreeActionTest {
     TreeWsResponse response = ws.newRequest()
       .setParam(PARAM_STRATEGY, "all")
       .setParam(PARAM_QUALIFIERS, FILE)
-      .setParam(PARAM_COMPONENT, project.getDbKey()).executeProtobuf(TreeWsResponse.class);
+      .setParam(PARAM_COMPONENT, project.getKey()).executeProtobuf(TreeWsResponse.class);
 
     assertThat(response.getComponentsList()).extracting("key").containsExactly("file-key-1", "file-key-2");
   }
@@ -221,7 +221,7 @@ public class TreeActionTest {
 
     TreeWsResponse response = ws.newRequest()
       .setParam(PARAM_STRATEGY, "leaves")
-      .setParam(PARAM_COMPONENT, project.getDbKey())
+      .setParam(PARAM_COMPONENT, project.getKey())
       .setParam(PARAM_QUALIFIERS, FILE).executeProtobuf(TreeWsResponse.class);
 
     assertThat(response.getComponentsCount()).isEqualTo(3);
@@ -244,7 +244,7 @@ public class TreeActionTest {
     TreeWsResponse response = ws.newRequest()
       .setParam(PARAM_STRATEGY, "all")
       .setParam(Param.SORT, "qualifier, name")
-      .setParam(PARAM_COMPONENT, project.getDbKey()).executeProtobuf(TreeWsResponse.class);
+      .setParam(PARAM_COMPONENT, project.getKey()).executeProtobuf(TreeWsResponse.class);
 
     assertThat(response.getComponentsList()).extracting("key").containsExactly("MODULE_KEY_module-uuid-1", "KEY_project-uuid:directory-uuid-1", "file-key-1", "file-key-2");
   }
@@ -253,7 +253,7 @@ public class TreeActionTest {
   public void project_reference_from_portfolio() {
     ComponentDto view = ComponentTesting.newPortfolio("view-uuid");
     db.components().insertPortfolioAndSnapshot(view);
-    ComponentDto project = newPrivateProjectDto("project-uuid-1").setName("project-name").setDbKey("project-key-1");
+    ComponentDto project = newPrivateProjectDto("project-uuid-1").setName("project-name").setKey("project-key-1");
     db.components().insertProjectAndSnapshot(project);
     db.components().insertComponent(newProjectCopy("project-uuid-1-copy", project, view));
     db.components().insertComponent(ComponentTesting.newSubPortfolio(view, "sub-view-uuid", "sub-view-key").setName("sub-view-name"));
@@ -263,7 +263,7 @@ public class TreeActionTest {
 
     TreeWsResponse response = ws.newRequest()
       .setParam(PARAM_STRATEGY, "children")
-      .setParam(PARAM_COMPONENT, view.getDbKey())
+      .setParam(PARAM_COMPONENT, view.getKey())
       .setParam(Param.TEXT_QUERY, "name").executeProtobuf(TreeWsResponse.class);
 
     assertThat(response.getComponentsList()).extracting("key").containsExactly("KEY_view-uuidproject-key-1", "sub-view-key");
@@ -273,12 +273,12 @@ public class TreeActionTest {
 
   @Test
   public void project_branch_reference_from_application_branch() {
-    ComponentDto application = db.components().insertPrivateProject(c -> c.setQualifier(APP).setDbKey("app-key"));
+    ComponentDto application = db.components().insertPrivateProject(c -> c.setQualifier(APP).setKey("app-key"));
     ComponentDto applicationBranch = db.components().insertProjectBranch(application, a -> a.setKey("app-branch"));
-    ComponentDto project = db.components().insertPrivateProject(p -> p.setDbKey("project-key"));
+    ComponentDto project = db.components().insertPrivateProject(p -> p.setKey("project-key"));
     ComponentDto projectBranch = db.components().insertProjectBranch(project, b -> b.setKey("project-branch"));
     ComponentDto techProjectBranch = db.components().insertComponent(newProjectCopy(projectBranch, applicationBranch)
-      .setDbKey(applicationBranch.getKey() + applicationBranch.getBranch() + projectBranch.getDbKey()));
+      .setKey(applicationBranch.getKey() + applicationBranch.getBranch() + projectBranch.getKey()));
     logInWithBrowsePermission(application);
 
     TreeWsResponse result = ws.newRequest()
@@ -300,9 +300,9 @@ public class TreeActionTest {
     logInWithBrowsePermission(project);
 
     TreeWsResponse response = ws.newRequest()
-      .setParam(PARAM_COMPONENT, project.getDbKey()).executeProtobuf(TreeWsResponse.class);
+      .setParam(PARAM_COMPONENT, project.getKey()).executeProtobuf(TreeWsResponse.class);
 
-    assertThat(response.getBaseComponent().getKey()).isEqualTo(project.getDbKey());
+    assertThat(response.getBaseComponent().getKey()).isEqualTo(project.getKey());
     assertThat(response.getComponentsList()).isEmpty();
     assertThat(response.getPaging().getTotal()).isZero();
     assertThat(response.getPaging().getPageSize()).isEqualTo(100);
@@ -320,13 +320,13 @@ public class TreeActionTest {
       .registerComponents(project, view);
 
     TreeWsResponse response = ws.newRequest()
-      .setParam(PARAM_COMPONENT, view.getDbKey())
+      .setParam(PARAM_COMPONENT, view.getKey())
       .executeProtobuf(TreeWsResponse.class);
 
-    assertThat(response.getBaseComponent().getKey()).isEqualTo(view.getDbKey());
+    assertThat(response.getBaseComponent().getKey()).isEqualTo(view.getKey());
     assertThat(response.getComponentsCount()).isOne();
-    assertThat(response.getComponents(0).getKey()).isEqualTo(projectCopy.getDbKey());
-    assertThat(response.getComponents(0).getRefKey()).isEqualTo(project.getDbKey());
+    assertThat(response.getComponents(0).getKey()).isEqualTo(projectCopy.getKey());
+    assertThat(response.getComponents(0).getRefKey()).isEqualTo(project.getKey());
   }
 
   @Test
@@ -382,10 +382,10 @@ public class TreeActionTest {
     ComponentDto branch = db.components().insertProjectBranch(project);
 
     TestRequest request = ws.newRequest()
-      .setParam(PARAM_COMPONENT, branch.getDbKey());
+      .setParam(PARAM_COMPONENT, branch.getKey());
     assertThatThrownBy(() -> request.executeProtobuf(Components.ShowWsResponse.class))
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Component key '%s' not found", branch.getDbKey()));
+      .hasMessage(format("Component key '%s' not found", branch.getKey()));
   }
 
   @Test
@@ -395,10 +395,10 @@ public class TreeActionTest {
     ComponentDto branch = db.components().insertProjectBranch(project);
 
     TestRequest request = ws.newRequest()
-      .setParam(PARAM_COMPONENT, branch.getDbKey());
+      .setParam(PARAM_COMPONENT, branch.getKey());
     assertThatThrownBy(() -> request.executeProtobuf(Components.ShowWsResponse.class))
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Component key '%s' not found", branch.getDbKey()));
+      .hasMessage(format("Component key '%s' not found", branch.getKey()));
   }
 
   @Test
@@ -409,7 +409,7 @@ public class TreeActionTest {
     db.commit();
 
     TestRequest request = ws.newRequest()
-      .setParam(PARAM_COMPONENT, project.getDbKey());
+      .setParam(PARAM_COMPONENT, project.getKey());
     assertThatThrownBy(request::execute)
       .isInstanceOf(ForbiddenException.class);
   }
@@ -420,7 +420,7 @@ public class TreeActionTest {
     db.commit();
 
     TestRequest request = ws.newRequest()
-      .setParam(PARAM_COMPONENT, project.getDbKey())
+      .setParam(PARAM_COMPONENT, project.getKey())
       .setParam(Param.PAGE_SIZE, "501");
 
     assertThatThrownBy(request::execute)
@@ -434,7 +434,7 @@ public class TreeActionTest {
     db.commit();
 
     TestRequest request = ws.newRequest()
-      .setParam(PARAM_COMPONENT, project.getDbKey())
+      .setParam(PARAM_COMPONENT, project.getKey())
       .setParam(Param.TEXT_QUERY, "fi");
     assertThatThrownBy(request::execute)
       .isInstanceOf(IllegalArgumentException.class)
@@ -476,7 +476,7 @@ public class TreeActionTest {
   @Test
   public void fail_when_base_component_is_removed() {
     ComponentDto project = db.components().insertComponent(newPrivateProjectDto());
-    db.components().insertComponent(ComponentTesting.newFileDto(project).setDbKey("file-key").setEnabled(false));
+    db.components().insertComponent(ComponentTesting.newFileDto(project).setKey("file-key").setEnabled(false));
     logInWithBrowsePermission(project);
 
     TestRequest request = ws.newRequest()
@@ -511,7 +511,7 @@ public class TreeActionTest {
   private static ComponentDto newFileDto(ComponentDto moduleOrProject, @Nullable ComponentDto directory, int i) {
     return ComponentTesting.newFileDto(moduleOrProject, directory, "file-uuid-" + i)
       .setName("file-name-" + i)
-      .setDbKey("file-key-" + i)
+      .setKey("file-key-" + i)
       .setPath("file-path-" + i);
   }
 
@@ -522,9 +522,9 @@ public class TreeActionTest {
   private ComponentDto initJsonExampleComponents() throws IOException {
     ComponentDto project = db.components().insertPrivateProject(c -> c.setUuid("MY_PROJECT_ID")
       .setDescription("MY_PROJECT_DESCRIPTION")
-      .setDbKey("MY_PROJECT_KEY")
+      .setKey("MY_PROJECT_KEY")
       .setName("Project Name")
-      .setProjectUuid("MY_PROJECT_ID"),
+      .setBranchUuid("MY_PROJECT_ID"),
       p -> p.setTagsString("abc,def"));
     db.components().insertSnapshot(project);
 
@@ -537,7 +537,7 @@ public class TreeActionTest {
       JsonObject componentAsJsonObject = componentAsJsonElement.getAsJsonObject();
       String uuid = format("child-component-uuid-%d", i);
       db.components().insertComponent(newChildComponent(uuid, project, project)
-        .setDbKey(getJsonField(componentAsJsonObject, "key"))
+        .setKey(getJsonField(componentAsJsonObject, "key"))
         .setName(getJsonField(componentAsJsonObject, "name"))
         .setLanguage(getJsonField(componentAsJsonObject, "language"))
         .setPath(getJsonField(componentAsJsonObject, "path"))
index 0882301f62d6d26a127a5483b897d8c269e5601e..0aa1331da6b7e030bb9cd690fadfbc72cb8bc675 100644 (file)
@@ -151,7 +151,7 @@ public class SearchEventsActionNewIssuesTest {
   @Test
   public void return_link_to_issue_search_for_new_issues_event() {
     userSession.logIn("my_login");
-    ComponentDto project = db.components().insertPrivateProject(p -> p.setDbKey("my_project"));
+    ComponentDto project = db.components().insertPrivateProject(p -> p.setKey("my_project"));
     userSession.addProjectPermission(USER, project);
     SnapshotDto analysis = insertAnalysis(project, 1_400_000_000_000L);
     insertIssue(project, analysis);
@@ -240,7 +240,7 @@ public class SearchEventsActionNewIssuesTest {
   public void encode_link() {
     userSession.logIn("rÃ¥gnar").setSystemAdministrator();
     long from = 1_500_000_000_000L;
-    ComponentDto project = db.components().insertPrivateProject(p -> p.setDbKey("M&M's"));
+    ComponentDto project = db.components().insertPrivateProject(p -> p.setKey("M&M's"));
     userSession.addProjectPermission(USER, project);
     SnapshotDto analysis = insertAnalysis(project, from);
     insertIssue(project, analysis);
index 2247ab7da899a00e52a630daac6ce237eab62783..03d722524601d90d36a26c005b907a6935e85946 100644 (file)
@@ -173,7 +173,7 @@ public class SearchEventsActionQualityGateTest {
 
   @Test
   public void encode_link() {
-    ComponentDto project = db.components().insertPrivateProject(p -> p.setDbKey("M&M's"));
+    ComponentDto project = db.components().insertPrivateProject(p -> p.setKey("M&M's"));
     userSession.addProjectPermission(USER, project);
     SnapshotDto analysis = insertSuccessfulActivity(project, 1_500_000_000_000L);
     EventDto event = db.events().insertEvent(newQualityGateEvent(analysis).setName("Failed").setDate(analysis.getCreatedAt()));
index 7a793283dc75f31944a0b9ad45ed1a6e33f78e94..b8e93f8d6afa84725a4d0a2ea6d33b02a30047aa 100644 (file)
@@ -107,7 +107,7 @@ public class SearchEventsActionTest {
 
   @Test
   public void json_example() {
-    ComponentDto project = db.components().insertPrivateProject(p -> p.setName("My Project").setDbKey(KeyExamples.KEY_PROJECT_EXAMPLE_001));
+    ComponentDto project = db.components().insertPrivateProject(p -> p.setName("My Project").setKey(KeyExamples.KEY_PROJECT_EXAMPLE_001));
     userSession.addProjectPermission(USER, project);
     SnapshotDto analysis = insertAnalysis(project, 1_500_000_000_000L);
     EventDto e1 = db.events().insertEvent(newQualityGateEvent(analysis).setName("Failed").setDate(analysis.getCreatedAt()));
index 2259a8bf7d10f50532f234cc0a017b08ac662ee2..629d0ca0e12f302fa3264efda74e1685e6b61d48 100644 (file)
@@ -57,7 +57,7 @@ public class DuplicationsParserTest {
         "    <b s=\"31\" l=\"5\" r=\"%s\"/>\n" +
         "    <b s=\"20\" l=\"5\" r=\"%s\"/>\n" +
         "  </g>\n" +
-        "</duplications>", file.getDbKey(), file.getDbKey()));
+        "</duplications>", file.getKey(), file.getKey()));
     assertThat(blocks).hasSize(1);
 
     List<Duplication> duplications = blocks.get(0).getDuplications();
@@ -86,7 +86,7 @@ public class DuplicationsParserTest {
         "    <b s=\"20\" l=\"5\" r=\"%s\"/>\n" +
         "    <b s=\"31\" l=\"5\" r=\"%s\"/>\n" +
         "  </g>\n" +
-        "</duplications>", file2.getDbKey(), file1.getDbKey()));
+        "</duplications>", file2.getKey(), file1.getKey()));
     assertThat(blocks).hasSize(1);
 
     List<Duplication> duplications = blocks.get(0).getDuplications();
@@ -118,7 +118,7 @@ public class DuplicationsParserTest {
         "    <b s=\"137\" l=\"24\" r=\"%s\"/>\n" +
         "    <b s=\"111\" l=\"24\" r=\"%s\"/>\n" +
         "  </g>\n" +
-        "</duplications>", file1.getDbKey(), fileOnProject2.getDbKey(), file2.getDbKey()));
+        "</duplications>", file1.getKey(), fileOnProject2.getKey(), file2.getKey()));
     assertThat(blocks).hasSize(1);
 
     List<Duplication> duplications = blocks.get(0).getDuplications();
@@ -148,11 +148,11 @@ public class DuplicationsParserTest {
   public void duplications_on_many_blocks() {
     ComponentDto project1 = db.components().insertPrivateProject();
     ComponentDto file1 = db.components().insertComponent(newFileDto(project1)
-      .setDbKey("org.codehaus.sonar:sonar-plugin-api:src/main/java/org/sonar/api/utils/command/CommandExecutor.java")
+      .setKey("org.codehaus.sonar:sonar-plugin-api:src/main/java/org/sonar/api/utils/command/CommandExecutor.java")
       .setLongName("CommandExecutor"));
     ComponentDto project2 = db.components().insertPrivateProject();
     ComponentDto file2 = db.components().insertComponent(newFileDto(project2)
-      .setDbKey("com.sonarsource.orchestrator:sonar-orchestrator:src/main/java/com/sonar/orchestrator/util/CommandExecutor.java")
+      .setKey("com.sonarsource.orchestrator:sonar-orchestrator:src/main/java/com/sonar/orchestrator/util/CommandExecutor.java")
       .setLongName("CommandExecutor"));
     List<DuplicationsParser.Block> blocks = parser.parse(db.getSession(), file1, null, null,
       format("<duplications>\n" +
@@ -164,7 +164,7 @@ public class DuplicationsParserTest {
         "    <b s=\"38\" l=\"40\" r=\"%s\"/>\n" +
         "    <b s=\"29\" l=\"39\" r=\"%s\"/>\n" +
         "  </g>\n" +
-        "</duplications>\n", file2.getDbKey(), file1.getDbKey(), file2.getDbKey(), file1.getDbKey()));
+        "</duplications>\n", file2.getKey(), file1.getKey(), file2.getKey(), file1.getKey()));
     assertThat(blocks).hasSize(2);
 
     // Block with smaller line should come first
@@ -186,7 +186,7 @@ public class DuplicationsParserTest {
         "    <b s=\"20\" l=\"5\" r=\"%s\"/>\n" +
         "    <b s=\"31\" l=\"5\" r=\"%s\"/>\n" +
         "  </g>\n" +
-        "</duplications>", file.getDbKey(), "not_existing"));
+        "</duplications>", file.getKey(), "not_existing"));
     assertThat(blocks).hasSize(1);
 
     List<Duplication> duplications = blocks.get(0).getDuplications();
@@ -198,7 +198,7 @@ public class DuplicationsParserTest {
     assertThat(duplication1.from()).isEqualTo(31);
     assertThat(duplication1.size()).isEqualTo(5);
 
-    Duplication duplication2 = duplication(duplications, file.getDbKey());
+    Duplication duplication2 = duplication(duplications, file.getKey());
     assertThat(duplication2.componentDto()).isEqualTo(file);
     assertThat(duplication2.from()).isEqualTo(20);
     assertThat(duplication2.size()).isEqualTo(5);
@@ -212,7 +212,7 @@ public class DuplicationsParserTest {
     ComponentDto fileOnSameProject = db.components().insertComponent(newFileDto(project1, null));
     ComponentDto fileOnDifferentProject = db.components().insertComponent(newFileDto(project2, null));
 
-    DuplicationsParser.DuplicationComparator comparator = new DuplicationsParser.DuplicationComparator(currentFile.uuid(), currentFile.projectUuid());
+    DuplicationsParser.DuplicationComparator comparator = new DuplicationsParser.DuplicationComparator(currentFile.uuid(), currentFile.branchUuid());
 
     // On same file
     assertThat(comparator.compare(Duplication.newComponent(currentFile, 2, 2),
@@ -256,7 +256,7 @@ public class DuplicationsParserTest {
         "    <b s=\"20\" l=\"5\" r=\"%s\"/>\n" +
         "    <b s=\"31\" l=\"5\" r=\"%s\"/>\n" +
         "  </g>\n" +
-        "</duplications>", file2.getDbKey(), file1.getDbKey()));
+        "</duplications>", file2.getKey(), file1.getKey()));
     assertThat(blocks).hasSize(1);
 
     List<Duplication> duplications = blocks.get(0).getDuplications();
@@ -288,7 +288,7 @@ public class DuplicationsParserTest {
         "    <b s=\"20\" l=\"5\" r=\"%s\"/>\n" +
         "    <b s=\"31\" l=\"5\" r=\"%s\"/>\n" +
         "  </g>\n" +
-        "</duplications>", file2.getDbKey(), file1.getDbKey()));
+        "</duplications>", file2.getKey(), file1.getKey()));
     assertThat(blocks).hasSize(1);
 
     List<Duplication> duplications = blocks.get(0).getDuplications();
@@ -310,7 +310,7 @@ public class DuplicationsParserTest {
 
   private static Duplication duplication(List<Duplication> duplications, @Nullable final String componentKey) {
     return Iterables.find(duplications, input -> input != null && (componentKey == null ? input.componentDto() == null
-      : input.componentDto() != null && componentKey.equals(input.componentDto().getDbKey())));
+      : input.componentDto() != null && componentKey.equals(input.componentDto().getKey())));
   }
 
 }
index 1b6ca0379609f60baba3df47953a242eda174a11..ccfcd558cd250f763c93745884e4605e9e7f4d74 100644 (file)
@@ -82,18 +82,18 @@ public class ShowActionTest {
   @Test
   public void get_duplications_by_file_key() {
     TestRequest request = newBaseRequest();
-    verifyCallToFileWithDuplications(file -> request.setParam("key", file.getDbKey()));
+    verifyCallToFileWithDuplications(file -> request.setParam("key", file.getKey()));
   }
 
   @Test
   public void return_file_with_missing_duplication_data() {
     ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto file = db.components().insertComponent(newFileDto(project).setDbKey("foo.js"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project).setKey("foo.js"));
     db.components().insertSnapshot(newAnalysis(project));
 
     userSessionRule.addProjectPermission(UserRole.CODEVIEWER, project);
 
-    TestResponse result = newBaseRequest().setParam("key", file.getDbKey()).execute();
+    TestResponse result = newBaseRequest().setParam("key", file.getKey()).execute();
 
     assertJson(result.getInput()).isSimilarTo("{\n" +
       "  \"duplications\": [],\n" +
@@ -112,7 +112,7 @@ public class ShowActionTest {
       "    <b s=\"31\" l=\"5\" r=\"%s\"/>\n" +
       "    <b s=\"20\" l=\"5\" r=\"%s\"/>\n" +
       "  </g>\n" +
-      "</duplications>\n", file.getDbKey(), file.getDbKey())));
+      "</duplications>\n", file.getKey(), file.getKey())));
 
     String result = ws.newRequest()
       .setParam("key", file.getKey())
@@ -164,7 +164,7 @@ public class ShowActionTest {
       "    <b s=\"31\" l=\"5\" r=\"%s\"/>\n" +
       "    <b s=\"20\" l=\"5\" r=\"%s\"/>\n" +
       "  </g>\n" +
-      "</duplications>\n", file.getDbKey(), file.getDbKey())));
+      "</duplications>\n", file.getKey(), file.getKey())));
 
     String result = ws.newRequest()
       .setParam("key", file.getKey())
@@ -217,7 +217,7 @@ public class ShowActionTest {
   public void fail_if_user_is_not_allowed_to_access_project() {
     ComponentDto project = db.components().insertPrivateProject();
     ComponentDto file = db.components().insertComponent(newFileDto(project));
-    TestRequest request = newBaseRequest().setParam("key", file.getDbKey());
+    TestRequest request = newBaseRequest().setParam("key", file.getKey());
 
     assertThatThrownBy(request::execute)
       .isInstanceOf(ForbiddenException.class);
@@ -238,11 +238,11 @@ public class ShowActionTest {
     userSessionRule.addProjectPermission(UserRole.CODEVIEWER, project);
     ComponentDto branch = db.components().insertProjectBranch(project);
     TestRequest request = ws.newRequest()
-      .setParam("key", branch.getDbKey());
+      .setParam("key", branch.getKey());
 
     assertThatThrownBy(request::execute)
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Component key '%s' not found", branch.getDbKey()));
+      .hasMessage(format("Component key '%s' not found", branch.getKey()));
   }
 
   private TestRequest newBaseRequest() {
@@ -252,7 +252,7 @@ public class ShowActionTest {
   private void verifyCallToFileWithDuplications(Function<ComponentDto, TestRequest> requestFactory) {
     ComponentDto project = db.components().insertPrivateProject();
     userSessionRule.addProjectPermission(UserRole.CODEVIEWER, project);
-    ComponentDto file = db.components().insertComponent(newFileDto(project).setDbKey("foo.js"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project).setKey("foo.js"));
     String xml = "<duplications>\n" +
       "  <g>\n" +
       "    <b s=\"31\" l=\"5\" r=\"foo.js\"/>\n" +
index fd86d0131fb91e0d2c91ba3bcd635de4e4cec840..a23e1c3e420c0684eb9be599cebd0b490b6a00e3 100644 (file)
@@ -117,9 +117,9 @@ public class AddActionTest {
     UserDto user = db.users().insertUser();
     userSession.logIn(user).addProjectPermission(USER, project);
 
-    assertThatThrownBy(() -> call(branch.getDbKey()))
+    assertThatThrownBy(() -> call(branch.getKey()))
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Component key '%s' not found", branch.getDbKey()));
+      .hasMessage(format("Component key '%s' not found", branch.getKey()));
   }
 
   @Test
index 0373bd7eb869f31ba439a4121745641ac2d1b15d..54d1083cc3a14fa7c6ca36a6f4c8b971ea004663 100644 (file)
@@ -110,7 +110,7 @@ public class RemoveActionTest {
     ComponentDto project = db.components().insertPrivateProject();
     userSession.logIn().addProjectPermission(UserRole.USER, project);
     ComponentDto branch = db.components().insertProjectBranch(project);
-    String branchKey = branch.getDbKey();
+    String branchKey = branch.getKey();
 
     assertThatThrownBy(() -> call(branchKey))
       .isInstanceOf(NotFoundException.class)
@@ -129,7 +129,7 @@ public class RemoveActionTest {
   }
 
   private ComponentDto insertProject() {
-    return db.components().insertComponent(newPrivateProjectDto(PROJECT_UUID).setDbKey(PROJECT_KEY));
+    return db.components().insertComponent(newPrivateProjectDto(PROJECT_UUID).setKey(PROJECT_KEY));
   }
 
   private ComponentDto insertProjectAndPermissions() {
index 47aeea7199955c8410c8d5f78ac7dab939ebe0dd..337df2043e775fa19c6d7239997c650ce5546cf2 100644 (file)
@@ -76,10 +76,10 @@ public class SearchActionTest {
 
   @Test
   public void return_favorites() {
-    ComponentDto project = newPrivateProjectDto("P1").setDbKey("K1").setName("N1");
+    ComponentDto project = newPrivateProjectDto("P1").setKey("K1").setName("N1");
     addComponent(project);
-    addComponent(newFileDto(project).setDbKey("K11").setName("N11"));
-    addComponent(newPrivateProjectDto("P2").setDbKey("K2").setName("N2"));
+    addComponent(newFileDto(project).setKey("K11").setName("N11"));
+    addComponent(newPrivateProjectDto("P2").setKey("K2").setName("N2"));
 
     SearchResponse result = call();
 
@@ -104,7 +104,7 @@ public class SearchActionTest {
 
   @Test
   public void filter_authorized_components() {
-    addComponent(ComponentTesting.newPrivateProjectDto().setDbKey("K1"));
+    addComponent(ComponentTesting.newPrivateProjectDto().setKey("K1"));
     ComponentDto unauthorizedProject = db.components().insertComponent(ComponentTesting.newPrivateProjectDto());
     db.favorites().add(unauthorizedProject, userUuid, userLogin);
 
@@ -117,7 +117,7 @@ public class SearchActionTest {
   @Test
   public void paginate_results() {
     IntStream.rangeClosed(1, 9)
-      .forEach(i -> addComponent(ComponentTesting.newPrivateProjectDto().setDbKey("K" + i).setName("N" + i)));
+      .forEach(i -> addComponent(ComponentTesting.newPrivateProjectDto().setKey("K" + i).setName("N" + i)));
     ComponentDto unauthorizedProject = db.components().insertComponent(ComponentTesting.newPrivateProjectDto());
     db.favorites().add(unauthorizedProject, userUuid, userLogin);
 
@@ -132,8 +132,8 @@ public class SearchActionTest {
 
   @Test
   public void return_only_users_favorite() {
-    addComponent(ComponentTesting.newPrivateProjectDto().setDbKey("K1"));
-    ComponentDto otherUserFavorite = ComponentTesting.newPrivateProjectDto().setDbKey("K42");
+    addComponent(ComponentTesting.newPrivateProjectDto().setKey("K1"));
+    ComponentDto otherUserFavorite = ComponentTesting.newPrivateProjectDto().setKey("K42");
     db.components().insertComponent(otherUserFavorite);
     db.favorites().add(otherUserFavorite, "42", userLogin);
     db.commit();
@@ -157,9 +157,9 @@ public class SearchActionTest {
 
   @Test
   public void json_example() {
-    addComponent(ComponentTesting.newPrivateProjectDto().setDbKey("K1").setName("Samba"));
-    addComponent(ComponentTesting.newPrivateProjectDto().setDbKey("K2").setName("Apache HBase"));
-    addComponent(ComponentTesting.newPrivateProjectDto().setDbKey("K3").setName("JDK9"));
+    addComponent(ComponentTesting.newPrivateProjectDto().setKey("K1").setName("Samba"));
+    addComponent(ComponentTesting.newPrivateProjectDto().setKey("K2").setName("Apache HBase"));
+    addComponent(ComponentTesting.newPrivateProjectDto().setKey("K3").setName("JDK9"));
 
     String result = ws.newRequest().execute().getInput();
 
index 951f51c00ac1a4b68df5fba354f8868fec17e7c8..38b9cc4eb4127b76aa43bff546073cdde70c617a 100644 (file)
@@ -725,7 +725,7 @@ public class SearchActionTest {
       .extracting(SearchWsResponse.Hotspot::getKey)
       .containsExactlyInAnyOrder(Arrays.stream(hotspotPR).map(IssueDto::getKey).toArray(String[]::new));
 
-    verify(issueIndexSyncProgressChecker, times(3)).checkIfComponentNeedIssueSync(any(), eq(project.getDbKey()));
+    verify(issueIndexSyncProgressChecker, times(3)).checkIfComponentNeedIssueSync(any(), eq(project.getKey()));
   }
 
   @Test
@@ -1920,11 +1920,11 @@ public class SearchActionTest {
     ComponentDto project = dbTester.components().insertPublicProject(componentDto -> componentDto
       .setName("test-project")
       .setLongName("test-project")
-      .setDbKey("com.sonarsource:test-project"));
+      .setKey("com.sonarsource:test-project"));
     userSessionRule.registerComponents(project);
     indexPermissions();
     ComponentDto fileWithHotspot = dbTester.components().insertComponent(newFileDto(project)
-      .setDbKey("com.sonarsource:test-project:src/main/java/com/sonarsource/FourthClass.java")
+      .setKey("com.sonarsource:test-project:src/main/java/com/sonarsource/FourthClass.java")
       .setName("FourthClass.java")
       .setLongName("src/main/java/com/sonarsource/FourthClass.java")
       .setPath("src/main/java/com/sonarsource/FourthClass.java"));
index 1b89f229f3a76ee56aa3be6e42b8346e1f2dca64..eef8d335517ea808114ccd0fca0e2c373a0aa66c 100644 (file)
@@ -1065,13 +1065,13 @@ public class ShowActionTest {
     ComponentDto project = dbTester.components().insertPublicProject(componentDto -> componentDto
       .setName("test-project")
       .setLongName("test-project")
-      .setDbKey("com.sonarsource:test-project"));
+      .setKey("com.sonarsource:test-project"));
     userSessionRule.registerComponents(project)
       .addProjectPermission(UserRole.SECURITYHOTSPOT_ADMIN, project);
 
     ComponentDto file = dbTester.components().insertComponent(
       newFileDto(project)
-        .setDbKey("com.sonarsource:test-project:src/main/java/com/sonarsource/FourthClass.java")
+        .setKey("com.sonarsource:test-project:src/main/java/com/sonarsource/FourthClass.java")
         .setName("FourthClass.java")
         .setLongName("src/main/java/com/sonarsource/FourthClass.java")
         .setPath("src/main/java/com/sonarsource/FourthClass.java"));
index 36837d499202a455e3ff32d7a9163e2a14626a6e..29b0d0f7a2be0575fefba5d953a851a8243b8c8c 100644 (file)
@@ -206,7 +206,7 @@ public class PullTaintActionTest {
 
   @Test
   public void givenValidProjectKeyAndOneTaintOnBranch_returnOneTaint_WithMetadataSeverity() throws IOException {
-    loginWithBrowsePermission(correctProject.projectUuid(), correctFile.uuid());
+    loginWithBrowsePermission(correctProject.branchUuid(), correctFile.uuid());
     DbCommons.TextRange textRange = DbCommons.TextRange.newBuilder()
       .setStartLine(1)
       .setEndLine(2)
index 9edd790d12f36a78e17c287042b93b3608fc44ee..26a262a21e028cd890e9fd2df38e15e0ebe1eead 100644 (file)
@@ -167,8 +167,8 @@ public class SearchActionComponentsTest {
 
   @Test
   public void search_since_leak_period_on_project() {
-    ComponentDto project = db.components().insertPublicProject(p -> p.setDbKey("PK1"));
-    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "F1").setDbKey("FK1"));
+    ComponentDto project = db.components().insertPublicProject(p -> p.setKey("PK1"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
     db.components().insertSnapshot(project, a -> a.setPeriodDate(parseDateTime("2015-09-03T00:00:00+0100").getTime()));
     RuleDto rule = db.rules().insertIssueRule(r -> r.setRuleKey(RuleKey.of("xoo", "x1")));
     IssueDto issueAfterLeak = db.issues().insertIssue(rule, project, file, i -> i.setKee(UUID_EXAMPLE_01)
@@ -181,7 +181,7 @@ public class SearchActionComponentsTest {
     indexIssues();
 
     ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, project.getDbKey())
+      .setParam(PARAM_COMPONENT_KEYS, project.getKey())
       .setParam(PARAM_SINCE_LEAK_PERIOD, "true")
       .execute()
       .assertJson(this.getClass(), "search_since_leak_period.json");
@@ -189,9 +189,9 @@ public class SearchActionComponentsTest {
 
   @Test
   public void search_since_leak_period_on_file_in_module_project() {
-    ComponentDto project = db.components().insertPublicProject(p -> p.setDbKey("PK1"));
+    ComponentDto project = db.components().insertPublicProject(p -> p.setKey("PK1"));
     ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto file = db.components().insertComponent(newFileDto(module, null, "F1").setDbKey("FK1"));
+    ComponentDto file = db.components().insertComponent(newFileDto(module, null, "F1").setKey("FK1"));
     db.components().insertSnapshot(project, a -> a.setPeriodDate(parseDateTime("2015-09-03T00:00:00+0100").getTime()));
     RuleDto rule = db.rules().insertIssueRule(r -> r.setRuleKey(RuleKey.of("xoo", "x1")));
     IssueDto issueAfterLeak = db.issues().insertIssue(rule, project, file, i -> i.setKee(UUID_EXAMPLE_01)
@@ -204,7 +204,7 @@ public class SearchActionComponentsTest {
     indexIssues();
 
     ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, project.getDbKey())
+      .setParam(PARAM_COMPONENT_KEYS, project.getKey())
       .setParam(PARAM_FILES, file.path())
       .setParam(PARAM_SINCE_LEAK_PERIOD, "true")
       .execute()
@@ -213,8 +213,8 @@ public class SearchActionComponentsTest {
 
   @Test
   public void search_by_file_uuid() {
-    ComponentDto project = db.components().insertPublicProject(p -> p.setDbKey("PK1"));
-    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "F1").setDbKey("FK1"));
+    ComponentDto project = db.components().insertPublicProject(p -> p.setKey("PK1"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
     RuleDto rule = db.rules().insertIssueRule(r -> r.setRuleKey(RuleKey.of("xoo", "x1")));
     IssueDto issue = db.issues().insertIssue(rule, project, file, i -> i.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"));
     allowAnyoneOnProjects(project);
@@ -233,9 +233,9 @@ public class SearchActionComponentsTest {
 
   @Test
   public void search_by_file_key() {
-    ComponentDto project = db.components().insertPublicProject(p -> p.setDbKey("PK1"));
-    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "F1").setDbKey("FK1"));
-    ComponentDto unitTest = db.components().insertComponent(newFileDto(project, null, "F2").setQualifier(Qualifiers.UNIT_TEST_FILE).setDbKey("FK2"));
+    ComponentDto project = db.components().insertPublicProject(p -> p.setKey("PK1"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
+    ComponentDto unitTest = db.components().insertComponent(newFileDto(project, null, "F2").setQualifier(Qualifiers.UNIT_TEST_FILE).setKey("FK2"));
     RuleDto rule = db.rules().insertIssueRule(r -> r.setRuleKey(RuleKey.of("xoo", "x1")));
     IssueDto issueOnFile = db.issues().insertIssue(rule, project, file, i -> i.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"));
     IssueDto issueOnTest = db.issues().insertIssue(rule, project, unitTest, i -> i.setKee("2bd4eac2-b650-4037-80bc-7b1182fd47d4"));
@@ -255,9 +255,9 @@ public class SearchActionComponentsTest {
 
   @Test
   public void search_by_directory_path() {
-    ComponentDto project = db.components().insertPublicProject(p -> p.setDbKey("PK1"));
+    ComponentDto project = db.components().insertPublicProject(p -> p.setKey("PK1"));
     ComponentDto directory = db.components().insertComponent(newDirectory(project, "D1", "src/main/java/dir"));
-    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "F1").setDbKey("FK1").setPath(directory.path() + "/MyComponent.java"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "F1").setKey("FK1").setPath(directory.path() + "/MyComponent.java"));
     RuleDto rule = db.rules().insertIssueRule(r -> r.setRuleKey(RuleKey.of("xoo", "x1")));
     db.issues().insertIssue(rule, project, file, i -> i.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"));
     allowAnyoneOnProjects(project);
@@ -286,9 +286,9 @@ public class SearchActionComponentsTest {
 
   @Test
   public void search_by_view_uuid() {
-    ComponentDto project = db.components().insertPublicProject(p -> p.setDbKey("PK1"));
-    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "F1").setDbKey("FK1"));
-    ComponentDto view = db.components().insertComponent(ComponentTesting.newPortfolio("V1").setDbKey("MyView"));
+    ComponentDto project = db.components().insertPublicProject(p -> p.setKey("PK1"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
+    ComponentDto view = db.components().insertComponent(ComponentTesting.newPortfolio("V1").setKey("MyView"));
     db.components().insertComponent(newProjectCopy(project, view));
     RuleDto rule = db.rules().insertIssueRule(r -> r.setRuleKey(RuleKey.of("xoo", "x1")));
     db.issues().insertIssue(rule, project, file, i -> i.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"));
@@ -303,11 +303,11 @@ public class SearchActionComponentsTest {
 
   @Test
   public void search_by_sub_view_uuid() {
-    ComponentDto project = db.components().insertPublicProject(p -> p.setDbKey("PK1"));
-    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "F1").setDbKey("FK1"));
+    ComponentDto project = db.components().insertPublicProject(p -> p.setKey("PK1"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
     RuleDto rule = db.rules().insertIssueRule(r -> r.setRuleKey(RuleKey.of("xoo", "x1")));
     db.issues().insertIssue(rule, project, file, i -> i.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"));
-    ComponentDto view = db.components().insertComponent(ComponentTesting.newPortfolio("V1").setDbKey("MyView"));
+    ComponentDto view = db.components().insertComponent(ComponentTesting.newPortfolio("V1").setKey("MyView"));
     ComponentDto subView = db.components().insertComponent(ComponentTesting.newSubPortfolio(view, "SV1", "MySubView"));
     db.components().insertComponent(newProjectCopy(project, subView));
     allowAnyoneOnProjects(project, view, subView);
@@ -321,11 +321,11 @@ public class SearchActionComponentsTest {
 
   @Test
   public void search_by_sub_view_uuid_return_only_authorized_view() {
-    ComponentDto project = db.components().insertPublicProject(p -> p.setDbKey("PK1"));
-    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "F1").setDbKey("FK1"));
+    ComponentDto project = db.components().insertPublicProject(p -> p.setKey("PK1"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
     RuleDto rule = db.rules().insertIssueRule(r -> r.setRuleKey(RuleKey.of("xoo", "x1")));
     db.issues().insertIssue(rule, project, file, i -> i.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"));
-    ComponentDto view = db.components().insertComponent(ComponentTesting.newPortfolio("V1").setDbKey("MyView"));
+    ComponentDto view = db.components().insertComponent(ComponentTesting.newPortfolio("V1").setKey("MyView"));
     ComponentDto subView = db.components().insertComponent(ComponentTesting.newSubPortfolio(view, "SV1", "MySubView"));
     db.components().insertComponent(newProjectCopy(project, subView));
     // User has no permission on the view, no issue will be returned
@@ -353,7 +353,7 @@ public class SearchActionComponentsTest {
     indexIssuesAndViews();
 
     SearchWsResponse result = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, application.getDbKey())
+      .setParam(PARAM_COMPONENT_KEYS, application.getKey())
       .executeProtobuf(SearchWsResponse.class);
 
     assertThat(result.getIssuesList()).extracting(Issue::getKey)
@@ -362,14 +362,14 @@ public class SearchActionComponentsTest {
 
   @Test
   public void search_by_application_key_and_branch() {
-    ComponentDto application = db.components().insertPrivateProject(c -> c.setQualifier(APP).setDbKey("app"));
+    ComponentDto application = db.components().insertPrivateProject(c -> c.setQualifier(APP).setKey("app"));
     ComponentDto applicationBranch1 = db.components().insertProjectBranch(application, a -> a.setKey("app-branch1"));
     ComponentDto applicationBranch2 = db.components().insertProjectBranch(application, a -> a.setKey("app-branch2"));
-    ComponentDto project1 = db.components().insertPrivateProject(p -> p.setDbKey("prj1"));
+    ComponentDto project1 = db.components().insertPrivateProject(p -> p.setKey("prj1"));
     ComponentDto project1Branch1 = db.components().insertProjectBranch(project1);
     ComponentDto fileOnProject1Branch1 = db.components().insertComponent(newFileDto(project1Branch1));
     ComponentDto project1Branch2 = db.components().insertProjectBranch(project1);
-    ComponentDto project2 = db.components().insertPrivateProject(p -> p.setDbKey("prj2"));
+    ComponentDto project2 = db.components().insertPrivateProject(p -> p.setKey("prj2"));
     db.components().insertComponents(newProjectCopy(project1Branch1, applicationBranch1));
     db.components().insertComponents(newProjectCopy(project2, applicationBranch1));
     db.components().insertComponents(newProjectCopy(project1Branch2, applicationBranch2));
@@ -421,7 +421,7 @@ public class SearchActionComponentsTest {
     indexIssuesAndViews();
 
     SearchWsResponse result = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, application.getDbKey())
+      .setParam(PARAM_COMPONENT_KEYS, application.getKey())
       .executeProtobuf(SearchWsResponse.class);
 
     assertThat(result.getIssuesList()).isEmpty();
@@ -437,7 +437,7 @@ public class SearchActionComponentsTest {
     indexIssuesAndViews();
 
     SearchWsResponse result = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, application.getDbKey())
+      .setParam(PARAM_COMPONENT_KEYS, application.getKey())
       .executeProtobuf(SearchWsResponse.class);
 
     assertThat(result.getIssuesList()).isEmpty();
@@ -465,7 +465,7 @@ public class SearchActionComponentsTest {
     indexIssuesAndViews();
 
     SearchWsResponse result = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, application.getDbKey())
+      .setParam(PARAM_COMPONENT_KEYS, application.getKey())
       .setParam(PARAM_SINCE_LEAK_PERIOD, "true")
       .executeProtobuf(SearchWsResponse.class);
 
@@ -488,8 +488,8 @@ public class SearchActionComponentsTest {
     indexIssuesAndViews();
 
     SearchWsResponse result = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, application.getDbKey())
-      .setParam(PARAM_PROJECTS, project1.getDbKey())
+      .setParam(PARAM_COMPONENT_KEYS, application.getKey())
+      .setParam(PARAM_PROJECTS, project1.getKey())
       .executeProtobuf(SearchWsResponse.class);
 
     assertThat(result.getIssuesList()).extracting(Issue::getKey)
@@ -519,8 +519,8 @@ public class SearchActionComponentsTest {
     indexIssuesAndViews();
 
     SearchWsResponse result = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, application.getDbKey())
-      .setParam(PARAM_PROJECTS, project1.getDbKey())
+      .setParam(PARAM_COMPONENT_KEYS, application.getKey())
+      .setParam(PARAM_PROJECTS, project1.getKey())
       .setParam(PARAM_SINCE_LEAK_PERIOD, "true")
       .executeProtobuf(SearchWsResponse.class);
 
@@ -551,7 +551,7 @@ public class SearchActionComponentsTest {
     indexIssuesAndViews();
 
     SearchWsResponse result = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, application.getDbKey())
+      .setParam(PARAM_COMPONENT_KEYS, application.getKey())
       .setParam(PARAM_SINCE_LEAK_PERIOD, "true")
       .executeProtobuf(SearchWsResponse.class);
 
@@ -704,7 +704,7 @@ public class SearchActionComponentsTest {
     indexIssues();
 
     SearchWsResponse result = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, branch.getDbKey())
+      .setParam(PARAM_COMPONENT_KEYS, branch.getKey())
       .executeProtobuf(SearchWsResponse.class);
 
     assertThat(result.getIssuesList()).isEmpty();
index 9d195878e38dd52bcb95e85f0e3f948ee924ea37..fd08abd57be8c0bf817f2a9b73afe3e31dcec2db 100644 (file)
@@ -358,7 +358,7 @@ public class SearchActionTest {
         .setChangeData("*My comment*")
         .setChangeType(IssueChangeDto.TYPE_COMMENT)
         .setUserUuid(john.getUuid())
-        .setProjectUuid(project.projectUuid())
+        .setProjectUuid(project.branchUuid())
         .setIssueChangeCreationDate(parseDateTime("2014-09-09T12:00:00+0000").getTime()));
     dbClient.issueChangeDao().insert(session,
       new IssueChangeDto()
@@ -368,7 +368,7 @@ public class SearchActionTest {
         .setChangeData("Another comment")
         .setChangeType(IssueChangeDto.TYPE_COMMENT)
         .setUserUuid(fabrice.getUuid())
-        .setProjectUuid(project.projectUuid())
+        .setProjectUuid(project.branchUuid())
         .setIssueChangeCreationDate(parseDateTime("2014-09-10T12:00:00+0000").getTime()));
     dbClient.issueChangeDao().insert(session,
       new IssueChangeDto()
@@ -377,7 +377,7 @@ public class SearchActionTest {
         .setKey("COMMENT-NO-USER")
         .setChangeData("Another comment without user")
         .setChangeType(IssueChangeDto.TYPE_COMMENT)
-        .setProjectUuid(project.projectUuid())
+        .setProjectUuid(project.branchUuid())
         .setIssueChangeCreationDate(parseDateTime("2022-09-10T12:00:00+0000").getTime()));
     session.commit();
     indexIssues();
@@ -406,7 +406,7 @@ public class SearchActionTest {
         .setChangeData("*My comment*")
         .setChangeType(IssueChangeDto.TYPE_COMMENT)
         .setUserUuid(john.getUuid())
-        .setProjectUuid(project.projectUuid())
+        .setProjectUuid(project.branchUuid())
         .setCreatedAt(parseDateTime("2014-09-09T12:00:00+0000").getTime()));
     dbClient.issueChangeDao().insert(session,
       new IssueChangeDto()
@@ -416,7 +416,7 @@ public class SearchActionTest {
         .setChangeData("Another comment")
         .setChangeType(IssueChangeDto.TYPE_COMMENT)
         .setUserUuid(fabrice.getUuid())
-        .setProjectUuid(project.projectUuid())
+        .setProjectUuid(project.branchUuid())
         .setCreatedAt(parseDateTime("2014-09-10T19:10:03+0000").getTime()));
     session.commit();
     indexIssues();
@@ -452,10 +452,10 @@ public class SearchActionTest {
     UserDto simon = db.users().insertUser(u -> u.setLogin("simon").setName("Simon").setEmail("simon@email.com"));
     UserDto fabrice = db.users().insertUser(u -> u.setLogin("fabrice").setName("Fabrice").setEmail("fabrice@email.com"));
 
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY").setLanguage("java"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setKey("PROJECT_KEY").setLanguage("java"));
     grantPermissionToAnyone(project, ISSUE_ADMIN);
     indexPermissions();
-    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY").setLanguage("js"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setKey("FILE_KEY").setLanguage("js"));
 
     IssueDto issue = newDto(newIssueRule(), file, project)
       .setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2")
@@ -476,8 +476,8 @@ public class SearchActionTest {
   @Test
   public void search_by_rule_key() {
     RuleDto rule = newIssueRule();
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY").setLanguage("java"));
-    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY").setLanguage("java"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setKey("PROJECT_KEY").setLanguage("java"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setKey("FILE_KEY").setLanguage("java"));
 
     db.issues().insertIssue(rule, project, file);
     session.commit();
@@ -497,8 +497,8 @@ public class SearchActionTest {
   @Test
   public void search_by_non_existing_rule_key() {
     RuleDto rule = newIssueRule();
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY").setLanguage("java"));
-    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY").setLanguage("java"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setKey("PROJECT_KEY").setLanguage("java"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setKey("FILE_KEY").setLanguage("java"));
 
     db.issues().insertIssue(rule, project, file);
     session.commit();
@@ -518,10 +518,10 @@ public class SearchActionTest {
   @Test
   public void issue_on_removed_file() {
     RuleDto rule = newIssueRule();
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
     indexPermissions();
     ComponentDto removedFile = db.components().insertComponent(newFileDto(project, null).setUuid("REMOVED_FILE_ID")
-      .setDbKey("REMOVED_FILE_KEY")
+      .setKey("REMOVED_FILE_KEY")
       .setEnabled(false));
 
     IssueDto issue = newDto(rule, removedFile, project)
@@ -543,9 +543,9 @@ public class SearchActionTest {
   @Test
   public void apply_paging_with_one_component() {
     RuleDto rule = newIssueRule();
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
     indexPermissions();
-    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     for (int i = 0; i < SearchOptions.MAX_PAGE_SIZE + 1; i++) {
       IssueDto issue = newDto(rule, file, project).setAssigneeUuid(null);
       dbClient.issueDao().insert(session, issue);
@@ -559,10 +559,10 @@ public class SearchActionTest {
 
   @Test
   public void components_contains_sub_projects() {
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("ProjectHavingModule"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setKey("ProjectHavingModule"));
     indexPermissions();
-    ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project).setDbKey("ModuleHavingFile"));
-    ComponentDto file = db.components().insertComponent(newFileDto(module, null, "BCDE").setDbKey("FileLinkedToModule"));
+    ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project).setKey("ModuleHavingFile"));
+    ComponentDto file = db.components().insertComponent(newFileDto(module, null, "BCDE").setKey("FileLinkedToModule"));
     IssueDto issue = newDto(newIssueRule(), file, project);
     dbClient.issueDao().insert(session, issue);
     session.commit();
@@ -576,9 +576,9 @@ public class SearchActionTest {
   public void filter_by_assigned_to_me() {
     UserDto john = db.users().insertUser(u -> u.setLogin("john").setName("John").setEmail("john@email.com"));
     UserDto alice = db.users().insertUser(u -> u.setLogin("alice").setName("Alice").setEmail("alice@email.com"));
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
     indexPermissions();
-    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     RuleDto rule = newIssueRule();
     IssueDto issue1 = newDto(rule, file, project)
       .setIssueCreationDate(parseDate("2014-09-04"))
@@ -622,11 +622,11 @@ public class SearchActionTest {
   public void filter_by_new_code_period() {
     UserDto john = db.users().insertUser(u -> u.setLogin("john").setName("John").setEmail("john@email.com"));
     UserDto alice = db.users().insertUser(u -> u.setLogin("alice").setName("Alice").setEmail("alice@email.com"));
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
     SnapshotDto snapshotDto = db.components().insertSnapshot(project, s -> s.setLast(true).setPeriodDate(parseDateTime("2014-09-05T00:00:00+0100").getTime()));
     indexPermissions();
 
-    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     RuleDto rule = newIssueRule();
     IssueDto issue1 = newDto(rule, file, project)
       .setIssueCreationDate(parseDateTime("2014-09-04T00:00:00+0100"))
@@ -693,10 +693,10 @@ public class SearchActionTest {
   public void filter_by_leak_period_without_a_period() {
     UserDto john = db.users().insertUser(u -> u.setLogin("john").setName("John").setEmail("john@email.com"));
     UserDto alice = db.users().insertUser(u -> u.setLogin("alice").setName("Alice").setEmail("alice@email.com"));
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
     SnapshotDto snapshotDto = db.components().insertSnapshot(project);
     indexPermissions();
-    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     RuleDto rule = newIssueRule();
     IssueDto issue1 = newDto(rule, file, project)
       .setIssueCreationDate(parseDateTime("2014-09-04T00:00:00+0100"))
@@ -744,11 +744,11 @@ public class SearchActionTest {
   public void filter_by_leak_period_has_no_effect_on_prs() {
     UserDto john = db.users().insertUser(u -> u.setLogin("john").setName("John").setEmail("john@email.com"));
     UserDto alice = db.users().insertUser(u -> u.setLogin("alice").setName("Alice").setEmail("alice@email.com"));
-    ComponentDto project = db.components().insertPublicProject(c -> c.setUuid("PROJECT_ID").setDbKey("PROJECT_KEY"));
+    ComponentDto project = db.components().insertPublicProject(c -> c.setUuid("PROJECT_ID").setKey("PROJECT_KEY"));
     ComponentDto pr = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.PULL_REQUEST).setKey("pr"));
     SnapshotDto snapshotDto = db.components().insertSnapshot(pr);
     indexPermissions();
-    ComponentDto file = db.components().insertComponent(newFileDto(pr, null, "FILE_ID").setDbKey("FILE_KEY" + PULL_REQUEST_SEPARATOR + "pr"));
+    ComponentDto file = db.components().insertComponent(newFileDto(pr, null, "FILE_ID").setKey("FILE_KEY" + PULL_REQUEST_SEPARATOR + "pr"));
     RuleDto rule = newIssueRule();
     IssueDto issue1 = newDto(rule, file, pr)
       .setIssueCreationDate(parseDateTime("2014-09-04T00:00:00+0100"))
@@ -799,9 +799,9 @@ public class SearchActionTest {
   public void return_empty_when_login_is_unknown() {
     UserDto john = db.users().insertUser(u -> u.setLogin("john").setName("John").setEmail("john@email.com"));
     UserDto alice = db.users().insertUser(u -> u.setLogin("alice").setName("Alice").setEmail("alice@email.com"));
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
     indexPermissions();
-    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     RuleDto rule = newIssueRule();
     IssueDto issue1 = newDto(rule, file, project)
       .setIssueCreationDate(parseDate("2014-09-04"))
@@ -848,9 +848,9 @@ public class SearchActionTest {
     userSession.logIn(poy);
     UserDto alice = db.users().insertUser(u -> u.setLogin("alice").setName("Alice").setEmail("alice@email.com"));
     UserDto john = db.users().insertUser(u -> u.setLogin("john").setName("John").setEmail("john@email.com"));
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
     indexPermissions();
-    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     RuleDto rule = newIssueRule();
     IssueDto issue1 = newDto(rule, file, project)
       .setStatus("OPEN")
@@ -909,12 +909,12 @@ public class SearchActionTest {
 
   @Test
   public void filter_by_test_scope() {
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
     indexPermissions();
     ComponentDto mainCodeFile = db.components().insertComponent(
-      newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
+      newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     ComponentDto testCodeFile = db.components().insertComponent(
-      newFileDto(project, null, "ANOTHER_FILE_ID").setDbKey("ANOTHER_FILE_KEY").setQualifier(UNIT_TEST_FILE));
+      newFileDto(project, null, "ANOTHER_FILE_ID").setKey("ANOTHER_FILE_KEY").setQualifier(UNIT_TEST_FILE));
     RuleDto rule = newIssueRule();
     IssueDto issue1 = newDto(rule, mainCodeFile, project)
       .setIssueCreationDate(parseDate("2014-09-04"))
@@ -950,12 +950,12 @@ public class SearchActionTest {
 
   @Test
   public void filter_by_main_scope() {
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
     indexPermissions();
     ComponentDto mainCodeFile = db.components().insertComponent(
-      newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
+      newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     ComponentDto testCodeFile = db.components().insertComponent(
-      newFileDto(project, null, "ANOTHER_FILE_ID").setDbKey("ANOTHER_FILE_KEY").setQualifier(UNIT_TEST_FILE));
+      newFileDto(project, null, "ANOTHER_FILE_ID").setKey("ANOTHER_FILE_KEY").setQualifier(UNIT_TEST_FILE));
     RuleDto rule = newIssueRule();
     IssueDto issue1 = newDto(rule, mainCodeFile, project)
       .setType(CODE_SMELL)
@@ -994,10 +994,10 @@ public class SearchActionTest {
 
   @Test
   public void filter_by_scope_always_returns_all_scope_facet_values() {
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
     indexPermissions();
     ComponentDto mainCodeFile = db.components().insertComponent(
-      newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
+      newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     RuleDto rule = newIssueRule();
     IssueDto issue1 = newDto(rule, mainCodeFile, project)
       .setType(CODE_SMELL)
@@ -1029,9 +1029,9 @@ public class SearchActionTest {
   @Test
   public void sort_by_updated_at() {
     RuleDto rule = newIssueRule();
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
     indexPermissions();
-    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     dbClient.issueDao().insert(session, newDto(rule, file, project)
       .setKee("82fd47d4-b650-4037-80bc-7b112bd4eac1")
       .setIssueUpdateDate(parseDateTime("2014-11-02T00:00:00+0100")));
@@ -1694,9 +1694,9 @@ public class SearchActionTest {
   @Test
   public void paging() {
     RuleDto rule = newIssueRule();
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
     indexPermissions();
-    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     for (int i = 0; i < 12; i++) {
       IssueDto issue = newDto(rule, file, project);
       dbClient.issueDao().insert(session, issue);
index c5f5878b5522b3d2b71e387154e472f204517503..6b98e7d82d8d8252a3870ec2a000ec20239f9902 100644 (file)
@@ -161,13 +161,13 @@ public class SearchResponseFormatFormatOperationTest {
     RuleDto ruleDto = newRule();
     String projectUuid = "project_uuid_" + randomAlphanumeric(5);
     ComponentDto projectDto = newPrivateProjectDto();
-    projectDto.setProjectUuid(projectUuid);
+    projectDto.setBranchUuid(projectUuid);
     return newIssue(ruleDto, projectUuid, "project_key_" + randomAlphanumeric(5), projectDto);
   }
 
   @Test
   public void formatOperation_should_add_branch_on_issue() {
-    componentDto.setDbKey(randomAlphanumeric(5) + BRANCH_KEY_SEPARATOR + randomAlphanumeric(5));
+    componentDto.setKey(randomAlphanumeric(5) + BRANCH_KEY_SEPARATOR + randomAlphanumeric(5));
 
     Operation result = searchResponseFormat.formatOperation(searchResponseData);
 
@@ -176,7 +176,7 @@ public class SearchResponseFormatFormatOperationTest {
 
   @Test
   public void formatOperation_should_add_pullrequest_on_issue() {
-    componentDto.setDbKey(randomAlphanumeric(5) + PULL_REQUEST_SEPARATOR + randomAlphanumeric(5));
+    componentDto.setKey(randomAlphanumeric(5) + PULL_REQUEST_SEPARATOR + randomAlphanumeric(5));
 
     Operation result = searchResponseFormat.formatOperation(searchResponseData);
 
@@ -283,7 +283,7 @@ public class SearchResponseFormatFormatOperationTest {
 
     String projectUuid = "project_uuid_" + randomAlphanumeric(5);
     ComponentDto projectDto = newPrivateProjectDto();
-    projectDto.setProjectUuid(projectUuid);
+    projectDto.setBranchUuid(projectUuid);
 
     UserDto userDto = newUserDto();
 
index c7d69683615a6f969a758e53bcf27111dcd651ac..9900dcf7bc2bb94d26eeb43bea88c05e729809d6 100644 (file)
@@ -95,7 +95,7 @@ public class ComponentActionTest {
     assertThat(response.getMetrics().getMetricsCount()).isOne();
     assertThat(response.hasPeriod()).isFalse();
     assertThat(response.getPeriods().getPeriodsCount()).isZero();
-    assertThat(response.getComponent().getKey()).isEqualTo(project.getDbKey());
+    assertThat(response.getComponent().getKey()).isEqualTo(project.getKey());
   }
 
   @Test
@@ -243,11 +243,11 @@ public class ComponentActionTest {
     MetricDto metric = db.measures().insertMetric(m -> m.setValueType("INT"));
 
     ComponentWsResponse response = ws.newRequest()
-      .setParam("component", project.getDbKey())
+      .setParam("component", project.getKey())
       .setParam(PARAM_METRIC_KEYS, metric.getKey())
       .executeProtobuf(ComponentWsResponse.class);
 
-    assertThat(response.getComponent().getKey()).isEqualTo(project.getDbKey());
+    assertThat(response.getComponent().getKey()).isEqualTo(project.getKey());
   }
 
   @Test
@@ -386,12 +386,12 @@ public class ComponentActionTest {
 
     assertThatThrownBy(() -> {
       ws.newRequest()
-        .setParam(PARAM_COMPONENT, branch.getDbKey())
+        .setParam(PARAM_COMPONENT, branch.getKey())
         .setParam(PARAM_METRIC_KEYS, metric.getKey())
         .execute();
     })
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Component key '%s' not found", branch.getDbKey()));
+      .hasMessage(format("Component key '%s' not found", branch.getKey()));
   }
 
   @Test
@@ -403,7 +403,7 @@ public class ComponentActionTest {
         .setPeriodMode("previous_version")
         .setPeriodParam("1.0-SNAPSHOT"));
     ComponentDto file = db.components().insertComponent(newFileDto(project)
-      .setDbKey("MY_PROJECT:ElementImpl.java")
+      .setKey("MY_PROJECT:ElementImpl.java")
       .setName("ElementImpl.java")
       .setLanguage("java")
       .setPath("src/main/java/com/sonarsource/markdown/impl/ElementImpl.java"));
index 70aa1394b4e4e5e240c7095dd58c2b1169167cb8..0afae7b792cc5042b4df56134bffa9881fc586bf 100644 (file)
@@ -116,7 +116,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void json_example() {
-    ComponentDto project = db.components().insertPrivateProject(p -> p.setDbKey("MY_PROJECT")
+    ComponentDto project = db.components().insertPrivateProject(p -> p.setKey("MY_PROJECT")
       .setName("My Project"));
     userSession.addProjectPermission(USER, project);
     SnapshotDto analysis = db.components().insertSnapshot(project, s -> s.setPeriodDate(parseDateTime("2016-01-11T10:49:50+0100").getTime())
@@ -124,21 +124,21 @@ public class ComponentTreeActionTest {
       .setPeriodParam("1.0-SNAPSHOT"));
     ComponentDto file1 = db.components().insertComponent(newFileDto(project, null)
       .setUuid("AVIwDXE-bJbJqrw6wFv5")
-      .setDbKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl/ElementImpl.java")
+      .setKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl/ElementImpl.java")
       .setName("ElementImpl.java")
       .setLanguage("java")
       .setQualifier(FILE)
       .setPath("src/main/java/com/sonarsource/markdown/impl/ElementImpl.java"));
     ComponentDto file2 = db.components().insertComponent(newFileDto(project, null)
       .setUuid("AVIwDXE_bJbJqrw6wFwJ")
-      .setDbKey("com.sonarsource:java-markdown:src/test/java/com/sonarsource/markdown/impl/ElementImplTest.java")
+      .setKey("com.sonarsource:java-markdown:src/test/java/com/sonarsource/markdown/impl/ElementImplTest.java")
       .setName("ElementImplTest.java")
       .setLanguage("java")
       .setQualifier(UNIT_TEST_FILE)
       .setPath("src/test/java/com/sonarsource/markdown/impl/ElementImplTest.java"));
     ComponentDto dir = db.components().insertComponent(newDirectory(project, "src/main/java/com/sonarsource/markdown/impl")
       .setUuid("AVIwDXE-bJbJqrw6wFv8")
-      .setDbKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl")
+      .setKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl")
       .setQualifier(DIRECTORY));
 
     MetricDto complexity = insertComplexityMetric();
@@ -353,15 +353,15 @@ public class ComponentTreeActionTest {
     ComponentDto project = db.components().insertPrivateProject();
     userSession.addProjectPermission(USER, project);
     SnapshotDto projectSnapshot = db.components().insertSnapshot(project);
-    ComponentDto file9 = db.components().insertComponent(newFileDto(project, null, "file-uuid-9").setName("file-1").setDbKey("file-9-key"));
-    ComponentDto file8 = db.components().insertComponent(newFileDto(project, null, "file-uuid-8").setName("file-1").setDbKey("file-8-key"));
-    ComponentDto file7 = db.components().insertComponent(newFileDto(project, null, "file-uuid-7").setName("file-1").setDbKey("file-7-key"));
-    ComponentDto file6 = db.components().insertComponent(newFileDto(project, null, "file-uuid-6").setName("file-1").setDbKey("file-6-key"));
-    ComponentDto file5 = db.components().insertComponent(newFileDto(project, null, "file-uuid-5").setName("file-1").setDbKey("file-5-key"));
-    ComponentDto file4 = db.components().insertComponent(newFileDto(project, null, "file-uuid-4").setName("file-1").setDbKey("file-4-key"));
-    ComponentDto file3 = db.components().insertComponent(newFileDto(project, null, "file-uuid-3").setName("file-1").setDbKey("file-3-key"));
-    ComponentDto file2 = db.components().insertComponent(newFileDto(project, null, "file-uuid-2").setName("file-1").setDbKey("file-2-key"));
-    ComponentDto file1 = db.components().insertComponent(newFileDto(project, null, "file-uuid-1").setName("file-1").setDbKey("file-1-key"));
+    ComponentDto file9 = db.components().insertComponent(newFileDto(project, null, "file-uuid-9").setName("file-1").setKey("file-9-key"));
+    ComponentDto file8 = db.components().insertComponent(newFileDto(project, null, "file-uuid-8").setName("file-1").setKey("file-8-key"));
+    ComponentDto file7 = db.components().insertComponent(newFileDto(project, null, "file-uuid-7").setName("file-1").setKey("file-7-key"));
+    ComponentDto file6 = db.components().insertComponent(newFileDto(project, null, "file-uuid-6").setName("file-1").setKey("file-6-key"));
+    ComponentDto file5 = db.components().insertComponent(newFileDto(project, null, "file-uuid-5").setName("file-1").setKey("file-5-key"));
+    ComponentDto file4 = db.components().insertComponent(newFileDto(project, null, "file-uuid-4").setName("file-1").setKey("file-4-key"));
+    ComponentDto file3 = db.components().insertComponent(newFileDto(project, null, "file-uuid-3").setName("file-1").setKey("file-3-key"));
+    ComponentDto file2 = db.components().insertComponent(newFileDto(project, null, "file-uuid-2").setName("file-1").setKey("file-2-key"));
+    ComponentDto file1 = db.components().insertComponent(newFileDto(project, null, "file-uuid-1").setName("file-1").setKey("file-1-key"));
     MetricDto coverage = insertCoverageMetric();
     db.commit();
     db.measures().insertLiveMeasure(file1, coverage, m -> m.setValue(1.0d));
@@ -396,10 +396,10 @@ public class ComponentTreeActionTest {
     ComponentDto project = db.components().insertPrivateProject();
     userSession.addProjectPermission(USER, project);
     SnapshotDto projectSnapshot = db.components().insertSnapshot(project);
-    ComponentDto file4 = db.components().insertComponent(newFileDto(project, null, "file-uuid-4").setDbKey("file-4-key"));
-    ComponentDto file3 = db.components().insertComponent(newFileDto(project, null, "file-uuid-3").setDbKey("file-3-key"));
-    ComponentDto file1 = db.components().insertComponent(newFileDto(project, null, "file-uuid-1").setDbKey("file-1-key"));
-    ComponentDto file2 = db.components().insertComponent(newFileDto(project, null, "file-uuid-2").setDbKey("file-2-key"));
+    ComponentDto file4 = db.components().insertComponent(newFileDto(project, null, "file-uuid-4").setKey("file-4-key"));
+    ComponentDto file3 = db.components().insertComponent(newFileDto(project, null, "file-uuid-3").setKey("file-3-key"));
+    ComponentDto file1 = db.components().insertComponent(newFileDto(project, null, "file-uuid-1").setKey("file-1-key"));
+    ComponentDto file2 = db.components().insertComponent(newFileDto(project, null, "file-uuid-2").setKey("file-2-key"));
     MetricDto ncloc = newMetricDto().setKey("ncloc").setValueType(INT.name()).setDirection(1);
     dbClient.metricDao().insert(dbSession, ncloc);
     db.commit();
@@ -423,10 +423,10 @@ public class ComponentTreeActionTest {
     ComponentDto project = db.components().insertPrivateProject();
     userSession.addProjectPermission(USER, project);
     SnapshotDto projectSnapshot = db.components().insertSnapshot(project);
-    ComponentDto file1 = newFileDto(project, null, "file-uuid-1").setDbKey("file-1-key");
-    ComponentDto file2 = newFileDto(project, null, "file-uuid-2").setDbKey("file-2-key");
-    ComponentDto file3 = newFileDto(project, null, "file-uuid-3").setDbKey("file-3-key");
-    ComponentDto file4 = newFileDto(project, null, "file-uuid-4").setDbKey("file-4-key");
+    ComponentDto file1 = newFileDto(project, null, "file-uuid-1").setKey("file-1-key");
+    ComponentDto file2 = newFileDto(project, null, "file-uuid-2").setKey("file-2-key");
+    ComponentDto file3 = newFileDto(project, null, "file-uuid-3").setKey("file-3-key");
+    ComponentDto file4 = newFileDto(project, null, "file-uuid-4").setKey("file-4-key");
     db.components().insertComponent(file1);
     db.components().insertComponent(file2);
     db.components().insertComponent(file3);
@@ -459,9 +459,9 @@ public class ComponentTreeActionTest {
     ComponentDto project = db.components().insertPrivateProject();
     userSession.addProjectPermission(USER, project);
     SnapshotDto projectSnapshot = db.components().insertSnapshot(project);
-    ComponentDto file3 = db.components().insertComponent(newFileDto(project, null, "file-uuid-3").setDbKey("file-3-key"));
-    ComponentDto file1 = db.components().insertComponent(newFileDto(project, null, "file-uuid-1").setDbKey("file-1-key"));
-    ComponentDto file2 = db.components().insertComponent(newFileDto(project, null, "file-uuid-2").setDbKey("file-2-key"));
+    ComponentDto file3 = db.components().insertComponent(newFileDto(project, null, "file-uuid-3").setKey("file-3-key"));
+    ComponentDto file1 = db.components().insertComponent(newFileDto(project, null, "file-uuid-1").setKey("file-1-key"));
+    ComponentDto file2 = db.components().insertComponent(newFileDto(project, null, "file-uuid-2").setKey("file-2-key"));
     MetricDto ncloc = newMetricDto().setKey("ncloc").setValueType(INT.name()).setDirection(1);
     dbClient.metricDao().insert(dbSession, ncloc);
     db.commit();
@@ -485,10 +485,10 @@ public class ComponentTreeActionTest {
     ComponentDto project = db.components().insertPrivateProject();
     userSession.addProjectPermission(USER, project);
     SnapshotDto projectSnapshot = db.components().insertSnapshot(project);
-    ComponentDto file4 = db.components().insertComponent(newFileDto(project, null, "file-uuid-4").setDbKey("file-4-key"));
-    ComponentDto file3 = db.components().insertComponent(newFileDto(project, null, "file-uuid-3").setDbKey("file-3-key"));
-    ComponentDto file2 = db.components().insertComponent(newFileDto(project, null, "file-uuid-2").setDbKey("file-2-key"));
-    ComponentDto file1 = db.components().insertComponent(newFileDto(project, null, "file-uuid-1").setDbKey("file-1-key"));
+    ComponentDto file4 = db.components().insertComponent(newFileDto(project, null, "file-uuid-4").setKey("file-4-key"));
+    ComponentDto file3 = db.components().insertComponent(newFileDto(project, null, "file-uuid-3").setKey("file-3-key"));
+    ComponentDto file2 = db.components().insertComponent(newFileDto(project, null, "file-uuid-2").setKey("file-2-key"));
+    ComponentDto file1 = db.components().insertComponent(newFileDto(project, null, "file-uuid-1").setKey("file-1-key"));
     MetricDto ncloc = newMetricDto().setKey("new_ncloc").setValueType(INT.name()).setDirection(1);
     dbClient.metricDao().insert(dbSession, ncloc);
     db.measures().insertLiveMeasure(file1, ncloc, m -> m.setData((String) null).setValue(null).setVariation(1.0d));
@@ -674,7 +674,7 @@ public class ComponentTreeActionTest {
   @Test
   public void portfolio_local_reference_in_portfolio() {
     ComponentDto view = db.components().insertComponent(ComponentTesting.newPortfolio("VIEW1-UUID")
-      .setDbKey("Apache-Projects").setName("Apache Projects"));
+      .setKey("Apache-Projects").setName("Apache Projects"));
     userSession.registerComponents(view);
     ComponentDto view2 = db.components().insertPrivatePortfolio();
     userSession.addProjectPermission(USER, view2);
@@ -697,7 +697,7 @@ public class ComponentTreeActionTest {
   @Test
   public void application_local_reference_in_portfolio() {
     ComponentDto apache_projects = ComponentTesting.newPortfolio("VIEW1-UUID")
-      .setDbKey("Apache-Projects").setName("Apache Projects").setPrivate(true);
+      .setKey("Apache-Projects").setName("Apache Projects").setPrivate(true);
     userSession.addProjectPermission(USER, apache_projects);
     ComponentDto view = db.components().insertComponent(apache_projects);
     ComponentDto application = db.components().insertPrivateApplication();
@@ -721,13 +721,13 @@ public class ComponentTreeActionTest {
   @Test
   public void project_branch_reference_from_application_branch() {
     MetricDto ncloc = insertNclocMetric();
-    ComponentDto application = db.components().insertPublicProject(c -> c.setQualifier(APP).setDbKey("app-key"));
+    ComponentDto application = db.components().insertPublicProject(c -> c.setQualifier(APP).setKey("app-key"));
     userSession.registerApplication(application);
     ComponentDto applicationBranch = db.components().insertProjectBranch(application, a -> a.setKey("app-branch"), a -> a.setUuid("custom-uuid"));
-    ComponentDto project = db.components().insertPrivateProject(p -> p.setDbKey("project-key"));
+    ComponentDto project = db.components().insertPrivateProject(p -> p.setKey("project-key"));
     ComponentDto projectBranch = db.components().insertProjectBranch(project, b -> b.setKey("project-branch"));
     ComponentDto techProjectBranch = db.components().insertComponent(newProjectCopy(projectBranch, applicationBranch)
-      .setDbKey(applicationBranch.getKey() + applicationBranch.getBranch() + projectBranch.getDbKey()));
+      .setKey(applicationBranch.getKey() + applicationBranch.getBranch() + projectBranch.getKey()));
     SnapshotDto applicationBranchAnalysis = db.components().insertSnapshot(applicationBranch);
     db.measures().insertLiveMeasure(applicationBranch, ncloc, m -> m.setValue(5d));
     db.measures().insertLiveMeasure(techProjectBranch, ncloc, m -> m.setValue(1d));
@@ -993,7 +993,7 @@ public class ComponentTreeActionTest {
   public void fail_when_component_is_removed() {
     ComponentDto project = db.components().insertPrivateProject();
     db.components().insertSnapshot(project);
-    ComponentDto file = db.components().insertComponent(newFileDto(project).setDbKey("file-key").setEnabled(false));
+    ComponentDto file = db.components().insertComponent(newFileDto(project).setKey("file-key").setEnabled(false));
     userSession.anonymous().addProjectPermission(USER, project);
     insertNclocMetric();
 
@@ -1034,12 +1034,12 @@ public class ComponentTreeActionTest {
 
     assertThatThrownBy(() -> {
       ws.newRequest()
-        .setParam(PARAM_COMPONENT, branch.getDbKey())
+        .setParam(PARAM_COMPONENT, branch.getKey())
         .setParam(PARAM_METRIC_KEYS, "ncloc")
         .execute();
     })
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Component key '%s' not found", branch.getDbKey()));
+      .hasMessage(format("Component key '%s' not found", branch.getKey()));
   }
 
   private static MetricDto newMetricDto() {
index 9ed94cbaeba9c7f2f69cd11d1187bb3d83e5b1f0..daeeaee2439d93ae29a7bee511435b23acae4176 100644 (file)
@@ -70,9 +70,9 @@ public class SearchActionTest {
 
   @Test
   public void json_example() {
-    ComponentDto project1 = db.components().insertPrivateProject(p -> p.setDbKey("MY_PROJECT_1").setName("Project 1"));
-    ComponentDto project2 = db.components().insertPrivateProject(p -> p.setDbKey("MY_PROJECT_2").setName("Project 2"));
-    ComponentDto project3 = db.components().insertPrivateProject(p -> p.setDbKey("MY_PROJECT_3").setName("Project 3"));
+    ComponentDto project1 = db.components().insertPrivateProject(p -> p.setKey("MY_PROJECT_1").setName("Project 1"));
+    ComponentDto project2 = db.components().insertPrivateProject(p -> p.setKey("MY_PROJECT_2").setName("Project 2"));
+    ComponentDto project3 = db.components().insertPrivateProject(p -> p.setKey("MY_PROJECT_3").setName("Project 3"));
 
     userSession.addProjectPermission(UserRole.USER, project1);
     userSession.addProjectPermission(UserRole.USER, project2);
@@ -93,7 +93,7 @@ public class SearchActionTest {
     db.measures().insertLiveMeasure(project2, newViolations, m -> m.setVariation(25.0d));
     db.measures().insertLiveMeasure(project3, newViolations, m -> m.setVariation(255.0d));
 
-    List<String> projectKeys = Arrays.asList(project1.getDbKey(), project2.getDbKey(), project3.getDbKey());
+    List<String> projectKeys = Arrays.asList(project1.getKey(), project2.getKey(), project3.getKey());
 
     String result = ws.newRequest()
       .setParam(PARAM_PROJECT_KEYS, Joiner.on(",").join(projectKeys))
@@ -111,7 +111,7 @@ public class SearchActionTest {
     MetricDto coverage = db.measures().insertMetric(m -> m.setValueType(FLOAT.name()));
     db.measures().insertLiveMeasure(project, coverage, m -> m.setValue(15.5d));
 
-    SearchWsResponse result = call(singletonList(project.getDbKey()), singletonList(coverage.getKey()));
+    SearchWsResponse result = call(singletonList(project.getKey()), singletonList(coverage.getKey()));
 
     List<Measure> measures = result.getMeasuresList();
     assertThat(measures).hasSize(1);
@@ -131,7 +131,7 @@ public class SearchActionTest {
     MetricDto noBestValue = db.measures().insertMetric(m -> m.setValueType(INT.name()).setBestValue(null));
     db.measures().insertLiveMeasure(project, noBestValue, m -> m.setValue(123d));
 
-    SearchWsResponse result = call(singletonList(project.getDbKey()),
+    SearchWsResponse result = call(singletonList(project.getKey()),
       asList(matchBestValue.getKey(), doesNotMatchBestValue.getKey(), noBestValue.getKey()));
 
     List<Measure> measures = result.getMeasuresList();
@@ -150,7 +150,7 @@ public class SearchActionTest {
     MetricDto coverage = db.measures().insertMetric(m -> m.setValueType(FLOAT.name()));
     db.measures().insertLiveMeasure(project, coverage, m -> m.setValue(15.5d).setVariation(10d));
 
-    SearchWsResponse result = call(singletonList(project.getDbKey()), singletonList(coverage.getKey()));
+    SearchWsResponse result = call(singletonList(project.getKey()), singletonList(coverage.getKey()));
 
     List<Measure> measures = result.getMeasuresList();
     assertThat(measures).hasSize(1);
@@ -179,12 +179,12 @@ public class SearchActionTest {
     db.measures().insertLiveMeasure(project2, complexity, m -> m.setValue(15d));
     db.measures().insertLiveMeasure(project3, complexity, m -> m.setValue(20d));
 
-    SearchWsResponse result = call(asList(project1.getDbKey(), project2.getDbKey(), project3.getDbKey()), asList(coverage.getKey(), complexity.getKey()));
+    SearchWsResponse result = call(asList(project1.getKey(), project2.getKey(), project3.getKey()), asList(coverage.getKey(), complexity.getKey()));
 
     assertThat(result.getMeasuresList()).extracting(Measure::getMetric, Measure::getComponent)
       .containsExactly(
-        tuple(complexity.getKey(), project2.getDbKey()), tuple(complexity.getKey(), project3.getDbKey()), tuple(complexity.getKey(), project1.getDbKey()),
-        tuple(coverage.getKey(), project2.getDbKey()), tuple(coverage.getKey(), project3.getDbKey()), tuple(coverage.getKey(), project1.getDbKey()));
+        tuple(complexity.getKey(), project2.getKey()), tuple(complexity.getKey(), project3.getKey()), tuple(complexity.getKey(), project1.getKey()),
+        tuple(coverage.getKey(), project2.getKey()), tuple(coverage.getKey(), project3.getKey()), tuple(coverage.getKey(), project1.getKey()));
   }
 
   @Test
@@ -194,7 +194,7 @@ public class SearchActionTest {
     MetricDto coverage = db.measures().insertMetric(m -> m.setValueType(FLOAT.name()));
     db.measures().insertLiveMeasure(view, coverage, m -> m.setValue(15.5d));
 
-    SearchWsResponse result = call(singletonList(view.getDbKey()), singletonList(coverage.getKey()));
+    SearchWsResponse result = call(singletonList(view.getKey()), singletonList(coverage.getKey()));
 
     List<Measure> measures = result.getMeasuresList();
     assertThat(measures).hasSize(1);
@@ -210,7 +210,7 @@ public class SearchActionTest {
     MetricDto coverage = db.measures().insertMetric(m -> m.setValueType(FLOAT.name()));
     db.measures().insertLiveMeasure(application, coverage, m -> m.setValue(15.5d));
 
-    SearchWsResponse result = call(singletonList(application.getDbKey()), singletonList(coverage.getKey()));
+    SearchWsResponse result = call(singletonList(application.getKey()), singletonList(coverage.getKey()));
 
     List<Measure> measures = result.getMeasuresList();
     assertThat(measures).hasSize(1);
@@ -227,7 +227,7 @@ public class SearchActionTest {
     MetricDto metric = db.measures().insertMetric(m -> m.setValueType(FLOAT.name()));
     db.measures().insertLiveMeasure(subView, metric, m -> m.setValue(15.5d));
 
-    SearchWsResponse result = call(singletonList(subView.getDbKey()), singletonList(metric.getKey()));
+    SearchWsResponse result = call(singletonList(subView.getKey()), singletonList(metric.getKey()));
 
     List<Measure> measures = result.getMeasuresList();
     assertThat(measures).hasSize(1);
@@ -245,9 +245,9 @@ public class SearchActionTest {
     db.measures().insertLiveMeasure(project2, metric, m -> m.setValue(42.0d));
     Arrays.stream(new ComponentDto[] {project1}).forEach(p -> userSession.addProjectPermission(UserRole.USER, p));
 
-    SearchWsResponse result = call(asList(project1.getDbKey(), project2.getDbKey()), singletonList(metric.getKey()));
+    SearchWsResponse result = call(asList(project1.getKey(), project2.getKey()), singletonList(metric.getKey()));
 
-    assertThat(result.getMeasuresList()).extracting(Measure::getComponent).containsOnly(project1.getDbKey());
+    assertThat(result.getMeasuresList()).extracting(Measure::getComponent).containsOnly(project1.getKey());
   }
 
   @Test
@@ -258,7 +258,7 @@ public class SearchActionTest {
     db.measures().insertLiveMeasure(branch, coverage, m -> m.setValue(10d));
     userSession.addProjectPermission(UserRole.USER, project);
 
-    SearchWsResponse result = call(singletonList(branch.getDbKey()), singletonList(coverage.getKey()));
+    SearchWsResponse result = call(singletonList(branch.getKey()), singletonList(coverage.getKey()));
 
     assertThat(result.getMeasuresList()).isEmpty();
   }
@@ -289,7 +289,7 @@ public class SearchActionTest {
     userSession.addProjectPermission(UserRole.USER, project);
     MetricDto metric = db.measures().insertMetric();
 
-    assertThatThrownBy(() ->  call(singletonList(project.getDbKey()), newArrayList("violations", metric.getKey(), "ncloc")))
+    assertThatThrownBy(() ->  call(singletonList(project.getKey()), newArrayList("violations", metric.getKey(), "ncloc")))
       .isInstanceOf(BadRequestException.class)
       .hasMessage("The following metrics are not found: ncloc, violations");
   }
@@ -316,7 +316,7 @@ public class SearchActionTest {
   public void fail_if_more_than_100_project_keys() {
     List<String> keys = IntStream.rangeClosed(1, 101)
       .mapToObj(i -> db.components().insertPrivateProject())
-      .map(ComponentDto::getDbKey)
+      .map(ComponentDto::getKey)
       .collect(Collectors.toList());
     MetricDto metric = db.measures().insertMetric();
 
@@ -329,7 +329,7 @@ public class SearchActionTest {
   public void does_not_fail_on_100_projects() {
     List<String> keys = IntStream.rangeClosed(1, 100)
       .mapToObj(i -> db.components().insertPrivateProject())
-      .map(ComponentDto::getDbKey)
+      .map(ComponentDto::getKey)
       .collect(Collectors.toList());
     MetricDto metric = db.measures().insertMetric();
 
@@ -343,7 +343,7 @@ public class SearchActionTest {
     userSession.addProjectPermission(UserRole.USER, project);
     MetricDto metric = db.measures().insertMetric();
 
-    assertThatThrownBy(() -> call(singletonList(module.getDbKey()), singletonList(metric.getKey())))
+    assertThatThrownBy(() -> call(singletonList(module.getKey()), singletonList(metric.getKey())))
       .isInstanceOf(IllegalArgumentException.class)
       .hasMessage("Only component of qualifiers [TRK, APP, VW, SVW] are allowed");
   }
@@ -355,7 +355,7 @@ public class SearchActionTest {
     userSession.addProjectPermission(UserRole.USER, project);
     MetricDto metric = db.measures().insertMetric();
 
-    assertThatThrownBy(() -> call(singletonList(dir.getDbKey()), singletonList(metric.getKey())))
+    assertThatThrownBy(() -> call(singletonList(dir.getKey()), singletonList(metric.getKey())))
       .isInstanceOf(IllegalArgumentException.class)
       .hasMessage("Only component of qualifiers [TRK, APP, VW, SVW] are allowed");
   }
@@ -367,7 +367,7 @@ public class SearchActionTest {
     userSession.addProjectPermission(UserRole.USER, project);
     MetricDto metric = db.measures().insertMetric();
 
-    assertThatThrownBy(() -> call(singletonList(file.getDbKey()), singletonList(metric.getKey())))
+    assertThatThrownBy(() -> call(singletonList(file.getKey()), singletonList(metric.getKey())))
       .isInstanceOf(IllegalArgumentException.class)
       .hasMessage("Only component of qualifiers [TRK, APP, VW, SVW] are allowed");
   }
index 73d9054b9e8048d25652b4c729ad2832277839c0..3d17e12fe0c96af715dfdba3c56ea4a1eb5df98b 100644 (file)
@@ -110,7 +110,7 @@ public class SearchHistoryActionTest {
     project = db.components().insertPrivateProject();
     userSession.addProjectPermission(UserRole.USER, project);
     SearchHistoryRequest request = SearchHistoryRequest.builder()
-      .setComponent(project.getDbKey())
+      .setComponent(project.getKey())
       .setMetrics(singletonList(complexityMetric.getKey()))
       .build();
 
@@ -131,7 +131,7 @@ public class SearchHistoryActionTest {
     userSession.addProjectPermission(UserRole.USER, project);
 
     SearchHistoryRequest request = SearchHistoryRequest.builder()
-      .setComponent(project.getDbKey())
+      .setComponent(project.getKey())
       .setMetrics(singletonList(complexityMetric.getKey()))
       .build();
 
@@ -148,7 +148,7 @@ public class SearchHistoryActionTest {
     db.commit();
 
     SearchHistoryRequest request = SearchHistoryRequest.builder()
-      .setComponent(project.getDbKey())
+      .setComponent(project.getKey())
       .setMetrics(asList(complexityMetric.getKey(), nclocMetric.getKey(), newViolationMetric.getKey()))
       .build();
 
@@ -173,7 +173,7 @@ public class SearchHistoryActionTest {
     db.commit();
 
     SearchHistoryRequest request = SearchHistoryRequest.builder()
-      .setComponent(project.getDbKey())
+      .setComponent(project.getKey())
       .setMetrics(asList(complexityMetric.getKey(), nclocMetric.getKey(), newViolationMetric.getKey()))
       .build();
     SearchHistoryResponse result = call(request);
@@ -213,7 +213,7 @@ public class SearchHistoryActionTest {
     db.commit();
 
     SearchHistoryRequest request = SearchHistoryRequest.builder()
-      .setComponent(project.getDbKey())
+      .setComponent(project.getKey())
       .setMetrics(asList(complexityMetric.getKey(), nclocMetric.getKey(), newViolationMetric.getKey()))
       .setPage(2)
       .setPageSize(3)
@@ -237,7 +237,7 @@ public class SearchHistoryActionTest {
     db.commit();
 
     SearchHistoryRequest request = SearchHistoryRequest.builder()
-      .setComponent(project.getDbKey())
+      .setComponent(project.getKey())
       .setMetrics(asList(complexityMetric.getKey(), nclocMetric.getKey(), newViolationMetric.getKey()))
       .setFrom(analysisDates.get(1))
       .setTo(analysisDates.get(3))
@@ -257,7 +257,7 @@ public class SearchHistoryActionTest {
     ComponentDto file = db.components().insertComponent(newFileDto(project));
 
     SearchHistoryRequest request = SearchHistoryRequest.builder()
-      .setComponent(file.getDbKey())
+      .setComponent(file.getKey())
       .setMetrics(asList("optimized", "new_optimized"))
       .build();
     SearchHistoryResponse result = call(request);
@@ -268,7 +268,7 @@ public class SearchHistoryActionTest {
 
     // Best value is not applied to project
     request = SearchHistoryRequest.builder()
-      .setComponent(project.getDbKey())
+      .setComponent(project.getKey())
       .setMetrics(asList("optimized", "new_optimized"))
       .build();
     result = call(request);
@@ -283,7 +283,7 @@ public class SearchHistoryActionTest {
     db.commit();
 
     SearchHistoryRequest request = SearchHistoryRequest.builder()
-      .setComponent(project.getDbKey())
+      .setComponent(project.getKey())
       .setMetrics(asList(complexityMetric.getKey(), nclocMetric.getKey(), newViolationMetric.getKey()))
       .build();
     SearchHistoryResponse result = call(request);
@@ -345,17 +345,17 @@ public class SearchHistoryActionTest {
     ComponentDto branch = db.components().insertProjectBranch(project);
 
     assertThatThrownBy(() -> ws.newRequest()
-      .setParam(PARAM_COMPONENT, branch.getDbKey())
+      .setParam(PARAM_COMPONENT, branch.getKey())
       .setParam(PARAM_METRICS, "ncloc")
       .execute())
         .isInstanceOf(NotFoundException.class)
-        .hasMessageContaining(format("Component key '%s' not found", branch.getDbKey()));
+        .hasMessageContaining(format("Component key '%s' not found", branch.getKey()));
   }
 
   @Test
   public void fail_if_unknown_metric() {
     SearchHistoryRequest request = SearchHistoryRequest.builder()
-      .setComponent(project.getDbKey())
+      .setComponent(project.getKey())
       .setMetrics(asList(complexityMetric.getKey(), nclocMetric.getKey(), "METRIC_42", "42_METRIC"))
       .build();
 
@@ -368,7 +368,7 @@ public class SearchHistoryActionTest {
   public void fail_if_not_enough_permissions() {
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
     SearchHistoryRequest request = SearchHistoryRequest.builder()
-      .setComponent(project.getDbKey())
+      .setComponent(project.getKey())
       .setMetrics(singletonList(complexityMetric.getKey()))
       .build();
 
@@ -390,7 +390,7 @@ public class SearchHistoryActionTest {
       .addProjectPermission(UserRole.USER, application, project1);
 
     SearchHistoryRequest request = SearchHistoryRequest.builder()
-      .setComponent(application.getDbKey())
+      .setComponent(application.getKey())
       .setMetrics(singletonList(complexityMetric.getKey()))
       .build();
 
@@ -412,7 +412,7 @@ public class SearchHistoryActionTest {
   @Test
   public void fail_when_component_is_removed() {
     ComponentDto project = db.components().insertComponent(newPrivateProjectDto());
-    db.components().insertComponent(newFileDto(project).setDbKey("file-key").setEnabled(false));
+    db.components().insertComponent(newFileDto(project).setKey("file-key").setEnabled(false));
     userSession.addProjectPermission(UserRole.USER, project);
 
     assertThatThrownBy(() -> ws.newRequest()
@@ -470,7 +470,7 @@ public class SearchHistoryActionTest {
     db.commit();
 
     String result = ws.newRequest()
-      .setParam(PARAM_COMPONENT, project.getDbKey())
+      .setParam(PARAM_COMPONENT, project.getKey())
       .setParam(PARAM_METRICS, String.join(",", asList(complexityMetric.getKey(), nclocMetric.getKey(), newViolationMetric.getKey())))
       .execute().getInput();
 
@@ -483,7 +483,7 @@ public class SearchHistoryActionTest {
     db.commit();
 
     SearchHistoryRequest request = SearchHistoryRequest.builder()
-      .setComponent(project.getDbKey())
+      .setComponent(project.getKey())
       .setMetrics(singletonList(stringMetric.getKey()))
       .build();
     SearchHistoryResponse result = call(request);
index 98a5b3aed7d4f2a1d977527e96f7b81b1736d685..2ae9fdf54d114ed46f87d884f7a0641e3dea9ea5 100644 (file)
@@ -218,7 +218,7 @@ public class ShowActionTest {
     ComponentDto project = componentDb.insertPublicProject();
     logInAsProjectScan(project);
 
-    tester.insert(project.projectUuid(), NewCodePeriodType.NUMBER_OF_DAYS, "3");
+    tester.insert(project.branchUuid(), NewCodePeriodType.NUMBER_OF_DAYS, "3");
 
     ShowWSResponse response = ws.newRequest()
       .setParam("project", project.getKey())
index 6008edc1024d4a14c02cab7e4f13df7bf95f86fa..36d5097c81dc4349079a864713c3d1360548732d 100644 (file)
@@ -110,7 +110,7 @@ public class AddActionTest {
     when(dispatchers.getGlobalDispatchers()).thenReturn(singletonList(NOTIF_MY_NEW_ISSUES));
     when(dispatchers.getProjectDispatchers()).thenReturn(singletonList(NOTIF_MY_NEW_ISSUES));
 
-    call(NOTIF_MY_NEW_ISSUES, null, project.getDbKey(), null);
+    call(NOTIF_MY_NEW_ISSUES, null, project.getKey(), null);
 
     db.notifications().assertExists(defaultChannel.getKey(), NOTIF_MY_NEW_ISSUES, userSession.getUuid(), project);
   }
@@ -124,7 +124,7 @@ public class AddActionTest {
     when(dispatchers.getGlobalDispatchers()).thenReturn(singletonList(NOTIF_MY_NEW_ISSUES));
     when(dispatchers.getProjectDispatchers()).thenReturn(singletonList(NOTIF_MY_NEW_ISSUES));
 
-    call(NOTIF_MY_NEW_ISSUES, null, project.getDbKey(), null);
+    call(NOTIF_MY_NEW_ISSUES, null, project.getKey(), null);
 
     db.notifications().assertExists(defaultChannel.getKey(), NOTIF_MY_NEW_ISSUES, userSession.getUuid(), project);
   }
@@ -137,7 +137,7 @@ public class AddActionTest {
     when(dispatchers.getProjectDispatchers()).thenReturn(asList(NOTIF_MY_NEW_ISSUES));
     ComponentDto project = db.components().insertPrivateProject();
     userSession.addProjectPermission(USER, project);
-    call(NOTIF_MY_NEW_ISSUES, null, project.getDbKey(), null);
+    call(NOTIF_MY_NEW_ISSUES, null, project.getKey(), null);
 
     call(NOTIF_MY_NEW_ISSUES, null, null, null);
 
@@ -155,7 +155,7 @@ public class AddActionTest {
     call(NOTIF_MY_NEW_ISSUES, null, null, null);
 
     userSession.addProjectPermission(USER, project);
-    call(NOTIF_MY_NEW_ISSUES, null, project.getDbKey(), null);
+    call(NOTIF_MY_NEW_ISSUES, null, project.getKey(), null);
 
     db.notifications().assertExists(defaultChannel.getKey(), NOTIF_MY_NEW_ISSUES, userSession.getUuid(), project);
     db.notifications().assertExists(defaultChannel.getKey(), NOTIF_MY_NEW_ISSUES, userSession.getUuid(), null);
@@ -171,7 +171,7 @@ public class AddActionTest {
     userSession.registerComponents(project);
     call(NOTIF_MY_NEW_ISSUES, null, null, null);
 
-    call(NOTIF_MY_NEW_ISSUES, null, project.getDbKey(), null);
+    call(NOTIF_MY_NEW_ISSUES, null, project.getKey(), null);
 
     db.notifications().assertExists(defaultChannel.getKey(), NOTIF_MY_NEW_ISSUES, userSession.getUuid(), project);
     db.notifications().assertExists(defaultChannel.getKey(), NOTIF_MY_NEW_ISSUES, userSession.getUuid(), null);
@@ -295,7 +295,7 @@ public class AddActionTest {
   public void fail_when_component_is_not_a_project() {
     UserDto user = db.users().insertUser();
     userSession.logIn(user);
-    db.components().insertPortfolioAndSnapshot(newPortfolio().setDbKey("VIEW_1"));
+    db.components().insertPortfolioAndSnapshot(newPortfolio().setKey("VIEW_1"));
     when(dispatchers.getGlobalDispatchers()).thenReturn(singletonList(NOTIF_MY_NEW_ISSUES));
     when(dispatchers.getProjectDispatchers()).thenReturn(singletonList(NOTIF_MY_NEW_ISSUES));
 
@@ -321,9 +321,9 @@ public class AddActionTest {
     ComponentDto project = db.components().insertPublicProject();
     ComponentDto branch = db.components().insertProjectBranch(project);
 
-    assertThatThrownBy(() -> call(NOTIF_MY_NEW_ISSUES, null, branch.getDbKey(), null))
+    assertThatThrownBy(() -> call(NOTIF_MY_NEW_ISSUES, null, branch.getKey(), null))
       .isInstanceOf(NotFoundException.class)
-      .hasMessageContaining(format("Component key '%s' not found", branch.getDbKey()));
+      .hasMessageContaining(format("Component key '%s' not found", branch.getKey()));
   }
 
   @Test
@@ -333,7 +333,7 @@ public class AddActionTest {
     when(dispatchers.getGlobalDispatchers()).thenReturn(singletonList(NOTIF_MY_NEW_ISSUES));
     when(dispatchers.getProjectDispatchers()).thenReturn(singletonList(NOTIF_MY_NEW_ISSUES));
 
-    assertThatThrownBy(() -> call(NOTIF_MY_NEW_ISSUES, null, project.getDbKey(), userSession.getLogin()))
+    assertThatThrownBy(() -> call(NOTIF_MY_NEW_ISSUES, null, project.getKey(), userSession.getLogin()))
       .isInstanceOf(ForbiddenException.class);
   }
 
index b465137c56dc61a1aaa707412393c44b96034195..5cbf00521a27be0d1bfa3b07654225cd466de556 100644 (file)
@@ -241,7 +241,7 @@ public class ListActionTest {
     userSession.logIn(user);
     when(dispatchers.getGlobalDispatchers()).thenReturn(asList(NOTIF_MY_NEW_ISSUES, NOTIF_NEW_ISSUES, NOTIF_NEW_QUALITY_GATE_STATUS));
     when(dispatchers.getProjectDispatchers()).thenReturn(asList(NOTIF_MY_NEW_ISSUES, NOTIF_NEW_QUALITY_GATE_STATUS));
-    ComponentDto project = db.components().insertPrivateProject(p -> p.setDbKey(KEY_PROJECT_EXAMPLE_001).setName("My Project"));
+    ComponentDto project = db.components().insertPrivateProject(p -> p.setKey(KEY_PROJECT_EXAMPLE_001).setName("My Project"));
     db.users().insertProjectPermissionOnUser(user, USER, project);
     notificationUpdater.add(dbSession, twitterChannel.getKey(), NOTIF_MY_NEW_ISSUES, user, null);
     notificationUpdater.add(dbSession, emailChannel.getKey(), NOTIF_MY_NEW_ISSUES, user, null);
index 97e4aa3d88466c20cc11dcc572b437f17a5a155d..a72bfe25c133ca04f5afae7807e3a7dbb2075821 100644 (file)
@@ -116,7 +116,7 @@ public class RemoveActionTest {
     notificationUpdater.add(dbSession, defaultChannel.getKey(), NOTIF_MY_NEW_ISSUES, user, project);
     dbSession.commit();
 
-    call(request.setProject(project.getDbKey()));
+    call(request.setProject(project.getKey()));
 
     db.notifications().assertDoesNotExist(defaultChannel.getKey(), NOTIF_MY_NEW_ISSUES, user.getUuid(), project);
   }
@@ -146,7 +146,7 @@ public class RemoveActionTest {
     notificationUpdater.add(dbSession, defaultChannel.getKey(), NOTIF_MY_NEW_ISSUES, user, null);
     dbSession.commit();
 
-    RemoveRequest request = this.request.setProject(project.getDbKey());
+    RemoveRequest request = this.request.setProject(project.getKey());
     assertThatThrownBy(() -> call(request))
       .isInstanceOf(IllegalArgumentException.class)
       .hasMessage("Notification doesn't exist");
@@ -248,7 +248,7 @@ public class RemoveActionTest {
     when(dispatchers.getProjectDispatchers()).thenReturn(asList(NOTIF_MY_NEW_ISSUES, NOTIF_NEW_QUALITY_GATE_STATUS));
     ComponentDto project = db.components().insertPrivateProject();
 
-    RemoveRequest request = this.request.setType("Dispatcher42").setProject(project.getDbKey());
+    RemoveRequest request = this.request.setType("Dispatcher42").setProject(project.getKey());
     assertThatThrownBy(() -> call(request))
       .isInstanceOf(BadRequestException.class)
       .hasMessage("Value of parameter 'type' (Dispatcher42) must be one of: [Dispatcher1, Dispatcher3]");
@@ -284,7 +284,7 @@ public class RemoveActionTest {
     userSession.logIn(user);
     when(dispatchers.getGlobalDispatchers()).thenReturn(singletonList(NOTIF_MY_NEW_ISSUES));
     when(dispatchers.getProjectDispatchers()).thenReturn(singletonList(NOTIF_MY_NEW_ISSUES));
-    db.components().insertPortfolioAndSnapshot(newPortfolio().setDbKey("VIEW_1"));
+    db.components().insertPortfolioAndSnapshot(newPortfolio().setKey("VIEW_1"));
 
     RemoveRequest request = this.request.setProject("VIEW_1");
     assertThatThrownBy(() -> call(request))
@@ -310,10 +310,10 @@ public class RemoveActionTest {
     ComponentDto project = db.components().insertPublicProject();
     ComponentDto branch = db.components().insertProjectBranch(project);
 
-    RemoveRequest request = this.request.setProject(branch.getDbKey());
+    RemoveRequest request = this.request.setProject(branch.getKey());
     assertThatThrownBy(() -> call(request))
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Component key '%s' not found", branch.getDbKey()));
+      .hasMessage(format("Component key '%s' not found", branch.getKey()));
   }
 
   private TestResponse call(RemoveRequest remove) {
index 5d687921ea30be511337513e48221b0b41e5c081..4119edf475a665bdd620ede29049dd580c887cb9 100644 (file)
@@ -470,7 +470,7 @@ public class PermissionTemplateServiceTest {
       .map(x -> String.format("\"%s\"", x))
       .collect(Collectors.joining(", "));
 
-    ComponentDto project = dbTester.components().insertPrivateProject(p -> p.setDbKey(key));
+    ComponentDto project = dbTester.components().insertPrivateProject(p -> p.setKey(key));
 
     assertThatThrownBy(() -> underTest.applyDefaultToNewComponent(session, project, null))
       .isInstanceOf(TemplateMatchingKeyException.class)
index 69ca9cf2729c8020a4e939a886826d8a6b0d9030..90f0663cd23948cd3516ba7342ce6ab387aaaa15 100644 (file)
@@ -126,7 +126,7 @@ public class AddGroupActionTest extends BasePermissionWsTest<AddGroupAction> {
   @Test
   public void add_permission_to_project_referenced_by_its_id() {
     GroupDto group = db.users().insertGroup("sonar-administrators");
-    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(A_PROJECT_UUID).setDbKey(A_PROJECT_KEY));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(A_PROJECT_UUID).setKey(A_PROJECT_KEY));
     loginAsAdmin();
 
     newRequest()
@@ -142,7 +142,7 @@ public class AddGroupActionTest extends BasePermissionWsTest<AddGroupAction> {
   @Test
   public void add_permission_to_project_referenced_by_its_key() {
     GroupDto group = db.users().insertGroup("sonar-administrators");
-    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(A_PROJECT_UUID).setDbKey(A_PROJECT_KEY));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(A_PROJECT_UUID).setKey(A_PROJECT_KEY));
     loginAsAdmin();
 
     newRequest()
@@ -230,7 +230,7 @@ public class AddGroupActionTest extends BasePermissionWsTest<AddGroupAction> {
         .execute();
     })
       .isInstanceOf(BadRequestException.class)
-      .hasMessage("Component '" + file.getDbKey() + "' (id: " + file.uuid() + ") must be a project or a view.");
+      .hasMessage("Component '" + file.getKey() + "' (id: " + file.uuid() + ") must be a project or a view.");
   }
 
   @Test
@@ -325,7 +325,7 @@ public class AddGroupActionTest extends BasePermissionWsTest<AddGroupAction> {
         .setParam(PARAM_GROUP_NAME, group.getName())
         .setParam(PARAM_PERMISSION, SYSTEM_ADMIN)
         .setParam(PARAM_PROJECT_ID, project.uuid())
-        .setParam(PARAM_PROJECT_KEY, project.getDbKey())
+        .setParam(PARAM_PROJECT_KEY, project.getKey())
         .execute();
     })
       .isInstanceOf(BadRequestException.class)
@@ -356,7 +356,7 @@ public class AddGroupActionTest extends BasePermissionWsTest<AddGroupAction> {
       newRequest()
         .setParam(PARAM_GROUP_NAME, group.getName())
         .setParam(PARAM_PERMISSION, PROVISION_PROJECTS.getKey())
-        .setParam(PARAM_PROJECT_KEY, project.getDbKey())
+        .setParam(PARAM_PROJECT_KEY, project.getKey())
         .execute();
     })
       .isInstanceOf(ForbiddenException.class);
@@ -467,13 +467,13 @@ public class AddGroupActionTest extends BasePermissionWsTest<AddGroupAction> {
 
     assertThatThrownBy(() ->  {
       newRequest()
-        .setParam(PARAM_PROJECT_KEY, branch.getDbKey())
+        .setParam(PARAM_PROJECT_KEY, branch.getKey())
         .setParam(PARAM_GROUP_NAME, group.getName())
         .setParam(PARAM_PERMISSION, ISSUE_ADMIN)
         .execute();
     })
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Project key '%s' not found", branch.getDbKey()));
+      .hasMessage(format("Project key '%s' not found", branch.getKey()));
   }
 
   @Test
index 237a70d74fe1c2bf0f2c0a95e5ee0555935ceeb7..e0d541afbe405e71c6cbfcdc113a89961b654a99 100644 (file)
@@ -106,7 +106,7 @@ public class AddUserActionTest extends BasePermissionWsTest<AddUserAction> {
 
     newRequest()
       .setParam(PARAM_USER_LOGIN, user.getLogin())
-      .setParam(PARAM_PROJECT_KEY, project.getDbKey())
+      .setParam(PARAM_PROJECT_KEY, project.getKey())
       .setParam(PARAM_PERMISSION, SYSTEM_ADMIN)
       .execute();
 
@@ -116,7 +116,7 @@ public class AddUserActionTest extends BasePermissionWsTest<AddUserAction> {
 
   @Test
   public void add_permission_to_view() {
-    ComponentDto view = db.components().insertComponent(ComponentTesting.newPortfolio("view-uuid").setDbKey("view-key"));
+    ComponentDto view = db.components().insertComponent(ComponentTesting.newPortfolio("view-uuid").setKey("view-key"));
     loginAsAdmin();
 
     newRequest()
@@ -186,7 +186,7 @@ public class AddUserActionTest extends BasePermissionWsTest<AddUserAction> {
         .execute();
     })
       .isInstanceOf(BadRequestException.class)
-      .hasMessage("Component '" + file.getDbKey() + "' (id: " + file.uuid() + ") must be a project or a view.");
+      .hasMessage("Component '" + file.getKey() + "' (id: " + file.uuid() + ") must be a project or a view.");
   }
 
   @Test
@@ -295,7 +295,7 @@ public class AddUserActionTest extends BasePermissionWsTest<AddUserAction> {
       newRequest()
         .setParam(PARAM_USER_LOGIN, user.getLogin())
         .setParam(PARAM_PERMISSION, SYSTEM_ADMIN)
-        .setParam(PARAM_PROJECT_KEY, project.getDbKey())
+        .setParam(PARAM_PROJECT_KEY, project.getKey())
         .execute();
     })
       .isInstanceOf(ForbiddenException.class);
@@ -312,7 +312,7 @@ public class AddUserActionTest extends BasePermissionWsTest<AddUserAction> {
 
     newRequest()
       .setParam(PARAM_USER_LOGIN, user.getLogin())
-      .setParam(PARAM_PROJECT_KEY, project.getDbKey())
+      .setParam(PARAM_PROJECT_KEY, project.getKey())
       .setParam(PARAM_PERMISSION, UserRole.ISSUE_ADMIN)
       .execute();
 
@@ -355,13 +355,13 @@ public class AddUserActionTest extends BasePermissionWsTest<AddUserAction> {
 
     assertThatThrownBy(() ->  {
       newRequest()
-        .setParam(PARAM_PROJECT_KEY, branch.getDbKey())
+        .setParam(PARAM_PROJECT_KEY, branch.getKey())
         .setParam(PARAM_USER_LOGIN, user.getLogin())
         .setParam(PARAM_PERMISSION, SYSTEM_ADMIN)
         .execute();
     })
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Project key '%s' not found", branch.getDbKey()));
+      .hasMessage(format("Project key '%s' not found", branch.getKey()));
   }
 
   @Test
index c1d54a5e01b21083112db403ea4293f5661cd64b..d3dc23d714b8ba649ace1d06b49d6cdd7b8e9cef 100644 (file)
@@ -257,7 +257,7 @@ public class GroupsActionTest extends BasePermissionWsTest<GroupsAction> {
 
   @Test
   public void search_groups_on_views() {
-    ComponentDto view = db.components().insertComponent(ComponentTesting.newPortfolio("view-uuid").setDbKey("view-key"));
+    ComponentDto view = db.components().insertComponent(ComponentTesting.newPortfolio("view-uuid").setKey("view-key"));
     GroupDto group = db.users().insertGroup("project-group-name");
     db.users().insertProjectPermissionOnGroup(group, ISSUE_ADMIN, view);
 
@@ -341,11 +341,11 @@ public class GroupsActionTest extends BasePermissionWsTest<GroupsAction> {
     assertThatThrownBy(() ->  {
       newRequest()
         .setParam(PARAM_PERMISSION, ISSUE_ADMIN)
-        .setParam(PARAM_PROJECT_KEY, branch.getDbKey())
+        .setParam(PARAM_PROJECT_KEY, branch.getKey())
         .execute();
     })
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Project key '%s' not found", branch.getDbKey()));
+      .hasMessage(format("Project key '%s' not found", branch.getKey()));
   }
 
 }
index 48d8170b9efddeebdb011d3499e2b6b1f18de3d5..8ffaf36bcfd66dd47e7b9130d1e04ec4ba24b666 100644 (file)
@@ -161,7 +161,7 @@ public class RemoveGroupActionTest extends BasePermissionWsTest<RemoveGroupActio
 
     newRequest()
       .setParam(PARAM_GROUP_NAME, aGroup.getName())
-      .setParam(PARAM_PROJECT_KEY, project.getDbKey())
+      .setParam(PARAM_PROJECT_KEY, project.getKey())
       .setParam(PARAM_PERMISSION, ADMIN)
       .execute();
 
@@ -249,7 +249,7 @@ public class RemoveGroupActionTest extends BasePermissionWsTest<RemoveGroupActio
         .execute();
     })
       .isInstanceOf(BadRequestException.class)
-      .hasMessage("Component '" + file.getDbKey() + "' (id: " + file.uuid() + ") must be a project or a view.");
+      .hasMessage("Component '" + file.getKey() + "' (id: " + file.uuid() + ") must be a project or a view.");
   }
 
   @Test
@@ -302,7 +302,7 @@ public class RemoveGroupActionTest extends BasePermissionWsTest<RemoveGroupActio
         .setParam(PARAM_GROUP_NAME, aGroup.getName())
         .setParam(PARAM_PERMISSION, SYSTEM_ADMIN)
         .setParam(PARAM_PROJECT_ID, project.uuid())
-        .setParam(PARAM_PROJECT_KEY, project.getDbKey())
+        .setParam(PARAM_PROJECT_KEY, project.getKey())
         .execute();
     })
       .isInstanceOf(BadRequestException.class)
@@ -338,7 +338,7 @@ public class RemoveGroupActionTest extends BasePermissionWsTest<RemoveGroupActio
       newRequest()
         .setParam(PARAM_GROUP_NAME, aGroup.getName())
         .setParam(PARAM_PERMISSION, PROVISIONING)
-        .setParam(PARAM_PROJECT_KEY, project.getDbKey())
+        .setParam(PARAM_PROJECT_KEY, project.getKey())
         .execute();
     })
       .isInstanceOf(ForbiddenException.class);
@@ -457,13 +457,13 @@ public class RemoveGroupActionTest extends BasePermissionWsTest<RemoveGroupActio
 
     assertThatThrownBy(() -> {
       newRequest()
-        .setParam(PARAM_PROJECT_KEY, branch.getDbKey())
+        .setParam(PARAM_PROJECT_KEY, branch.getKey())
         .setParam(PARAM_GROUP_NAME, group.getName())
         .setParam(PARAM_PERMISSION, SYSTEM_ADMIN)
         .execute();
     })
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Project key '%s' not found", branch.getDbKey()));
+      .hasMessage(format("Project key '%s' not found", branch.getKey()));
   }
 
   @Test
index 3b808431776aa96cd907bb393e64106fc4f42dff..edefb4dd7566c0a7ba54ff9b031f859b7619c844 100644 (file)
@@ -165,7 +165,7 @@ public class RemoveUserActionTest extends BasePermissionWsTest<RemoveUserAction>
 
     newRequest()
       .setParam(PARAM_USER_LOGIN, user.getLogin())
-      .setParam(PARAM_PROJECT_KEY, project.getDbKey())
+      .setParam(PARAM_PROJECT_KEY, project.getKey())
       .setParam(PARAM_PERMISSION, ISSUE_ADMIN)
       .execute();
 
@@ -181,7 +181,7 @@ public class RemoveUserActionTest extends BasePermissionWsTest<RemoveUserAction>
 
     newRequest()
       .setParam(PARAM_USER_LOGIN, user.getLogin())
-      .setParam(PARAM_PROJECT_KEY, view.getDbKey())
+      .setParam(PARAM_PROJECT_KEY, view.getKey())
       .setParam(PARAM_PERMISSION, ISSUE_ADMIN)
       .execute();
 
@@ -258,7 +258,7 @@ public class RemoveUserActionTest extends BasePermissionWsTest<RemoveUserAction>
         .execute();
     })
       .isInstanceOf(BadRequestException.class)
-      .hasMessage("Component '" + file.getDbKey() + "' (id: " + file.uuid() + ") must be a project or a view.");
+      .hasMessage("Component '" + file.getKey() + "' (id: " + file.uuid() + ") must be a project or a view.");
   }
 
   @Test
@@ -309,7 +309,7 @@ public class RemoveUserActionTest extends BasePermissionWsTest<RemoveUserAction>
         .setParam(PARAM_PERMISSION, SYSTEM_ADMIN)
         .setParam(PARAM_USER_LOGIN, user.getLogin())
         .setParam(PARAM_PROJECT_ID, project.uuid())
-        .setParam(PARAM_PROJECT_KEY, project.getDbKey())
+        .setParam(PARAM_PROJECT_KEY, project.getKey())
         .execute();
     })
       .isInstanceOf(BadRequestException.class)
@@ -338,7 +338,7 @@ public class RemoveUserActionTest extends BasePermissionWsTest<RemoveUserAction>
       newRequest()
         .setParam(PARAM_USER_LOGIN, user.getLogin())
         .setParam(PARAM_PERMISSION, ISSUE_ADMIN)
-        .setParam(PARAM_PROJECT_KEY, project.getDbKey())
+        .setParam(PARAM_PROJECT_KEY, project.getKey())
         .execute();
     })
       .isInstanceOf(ForbiddenException.class);
@@ -404,13 +404,13 @@ public class RemoveUserActionTest extends BasePermissionWsTest<RemoveUserAction>
 
     assertThatThrownBy(() -> {
       newRequest()
-        .setParam(PARAM_PROJECT_KEY, branch.getDbKey())
+        .setParam(PARAM_PROJECT_KEY, branch.getKey())
         .setParam(PARAM_USER_LOGIN, user.getLogin())
         .setParam(PARAM_PERMISSION, SYSTEM_ADMIN)
         .execute();
     })
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Project key '%s' not found", branch.getDbKey()));
+      .hasMessage(format("Project key '%s' not found", branch.getKey()));
   }
 
   @Test
index d266cc43f53b3a7bb126507ed5a600327a422517..c562e222e7d446b393ca2a85c39a060196d2e9fb 100644 (file)
@@ -336,13 +336,13 @@ public class UsersActionTest extends BasePermissionWsTest<UsersAction> {
 
     assertThatThrownBy(() -> {
       newRequest()
-        .setParam(PARAM_PROJECT_KEY, branch.getDbKey())
+        .setParam(PARAM_PROJECT_KEY, branch.getKey())
         .setParam(PARAM_USER_LOGIN, user.getLogin())
         .setParam(PARAM_PERMISSION, SYSTEM_ADMIN)
         .execute();
     })
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Project key '%s' not found", branch.getDbKey()));
+      .hasMessage(format("Project key '%s' not found", branch.getKey()));
   }
 
   @Test
index 8aa93341310011b6430b8da3c8bf62d8bd04ddf5..6479200d64e3320cbbd608d4e0f5c6fb75e814a3 100644 (file)
@@ -48,7 +48,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.sonar.api.resources.Qualifiers.APP;
 import static org.sonar.api.resources.Qualifiers.PROJECT;
 import static org.sonar.api.resources.Qualifiers.VIEW;
-import static org.sonar.api.web.UserRole.CODEVIEWER;
 import static org.sonar.db.permission.GlobalPermission.SCAN;
 import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_ID;
 import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_KEY;
@@ -130,7 +129,7 @@ public class ApplyTemplateActionTest extends BasePermissionWsTest<ApplyTemplateA
   public void apply_template_with_project_key() {
     loginAsAdmin();
 
-    newRequest(template1.getUuid(), null, project.getDbKey());
+    newRequest(template1.getUuid(), null, project.getKey());
 
     assertTemplate1AppliedToProject();
   }
index f1807957cfac27a93badc0b593aa7a2e2fea7f96..c8d74ba43239139812433414c335fb0637c4065d 100644 (file)
@@ -178,11 +178,11 @@ public class BulkApplyTemplateActionTest extends BasePermissionWsTest<BulkApplyT
 
   @Test
   public void apply_template_by_query_on_name_and_key_public_project() {
-    ComponentDto publicProjectFoundByKey = ComponentTesting.newPublicProjectDto().setDbKey("sonar");
+    ComponentDto publicProjectFoundByKey = ComponentTesting.newPublicProjectDto().setKey("sonar");
     db.components().insertProjectAndSnapshot(publicProjectFoundByKey);
     ComponentDto publicProjectFoundByName = ComponentTesting.newPublicProjectDto().setName("name-sonar-name");
     db.components().insertProjectAndSnapshot(publicProjectFoundByName);
-    ComponentDto projectUntouched = ComponentTesting.newPublicProjectDto().setDbKey("new-sona").setName("project-name");
+    ComponentDto projectUntouched = ComponentTesting.newPublicProjectDto().setKey("new-sona").setName("project-name");
     db.components().insertProjectAndSnapshot(projectUntouched);
     loginAsAdmin();
 
@@ -199,11 +199,11 @@ public class BulkApplyTemplateActionTest extends BasePermissionWsTest<BulkApplyT
   @Test
   public void apply_template_by_query_on_name_and_key() {
     // partial match on key
-    ComponentDto privateProjectFoundByKey = ComponentTesting.newPrivateProjectDto().setDbKey("sonarqube");
+    ComponentDto privateProjectFoundByKey = ComponentTesting.newPrivateProjectDto().setKey("sonarqube");
     db.components().insertProjectAndSnapshot(privateProjectFoundByKey);
     ComponentDto privateProjectFoundByName = ComponentTesting.newPrivateProjectDto().setName("name-sonar-name");
     db.components().insertProjectAndSnapshot(privateProjectFoundByName);
-    ComponentDto projectUntouched = ComponentTesting.newPublicProjectDto().setDbKey("new-sona").setName("project-name");
+    ComponentDto projectUntouched = ComponentTesting.newPublicProjectDto().setKey("new-sona").setName("project-name");
     db.components().insertProjectAndSnapshot(projectUntouched);
     loginAsAdmin();
 
index a831c48045329bb42a6472a62e898fd63291aed1..aeece4adf7d87836ffc34f7f3f641288448ba5b1 100644 (file)
@@ -89,7 +89,7 @@ public class BulkDeleteActionTest {
     ComponentDto toKeep = db.components().insertPrivateProject();
 
     TestResponse result = ws.newRequest()
-      .setParam(PARAM_PROJECTS, project1ToDelete.getDbKey() + "," + project2ToDelete.getDbKey())
+      .setParam(PARAM_PROJECTS, project1ToDelete.getKey() + "," + project2ToDelete.getKey())
       .execute();
 
     assertThat(result.getStatus()).isEqualTo(HttpURLConnection.HTTP_NO_CONTENT);
@@ -106,7 +106,7 @@ public class BulkDeleteActionTest {
     ComponentDto toKeep = db.components().insertPrivateProject();
 
     ws.newRequest()
-      .setParam(PARAM_PROJECTS, toDeleteInOrg1.getDbKey() + "," + toDeleteInOrg2.getDbKey())
+      .setParam(PARAM_PROJECTS, toDeleteInOrg1.getKey() + "," + toDeleteInOrg2.getKey())
       .execute();
 
     verifyComponentDeleted(toDeleteInOrg1, toDeleteInOrg2);
@@ -136,7 +136,7 @@ public class BulkDeleteActionTest {
     ComponentDto toDelete2 = db.components().insertPrivateProject();
 
     ws.newRequest()
-      .setParam("projects", toDelete1.getDbKey() + ",missing," + toDelete2.getDbKey() + ",doesNotExist")
+      .setParam("projects", toDelete1.getKey() + ",missing," + toDelete2.getKey() + ",doesNotExist")
       .execute();
 
     verifyComponentDeleted(toDelete1, toDelete2);
@@ -207,9 +207,9 @@ public class BulkDeleteActionTest {
   @Test
   public void delete_by_key_query_with_partial_match_case_insensitive() {
     userSession.logIn().addPermission(ADMINISTER);
-    ComponentDto matchKeyProject = db.components().insertPrivateProject(p -> p.setDbKey("project-_%-key"));
-    ComponentDto matchUppercaseKeyProject = db.components().insertPrivateProject(p -> p.setDbKey("PROJECT-_%-KEY"));
-    ComponentDto noMatchProject = db.components().insertPrivateProject(p -> p.setDbKey("project-key-without-escaped-characters"));
+    ComponentDto matchKeyProject = db.components().insertPrivateProject(p -> p.setKey("project-_%-key"));
+    ComponentDto matchUppercaseKeyProject = db.components().insertPrivateProject(p -> p.setKey("PROJECT-_%-KEY"));
+    ComponentDto noMatchProject = db.components().insertPrivateProject(p -> p.setKey("project-key-without-escaped-characters"));
 
     ws.newRequest().setParam(Param.TEXT_QUERY, "JeCt-_%-k").execute();
 
@@ -224,7 +224,7 @@ public class BulkDeleteActionTest {
   public void delete_only_the_1000_first_projects() {
     userSession.logIn().addPermission(ADMINISTER);
     List<String> keys = IntStream.range(0, 1_010).mapToObj(i -> "key" + i).collect(MoreCollectors.toArrayList());
-    keys.forEach(key -> db.components().insertPrivateProject(p -> p.setDbKey(key)));
+    keys.forEach(key -> db.components().insertPrivateProject(p -> p.setKey(key)));
 
     ws.newRequest()
       .setParam("projects", StringUtils.join(keys, ","))
@@ -251,7 +251,7 @@ public class BulkDeleteActionTest {
 
     try {
       ws.newRequest()
-        .setParam("projects", project1.getDbKey() + "," + project2.getDbKey() + "," + project3.getDbKey())
+        .setParam("projects", project1.getKey() + "," + project2.getKey() + "," + project3.getKey())
         .execute();
     } catch (RuntimeException e) {
       assertThat(e).isSameAs(expectedException);
@@ -266,7 +266,7 @@ public class BulkDeleteActionTest {
     ComponentDto toDelete2 = db.components().insertPrivateProject();
 
     ws.newRequest()
-      .setParam("projects", toDelete1.getDbKey() + "," + toDelete2.getDbKey())
+      .setParam("projects", toDelete1.getKey() + "," + toDelete2.getKey())
       .execute();
 
     verifyComponentDeleted(toDelete1, toDelete2);
index 881b3c6990728e259724b3c7c0e1ded180be25c5..d1ce1d3938e150ed4f1ef0ea52bc40caeba219b1 100644 (file)
@@ -91,29 +91,6 @@ public class CreateActionTest {
     when(projectDefaultVisibility.get(any())).thenReturn(Visibility.PUBLIC);
   }
 
-  @Test
-  public void fail_if_invalid_project_name() {
-    userSession.addPermission(PROVISION_PROJECTS);
-
-    var createRequestBRANCHinKey = CreateRequest.builder()
-      .setProjectKey("test:BRANCH:test")
-      .setName(DEFAULT_PROJECT_NAME)
-      .build();
-    assertThatThrownBy(() -> call(createRequestBRANCHinKey))
-      .isInstanceOf(IllegalArgumentException.class)
-      .hasMessageContainingAll("Invalid project key. Project key must not contain following phrases",
-        ":PULLREQUEST:", ":BRANCH:");
-
-    var createRequestPRinKey = CreateRequest.builder()
-      .setProjectKey("test:PULLREQUEST:test")
-      .setName(DEFAULT_PROJECT_NAME)
-      .build();
-    assertThatThrownBy(() -> call(createRequestPRinKey))
-      .isInstanceOf(IllegalArgumentException.class)
-      .hasMessageContainingAll("Invalid project key. Project key must not contain following phrases",
-        ":PULLREQUEST:", ":BRANCH:");
-  }
-
   @Test
   public void create_project() {
     userSession.addPermission(PROVISION_PROJECTS);
@@ -127,7 +104,7 @@ public class CreateActionTest {
       .extracting(Project::getKey, Project::getName, Project::getQualifier, Project::getVisibility)
       .containsOnly(DEFAULT_PROJECT_KEY, DEFAULT_PROJECT_NAME, "TRK", "public");
     assertThat(db.getDbClient().componentDao().selectByKey(db.getSession(), DEFAULT_PROJECT_KEY).get())
-      .extracting(ComponentDto::getDbKey, ComponentDto::name, ComponentDto::qualifier, ComponentDto::scope, ComponentDto::isPrivate, ComponentDto::getMainBranchProjectUuid)
+      .extracting(ComponentDto::getKey, ComponentDto::name, ComponentDto::qualifier, ComponentDto::scope, ComponentDto::isPrivate, ComponentDto::getMainBranchProjectUuid)
       .containsOnly(DEFAULT_PROJECT_KEY, DEFAULT_PROJECT_NAME, "TRK", "PRJ", false, null);
   }
 
@@ -230,7 +207,7 @@ public class CreateActionTest {
 
   @Test
   public void fail_when_project_already_exists() {
-    db.components().insertPublicProject(project -> project.setDbKey(DEFAULT_PROJECT_KEY));
+    db.components().insertPublicProject(project -> project.setKey(DEFAULT_PROJECT_KEY));
     userSession.addPermission(PROVISION_PROJECTS);
 
     CreateRequest request = CreateRequest.builder()
index 7beba7fd6a3e12d72062e39c8128ead170c9e378..0d4e3e61136c3fb4159255f02ee04bddb3641d70 100644 (file)
@@ -87,9 +87,9 @@ public class DeleteActionTest {
     ComponentDto project = componentDbTester.insertPrivateProject();
     userSessionRule.logIn().addPermission(ADMINISTER);
 
-    call(tester.newRequest().setParam(PARAM_PROJECT, project.getDbKey()));
+    call(tester.newRequest().setParam(PARAM_PROJECT, project.getKey()));
 
-    assertThat(verifyDeletedKey()).isEqualTo(project.getDbKey());
+    assertThat(verifyDeletedKey()).isEqualTo(project.getKey());
     verify(projectLifeCycleListeners).onProjectsDeleted(singleton(Project.from(project)));
   }
 
@@ -98,9 +98,9 @@ public class DeleteActionTest {
     ComponentDto project = componentDbTester.insertPrivateProject();
     userSessionRule.logIn().addProjectPermission(ADMIN, project);
 
-    call(tester.newRequest().setParam(PARAM_PROJECT, project.getDbKey()));
+    call(tester.newRequest().setParam(PARAM_PROJECT, project.getKey()));
 
-    assertThat(verifyDeletedKey()).isEqualTo(project.getDbKey());
+    assertThat(verifyDeletedKey()).isEqualTo(project.getKey());
     verify(projectLifeCycleListeners).onProjectsDeleted(singleton(Project.from(project)));
   }
 
@@ -117,7 +117,7 @@ public class DeleteActionTest {
 
     new WsActionTester(underTest)
       .newRequest()
-      .setParam(PARAM_PROJECT, project.getDbKey())
+      .setParam(PARAM_PROJECT, project.getKey())
       .execute();
 
     UserDto userReloaded = dbClient.userDao().selectByUuid(dbSession, insert.getUuid());
@@ -156,7 +156,7 @@ public class DeleteActionTest {
       .addProjectPermission(UserRole.ISSUE_ADMIN, project)
       .addProjectPermission(UserRole.USER, project);
 
-    TestRequest request = tester.newRequest().setParam(PARAM_PROJECT, project.getDbKey());
+    TestRequest request = tester.newRequest().setParam(PARAM_PROJECT, project.getKey());
     assertThatThrownBy(() -> call(request))
       .isInstanceOf(ForbiddenException.class);
   }
@@ -167,7 +167,7 @@ public class DeleteActionTest {
 
     userSessionRule.anonymous();
 
-    TestRequest request = tester.newRequest().setParam(PARAM_PROJECT, project.getDbKey());
+    TestRequest request = tester.newRequest().setParam(PARAM_PROJECT, project.getKey());
     assertThatThrownBy(() -> call(request))
       .isInstanceOf(UnauthorizedException.class);
   }
@@ -178,10 +178,10 @@ public class DeleteActionTest {
     userSessionRule.logIn().addProjectPermission(UserRole.USER, project);
     ComponentDto branch = db.components().insertProjectBranch(project);
 
-    TestRequest request = tester.newRequest().setParam(PARAM_PROJECT, branch.getDbKey());
+    TestRequest request = tester.newRequest().setParam(PARAM_PROJECT, branch.getKey());
     assertThatThrownBy(() -> call(request))
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(String.format("Project '%s' not found", branch.getDbKey()));
+      .hasMessage(String.format("Project '%s' not found", branch.getKey()));
   }
 
   private String verifyDeletedKey() {
index 7fa184112452429b0af90e9d2bf127c52d276a01..cea96bce6b89f5ff632256cc3cc727a054d6a44b 100644 (file)
@@ -58,10 +58,10 @@ public class ProjectFinderTest {
 
   @Test
   public void sort_project_by_name() {
-    ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:one").setName("Projet Un"));
-    ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:two").setName("Projet Deux"));
-    ProjectDto project3 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:three").setName("Projet Trois"));
-    ProjectDto project4 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:four").setName("Projet Quatre"));
+    ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setKey("project:one").setName("Projet Un"));
+    ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setKey("project:two").setName("Projet Deux"));
+    ProjectDto project3 = db.components().insertPrivateProjectDto(p -> p.setKey("project:three").setName("Projet Trois"));
+    ProjectDto project4 = db.components().insertPrivateProjectDto(p -> p.setKey("project:four").setName("Projet Quatre"));
     userSession.addProjectPermission(SCAN, project1, project2, project3, project4);
 
     assertThat(underTest.search(db.getSession(), "projet")
@@ -72,11 +72,11 @@ public class ProjectFinderTest {
 
   @Test
   public void projects_are_filtered_by_permissions() {
-    ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:one").setName("Projet Un"));
-    ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:two").setName("Projet Deux"));
-    ProjectDto project3 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:three").setName("Projet Trois"));
-    ProjectDto project4 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:four").setName("Projet Quatre"));
-    db.components().insertPrivateProjectDto(p -> p.setDbKey("project:five").setName("Projet Cinq"));
+    ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setKey("project:one").setName("Projet Un"));
+    ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setKey("project:two").setName("Projet Deux"));
+    ProjectDto project3 = db.components().insertPrivateProjectDto(p -> p.setKey("project:three").setName("Projet Trois"));
+    ProjectDto project4 = db.components().insertPrivateProjectDto(p -> p.setKey("project:four").setName("Projet Quatre"));
+    db.components().insertPrivateProjectDto(p -> p.setKey("project:five").setName("Projet Cinq"));
 
     userSession.addProjectPermission(SCAN, project1, project2, project3, project4);
 
@@ -93,11 +93,11 @@ public class ProjectFinderTest {
 
   @Test
   public void projects_are_not_filtered_due_to_global_scan_permission() {
-    db.components().insertPrivateProjectDto(p -> p.setDbKey("project:one").setName("Projet Un"));
-    db.components().insertPrivateProjectDto(p -> p.setDbKey("project:two").setName("Projet Deux"));
-    db.components().insertPrivateProjectDto(p -> p.setDbKey("project:three").setName("Projet Trois"));
-    db.components().insertPrivateProjectDto(p -> p.setDbKey("project:four").setName("Projet Quatre"));
-    db.components().insertPrivateProjectDto(p -> p.setDbKey("project:five").setName("Projet Cinq"));
+    db.components().insertPrivateProjectDto(p -> p.setKey("project:one").setName("Projet Un"));
+    db.components().insertPrivateProjectDto(p -> p.setKey("project:two").setName("Projet Deux"));
+    db.components().insertPrivateProjectDto(p -> p.setKey("project:three").setName("Projet Trois"));
+    db.components().insertPrivateProjectDto(p -> p.setKey("project:four").setName("Projet Quatre"));
+    db.components().insertPrivateProjectDto(p -> p.setKey("project:five").setName("Projet Cinq"));
 
     userSession.addPermission(GlobalPermission.SCAN);
 
@@ -115,10 +115,10 @@ public class ProjectFinderTest {
 
   @Test
   public void search_by_query_on_name_case_insensitive() {
-    ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:one").setName("Projet Un"));
-    ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:two").setName("Projet Deux"));
-    ProjectDto project3 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:three").setName("Projet Trois"));
-    ProjectDto project4 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:four").setName("Projet Quatre"));
+    ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setKey("project:one").setName("Projet Un"));
+    ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setKey("project:two").setName("Projet Deux"));
+    ProjectDto project3 = db.components().insertPrivateProjectDto(p -> p.setKey("project:three").setName("Projet Trois"));
+    ProjectDto project4 = db.components().insertPrivateProjectDto(p -> p.setKey("project:four").setName("Projet Quatre"));
 
     userSession.addProjectPermission(SCAN, project1, project2, project3, project4);
 
index d220ecd2bcf5ca91f18899176cc719e152675301..509db5f4ee9e505ac66285f06d856649c9641bc2 100644 (file)
@@ -87,9 +87,9 @@ public class SearchActionTest {
   public void search_by_key_query_with_partial_match_case_insensitive() {
     userSession.addPermission(ADMINISTER);
     db.components().insertComponents(
-      ComponentTesting.newPrivateProjectDto().setDbKey("project-_%-key"),
-      ComponentTesting.newPrivateProjectDto().setDbKey("PROJECT-_%-KEY"),
-      ComponentTesting.newPrivateProjectDto().setDbKey("project-key-without-escaped-characters"));
+      ComponentTesting.newPrivateProjectDto().setKey("project-_%-key"),
+      ComponentTesting.newPrivateProjectDto().setKey("PROJECT-_%-KEY"),
+      ComponentTesting.newPrivateProjectDto().setKey("project-key-without-escaped-characters"));
 
     SearchWsResponse response = call(SearchRequest.builder().setQuery("JeCt-_%-k").build());
 
@@ -100,8 +100,8 @@ public class SearchActionTest {
   public void search_private_projects() {
     userSession.addPermission(ADMINISTER);
     db.components().insertComponents(
-      ComponentTesting.newPrivateProjectDto().setDbKey("private-key"),
-      ComponentTesting.newPublicProjectDto().setDbKey("public-key"));
+      ComponentTesting.newPrivateProjectDto().setKey("private-key"),
+      ComponentTesting.newPublicProjectDto().setKey("public-key"));
 
     SearchWsResponse response = call(SearchRequest.builder().setVisibility("private").build());
 
@@ -112,8 +112,8 @@ public class SearchActionTest {
   public void search_public_projects() {
     userSession.addPermission(ADMINISTER);
     db.components().insertComponents(
-      ComponentTesting.newPrivateProjectDto().setDbKey("private-key"),
-      ComponentTesting.newPublicProjectDto().setDbKey("public-key"));
+      ComponentTesting.newPrivateProjectDto().setKey("private-key"),
+      ComponentTesting.newPublicProjectDto().setKey("public-key"));
 
     SearchWsResponse response = call(SearchRequest.builder().setVisibility("public").build());
 
@@ -124,7 +124,7 @@ public class SearchActionTest {
   public void search_projects_when_no_qualifier_set() {
     userSession.addPermission(ADMINISTER);
     db.components().insertComponents(
-      ComponentTesting.newPrivateProjectDto().setDbKey(PROJECT_KEY_1),
+      ComponentTesting.newPrivateProjectDto().setKey(PROJECT_KEY_1),
       newPortfolio());
 
     SearchWsResponse response = call(SearchRequest.builder().build());
@@ -135,13 +135,13 @@ public class SearchActionTest {
   @Test
   public void search_projects() {
     userSession.addPermission(ADMINISTER);
-    ComponentDto project = ComponentTesting.newPrivateProjectDto().setDbKey(PROJECT_KEY_1);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto().setKey(PROJECT_KEY_1);
     ComponentDto module = newModuleDto(project);
     ComponentDto directory = newDirectory(module, "dir");
     ComponentDto file = newFileDto(directory);
     db.components().insertComponents(
       project, module, directory, file,
-      ComponentTesting.newPrivateProjectDto().setDbKey(PROJECT_KEY_2),
+      ComponentTesting.newPrivateProjectDto().setKey(PROJECT_KEY_2),
       newPortfolio());
 
     SearchWsResponse response = call(SearchRequest.builder().setQualifiers(singletonList("TRK")).build());
@@ -153,8 +153,8 @@ public class SearchActionTest {
   public void search_views() {
     userSession.addPermission(ADMINISTER);
     db.components().insertComponents(
-      ComponentTesting.newPrivateProjectDto().setDbKey(PROJECT_KEY_1),
-      newPortfolio().setDbKey("view1"));
+      ComponentTesting.newPrivateProjectDto().setKey(PROJECT_KEY_1),
+      newPortfolio().setKey("view1"));
 
     SearchWsResponse response = call(SearchRequest.builder().setQualifiers(singletonList("VW")).build());
 
@@ -165,8 +165,8 @@ public class SearchActionTest {
   public void search_projects_and_views() {
     userSession.addPermission(ADMINISTER);
     db.components().insertComponents(
-      ComponentTesting.newPrivateProjectDto().setDbKey(PROJECT_KEY_1),
-      newPortfolio().setDbKey("view1"));
+      ComponentTesting.newPrivateProjectDto().setKey(PROJECT_KEY_1),
+      newPortfolio().setKey("view1"));
 
     SearchWsResponse response = call(SearchRequest.builder().setQualifiers(asList("TRK", "VW")).build());
 
@@ -177,9 +177,9 @@ public class SearchActionTest {
   public void search_all() {
     userSession.addPermission(ADMINISTER);
     db.components().insertComponents(
-      ComponentTesting.newPrivateProjectDto().setDbKey(PROJECT_KEY_1),
-      ComponentTesting.newPrivateProjectDto().setDbKey(PROJECT_KEY_2),
-      ComponentTesting.newPrivateProjectDto().setDbKey(PROJECT_KEY_3));
+      ComponentTesting.newPrivateProjectDto().setKey(PROJECT_KEY_1),
+      ComponentTesting.newPrivateProjectDto().setKey(PROJECT_KEY_2),
+      ComponentTesting.newPrivateProjectDto().setKey(PROJECT_KEY_3));
 
     SearchWsResponse response = call(SearchRequest.builder().build());
 
@@ -227,7 +227,7 @@ public class SearchActionTest {
 
     SearchWsResponse response = call(SearchRequest.builder().build());
 
-    assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly(project.getDbKey());
+    assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly(project.getKey());
   }
 
   @Test
@@ -235,7 +235,7 @@ public class SearchActionTest {
     userSession.addPermission(ADMINISTER);
     List<ComponentDto> componentDtoList = new ArrayList<>();
     for (int i = 1; i <= 9; i++) {
-      componentDtoList.add(newPrivateProjectDto("project-uuid-" + i).setDbKey("project-key-" + i).setName("Project Name " + i));
+      componentDtoList.add(newPrivateProjectDto("project-uuid-" + i).setKey("project-key-" + i).setName("Project Name " + i));
     }
     db.components().insertComponents(componentDtoList.toArray(new ComponentDto[] {}));
 
@@ -358,8 +358,8 @@ public class SearchActionTest {
   @Test
   public void json_example() {
     userSession.addPermission(ADMINISTER);
-    ComponentDto publicProject = newPrivateProjectDto("project-uuid-1").setName("Project Name 1").setDbKey("project-key-1").setPrivate(false);
-    ComponentDto privateProject = newPrivateProjectDto("project-uuid-2").setName("Project Name 1").setDbKey("project-key-2");
+    ComponentDto publicProject = newPrivateProjectDto("project-uuid-1").setName("Project Name 1").setKey("project-key-1").setPrivate(false);
+    ComponentDto privateProject = newPrivateProjectDto("project-uuid-2").setName("Project Name 1").setKey("project-key-2");
     db.components().insertComponents(
       publicProject,
       privateProject);
index 6ff6057047190a5c83cd264f45e06d1634b99b5b..818bcd37cce389866972ad613d25aada2a442434 100644 (file)
@@ -193,7 +193,7 @@ public class SearchMyProjectsActionTest {
 
     assertThat(result.getProjectsList())
       .extracting(Project::getKey)
-      .containsExactlyInAnyOrder(project.getDbKey());
+      .containsExactlyInAnyOrder(project.getKey());
   }
 
   @Test
@@ -249,13 +249,13 @@ public class SearchMyProjectsActionTest {
   private ComponentDto insertClang() {
     return db.components().insertComponent(newPrivateProjectDto(Uuids.UUID_EXAMPLE_01)
       .setName("Clang")
-      .setDbKey("clang"));
+      .setKey("clang"));
   }
 
   private ComponentDto insertJdk7() {
     return db.components().insertComponent(newPrivateProjectDto(Uuids.UUID_EXAMPLE_02)
       .setName("JDK 7")
-      .setDbKey("net.java.openjdk:jdk7")
+      .setKey("net.java.openjdk:jdk7")
       .setDescription("JDK"));
   }
 
@@ -263,7 +263,7 @@ public class SearchMyProjectsActionTest {
     String uuid = "752d8bfd-420c-4a83-a4e5-8ab19b13c8fc";
     return db.components().insertPublicPortfolio(p -> p.setUuid("752d8bfd-420c-4a83-a4e5-8ab19b13c8fc")
         .setName("Java")
-        .setDbKey("Java"),
+        .setKey("Java"),
       p -> p.setRootUuid(uuid));
   }
 
index 1201b6197b017c3ac08bed4a9b6b7cb715fcb108..f8040c36e33e1a388658508498309a7e07081f80 100644 (file)
@@ -51,10 +51,10 @@ public class SearchMyScannableProjectsActionTest {
 
   @Test
   public void projects_filtered_by_query() {
-    ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:one").setName("Projet Un"));
-    ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:two").setName("Projet Deux"));
-    ProjectDto project3 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:three").setName("Project Three"));
-    ProjectDto project4 = db.components().insertPublicProjectDto(p -> p.setDbKey("project:four").setName("Project Four"));
+    ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setKey("project:one").setName("Projet Un"));
+    ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setKey("project:two").setName("Projet Deux"));
+    ProjectDto project3 = db.components().insertPrivateProjectDto(p -> p.setKey("project:three").setName("Project Three"));
+    ProjectDto project4 = db.components().insertPublicProjectDto(p -> p.setKey("project:four").setName("Project Four"));
     userSession.addProjectPermission(SCAN, project1, project2, project3, project4);
 
     List<Project> result = ws.newRequest()
@@ -71,10 +71,10 @@ public class SearchMyScannableProjectsActionTest {
 
   @Test
   public void projects_not_filtered_by_empty_query() {
-    ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:one").setName("Projet Un"));
-    ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:two").setName("Projet Deux"));
-    ProjectDto project3 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:three").setName("Project Three"));
-    ProjectDto project4 = db.components().insertPublicProjectDto(p -> p.setDbKey("project:four").setName("Project Four"));
+    ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setKey("project:one").setName("Projet Un"));
+    ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setKey("project:two").setName("Projet Deux"));
+    ProjectDto project3 = db.components().insertPrivateProjectDto(p -> p.setKey("project:three").setName("Project Three"));
+    ProjectDto project4 = db.components().insertPublicProjectDto(p -> p.setKey("project:four").setName("Project Four"));
     userSession.addProjectPermission(SCAN, project1, project2, project3, project4);
 
     List<Project> result = ws.newRequest()
@@ -93,10 +93,10 @@ public class SearchMyScannableProjectsActionTest {
 
   @Test
   public void projects_filtered_by_scan_permission() {
-    db.components().insertPrivateProjectDto(p -> p.setDbKey("project:one").setName("Projet Un"));
-    db.components().insertPrivateProjectDto(p -> p.setDbKey("project:two").setName("Projet Deux"));
-    db.components().insertPrivateProjectDto(p -> p.setDbKey("project:three").setName("Project Three"));
-    db.components().insertPublicProjectDto(p -> p.setDbKey("project:four").setName("Project Four"));
+    db.components().insertPrivateProjectDto(p -> p.setKey("project:one").setName("Projet Un"));
+    db.components().insertPrivateProjectDto(p -> p.setKey("project:two").setName("Projet Deux"));
+    db.components().insertPrivateProjectDto(p -> p.setKey("project:three").setName("Project Three"));
+    db.components().insertPublicProjectDto(p -> p.setKey("project:four").setName("Project Four"));
 
     List<Project> result = ws.newRequest()
       .executeProtobuf(SearchMyScannableProjectsResponse.class)
@@ -107,10 +107,10 @@ public class SearchMyScannableProjectsActionTest {
 
   @Test
   public void projects_filtered_for_anonymous_user() {
-    ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:one").setName("Projet Un"));
-    ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:two").setName("Projet Deux"));
-    ProjectDto project3 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:three").setName("Project Three"));
-    ProjectDto project4 = db.components().insertPublicProjectDto(p -> p.setDbKey("project:four").setName("Project Four"));
+    ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setKey("project:one").setName("Projet Un"));
+    ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setKey("project:two").setName("Projet Deux"));
+    ProjectDto project3 = db.components().insertPrivateProjectDto(p -> p.setKey("project:three").setName("Project Three"));
+    ProjectDto project4 = db.components().insertPublicProjectDto(p -> p.setKey("project:four").setName("Project Four"));
     userSession.addProjectPermission(SCAN, project1, project2, project3, project4);
 
     WsActionTester ws = new WsActionTester(
@@ -125,10 +125,10 @@ public class SearchMyScannableProjectsActionTest {
 
   @Test
   public void projects_not_filtered_due_to_global_scan_permission() {
-    db.components().insertPrivateProjectDto(p -> p.setDbKey("project:one").setName("Projet Un"));
-    db.components().insertPrivateProjectDto(p -> p.setDbKey("project:two").setName("Projet Deux"));
-    db.components().insertPrivateProjectDto(p -> p.setDbKey("project:three").setName("Project Three"));
-    db.components().insertPublicProjectDto(p -> p.setDbKey("project:four").setName("Project Four"));
+    db.components().insertPrivateProjectDto(p -> p.setKey("project:one").setName("Projet Un"));
+    db.components().insertPrivateProjectDto(p -> p.setKey("project:two").setName("Projet Deux"));
+    db.components().insertPrivateProjectDto(p -> p.setKey("project:three").setName("Project Three"));
+    db.components().insertPublicProjectDto(p -> p.setKey("project:four").setName("Project Four"));
     userSession.addPermission(GlobalPermission.SCAN);
 
     List<Project> result = ws.newRequest()
@@ -146,9 +146,9 @@ public class SearchMyScannableProjectsActionTest {
 
   @Test
   public void json_example() {
-    ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project-key-1").setName("Project 1"));
-    ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project-key-2").setName("Project 2"));
-    ProjectDto project3 = db.components().insertPublicProjectDto(p -> p.setDbKey("public-project-without-scan-permissions")
+    ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setKey("project-key-1").setName("Project 1"));
+    ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setKey("project-key-2").setName("Project 2"));
+    ProjectDto project3 = db.components().insertPublicProjectDto(p -> p.setKey("public-project-without-scan-permissions")
       .setName("Public Project with Scan Permissions"));
     userSession.addProjectPermission(SCAN, project1, project2);
     userSession.registerProjects(project3);
index a5e402677411b5de9adffa894d71e78c02250332..cc2434b907271eb5c6e5b8172b5cf075a733e33b 100644 (file)
@@ -64,9 +64,9 @@ public class UpdateKeyActionTest {
     ComponentDto project = insertProject();
     userSessionRule.addProjectPermission(UserRole.ADMIN, project);
 
-    call(project.getDbKey(), ANOTHER_KEY);
+    call(project.getKey(), ANOTHER_KEY);
 
-    assertThat(selectByKey(project.getDbKey())).isEmpty();
+    assertThat(selectByKey(project.getKey())).isEmpty();
     assertThat(selectByKey(ANOTHER_KEY).get().uuid()).isEqualTo(project.uuid());
   }
 
@@ -111,7 +111,7 @@ public class UpdateKeyActionTest {
     ComponentDto branch = db.components().insertProjectBranch(project);
     userSessionRule.addProjectPermission(UserRole.ADMIN, project);
 
-    String branchDbKey = branch.getDbKey();
+    String branchDbKey = branch.getKey();
     assertThatThrownBy(() -> call(branchDbKey, ANOTHER_KEY))
       .isInstanceOf(NotFoundException.class)
       .hasMessage(String.format("Project '%s' not found", branchDbKey));
index 7dc8c17ef288dd1f203aafc05ddd11082c1465db..3c7274a0f03eeae0bd02e64a5252ef434fb05d04 100644 (file)
@@ -201,13 +201,13 @@ public class UpdateVisibilityActionTest {
     userSessionRule.addProjectPermission(UserRole.ADMIN, project, portfolio, application);
 
     Stream.of(project, portfolio, application).forEach(c -> request
-      .setParam(PARAM_PROJECT, c.getDbKey())
+      .setParam(PARAM_PROJECT, c.getKey())
       .setParam(PARAM_VISIBILITY, randomVisibility)
       .execute());
 
     Stream.of(module, dir, file, subView, projectCopy)
       .forEach(nonRootComponent -> {
-        request.setParam(PARAM_PROJECT, nonRootComponent.getDbKey())
+        request.setParam(PARAM_PROJECT, nonRootComponent.getKey())
           .setParam(PARAM_VISIBILITY, randomVisibility);
 
         try {
@@ -222,7 +222,7 @@ public class UpdateVisibilityActionTest {
   @Test
   public void execute_throws_ForbiddenException_if_user_has_no_permission_on_specified_component() {
     ComponentDto project = dbTester.components().insertPrivateProject();
-    request.setParam(PARAM_PROJECT, project.getDbKey())
+    request.setParam(PARAM_PROJECT, project.getKey())
       .setParam(PARAM_VISIBILITY, randomVisibility);
 
     assertThatThrownBy(request::execute)
@@ -233,7 +233,7 @@ public class UpdateVisibilityActionTest {
   @Test
   public void execute_throws_ForbiddenException_if_user_has_all_permissions_but_ADMIN_on_specified_component() {
     ComponentDto project = dbTester.components().insertPublicProject();
-    request.setParam(PARAM_PROJECT, project.getDbKey())
+    request.setParam(PARAM_PROJECT, project.getKey())
       .setParam(PARAM_VISIBILITY, randomVisibility);
     userSessionRule.addProjectPermission(UserRole.ISSUE_ADMIN, project);
     Arrays.stream(GlobalPermission.values())
@@ -249,7 +249,7 @@ public class UpdateVisibilityActionTest {
   public void execute_throws_ForbiddenException_if_user_has_ADMIN_permission_but_sonar_allowPermissionManagementForProjectAdmins_is_set_to_false() {
     when(configuration.getBoolean(CORE_ALLOW_PERMISSION_MANAGEMENT_FOR_PROJECT_ADMINS_PROPERTY)).thenReturn(of(false));
     ComponentDto project = dbTester.components().insertPublicProject();
-    request.setParam(PARAM_PROJECT, project.getDbKey())
+    request.setParam(PARAM_PROJECT, project.getKey())
       .setParam(PARAM_VISIBILITY, randomVisibility);
     userSessionRule.addProjectPermission(UserRole.ADMIN, project);
 
@@ -263,7 +263,7 @@ public class UpdateVisibilityActionTest {
     when(configuration.getBoolean(CORE_ALLOW_PERMISSION_MANAGEMENT_FOR_PROJECT_ADMINS_PROPERTY)).thenReturn(of(false));
     ComponentDto project = dbTester.components().insertPublicProject();
     userSessionRule.setSystemAdministrator().addProjectPermission(UserRole.ADMIN, project);
-    request.setParam(PARAM_PROJECT, project.getDbKey())
+    request.setParam(PARAM_PROJECT, project.getKey())
       .setParam(PARAM_VISIBILITY, "private");
 
     request.execute();
@@ -276,7 +276,7 @@ public class UpdateVisibilityActionTest {
     ComponentDto project = randomPublicOrPrivateProject();
     IntStream.range(0, 1 + Math.abs(random.nextInt(5)))
       .forEach(i -> insertPendingTask(project));
-    request.setParam(PARAM_PROJECT, project.getDbKey())
+    request.setParam(PARAM_PROJECT, project.getKey())
       .setParam(PARAM_VISIBILITY, randomVisibility);
     userSessionRule.addProjectPermission(UserRole.ADMIN, project);
 
@@ -290,7 +290,7 @@ public class UpdateVisibilityActionTest {
     ComponentDto project = randomPublicOrPrivateProject();
     IntStream.range(0, 1 + Math.abs(random.nextInt(5)))
       .forEach(i -> insertInProgressTask(project));
-    request.setParam(PARAM_PROJECT, project.getDbKey())
+    request.setParam(PARAM_PROJECT, project.getKey())
       .setParam(PARAM_VISIBILITY, randomVisibility);
     userSessionRule.addProjectPermission(UserRole.ADMIN, project);
 
@@ -315,7 +315,7 @@ public class UpdateVisibilityActionTest {
     dbTester.components().insertComponents(branch, module, dir, file);
     userSessionRule.addProjectPermission(UserRole.ADMIN, project);
 
-    request.setParam(PARAM_PROJECT, project.getDbKey())
+    request.setParam(PARAM_PROJECT, project.getKey())
       .setParam(PARAM_VISIBILITY, initiallyPrivate ? PUBLIC : PRIVATE)
       .execute();
 
@@ -346,7 +346,7 @@ public class UpdateVisibilityActionTest {
     dbTester.components().insertComponents(branch, module, dir, file);
     userSessionRule.addProjectPermission(UserRole.ADMIN, project);
 
-    request.setParam(PARAM_PROJECT, project.getDbKey())
+    request.setParam(PARAM_PROJECT, project.getKey())
       .setParam(PARAM_VISIBILITY, initiallyPrivate ? PRIVATE : PUBLIC)
       .execute();
 
@@ -365,7 +365,7 @@ public class UpdateVisibilityActionTest {
     unsafeGiveAllPermissionsToRootComponent(project, user, group);
     userSessionRule.addProjectPermission(UserRole.ADMIN, project);
 
-    request.setParam(PARAM_PROJECT, project.getDbKey())
+    request.setParam(PARAM_PROJECT, project.getKey())
       .setParam(PARAM_VISIBILITY, PRIVATE)
       .execute();
 
@@ -380,7 +380,7 @@ public class UpdateVisibilityActionTest {
     unsafeGiveAllPermissionsToRootComponent(project, user, group);
     userSessionRule.addProjectPermission(UserRole.ADMIN, project);
 
-    request.setParam(PARAM_PROJECT, project.getDbKey())
+    request.setParam(PARAM_PROJECT, project.getKey())
       .setParam(PARAM_VISIBILITY, PRIVATE)
       .execute();
 
@@ -395,7 +395,7 @@ public class UpdateVisibilityActionTest {
     unsafeGiveAllPermissionsToRootComponent(project, user, group);
     userSessionRule.addProjectPermission(UserRole.ADMIN, project);
 
-    request.setParam(PARAM_PROJECT, project.getDbKey())
+    request.setParam(PARAM_PROJECT, project.getKey())
       .setParam(PARAM_VISIBILITY, PUBLIC)
       .execute();
 
@@ -410,7 +410,7 @@ public class UpdateVisibilityActionTest {
     unsafeGiveAllPermissionsToRootComponent(project, user, group);
     userSessionRule.addProjectPermission(UserRole.ADMIN, project);
 
-    request.setParam(PARAM_PROJECT, project.getDbKey())
+    request.setParam(PARAM_PROJECT, project.getKey())
       .setParam(PARAM_VISIBILITY, PUBLIC)
       .execute();
 
@@ -423,7 +423,7 @@ public class UpdateVisibilityActionTest {
     boolean initiallyPrivate = project.isPrivate();
     userSessionRule.addProjectPermission(UserRole.ADMIN, project);
 
-    request.setParam(PARAM_PROJECT, project.getDbKey())
+    request.setParam(PARAM_PROJECT, project.getKey())
       .setParam(PARAM_VISIBILITY, initiallyPrivate ? PUBLIC : PRIVATE)
       .execute();
 
@@ -436,7 +436,7 @@ public class UpdateVisibilityActionTest {
     boolean initiallyPrivate = project.isPrivate();
     userSessionRule.addProjectPermission(UserRole.ADMIN, project);
 
-    request.setParam(PARAM_PROJECT, project.getDbKey())
+    request.setParam(PARAM_PROJECT, project.getKey())
       .setParam(PARAM_VISIBILITY, initiallyPrivate ? PRIVATE : PUBLIC)
       .execute();
 
@@ -454,7 +454,7 @@ public class UpdateVisibilityActionTest {
     dbTester.users().insertProjectPermissionOnUser(user2, "p2", project);
     userSessionRule.addProjectPermission(UserRole.ADMIN, project);
 
-    request.setParam(PARAM_PROJECT, project.getDbKey())
+    request.setParam(PARAM_PROJECT, project.getKey())
       .setParam(PARAM_VISIBILITY, PRIVATE)
       .execute();
 
@@ -477,7 +477,7 @@ public class UpdateVisibilityActionTest {
     dbTester.users().insertProjectPermissionOnGroup(group2, "p2", project);
     userSessionRule.addProjectPermission(UserRole.ADMIN, project);
 
-    request.setParam(PARAM_PROJECT, project.getDbKey())
+    request.setParam(PARAM_PROJECT, project.getKey())
       .setParam(PARAM_VISIBILITY, PRIVATE)
       .execute();
 
@@ -498,7 +498,7 @@ public class UpdateVisibilityActionTest {
     dbTester.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, portfolio);
     userSessionRule.addProjectPermission(UserRole.ADMIN, portfolio);
 
-    request.setParam(PARAM_PROJECT, portfolio.getDbKey())
+    request.setParam(PARAM_PROJECT, portfolio.getKey())
       .setParam(PARAM_VISIBILITY, PRIVATE)
       .execute();
 
@@ -522,7 +522,7 @@ public class UpdateVisibilityActionTest {
     dbTester.users().insertProjectPermissionOnUser(user, UserRole.USER, portfolio);
     dbTester.users().insertProjectPermissionOnUser(user, UserRole.CODEVIEWER, portfolio);
 
-    request.setParam(PARAM_PROJECT, portfolio.getDbKey())
+    request.setParam(PARAM_PROJECT, portfolio.getKey())
       .setParam(PARAM_VISIBILITY, PUBLIC)
       .execute();
 
@@ -542,7 +542,7 @@ public class UpdateVisibilityActionTest {
     dbTester.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, application);
     userSessionRule.addProjectPermission(UserRole.ADMIN, application);
 
-    request.setParam(PARAM_PROJECT, application.getDbKey())
+    request.setParam(PARAM_PROJECT, application.getKey())
       .setParam(PARAM_VISIBILITY, PRIVATE)
       .execute();
 
@@ -566,7 +566,7 @@ public class UpdateVisibilityActionTest {
     dbTester.users().insertProjectPermissionOnUser(user, UserRole.USER, portfolio);
     dbTester.users().insertProjectPermissionOnUser(user, UserRole.CODEVIEWER, portfolio);
 
-    request.setParam(PARAM_PROJECT, portfolio.getDbKey())
+    request.setParam(PARAM_PROJECT, portfolio.getKey())
       .setParam(PARAM_VISIBILITY, PUBLIC)
       .execute();
 
@@ -583,11 +583,11 @@ public class UpdateVisibilityActionTest {
     userSessionRule.logIn().addProjectPermission(UserRole.USER, project);
     ComponentDto branch = dbTester.components().insertProjectBranch(project);
 
-    TestRequest request = this.request.setParam(PARAM_PROJECT, branch.getDbKey())
+    TestRequest request = this.request.setParam(PARAM_PROJECT, branch.getKey())
       .setParam(PARAM_VISIBILITY, PUBLIC);
     assertThatThrownBy(request::execute)
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(String.format("Component key '%s' not found", branch.getDbKey()));
+      .hasMessage(String.format("Component key '%s' not found", branch.getKey()));
   }
 
   private void unsafeGiveAllPermissionsToRootComponent(ComponentDto component, UserDto user, GroupDto group) {
index cb9f0dbd795c56e013235e6485937af38e3e0fb8..4d6e0c813cc4b080c97269aa93f768682efc65aa 100644 (file)
@@ -119,7 +119,7 @@ public class SearchActionTest {
 
   @Test
   public void json_example() {
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto().setDbKey(KEY_PROJECT_EXAMPLE_001));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto().setKey(KEY_PROJECT_EXAMPLE_001));
 
     userSession.addProjectPermission(UserRole.USER, project);
     SnapshotDto a1 = db.components().insertSnapshot(newAnalysis(project)
@@ -202,7 +202,7 @@ public class SearchActionTest {
 
   @Test
   public void return_only_processed_analyses() {
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto().setDbKey("P1"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto().setKey("P1"));
     userSession.addProjectPermission(UserRole.USER, project);
     db.components().insertSnapshot(newAnalysis(project).setUuid("A1"));
     db.components().insertSnapshot(newAnalysis(project).setUuid("A2").setStatus(SnapshotDto.STATUS_UNPROCESSED));
@@ -215,7 +215,7 @@ public class SearchActionTest {
 
   @Test
   public void return_events() {
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto().setDbKey("P1"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto().setKey("P1"));
     userSession.addProjectPermission(UserRole.USER, project);
     SnapshotDto a1 = db.components().insertSnapshot(newAnalysis(project).setUuid("A1"));
     SnapshotDto a42 = db.components().insertSnapshot(newAnalysis(ComponentTesting.newPrivateProjectDto()).setUuid("A42"));
@@ -241,7 +241,7 @@ public class SearchActionTest {
     SnapshotDto secondAnalysis = db.components().insertSnapshot(newAnalysis(application).setCreatedAt(2_000_000L));
     SnapshotDto thirdAnalysis = db.components().insertSnapshot(newAnalysis(application).setCreatedAt(3_000_000L));
 
-    List<Analysis> result = call(application.getDbKey()).getAnalysesList();
+    List<Analysis> result = call(application.getKey()).getAnalysesList();
 
     assertThat(result)
       .hasSize(3)
@@ -262,7 +262,7 @@ public class SearchActionTest {
     EventComponentChangeDto changeDto2 = generateEventComponentChange(event, REMOVED, "Another project", "app2", "master", uuidFactoryFast.create());
     insertEventComponentChanges(application, firstAnalysis, changeDto1, changeDto2);
 
-    List<Analysis> result = call(application.getDbKey()).getAnalysesList();
+    List<Analysis> result = call(application.getKey()).getAnalysesList();
 
     assertThat(result).hasSize(1);
     List<Event> events = result.get(0).getEventsList();
@@ -287,7 +287,7 @@ public class SearchActionTest {
     EventComponentChangeDto changeDto2 = generateEventComponentChange(event, ADDED, "My project", "app1", newBranch, changeDto1.getComponentUuid());
     insertEventComponentChanges(application, firstAnalysis, changeDto1, changeDto2);
 
-    List<Analysis> result = call(application.getDbKey()).getAnalysesList();
+    List<Analysis> result = call(application.getKey()).getAnalysesList();
 
     assertThat(result).hasSize(1);
     List<Event> events = result.get(0).getEventsList();
@@ -312,7 +312,7 @@ public class SearchActionTest {
     db.getDbClient().eventComponentChangeDao().insert(db.getSession(), changeDto2, eventPurgeData);
     db.getSession().commit();
 
-    List<Analysis> result = call(application.getDbKey()).getAnalysesList();
+    List<Analysis> result = call(application.getKey()).getAnalysesList();
 
     assertThat(result).hasSize(1);
     List<Event> events = result.get(0).getEventsList();
@@ -339,7 +339,7 @@ public class SearchActionTest {
     db.getDbClient().eventComponentChangeDao().insert(db.getSession(), changeDto1, eventPurgeData);
     db.getSession().commit();
 
-    List<Analysis> result = call(application.getDbKey()).getAnalysesList();
+    List<Analysis> result = call(application.getKey()).getAnalysesList();
 
     assertThat(result).hasSize(1);
     List<Event> events = result.get(0).getEventsList();
@@ -369,7 +369,7 @@ public class SearchActionTest {
     db.getDbClient().eventComponentChangeDao().insert(db.getSession(), changeDto3, eventPurgeData);
     db.getSession().commit();
 
-    List<Analysis> result = call(application.getDbKey()).getAnalysesList();
+    List<Analysis> result = call(application.getKey()).getAnalysesList();
 
     assertThat(result).hasSize(1);
     List<Event> events = result.get(0).getEventsList();
@@ -401,7 +401,7 @@ public class SearchActionTest {
     db.getDbClient().eventComponentChangeDao().insert(db.getSession(), changeDto1, eventPurgeData);
     db.getSession().commit();
 
-    List<Analysis> result = call(application.getDbKey()).getAnalysesList();
+    List<Analysis> result = call(application.getKey()).getAnalysesList();
 
     assertThat(result).hasSize(1);
     List<Event> events = result.get(0).getEventsList();
@@ -426,7 +426,7 @@ public class SearchActionTest {
     SnapshotDto secondAnalysis = db.components().insertSnapshot(newAnalysis(view).setCreatedAt(2_000_000L));
     SnapshotDto thirdAnalysis = db.components().insertSnapshot(newAnalysis(view).setCreatedAt(3_000_000L));
 
-    List<Analysis> result = call(view.getDbKey()).getAnalysesList();
+    List<Analysis> result = call(view.getKey()).getAnalysesList();
 
     assertThat(result)
       .hasSize(3)
@@ -440,7 +440,7 @@ public class SearchActionTest {
     IntStream.rangeClosed(1, 9).forEach(i -> db.components().insertSnapshot(newAnalysis(project).setCreatedAt(1_000_000L * i).setUuid("A" + i)));
 
     SearchResponse result = call(SearchRequest.builder()
-      .setProject(project.getDbKey())
+      .setProject(project.getKey())
       .setPage(2)
       .setPageSize(3)
       .build());
@@ -451,7 +451,7 @@ public class SearchActionTest {
 
   @Test
   public void filter_by_category() {
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto().setDbKey("P1"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto().setKey("P1"));
     userSession.addProjectPermission(UserRole.USER, project);
     SnapshotDto a1 = db.components().insertSnapshot(newAnalysis(project).setUuid("A1"));
     SnapshotDto a2 = db.components().insertSnapshot(newAnalysis(project).setUuid("A2"));
@@ -472,7 +472,7 @@ public class SearchActionTest {
 
   @Test
   public void paginate_with_filter_on_category() {
-    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto().setDbKey("P1"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto().setKey("P1"));
     userSession.addProjectPermission(UserRole.USER, project);
     SnapshotDto a1 = db.components().insertSnapshot(newAnalysis(project).setUuid("A1").setCreatedAt(1_000_000L));
     SnapshotDto a2 = db.components().insertSnapshot(newAnalysis(project).setUuid("A2").setCreatedAt(2_000_000L));
@@ -507,7 +507,7 @@ public class SearchActionTest {
     SnapshotDto a4 = db.components().insertSnapshot(newAnalysis(project).setUuid("a4").setCreatedAt(4_000_000_000L));
 
     SearchResponse result = call(SearchRequest.builder()
-      .setProject(project.getDbKey())
+      .setProject(project.getKey())
       .setFrom(formatDateTime(2_000_000_000L))
       .build());
 
@@ -527,7 +527,7 @@ public class SearchActionTest {
     SnapshotDto a4 = db.components().insertSnapshot(newAnalysis(project).setUuid("a4").setCreatedAt(4_000_000_000L));
 
     SearchResponse result = call(SearchRequest.builder()
-      .setProject(project.getDbKey())
+      .setProject(project.getKey())
       .setTo(formatDateTime(2_000_000_000L))
       .build());
 
@@ -547,7 +547,7 @@ public class SearchActionTest {
     SnapshotDto a4 = db.components().insertSnapshot(newAnalysis(project).setUuid("a4").setCreatedAt(4_000_000_000L));
 
     SearchResponse result = call(SearchRequest.builder()
-      .setProject(project.getDbKey())
+      .setProject(project.getKey())
       .setFrom(formatDateTime(2_000_000_000L))
       .setTo(formatDateTime(3_000_000_000L))
       .build());
@@ -568,7 +568,7 @@ public class SearchActionTest {
     SnapshotDto a4 = db.components().insertSnapshot(newAnalysis(project).setUuid("a4").setCreatedAt(4_000_000_000L));
 
     SearchResponse result = call(SearchRequest.builder()
-      .setProject(project.getDbKey())
+      .setProject(project.getKey())
       .setFrom(formatDate(new Date(2_000_000_000L)))
       .setTo(formatDate(new Date(3_000_000_000L)))
       .build());
@@ -602,7 +602,7 @@ public class SearchActionTest {
     ComponentDto project = db.components().insertPrivateProject();
     userSession.addProjectPermission(UserRole.USER, project);
 
-    SearchResponse result = call(project.getDbKey());
+    SearchResponse result = call(project.getKey());
 
     assertThat(result.hasPaging()).isTrue();
     assertThat(result.getPaging()).extracting(Paging::getPageIndex, Paging::getPageSize, Paging::getTotal).containsExactly(1, 100, 0);
@@ -620,7 +620,7 @@ public class SearchActionTest {
       db.components().insertSnapshot(newAnalysis(project).setProjectVersion("c").setBuildString("d"))
     };
 
-    SearchResponse result = call(project.getDbKey());
+    SearchResponse result = call(project.getKey());
 
     assertThat(result.getAnalysesList())
       .extracting(Analysis::getKey, Analysis::getProjectVersion, Analysis::getBuildString)
@@ -636,7 +636,7 @@ public class SearchActionTest {
     userSession.anonymous();
     ComponentDto project = db.components().insertPrivateProject();
 
-    var projectDbKey = project.getDbKey();
+    var projectDbKey = project.getKey();
     assertThatThrownBy(() -> call(projectDbKey))
       .isInstanceOf(ForbiddenException.class);
   }
@@ -654,7 +654,7 @@ public class SearchActionTest {
         toProjectDto(project2, 1L))
       .addProjectPermission(UserRole.USER, application, project1);
 
-    var projectDbKey = application.getDbKey();
+    var projectDbKey = application.getKey();
     assertThatThrownBy(() -> call(projectDbKey))
       .isInstanceOf(ForbiddenException.class);
   }
@@ -672,7 +672,7 @@ public class SearchActionTest {
     db.components().insertSnapshot(newAnalysis(project));
     userSession.registerComponents(project, file);
 
-    var fileDbKey = file.getDbKey();
+    var fileDbKey = file.getKey();
     assertThatThrownBy(() -> call(fileDbKey))
       .isInstanceOf(IllegalArgumentException.class)
       .hasMessage("A project, portfolio or application is required");
index 0b0952203fa5b36ad95f6c72785fd53202ba2b07..3e0e0235361db3ea27dab89cf94f18b2f24459d0 100644 (file)
@@ -101,7 +101,7 @@ public class UnsetBaselineActionTest {
     ComponentDto branch = db.components().insertProjectBranch(project);
     SnapshotDto projectAnalysis = db.components().insertSnapshot(project);
     SnapshotDto branchAnalysis = db.components().insertSnapshot(project);
-    db.newCodePeriods().insert(project.projectUuid(), NewCodePeriodType.SPECIFIC_ANALYSIS, projectAnalysis.getUuid());
+    db.newCodePeriods().insert(project.branchUuid(), NewCodePeriodType.SPECIFIC_ANALYSIS, projectAnalysis.getUuid());
     logInAsProjectAdministrator(project);
 
     call(project.getKey(), null);
@@ -115,7 +115,7 @@ public class UnsetBaselineActionTest {
     ComponentDto branch = db.components().insertProjectBranch(project);
     db.components().insertSnapshot(branch);
     SnapshotDto branchAnalysis = db.components().insertSnapshot(project);
-    db.newCodePeriods().insert(project.projectUuid(), branch.uuid(), NewCodePeriodType.SPECIFIC_ANALYSIS, branchAnalysis.getUuid());
+    db.newCodePeriods().insert(project.branchUuid(), branch.uuid(), NewCodePeriodType.SPECIFIC_ANALYSIS, branchAnalysis.getUuid());
 
     logInAsProjectAdministrator(project);
 
index d1a69a417ac1cb36344f2a26936b756bddfb7893..231955fd5958cd7eae65dfed6cd608281d11a1b3 100644 (file)
@@ -66,7 +66,7 @@ public class ExportActionTest {
 
   @Before
   public void setUp() {
-    project = db.components().insertComponent(newPrivateProjectDto(PROJECT_ID).setDbKey(PROJECT_KEY).setName(PROJECT_NAME));
+    project = db.components().insertComponent(newPrivateProjectDto(PROJECT_ID).setKey(PROJECT_KEY).setName(PROJECT_NAME));
   }
 
   @Test
@@ -87,7 +87,7 @@ public class ExportActionTest {
   public void fails_if_not_project_administrator() {
     userSession.logIn();
 
-    assertThatThrownBy(() -> actionTester.newRequest().setMethod("POST").setParam("key", project.getDbKey()).execute())
+    assertThatThrownBy(() -> actionTester.newRequest().setMethod("POST").setParam("key", project.getKey()).execute())
       .isInstanceOf(ForbiddenException.class);
   }
 
@@ -96,8 +96,8 @@ public class ExportActionTest {
     UserDto user = db.users().insertUser();
     userSession.logIn(user).addProjectPermission(UserRole.ADMIN, project);
 
-    when(exportSubmitter.submitProjectExport(project.getDbKey(), user.getUuid())).thenReturn(createResponseExampleTask());
-    TestResponse response = actionTester.newRequest().setMethod("POST").setParam("key", project.getDbKey()).execute();
+    when(exportSubmitter.submitProjectExport(project.getKey(), user.getUuid())).thenReturn(createResponseExampleTask());
+    TestResponse response = actionTester.newRequest().setMethod("POST").setParam("key", project.getKey()).execute();
 
     assertJson(response.getInput()).isSimilarTo(responseExample());
   }
@@ -106,7 +106,7 @@ public class ExportActionTest {
   public void fails_to_trigger_task_if_anonymous() {
     userSession.anonymous();
 
-    assertThatThrownBy(() -> actionTester.newRequest().setMethod("POST").setParam("key", project.getDbKey()).execute())
+    assertThatThrownBy(() -> actionTester.newRequest().setMethod("POST").setParam("key", project.getKey()).execute())
       .isInstanceOf(ForbiddenException.class)
       .hasMessage("Insufficient privileges");
   }
@@ -116,8 +116,8 @@ public class ExportActionTest {
     UserDto user = db.users().insertUser();
     userSession.logIn(user).addProjectPermission(UserRole.ADMIN, project);
 
-    when(exportSubmitter.submitProjectExport(project.getDbKey(), user.getUuid())).thenReturn(createResponseExampleTask());
-    TestResponse response = actionTester.newRequest().setMethod("POST").setParam("key", project.getDbKey()).execute();
+    when(exportSubmitter.submitProjectExport(project.getKey(), user.getUuid())).thenReturn(createResponseExampleTask());
+    TestResponse response = actionTester.newRequest().setMethod("POST").setParam("key", project.getKey()).execute();
 
     assertJson(response.getInput()).isSimilarTo(responseExample());
   }
@@ -131,7 +131,7 @@ public class ExportActionTest {
     assertThatThrownBy(() -> {
       actionTester.newRequest()
         .setMethod("POST")
-        .setParam("key", branch.getDbKey())
+        .setParam("key", branch.getKey())
         .execute();
     })
       .isInstanceOf(NotFoundException.class);
@@ -146,7 +146,7 @@ public class ExportActionTest {
   }
 
   private CeTask createResponseExampleTask() {
-    CeTask.Component component = new CeTask.Component(project.uuid(), project.getDbKey(), project.name());
+    CeTask.Component component = new CeTask.Component(project.uuid(), project.getKey(), project.name());
     return new CeTask.Builder()
       .setType(CeTaskTypes.PROJECT_EXPORT)
       .setUuid(TASK_ID)
index f9f866ef065b921b6055d2921825c66c25f49893..6956e15b1dbea7e1bedb1af3a2fba572d580a713 100644 (file)
@@ -284,7 +284,7 @@ public class StatusActionTest {
 
     assertThatThrownBy(() -> {
       underTest.newRequest()
-        .setParam(KEY_PARAM, branch.getDbKey())
+        .setParam(KEY_PARAM, branch.getKey())
         .execute();
     })
       .isInstanceOf(NotFoundException.class);
@@ -304,7 +304,7 @@ public class StatusActionTest {
   }
 
   private ProjectDto insertProject(String uuid, String key) {
-    return db.components().insertPrivateProjectDto(c -> c.setProjectUuid(uuid).setUuid(uuid).setDbKey(key));
+    return db.components().insertPrivateProjectDto(c -> c.setBranchUuid(uuid).setUuid(uuid).setKey(key));
   }
 
   private void insertSnapshot(ProjectDto projectDto, boolean last) {
index 1fb0cb9acd6b80dd7f4a3792c8acfdc75c23067f..b222f8cb501aae0261b3f3bc40cc2204cf50e4d4 100644 (file)
@@ -67,7 +67,7 @@ public class CreateActionTest {
 
     String result = ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_PROJECT_KEY, project.getDbKey())
+      .setParam(PARAM_PROJECT_KEY, project.getKey())
       .setParam(PARAM_NAME, "Custom")
       .setParam(PARAM_URL, "http://example.org")
       .execute().getInput();
@@ -222,12 +222,12 @@ public class CreateActionTest {
     ComponentDto branch = db.components().insertProjectBranch(project);
 
     assertThatThrownBy(() -> ws.newRequest()
-      .setParam(PARAM_PROJECT_KEY, branch.getDbKey())
+      .setParam(PARAM_PROJECT_KEY, branch.getKey())
       .setParam(PARAM_NAME, "Custom")
       .setParam(PARAM_URL, "http://example.org")
       .execute())
       .isInstanceOf(NotFoundException.class)
-      .hasMessageContaining(format("Project '%s' not found", branch.getDbKey()));
+      .hasMessageContaining(format("Project '%s' not found", branch.getKey()));
   }
 
   @Test
@@ -261,10 +261,10 @@ public class CreateActionTest {
     assertThatThrownBy(() -> ws.newRequest()
       .setParam(PARAM_NAME, "Custom")
       .setParam(PARAM_URL, "http://example.org")
-      .setParam(PARAM_PROJECT_KEY, component.getDbKey())
+      .setParam(PARAM_PROJECT_KEY, component.getKey())
       .execute())
       .isInstanceOf(NotFoundException.class)
-      .hasMessageContaining("Project '" + component.getDbKey() + "' not found");
+      .hasMessageContaining("Project '" + component.getKey() + "' not found");
   }
 
   private void failIfNotAProjectWithUuid(ComponentDto root, ComponentDto component) {
@@ -282,7 +282,7 @@ public class CreateActionTest {
   private void createAndTest(ComponentDto project, String name, String url, String type) {
     ProjectLinks.CreateWsResponse response = ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_PROJECT_KEY, project.getDbKey())
+      .setParam(PARAM_PROJECT_KEY, project.getKey())
       .setParam(PARAM_NAME, name)
       .setParam(PARAM_URL, url)
       .executeProtobuf(ProjectLinks.CreateWsResponse.class);
index efdb8b69068273eacc18fc81f34bd8788774537d..892c5f30d8aca2dfb1a8e8c7bc698dc26d7f31d5 100644 (file)
@@ -243,10 +243,10 @@ public class SearchActionTest {
     ComponentDto branch = db.components().insertProjectBranch(project);
 
     assertThatThrownBy(() -> ws.newRequest()
-      .setParam(PARAM_PROJECT_KEY, branch.getDbKey())
+      .setParam(PARAM_PROJECT_KEY, branch.getKey())
       .execute())
       .isInstanceOf(NotFoundException.class)
-      .hasMessageContaining(format("Project '%s' not found", branch.getDbKey()));
+      .hasMessageContaining(format("Project '%s' not found", branch.getKey()));
   }
 
   @Test
@@ -292,7 +292,7 @@ public class SearchActionTest {
     userSession.logIn().addProjectPermission(USER, root);
 
     assertThatThrownBy(() -> ws.newRequest()
-      .setParam(PARAM_PROJECT_KEY, component.getDbKey())
+      .setParam(PARAM_PROJECT_KEY, component.getKey())
       .execute())
       .isInstanceOf(NotFoundException.class)
       .hasMessageContaining("Project '" + component.getKey() + "' not found");
index 02017927bce14687a806db7820699ef5db97a84d..8620a38a451f9fe354f8267500f0513e7962d340 100644 (file)
@@ -110,7 +110,7 @@ public class SearchActionTest {
   private static ProjectMeasuresDoc newDoc(ComponentDto project) {
     return new ProjectMeasuresDoc()
       .setId(project.uuid())
-      .setKey(project.getDbKey())
+      .setKey(project.getKey())
       .setName(project.name());
   }
 
index 902cebb7c1818699026b34fdd4f9b08c675f53da..f252d53598cfc0601b734d111d8ba0c004f57941 100644 (file)
@@ -153,7 +153,7 @@ public class SetActionTest {
 
   @Test
   public void fail_if_component_is_a_view() {
-    ComponentDto view = db.components().insertPrivatePortfolio(v -> v.setDbKey("VIEW_KEY"));
+    ComponentDto view = db.components().insertPrivatePortfolio(v -> v.setKey("VIEW_KEY"));
 
     String viewKey = view.getKey();
     assertThatThrownBy(() -> call(viewKey, "point-of-view"))
@@ -164,7 +164,7 @@ public class SetActionTest {
   @Test
   public void fail_if_component_is_a_module() {
     ComponentDto projectComponent = dbClient.componentDao().selectByUuid(dbSession, project.getUuid()).get();
-    ComponentDto module = db.components().insertComponent(newModuleDto(projectComponent).setDbKey("MODULE_KEY"));
+    ComponentDto module = db.components().insertComponent(newModuleDto(projectComponent).setKey("MODULE_KEY"));
 
     String moduleKey = module.getKey();
     assertThatThrownBy(() -> call(moduleKey, "modz"))
@@ -175,7 +175,7 @@ public class SetActionTest {
   @Test
   public void fail_if_component_is_a_file() {
     ComponentDto projectComponent = dbClient.componentDao().selectByUuid(dbSession, project.getUuid()).get();
-    ComponentDto file = db.components().insertComponent(newFileDto(projectComponent).setDbKey("FILE_KEY"));
+    ComponentDto file = db.components().insertComponent(newFileDto(projectComponent).setKey("FILE_KEY"));
 
     String fileKey = file.getKey();
     assertThatThrownBy(() -> call(fileKey, "secret"))
@@ -189,7 +189,7 @@ public class SetActionTest {
     userSession.logIn().addProjectPermission(USER, project);
     ComponentDto branch = db.components().insertProjectBranch(project);
 
-    String branchDbKey = branch.getDbKey();
+    String branchDbKey = branch.getKey();
     assertThatThrownBy(() -> call(branchDbKey, "secret"))
       .isInstanceOf(NotFoundException.class)
       .hasMessage(format("Project '%s' not found", branchDbKey));
index ca404418e58bf5a611e019a4efa1e3fe478c8d56..04c2565c6fc91cd76ee31842e7568d0ee5ff91ab 100644 (file)
@@ -167,10 +167,10 @@ public class DeselectActionTest {
     ComponentDto branch = db.components().insertProjectBranch(project);
 
     assertThatThrownBy(() -> ws.newRequest()
-      .setParam("projectKey", branch.getDbKey())
+      .setParam("projectKey", branch.getKey())
       .execute())
       .isInstanceOf(NotFoundException.class)
-      .hasMessageContaining(format("Project '%s' not found", branch.getDbKey()));
+      .hasMessageContaining(format("Project '%s' not found", branch.getKey()));
   }
 
   @Test
index a541dba0edcc4d7269048ff0d829b16644485572..1b5e676ac9010b586efd8d49dc931f45f0a81615 100644 (file)
@@ -197,9 +197,9 @@ public class GetByProjectActionTest {
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
     ComponentDto branch = db.components().insertProjectBranch(project);
 
-    assertThatThrownBy(() -> ws.newRequest().setParam("project", branch.getDbKey()).execute())
+    assertThatThrownBy(() -> ws.newRequest().setParam("project", branch.getKey()).execute())
       .isInstanceOf(NotFoundException.class)
-      .hasMessageContaining(format("Project '%s' not found", branch.getDbKey()));
+      .hasMessageContaining(format("Project '%s' not found", branch.getKey()));
   }
 
   private void logInAsProjectUser(ProjectDto project) {
index f3132c3aa397ffa3fe4bcb9a1ce1ce4469a30c1a..a193ae44a12951628e0701de314679741859ded7 100644 (file)
@@ -406,10 +406,10 @@ public class ProjectStatusActionTest {
     SnapshotDto snapshot = db.components().insertSnapshot(branch);
 
     assertThatThrownBy(() -> ws.newRequest()
-      .setParam(PARAM_PROJECT_KEY, branch.getDbKey())
+      .setParam(PARAM_PROJECT_KEY, branch.getKey())
       .execute())
       .isInstanceOf(NotFoundException.class)
-      .hasMessageContaining(format("Project '%s' not found", branch.getDbKey()));
+      .hasMessageContaining(format("Project '%s' not found", branch.getKey()));
   }
 
   @Test
index 44a609bdc757ed1096f7564bd1e8d64ec88b450b..f29daa0519aef5532d7766adf2c80e04f8244fbb 100644 (file)
@@ -180,7 +180,7 @@ public class SelectActionTest {
 
     assertThatThrownBy(() -> ws.newRequest()
       .setParam("gateId", qualityGate.getUuid())
-      .setParam("projectKey", project.getDbKey())
+      .setParam("projectKey", project.getKey())
       .execute())
       .isInstanceOf(ForbiddenException.class);
   }
@@ -193,7 +193,7 @@ public class SelectActionTest {
 
     assertThatThrownBy(() -> ws.newRequest()
       .setParam("gateId", qualityGate.getUuid())
-      .setParam("projectKey", project.getDbKey())
+      .setParam("projectKey", project.getKey())
       .execute())
       .isInstanceOf(ForbiddenException.class);
   }
@@ -207,10 +207,10 @@ public class SelectActionTest {
 
     assertThatThrownBy(() -> ws.newRequest()
       .setParam("gateId", qualityGate.getUuid())
-      .setParam("projectKey", branch.getDbKey())
+      .setParam("projectKey", branch.getKey())
       .execute())
       .isInstanceOf(NotFoundException.class)
-      .hasMessageContaining(format("Project '%s' not found", branch.getDbKey()));
+      .hasMessageContaining(format("Project '%s' not found", branch.getKey()));
   }
 
   private void assertSelected(QualityGateDto qualityGate, ComponentDto project) {
index a31d95fc0f9ddaf5b3addbceb846649b1680e282..89e3fd257c278c3305d48de0ce4d12da316666ad 100644 (file)
@@ -217,12 +217,12 @@ public class AddProjectActionTest {
 
     assertThatThrownBy(() -> {
       tester.newRequest()
-        .setParam("project", branch.getDbKey())
+        .setParam("project", branch.getKey())
         .setParam("profileKey", profile.getKee())
         .execute();
     })
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Project '%s' not found", branch.getDbKey()));
+      .hasMessage(format("Project '%s' not found", branch.getKey()));
   }
 
   private void assertProjectIsAssociatedToProfile(ProjectDto project, QProfileDto profile) {
index 45683a0bb18e979ce772fde473b321128aba1151..8ee6be6c799f6708ef37c49cba497c46fd3dced8 100644 (file)
@@ -205,7 +205,7 @@ public class RemoveProjectActionTest {
 
     assertThatThrownBy(() -> {
       ws.newRequest()
-        .setParam("project", project.getDbKey())
+        .setParam("project", project.getKey())
         .setParam("language", "xoo")
         .setParam("qualityProfile", "unknown")
         .execute();
@@ -223,13 +223,13 @@ public class RemoveProjectActionTest {
 
     assertThatThrownBy(() -> {
       ws.newRequest()
-        .setParam("project", branch.getDbKey())
+        .setParam("project", branch.getKey())
         .setParam("language", profile.getLanguage())
         .setParam("qualityProfile", profile.getName())
         .execute();
     })
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Project '%s' not found", branch.getDbKey()));
+      .hasMessage(format("Project '%s' not found", branch.getKey()));
   }
 
   private void assertProjectIsAssociatedToProfile(ProjectDto project, QProfileDto profile) {
index 8e9b9131ed47ebe71d58a1238c202bfeb32f1638..8dac5638c8ae05f3e253b62f0a893bad5b648d8d 100644 (file)
@@ -282,7 +282,7 @@ public class ListDefinitionsActionTest {
       .onQualifiers(PROJECT)
       .build());
 
-    ListDefinitionsWsResponse result = executeRequest(project.getDbKey());
+    ListDefinitionsWsResponse result = executeRequest(project.getKey());
 
     assertThat(result.getDefinitionsList()).hasSize(1);
   }
@@ -310,7 +310,7 @@ public class ListDefinitionsActionTest {
       PropertyDefinition.builder("only-on-project").onlyOnQualifiers(PROJECT).build(),
       PropertyDefinition.builder("only-on-module").onlyOnQualifiers(MODULE).build()));
 
-    ListDefinitionsWsResponse result = executeRequest(project.getDbKey());
+    ListDefinitionsWsResponse result = executeRequest(project.getKey());
 
     assertThat(result.getDefinitionsList()).extracting("key").containsOnly("global-and-project", "only-on-project");
   }
@@ -380,7 +380,7 @@ public class ListDefinitionsActionTest {
       PropertyDefinition.builder("foo").onQualifiers(PROJECT).build(),
       PropertyDefinition.builder("secret.secured").onQualifiers(PROJECT).build()));
 
-    ListDefinitionsWsResponse result = executeRequest(project.getDbKey());
+    ListDefinitionsWsResponse result = executeRequest(project.getKey());
 
     assertThat(result.getDefinitionsList()).extracting(Definition::getKey).containsOnly("foo", "secret.secured");
   }
@@ -390,7 +390,7 @@ public class ListDefinitionsActionTest {
     userSession.logIn("project-admin").addProjectPermission(CODEVIEWER, project);
     propertyDefinitions.addComponent(PropertyDefinition.builder("foo").build());
 
-    assertThatThrownBy(() -> executeRequest(project.getDbKey()))
+    assertThatThrownBy(() -> executeRequest(project.getKey()))
       .isInstanceOf(ForbiddenException.class);
   }
 
index 954f7ea4468a9c07468163aa23d802346dde26c2..bfd3ba794f816966cb046d50e99327402bde4750 100644 (file)
@@ -376,11 +376,11 @@ public class ResetActionTest {
     assertThatThrownBy(() -> {
       ws.newRequest()
         .setParam("keys", "foo")
-        .setParam("component", branch.getDbKey())
+        .setParam("component", branch.getKey())
         .execute();
     })
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Component key '%s' not found", branch.getDbKey()));
+      .hasMessage(format("Component key '%s' not found", branch.getKey()));
   }
 
   @Test
@@ -451,11 +451,11 @@ public class ResetActionTest {
   }
 
   private void executeRequestOnProjectSetting(String key) {
-    executeRequest(key, project.getDbKey());
+    executeRequest(key, project.getKey());
   }
 
   private void executeRequestOnComponentSetting(String key, ComponentDto componentDto) {
-    executeRequest(key, componentDto.getDbKey());
+    executeRequest(key, componentDto.getKey());
   }
 
   private void executeRequest(String key, @Nullable String componentKey) {
index c1f00e8471596a61b0a40b924d7b37ae201344f8..59e1e7250911be64aba9815bee41ce74d88a99bb 100644 (file)
@@ -150,7 +150,7 @@ public class SetActionTest {
     ComponentDto project = db.components().insertPrivateProject();
     logInAsProjectAdministrator(project);
 
-    callForProjectSettingByKey("my.key", "my project value", project.getDbKey());
+    callForProjectSettingByKey("my.key", "my project value", project.getKey());
 
     assertGlobalSetting("my.key", "my global value");
     assertComponentSetting("my.key", "my project value", project.uuid());
@@ -162,7 +162,7 @@ public class SetActionTest {
     ComponentDto project = db.components().insertPrivateProject();
     logInAsProjectAdministrator(project);
 
-    callForProjectSettingByKey("my.key", "my value", project.getDbKey());
+    callForProjectSettingByKey("my.key", "my value", project.getKey());
 
     assertComponentSetting("my.key", "my value", project.uuid());
   }
@@ -177,7 +177,7 @@ public class SetActionTest {
     assertComponentSetting("my.key", "my project value", project.uuid());
     logInAsProjectAdministrator(project);
 
-    callForProjectSettingByKey("my.key", "my new project value", project.getDbKey());
+    callForProjectSettingByKey("my.key", "my new project value", project.getKey());
 
     assertComponentSetting("my.key", "my new project value", project.uuid());
   }
@@ -317,10 +317,10 @@ public class SetActionTest {
     callForComponentPropertySet("my.key", newArrayList(
       GSON.toJson(ImmutableMap.of("firstField", "firstValue", "secondField", "secondValue")),
       GSON.toJson(ImmutableMap.of("firstField", "anotherFirstValue", "secondField", "anotherSecondValue"))),
-      project.getDbKey());
+      project.getKey());
 
     assertThat(dbClient.propertiesDao().selectGlobalProperties(dbSession)).hasSize(3);
-    assertThat(dbClient.propertiesDao().selectProjectProperties(dbSession, project.getDbKey())).hasSize(5);
+    assertThat(dbClient.propertiesDao().selectProjectProperties(dbSession, project.getKey())).hasSize(5);
     assertGlobalSetting("my.key", "1");
     assertGlobalSetting("my.key.1.firstField", "oldFirstValue");
     assertGlobalSetting("my.key.1.secondField", "oldSecondValue");
@@ -803,7 +803,7 @@ public class SetActionTest {
 
     assertThatThrownBy(() -> {
       logInAsProjectAdministrator(view);
-      callForProjectSettingByKey("my.key", "My Value", view.getDbKey());
+      callForProjectSettingByKey("my.key", "My Value", view.getKey());
     })
       .isInstanceOf(BadRequestException.class)
       .hasMessage("Setting 'my.key' cannot be set on a View");
@@ -827,7 +827,7 @@ public class SetActionTest {
     logInAsProjectAdministrator(project);
 
     assertThatThrownBy(() -> {
-      callForProjectSettingByKey("my.key", "My Value", file.getDbKey());
+      callForProjectSettingByKey("my.key", "My Value", file.getKey());
     })
       .isInstanceOf(BadRequestException.class)
       .hasMessage("Setting 'my.key' cannot be set on a CptLabel");
@@ -884,7 +884,7 @@ public class SetActionTest {
   private void succeedForPropertyWithoutDefinitionAndValidComponent(ComponentDto project, ComponentDto module) {
     logInAsProjectAdministrator(project);
 
-    callForProjectSettingByKey("my.key", "My Value", module.getDbKey());
+    callForProjectSettingByKey("my.key", "My Value", module.getKey());
 
     assertComponentSetting("my.key", "My Value", module.uuid());
   }
@@ -894,7 +894,7 @@ public class SetActionTest {
     logInAsProjectAdministrator(root);
 
     assertThatThrownBy(() -> {
-      callForProjectSettingByKey("my.key", "My Value", component.getDbKey());
+      callForProjectSettingByKey("my.key", "My Value", component.getKey());
     })
       .isInstanceOf(BadRequestException.class)
       .hasMessage("Setting 'my.key' cannot be set on a QualifierLabel");
@@ -1154,7 +1154,7 @@ public class SetActionTest {
 
     assertThatThrownBy(() -> {
       callForComponentPropertySet("my.key", newArrayList(
-        GSON.toJson(ImmutableMap.of("firstField", "firstValue"))), project.getDbKey());
+        GSON.toJson(ImmutableMap.of("firstField", "firstValue"))), project.getKey());
     })
       .isInstanceOf(BadRequestException.class)
       .hasMessage("Setting 'my.key' cannot be set on a Project");
@@ -1167,10 +1167,10 @@ public class SetActionTest {
     ComponentDto branch = db.components().insertProjectBranch(project);
 
     assertThatThrownBy(() -> {
-      callForProjectSettingByKey("my.key", "My Value", branch.getDbKey());
+      callForProjectSettingByKey("my.key", "My Value", branch.getKey());
     })
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Component key '%s' not found", branch.getDbKey()));
+      .hasMessage(format("Component key '%s' not found", branch.getKey()));
   }
 
   @Test
index d1b67a3181b168f92c69312ac891f35a1dd3a983..20703ac513a6b43dc5a1e106f66d849c3512ef0c 100644 (file)
@@ -748,7 +748,7 @@ public class ValuesActionTest {
     definitions.addComponent(PropertyDefinition.builder("foo").build());
 
     assertThatThrownBy(() -> {
-      executeRequest(project.getDbKey(), "foo");
+      executeRequest(project.getKey(), "foo");
     })
       .isInstanceOf(ForbiddenException.class);
   }
@@ -828,11 +828,11 @@ public class ValuesActionTest {
     assertThatThrownBy(() -> {
       newTester().newRequest()
         .setParam("keys", "foo")
-        .setParam("component", branch.getDbKey())
+        .setParam("component", branch.getKey())
         .execute();
     })
       .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Component key '%s' not found", branch.getDbKey()));
+      .hasMessage(format("Component key '%s' not found", branch.getKey()));
   }
 
   @Test
@@ -894,11 +894,11 @@ public class ValuesActionTest {
   }
 
   private ValuesWsResponse executeRequestForComponentProperties(ComponentDto componentDto, String... keys) {
-    return executeRequest(componentDto.getDbKey(), keys);
+    return executeRequest(componentDto.getKey(), keys);
   }
 
   private ValuesWsResponse executeRequestForProjectProperties(String... keys) {
-    return executeRequest(project.getDbKey(), keys);
+    return executeRequest(project.getKey(), keys);
   }
 
   private ValuesWsResponse executeRequestForGlobalProperties(String... keys) {
index b44b1dc775417ed0163fe8de75244230bafe63af..66c679194eb08593cbff6a453be6aa4db1976526 100644 (file)
@@ -61,7 +61,7 @@ public class IndexActionTest {
     insertFileWithData(file, newData("public class HelloWorld {", "}"));
 
     TestResponse request = tester.newRequest()
-      .setParam("resource", file.getDbKey())
+      .setParam("resource", file.getKey())
       .execute();
 
     assertJson(request.getInput()).isSimilarTo("[\n" +
@@ -80,7 +80,7 @@ public class IndexActionTest {
     insertFileWithData(file, newData("/**", " */", "public class HelloWorld {", "}", "", "foo"));
 
     TestResponse request = tester.newRequest()
-      .setParam("resource", file.getDbKey())
+      .setParam("resource", file.getKey())
       .setParam("from", "3")
       .setParam("to", "5")
       .execute();
@@ -100,7 +100,7 @@ public class IndexActionTest {
     ComponentDto file = db.components().insertComponent(newFileDto(project));
 
     assertThatThrownBy(() -> tester.newRequest()
-      .setParam("resource", file.getDbKey())
+      .setParam("resource", file.getKey())
       .execute())
       .isInstanceOf(ForbiddenException.class);
   }
@@ -120,10 +120,10 @@ public class IndexActionTest {
     userSession.addProjectPermission(USER, project);
 
     assertThatThrownBy(() -> tester.newRequest()
-      .setParam("resource", branch.getDbKey())
+      .setParam("resource", branch.getKey())
       .execute())
       .isInstanceOf(NotFoundException.class)
-      .hasMessageContaining(format("Component key '%s' not found", branch.getDbKey()));
+      .hasMessageContaining(format("Component key '%s' not found", branch.getKey()));
   }
 
   private static DbFileSources.Data newData(String... lines) {
@@ -140,7 +140,7 @@ public class IndexActionTest {
   private void insertFileWithData(ComponentDto file, DbFileSources.Data fileData) {
     db.getDbClient().fileSourceDao().insert(db.getSession(), new FileSourceDto()
       .setUuid(Uuids.createFast())
-      .setProjectUuid(file.projectUuid())
+      .setProjectUuid(file.branchUuid())
       .setFileUuid(file.uuid())
       .setSourceData(fileData));
     db.commit();
index c886d4a1ad3e4bdc649d1d23630cd1859ffbf75f..fbbf478225056ac743ee69bd4a6831d97c99abb7 100644 (file)
@@ -186,7 +186,7 @@ public class LinesActionTest {
   @Test
   public void fail_when_file_is_removed() {
     ComponentDto privateProject = db.components().insertPrivateProject();
-    ComponentDto file = newFileDto(privateProject).setDbKey("file-key").setEnabled(false);
+    ComponentDto file = newFileDto(privateProject).setKey("file-key").setEnabled(false);
     db.components().insertComponents(file);
     setUserWithValidPermission(file);
 
@@ -334,10 +334,10 @@ public class LinesActionTest {
     userSession.addProjectPermission(UserRole.USER, project);
 
     assertThatThrownBy(() -> tester.newRequest()
-      .setParam("key", branch.getDbKey())
+      .setParam("key", branch.getKey())
       .execute())
       .isInstanceOf(NotFoundException.class)
-      .hasMessageContaining(format("Component key '%s' not found", branch.getDbKey()));
+      .hasMessageContaining(format("Component key '%s' not found", branch.getKey()));
   }
 
   @Test
@@ -393,7 +393,7 @@ public class LinesActionTest {
     ComponentDto file = insertFile(project);
     db.getDbClient().fileSourceDao().insert(db.getSession(), new FileSourceDto()
       .setUuid(Uuids.createFast())
-      .setProjectUuid(project.projectUuid())
+      .setProjectUuid(project.branchUuid())
       .setFileUuid(file.uuid())
       .setSourceData(fileData));
     db.commit();
index a37f173920f080f82a60fa35745864e88a3ea850..94f61d8448a3f6068b9d2fe3aca23ddc87fd65e0 100644 (file)
@@ -67,7 +67,7 @@ public class ScmActionTest {
   @Before
   public void setUp() {
     project = dbTester.components().insertPrivateProject(PROJECT_UUID);
-    file = ComponentTesting.newFileDto(project, null, FILE_UUID).setDbKey(FILE_KEY);
+    file = ComponentTesting.newFileDto(project, null, FILE_UUID).setKey(FILE_KEY);
     dbClient.componentDao().insert(dbTester.getSession(), file);
     dbTester.getSession().commit();
   }
@@ -222,10 +222,10 @@ public class ScmActionTest {
     userSessionRule.addProjectPermission(UserRole.CODEVIEWER, project);
 
     assertThatThrownBy(() -> tester.newRequest()
-      .setParam("key", branch.getDbKey())
+      .setParam("key", branch.getKey())
       .execute())
       .isInstanceOf(NotFoundException.class)
-      .hasMessageContaining(format("Component key '%s' not found", branch.getDbKey()));
+      .hasMessageContaining(format("Component key '%s' not found", branch.getKey()));
   }
 
   private DbFileSources.Line newSourceLine(String author, String revision, Date date, int line) {
index 78695eb8f2bfef3aa0ddae52907b0303750950ef..999dd32e094e5b20e7ebe02c1bdfd7489f267966 100644 (file)
@@ -132,7 +132,7 @@ public class ComponentActionTest {
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
     init();
 
-    verifySuccess(project.getDbKey());
+    verifySuccess(project.getKey());
   }
 
   @Test
@@ -141,7 +141,7 @@ public class ComponentActionTest {
     userSession.logIn().setSystemAdministrator();
     init();
 
-    verifySuccess(project.getDbKey());
+    verifySuccess(project.getKey());
   }
 
   @Test
@@ -150,7 +150,7 @@ public class ComponentActionTest {
     userSession.addProjectPermission(UserRole.USER, project);
     init();
 
-    executeAndVerify(project.getDbKey(), "return_component_info_when_anonymous_no_snapshot.json");
+    executeAndVerify(project.getKey(), "return_component_info_when_anonymous_no_snapshot.json");
   }
 
   @Test
@@ -162,7 +162,7 @@ public class ComponentActionTest {
     userSession.logIn(user).addProjectPermission(UserRole.USER, project);
     init();
 
-    executeAndVerify(project.getDbKey(), "return_component_info_with_favourite.json");
+    executeAndVerify(project.getKey(), "return_component_info_with_favourite.json");
   }
 
   @Test
@@ -211,7 +211,7 @@ public class ComponentActionTest {
       .getInput();
 
     assertJson(json).isSimilarTo("{" +
-      "  \"key\": \"" + subportfolio.getDbKey() + "\"," +
+      "  \"key\": \"" + subportfolio.getKey() + "\"," +
       "  \"isFavorite\": true," +
       "  \"id\": \"" + subportfolio.uuid() + "\"," +
       "  \"name\": \"" + subportfolio.name() + "\"" +
@@ -238,7 +238,7 @@ public class ComponentActionTest {
       .getInput();
 
     assertJson(json).isSimilarTo("{" +
-      "  \"key\": \"" + portfolio.getDbKey() + "\"," +
+      "  \"key\": \"" + portfolio.getKey() + "\"," +
       "  \"isFavorite\": true," +
       "  \"id\": \"" + portfolio.uuid() + "\"," +
       "  \"name\": \"" + portfolio.name() + "\"" +
@@ -269,13 +269,13 @@ public class ComponentActionTest {
     init();
 
     // access to all projects (project11, project12)
-    String json = execute(application1.getDbKey());
+    String json = execute(application1.getKey());
     assertJson(json).isSimilarTo("{" +
       "\"canBrowseAllChildProjects\":true" +
       "}");
 
     // access to some projects (project11)
-    json = execute(application2.getDbKey());
+    json = execute(application2.getKey());
     assertJson(json).isSimilarTo("{" +
       "\"canBrowseAllChildProjects\":false" +
       "}");
@@ -290,13 +290,13 @@ public class ComponentActionTest {
     userSession.addProjectPermission(UserRole.USER, project);
     init();
 
-    executeAndVerify(project.getDbKey(), "return_component_info_when_snapshot.json");
+    executeAndVerify(project.getKey(), "return_component_info_when_snapshot.json");
   }
 
   @Test
   public void return_component_info_when_file_on_master() {
     db.qualityGates().createDefaultQualityGate();
-    ComponentDto main = componentDbTester.insertPrivateProject(p -> p.setName("Sample").setDbKey("sample"));
+    ComponentDto main = componentDbTester.insertPrivateProject(p -> p.setName("Sample").setKey("sample"));
     userSession.addProjectPermission(UserRole.USER, main);
     init();
 
@@ -305,15 +305,15 @@ public class ComponentActionTest {
     ComponentDto fileDto = componentDbTester.insertComponent(newFileDto(main, dirDto)
       .setUuid("abcd")
       .setName("Main.xoo")
-      .setDbKey("sample:src/Main.xoo"));
+      .setKey("sample:src/Main.xoo"));
 
-    executeAndVerify(fileDto.getDbKey(), "return_component_info_when_file_on_master.json");
+    executeAndVerify(fileDto.getKey(), "return_component_info_when_file_on_master.json");
   }
 
   @Test
   public void return_component_info_when_file_on_branch() {
     db.qualityGates().createDefaultQualityGate();
-    ComponentDto project = componentDbTester.insertPrivateProject(p -> p.setName("Sample").setDbKey("sample"));
+    ComponentDto project = componentDbTester.insertPrivateProject(p -> p.setName("Sample").setKey("sample"));
     ComponentDto branch = componentDbTester.insertProjectBranch(project, b -> b.setKey("feature1"));
     userSession.addProjectPermission(UserRole.USER, project);
     init();
@@ -363,12 +363,12 @@ public class ComponentActionTest {
     userSession.addProjectPermission(UserRole.USER, project);
     init();
 
-    executeAndVerify(project.getDbKey(), "return_quality_profiles.json");
+    executeAndVerify(project.getKey(), "return_quality_profiles.json");
 
     db.getDbClient().qualityProfileDao().deleteOrgQProfilesByUuids(db.getSession(), ImmutableSet.of(qp1.getKee(), qp2.getKee()));
     db.commit();
 
-    executeAndVerify(project.getDbKey(), "return_deleted_quality_profiles.json");
+    executeAndVerify(project.getKey(), "return_deleted_quality_profiles.json");
   }
 
   @Test
@@ -377,7 +377,7 @@ public class ComponentActionTest {
     userSession.addProjectPermission(UserRole.USER, project);
     init();
 
-    executeAndVerify(project.getDbKey(), "return_empty_quality_profiles_when_no_measure.json");
+    executeAndVerify(project.getKey(), "return_empty_quality_profiles_when_no_measure.json");
   }
 
   @Test
@@ -418,7 +418,7 @@ public class ComponentActionTest {
     userSession.addProjectPermission(UserRole.USER, project);
     init();
 
-    executeAndVerify(project.getDbKey(), "return_default_quality_gate.json");
+    executeAndVerify(project.getKey(), "return_default_quality_gate.json");
   }
 
   @Test
@@ -427,7 +427,7 @@ public class ComponentActionTest {
     userSession.anonymous().addProjectPermission(UserRole.USER, project);
     init(createPages());
 
-    executeAndVerify(project.getDbKey(), "return_extensions.json");
+    executeAndVerify(project.getKey(), "return_extensions.json");
   }
 
   @Test
@@ -446,7 +446,7 @@ public class ComponentActionTest {
     init(page);
 
     String result = ws.newRequest()
-      .setParam(PARAM_COMPONENT, application.getDbKey())
+      .setParam(PARAM_COMPONENT, application.getKey())
       .execute().getInput();
 
     assertThat(result).contains("my_plugin/app_page");
@@ -460,7 +460,7 @@ public class ComponentActionTest {
       .addProjectPermission(UserRole.ADMIN, project);
     init(createPages());
 
-    executeAndVerify(project.getDbKey(), "return_extensions_for_admin.json");
+    executeAndVerify(project.getKey(), "return_extensions_for_admin.json");
   }
 
   @Test
@@ -484,7 +484,7 @@ public class ComponentActionTest {
       .build();
     init(page1, page2);
 
-    executeAndVerify(project.getDbKey(), "return_configuration_for_admin.json");
+    executeAndVerify(project.getKey(), "return_configuration_for_admin.json");
   }
 
   @Test
@@ -505,7 +505,7 @@ public class ComponentActionTest {
       .thenReturn(projectResourceType);
     init();
 
-    executeAndVerify(project.getDbKey(), "return_configuration_with_all_properties.json");
+    executeAndVerify(project.getKey(), "return_configuration_with_all_properties.json");
   }
 
   @Test
@@ -516,7 +516,7 @@ public class ComponentActionTest {
       .addPermission(ADMINISTER_QUALITY_PROFILES);
     init();
 
-    executeAndVerify(project.getDbKey(), "return_configuration_for_quality_profile_admin.json");
+    executeAndVerify(project.getKey(), "return_configuration_for_quality_profile_admin.json");
   }
 
   @Test
@@ -527,7 +527,7 @@ public class ComponentActionTest {
       .addPermission(ADMINISTER_QUALITY_GATES);
     init();
 
-    executeAndVerify(project.getDbKey(), "return_configuration_for_quality_gate_admin.json");
+    executeAndVerify(project.getKey(), "return_configuration_for_quality_gate_admin.json");
   }
 
   @Test
@@ -538,7 +538,7 @@ public class ComponentActionTest {
     userSessionRule.addProjectPermission(UserRole.USER, project);
     userSessionRule.addProjectPermission(UserRole.ADMIN, project);
 
-    String json = execute(project.getDbKey());
+    String json = execute(project.getKey());
 
     assertJson(json).isSimilarTo("{\n" +
       "  \"configuration\": {\n" +
@@ -566,7 +566,7 @@ public class ComponentActionTest {
     userSessionRule.addProjectPermission(UserRole.USER, project);
     userSessionRule.addProjectPermission(UserRole.ADMIN, project);
 
-    String json = execute(project.getDbKey());
+    String json = execute(project.getKey());
 
     assertJson(json).isSimilarTo("{\n" +
       "  \"configuration\": {\n" +
@@ -592,7 +592,7 @@ public class ComponentActionTest {
     init();
     userSessionRule.addProjectPermission(UserRole.USER, project);
 
-    String json = execute(project.getDbKey());
+    String json = execute(project.getKey());
 
     assertThat(json).doesNotContain("\"configuration\"");
   }
@@ -600,15 +600,15 @@ public class ComponentActionTest {
   @Test
   public void return_bread_crumbs_on_several_levels() {
     ComponentDto project = insertProject();
-    ComponentDto module = componentDbTester.insertComponent(newModuleDto("bcde", project).setDbKey("palap").setName("Palap"));
+    ComponentDto module = componentDbTester.insertComponent(newModuleDto("bcde", project).setKey("palap").setName("Palap"));
     ComponentDto directory = componentDbTester.insertComponent(newDirectory(module, "src/main/xoo"));
     ComponentDto file = componentDbTester.insertComponent(newFileDto(directory, directory, "cdef").setName("Source.xoo")
-      .setDbKey("palap:src/main/xoo/Source.xoo")
+      .setKey("palap:src/main/xoo/Source.xoo")
       .setPath(directory.path()));
     userSession.addProjectPermission(UserRole.USER, project);
     init();
 
-    executeAndVerify(file.getDbKey(), "return_bread_crumbs_on_several_levels.json");
+    executeAndVerify(file.getKey(), "return_bread_crumbs_on_several_levels.json");
   }
 
   @Test
@@ -617,7 +617,7 @@ public class ComponentActionTest {
     userSession.addProjectPermission(UserRole.ADMIN, project);
     init(createPages());
 
-    execute(project.getDbKey());
+    execute(project.getKey());
   }
 
   @Test
@@ -629,7 +629,7 @@ public class ComponentActionTest {
     userSession.logIn()
       .addProjectPermission(UserRole.ADMIN, project)
       .addPermission(GlobalPermission.ADMINISTER);
-    assertJson(execute(project.getDbKey())).isSimilarTo("{\"visibility\": \"private\"}");
+    assertJson(execute(project.getKey())).isSimilarTo("{\"visibility\": \"private\"}");
   }
 
   @Test
@@ -641,7 +641,7 @@ public class ComponentActionTest {
     userSession.logIn()
       .addProjectPermission(UserRole.ADMIN, project)
       .addPermission(GlobalPermission.ADMINISTER);
-    assertJson(execute(project.getDbKey())).isSimilarTo("{\"visibility\": \"public\"}");
+    assertJson(execute(project.getKey())).isSimilarTo("{\"visibility\": \"public\"}");
   }
 
   @Test
@@ -653,12 +653,12 @@ public class ComponentActionTest {
     userSession.logIn()
       .addProjectPermission(UserRole.ADMIN, project)
       .addPermission(GlobalPermission.ADMINISTER);
-    assertJson(execute(project.getDbKey())).isSimilarTo("{\"configuration\": {\"canApplyPermissionTemplate\": true}}");
+    assertJson(execute(project.getKey())).isSimilarTo("{\"configuration\": {\"canApplyPermissionTemplate\": true}}");
 
     userSession.logIn()
       .addProjectPermission(UserRole.ADMIN, project);
 
-    assertJson(execute(project.getDbKey())).isSimilarTo("{\"configuration\": {\"canApplyPermissionTemplate\": false}}");
+    assertJson(execute(project.getKey())).isSimilarTo("{\"configuration\": {\"canApplyPermissionTemplate\": false}}");
   }
 
   @Test
@@ -668,7 +668,7 @@ public class ComponentActionTest {
     init(createPages());
 
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
-    assertJson(execute(project.getDbKey())).isSimilarTo("{\"configuration\": {\"canUpdateProjectVisibilityToPrivate\": true}}");
+    assertJson(execute(project.getKey())).isSimilarTo("{\"configuration\": {\"canUpdateProjectVisibilityToPrivate\": true}}");
   }
 
   @Test
@@ -696,7 +696,7 @@ public class ComponentActionTest {
     init();
     userSession.logIn();
 
-    String projectDbKey = project.getDbKey();
+    String projectDbKey = project.getKey();
     assertThatThrownBy(() -> execute(projectDbKey))
       .isInstanceOf(ForbiddenException.class);
   }
@@ -705,7 +705,7 @@ public class ComponentActionTest {
   public void test_example_response() {
     init(createPages());
     ComponentDto project = newPrivateProjectDto("ABCD")
-      .setDbKey("org.codehaus.sonar:sonar")
+      .setKey("org.codehaus.sonar:sonar")
       .setName("Sonarqube")
       .setDescription("Open source platform for continuous inspection of code quality");
     componentDbTester.insertPrivateProject(project);
@@ -727,7 +727,7 @@ public class ComponentActionTest {
       .addProjectPermission(UserRole.USER, project)
       .addProjectPermission(UserRole.ADMIN, project);
 
-    String result = execute(project.getDbKey());
+    String result = execute(project.getKey());
     assertJson(result).ignoreFields("snapshotDate", "canBrowseAllChildProjects", "key", "qualityGate.key").isSimilarTo(ws.getDef().responseExampleAsString());
   }
 
@@ -756,7 +756,7 @@ public class ComponentActionTest {
   @Test
   public void fail_on_module_key_as_param() {
     ComponentDto project = insertProject();
-    ComponentDto module = componentDbTester.insertComponent(newModuleDto("bcde", project).setDbKey("palap").setName("Palap"));
+    ComponentDto module = componentDbTester.insertComponent(newModuleDto("bcde", project).setKey("palap").setName("Palap"));
     init();
 
     assertThatThrownBy(() -> execute(module.getKey()))
@@ -766,18 +766,18 @@ public class ComponentActionTest {
   @Test
   public void fail_on_directory_key_as_param() {
     ComponentDto project = insertProject();
-    ComponentDto module = componentDbTester.insertComponent(newModuleDto("bcde", project).setDbKey("palap").setName("Palap"));
+    ComponentDto module = componentDbTester.insertComponent(newModuleDto("bcde", project).setKey("palap").setName("Palap"));
     ComponentDto directory = componentDbTester.insertComponent(newDirectory(module, "src/main/xoo"));
     userSession.addProjectPermission(UserRole.USER, project);
     init();
 
-    assertThatThrownBy(() -> execute(directory.getDbKey()))
+    assertThatThrownBy(() -> execute(directory.getKey()))
       .isInstanceOf(BadRequestException.class);
   }
 
   private ComponentDto insertProject() {
     db.qualityGates().createDefaultQualityGate();
-    return db.components().insertPrivateProject("abcd", p -> p.setDbKey("polop")
+    return db.components().insertPrivateProject("abcd", p -> p.setKey("polop")
       .setName("Polop")
       .setDescription("test project")
       .setQualifier(Qualifiers.PROJECT)
index 8707a53595b9404bc0e2309dd046f903592f3326..5faba1a34bce3c8c4e9889e5276117b79107f4f2 100644 (file)
@@ -205,7 +205,7 @@ public class CurrentActionTest {
 
   @Test
   public void json_example() {
-    ComponentDto componentDto = db.components().insertPrivateProject(u -> u.setUuid("UUID-of-the-death-star").setDbKey("death-star-key"));
+    ComponentDto componentDto = db.components().insertPrivateProject(u -> u.setUuid("UUID-of-the-death-star").setKey("death-star-key"));
     UserDto obiwan = db.users().insertUser(user -> user
       .setLogin("obiwan.kenobi")
       .setName("Obiwan Kenobi")
index 7bdfa6ebc003c1f96f0af4f50df29f7d874d036d..df5e0bf9c813ec02b4bb6bef3cac7ee7a34919d2 100644 (file)
@@ -68,7 +68,7 @@ public class SearchActionTest {
 
   @Test
   public void search_json_example() {
-    ComponentDto project1 = db.components().insertPublicProject(p -> p.setDbKey("project-1").setName("Project 1"));
+    ComponentDto project1 = db.components().insertPublicProject(p -> p.setKey("project-1").setName("Project 1"));
     UserDto user1 = db.users().insertUser(u -> u.setLogin("grace.hopper"));
     UserDto user2 = db.users().insertUser(u -> u.setLogin("ada.lovelace"));
     db.users().insertToken(user1, t -> t.setName("Project scan on Travis").setCreatedAt(1448523067221L));
index f139d6c97808a848227d34c73181bd0cc07fd0fb..3ac6ec2bb19d3dced6b7184a01764ee30ee0483c 100644 (file)
@@ -96,7 +96,7 @@ public class CreateActionTest {
   @Test
   public void create_a_webhook_with_400_length_project_key() {
     String longProjectKey = generateStringWithLength(400);
-    ComponentDto project = componentDbTester.insertPrivateProject(componentDto -> componentDto.setDbKey(longProjectKey));
+    ComponentDto project = componentDbTester.insertPrivateProject(componentDto -> componentDto.setKey(longProjectKey));
 
     userSession.logIn().addProjectPermission(ADMIN, project);
 
index 83a00865dfd6622cadefaf69c97c8964d207e352..6215f1416a22defbe9c379610dec02d229194f30 100644 (file)
@@ -65,8 +65,8 @@ public class WebhookDeliveriesActionTest {
     ComponentFinder componentFinder = TestComponentFinder.from(db);
     WebhookDeliveriesAction underTest = new WebhookDeliveriesAction(dbClient, userSession, componentFinder);
     ws = new WsActionTester(underTest);
-    project = db.components().insertPrivateProject(c -> c.setDbKey("my-project"));
-    otherProject = db.components().insertPrivateProject(c -> c.setDbKey("other-project"));
+    project = db.components().insertPrivateProject(c -> c.setKey("my-project"));
+    otherProject = db.components().insertPrivateProject(c -> c.setKey("other-project"));
   }
 
   @Test
@@ -89,7 +89,7 @@ public class WebhookDeliveriesActionTest {
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
 
     Webhooks.DeliveriesWsResponse response = ws.newRequest()
-      .setParam("componentKey", project.getDbKey())
+      .setParam("componentKey", project.getKey())
       .executeProtobuf(Webhooks.DeliveriesWsResponse.class);
 
     assertThat(response.getDeliveriesCount()).isZero();
@@ -134,7 +134,7 @@ public class WebhookDeliveriesActionTest {
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
 
     String json = ws.newRequest()
-      .setParam("componentKey", project.getDbKey())
+      .setParam("componentKey", project.getKey())
       .execute()
       .getInput();
 
@@ -184,10 +184,10 @@ public class WebhookDeliveriesActionTest {
       .containsOnly(dto1.getUuid(), dto2.getUuid(), dto4.getUuid(), dto5.getUuid());
     assertThat(response.getDeliveriesList()).extracting(Webhooks.Delivery::getId, Webhooks.Delivery::getComponentKey)
       .containsOnly(
-        tuple(dto1.getUuid(), project.getDbKey()),
-        tuple(dto2.getUuid(), project.getDbKey()),
-        tuple(dto4.getUuid(), otherProject.getDbKey()),
-        tuple(dto5.getUuid(), otherProject.getDbKey()));
+        tuple(dto1.getUuid(), project.getKey()),
+        tuple(dto2.getUuid(), project.getKey()),
+        tuple(dto4.getUuid(), otherProject.getKey()),
+        tuple(dto5.getUuid(), otherProject.getKey()));
   }
 
   @Test
@@ -256,7 +256,7 @@ public class WebhookDeliveriesActionTest {
     userSession.logIn().addProjectPermission(UserRole.USER, project);
 
     TestRequest request = ws.newRequest()
-      .setParam("componentKey", project.getDbKey());
+      .setParam("componentKey", project.getKey());
     assertThatThrownBy(request::execute)
       .isInstanceOf(ForbiddenException.class)
       .hasMessage("Insufficient privileges");
@@ -282,7 +282,7 @@ public class WebhookDeliveriesActionTest {
     userSession.logIn();
 
     TestRequest request = ws.newRequest()
-      .setParam("componentKey", project.getDbKey())
+      .setParam("componentKey", project.getKey())
       .setParam("ceTaskId", "t1");
     assertThatThrownBy(request::execute)
       .isInstanceOf(IllegalArgumentException.class)
@@ -294,7 +294,7 @@ public class WebhookDeliveriesActionTest {
     userSession.logIn();
 
     TestRequest request = ws.newRequest()
-      .setParam("componentKey", project.getDbKey())
+      .setParam("componentKey", project.getKey())
       .setParam("webhook", "wh-uuid");
     assertThatThrownBy(request::execute)
       .isInstanceOf(IllegalArgumentException.class)
index fe2986a01b1f24f26352eac539797b37cc9367c8..53e6d7c42c0d89351013a533b78a69ff72806972 100644 (file)
@@ -61,7 +61,7 @@ public class WebhookDeliveryActionTest {
     ComponentFinder componentFinder = TestComponentFinder.from(db);
     WebhookDeliveryAction underTest = new WebhookDeliveryAction(dbClient, userSession, componentFinder);
     ws = new WsActionTester(underTest);
-    project = db.components().insertPrivateProject(c -> c.setDbKey("my-project"));
+    project = db.components().insertPrivateProject(c -> c.setKey("my-project"));
   }
 
   @Test
index 303391ee406b9c0ed31756c863b4f59ec009dc6a..6b4f05f9d25903accd2f8c9980919b043777c67d 100644 (file)
@@ -20,9 +20,7 @@
 package org.sonar.scanner.scan;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
-import java.util.Set;
 import java.util.stream.Stream;
 import javax.annotation.Nullable;
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
@@ -104,11 +102,6 @@ public class ProjectReactorValidator {
     if (!ComponentKeys.isValidProjectKey(projectDefinition.getKey())) {
       validationMessages.add(format("\"%s\" is not a valid project key. %s.", projectDefinition.getKey(), ALLOWED_CHARACTERS_MESSAGE));
     }
-    Set<String> forbiddenNamePhrases = Set.of(":BRANCH:", ":PULLREQUEST:");
-    if (forbiddenNamePhrases.stream().anyMatch(projectDefinition.getKey()::contains)) {
-      validationMessages.add(format("\"%s\" is not a valid project key. Project key must not contain following phrases [%s]", projectDefinition.getKey(),
-        String.join(", ", forbiddenNamePhrases)));
-    }
   }
 
   private boolean isBranchFeatureAvailable() {
index 7c2ee0b39e98de1dad32b28e331b48193cbe06ba..9ed7acc1b465d4c3933ea607b205fc4ca6aa6716 100644 (file)
@@ -96,23 +96,6 @@ public class ProjectReactorValidatorTest {
         + " '-', '_', '.' and ':', with at least one non-digit.");
   }
 
-  @Test
-  public void fail_when_key_contains_invalid_phrases() {
-    ProjectReactor reactorWithBranchInKey = createProjectReactor("test:BRANCH:test");
-
-    assertThatThrownBy(() -> underTest.validate(reactorWithBranchInKey))
-      .isInstanceOf(MessageException.class)
-      .hasMessageContainingAll("\"test:BRANCH:test\" is not a valid project key. "
-        + "Project key must not contain following phrases", ":BRANCH:", ":PULLREQUEST:");
-
-    ProjectReactor reactorWithPRinKey = createProjectReactor("test:PULLREQUEST:test");
-
-    assertThatThrownBy(() -> underTest.validate(reactorWithPRinKey))
-      .isInstanceOf(MessageException.class)
-      .hasMessageContainingAll("\"test:PULLREQUEST:test\" is not a valid project key. "
-        + "Project key must not contain following phrases", ":BRANCH:", ":PULLREQUEST:");
-  }
-
   @Test
   public void fail_when_only_digits() {
     ProjectReactor reactor = createProjectReactor("12345");