]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-17706 Remove module related columns in Components and all its uses
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Tue, 24 Jan 2023 21:17:30 +0000 (15:17 -0600)
committersonartech <sonartech@sonarsource.com>
Thu, 2 Feb 2023 20:03:39 +0000 (20:03 +0000)
116 files changed:
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycle.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/util/cache/ProtobufIssueDiskCache.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ExportComponentsStep.java
server/sonar-ce-task-projectanalysis/src/main/protobuf/issue_cache.proto
server/sonar-ce-task-projectanalysis/src/main/protobuf/project_dump.proto
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/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/ValidateProjectStepTest.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/rule/ExportAdHocRulesStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/ExportLinksStepTest.java
server/sonar-ce/src/test/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListenerTest.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/ComponentWithModuleUuidDto.java [deleted file]
server/sonar-db-dao/src/main/java/org/sonar/db/component/FilePathWithHashDto.java
server/sonar-db-dao/src/main/java/org/sonar/db/component/ResourceDto.java
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/IssueMapper.java
server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java
server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.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/ComponentMapper.xml
server/sonar-db-dao/src/main/resources/org/sonar/db/issue/IssueMapper.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/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/IssueDtoTest.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/MeasureDaoTest.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/purge/PurgeMapperTest.java
server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DbVersion100.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidInComponents.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidPathInComponents.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsModuleUuidInComponents.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidInComponents.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidPathInComponents.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidInComponentsTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidPathInComponentsTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsModuleUuidInComponentsTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidInComponentsTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidPathInComponentsTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidInComponentsTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidPathInComponentsTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsModuleUuidInComponentsTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidInComponentsTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidPathInComponentsTest/schema.sql [new file with mode: 0644]
server/sonar-server-common/src/main/java/org/sonar/server/issue/IssueFieldsSetter.java
server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueDoc.java
server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.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/view/index/ViewIndexer.java
server/sonar-server-common/src/test/java/org/sonar/server/es/ProjectIndexersImplTest.java
server/sonar-server-common/src/test/java/org/sonar/server/issue/index/IssueIteratorFactoryTest.java
server/sonar-server-common/src/testFixtures/java/org/sonar/server/issue/IssueDocTesting.java
server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java
server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQuery.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/issue/index/IssueIndexFiltersTest.java
server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/BatchWsModule.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/IssuesAction.java [deleted file]
server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/ProjectDataLoader.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/SuggestionCategory.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/setting/ws/ValuesAction.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/batch/BatchWsModuleTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/batch/IssuesActionTest.java [deleted file]
server/sonar-webserver-webapi/src/test/java/org/sonar/server/batch/ProjectDataLoaderTest.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/component/ComponentFinderTest.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/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/duplication/ws/ShowResponseBuilderTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/WebIssueStorageTest.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/SearchActionFacetsTest.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/measure/ws/SearchActionTest.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/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/project/ws/SearchActionTest.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/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/SetActionTest.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/ui/ws/ComponentActionTest.java
server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/components_contains_sub_projects.json [deleted file]
server/sonar-webserver-webapi/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_bread_crumbs_on_several_levels.json
sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java

index 212ebe03b6656e4590723fb174b704719d7235af..d628e1ddc00e9f7120c1fcd283c0d86bb19b8236 100644 (file)
@@ -193,7 +193,6 @@ public class IssueLifecycle {
     // (in which case base issue belongs to original file and raw issue to component)
     raw.setComponentUuid(base.componentUuid());
     raw.setComponentKey(base.componentKey());
-    raw.setModuleUuidPath(base.moduleUuidPath());
 
     // fields coming from raw
     updater.setPastLine(raw, base.getLine());
index b61f462d9f95233e0b15a32d53d0492fcd76f9c4..f120c211950f6753d5273d79c6a3667bec9efc5c 100644 (file)
@@ -54,7 +54,6 @@ import static java.util.Optional.ofNullable;
 import static org.sonar.api.resources.Qualifiers.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order.PRE_ORDER;
 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;
 
 /**
@@ -244,8 +243,6 @@ public class PersistComponentsStep implements ComputationStep {
         existingComponent.setUuidPath(updateDto.getBUuidPath());
         existingComponent.setLanguage(updateDto.getBLanguage());
         existingComponent.setLongName(updateDto.getBLongName());
-        existingComponent.setModuleUuid(updateDto.getBModuleUuid());
-        existingComponent.setModuleUuidPath(updateDto.getBModuleUuidPath());
         existingComponent.setName(updateDto.getBName());
         existingComponent.setPath(updateDto.getBPath());
         // We don't have a b_scope. The applyBChangesForRootComponentUuid query is using a case ... when to infer scope from the qualifier
@@ -267,7 +264,6 @@ public class PersistComponentsStep implements ComputationStep {
       res.setBranchUuid(res.uuid());
       res.setRootUuid(res.uuid());
       res.setUuidPath(UUID_PATH_OF_ROOT);
-      res.setModuleUuidPath(UUID_PATH_SEPARATOR + res.uuid() + UUID_PATH_SEPARATOR);
 
       return res;
     }
@@ -281,7 +277,7 @@ public class PersistComponentsStep implements ComputationStep {
       res.setLongName(directory.getName());
       res.setPath(directory.getName());
 
-      setParentModuleProperties(res, path);
+      setParentProperties(res, path);
 
       return res;
     }
@@ -296,7 +292,7 @@ public class PersistComponentsStep implements ComputationStep {
       res.setPath(file.getName());
       res.setLanguage(file.getFileAttributes().getLanguageKey());
 
-      setParentModuleProperties(res, path);
+      setParentProperties(res, path);
 
       return res;
     }
@@ -313,7 +309,6 @@ public class PersistComponentsStep implements ComputationStep {
       res.setBranchUuid(res.uuid());
       res.setRootUuid(res.uuid());
       res.setUuidPath(UUID_PATH_OF_ROOT);
-      res.setModuleUuidPath(UUID_PATH_SEPARATOR + res.uuid() + UUID_PATH_SEPARATOR);
 
       return res;
     }
@@ -362,35 +357,31 @@ public class PersistComponentsStep implements ComputationStep {
     }
 
     /**
-     * Applies to a node of type either MODULE, SUBVIEW, PROJECT_VIEW
+     * Applies to a node of type either SUBVIEW or PROJECT_VIEW
      */
     private void setRootAndParentModule(ComponentDto res, PathAwareVisitor.Path<ComponentDtoHolder> path) {
       ComponentDto rootDto = path.root().getDto();
       res.setRootUuid(rootDto.uuid());
       res.setBranchUuid(rootDto.uuid());
 
-      ComponentDto parentModule = path.parent().getDto();
-      res.setUuidPath(formatUuidPathFromParent(parentModule));
-      res.setModuleUuid(parentModule.uuid());
-      res.setModuleUuidPath(parentModule.moduleUuidPath() + res.uuid() + UUID_PATH_SEPARATOR);
+      ComponentDto parent = path.parent().getDto();
+      res.setUuidPath(formatUuidPathFromParent(parent));
     }
   }
 
   /**
    * Applies to a node of type either DIRECTORY or FILE
    */
-  private static void setParentModuleProperties(ComponentDto componentDto, PathAwareVisitor.Path<ComponentDtoHolder> path) {
+  private static void setParentProperties(ComponentDto componentDto, PathAwareVisitor.Path<ComponentDtoHolder> path) {
     componentDto.setBranchUuid(path.root().getDto().uuid());
 
-    ComponentDto parentModule = StreamSupport.stream(path.getCurrentPath().spliterator(), false)
+    ComponentDto parent = StreamSupport.stream(path.getCurrentPath().spliterator(), false)
       .filter(p -> p.component().getType() == Component.Type.PROJECT)
       .findFirst()
       .get()
       .element().getDto();
     componentDto.setUuidPath(formatUuidPathFromParent(path.parent().getDto()));
-    componentDto.setRootUuid(parentModule.uuid());
-    componentDto.setModuleUuid(parentModule.uuid());
-    componentDto.setModuleUuidPath(parentModule.moduleUuidPath());
+    componentDto.setRootUuid(parent.uuid());
 
   }
 
@@ -402,8 +393,6 @@ public class PersistComponentsStep implements ComputationStep {
       !StringUtils.equals(existing.getUuidPath(), target.getUuidPath()) ||
       !StringUtils.equals(existing.language(), target.language()) ||
       !StringUtils.equals(existing.longName(), target.longName()) ||
-      !StringUtils.equals(existing.moduleUuid(), target.moduleUuid()) ||
-      !StringUtils.equals(existing.moduleUuidPath(), target.moduleUuidPath()) ||
       !StringUtils.equals(existing.name(), target.name()) ||
       !StringUtils.equals(existing.path(), target.path()) ||
       !StringUtils.equals(existing.scope(), target.scope()) ||
index 0dd9df6526383c20a912bd97742a8a48b1726335..d67e46c0c1a6848d371cdbc9168fc06ff2cbf4d4 100644 (file)
@@ -98,7 +98,6 @@ public class ProtobufIssueDiskCache implements DiskCache<DefaultIssue> {
     defaultIssue.setType(RuleType.valueOf(next.getRuleType()));
     defaultIssue.setComponentUuid(next.hasComponentUuid() ? next.getComponentUuid() : null);
     defaultIssue.setComponentKey(next.getComponentKey());
-    defaultIssue.setModuleUuidPath(next.hasModuleUuidPath() ? next.getModuleUuidPath() : null);
     defaultIssue.setProjectUuid(next.getProjectUuid());
     defaultIssue.setProjectKey(next.getProjectKey());
     defaultIssue.setRuleKey(RuleKey.parse(next.getRuleKey()));
@@ -150,7 +149,6 @@ public class ProtobufIssueDiskCache implements DiskCache<DefaultIssue> {
     builder.setRuleType(defaultIssue.type().getDbConstant());
     ofNullable(defaultIssue.componentUuid()).ifPresent(builder::setComponentUuid);
     builder.setComponentKey(defaultIssue.componentKey());
-    ofNullable(defaultIssue.moduleUuidPath()).ifPresent(builder::setModuleUuidPath);
     builder.setProjectUuid(defaultIssue.projectUuid());
     builder.setProjectKey(defaultIssue.projectKey());
     builder.setRuleKey(defaultIssue.ruleKey().toString());
index 745bda9d96356323f46fca146bd9d2d3972052e9..1c1f137b21470bcce5b0a7ca62ff5979317ecfcd 100644 (file)
@@ -45,7 +45,7 @@ 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.branch_uuid, p.main_branch_project_uuid" +
+    " p.deprecated_kee, p.branch_uuid, p.main_branch_project_uuid" +
     " from components p" +
     " join components pp on pp.uuid = p.branch_uuid" +
     " join project_branches pb on pb.uuid = pp.uuid" +
@@ -90,11 +90,9 @@ public class ExportComponentsStep implements ComputationStep {
           .setLanguage(defaultString(getString(rs, 8)))
           .setLongName(defaultString(getString(rs, 9)))
           .setPath(defaultString(getString(rs, 10)))
-          .setModuleUuid(defaultString(getString(rs, 11)))
-          .setModuleUuidPath(defaultString(getString(rs, 12)))
-          .setDeprecatedKey(defaultString(getString(rs, 13)))
-          .setProjectUuid(getString(rs, 14))
-          .setMainBranchProjectUuid(defaultString(getString(rs, 15)))
+          .setDeprecatedKey(defaultString(getString(rs, 11)))
+          .setProjectUuid(getString(rs, 12))
+          .setMainBranchProjectUuid(defaultString(getString(rs, 13)))
           .build();
         output.write(component);
         ref++;
index 1e29d4126c0857135129010c11a19a6dbf78f3e9..9a0e93bf5a57b7f6d2cd974424ac1b2ada6ab096 100644 (file)
@@ -34,7 +34,7 @@ message Issue {
   optional string componentUuid = 3;
   optional string componentKey = 4;
   reserved 5; //moduleUuid
-  optional string moduleUuidPath = 6;
+  reserved 6; // moduleUuidPath
   optional string projectUuid = 7;
   optional string projectKey = 8;
   optional string ruleKey = 9;
index 2623f5ce877b636434fa14e1684545f08d8bc2a3..49c6915b0f8f683be78b4394b8ee0b31ffd2ab56 100644 (file)
@@ -30,8 +30,8 @@ message Component {
   string path = 9;
   string uuid = 10;
   string uuid_path = 12;
-  string module_uuid = 13;
-  string module_uuid_path = 14;
+  reserved 13; // module_uuid
+  reserved 14; // module_uuid_path
   string deprecated_key = 15;
   string project_uuid = 16;
   string main_branch_project_uuid = 17;
index 6905fc30a3158c8e7d4c118a2f9ff57d661f198a..757988e4620206a83ecef98db582dbd2fe4fd6a4 100644 (file)
@@ -111,7 +111,6 @@ public class MovedIssueVisitorTest {
 
     verify(issue).setComponentUuid(FILE.getUuid());
     verify(issue).setComponentKey(FILE.getKey());
-    verify(issue).setModuleUuidPath(null);
     verify(issue).setUpdateDate(new Date(ANALYSIS_DATE));
     verify(issue).setChanged(true);
   }
index d9cea98cd6c27148bc4fd907ab4e057894436294..397447fff57ea1943e6dc21eefbf0b1a7ffe09b8 100644 (file)
@@ -37,12 +37,9 @@ import org.sonar.db.issue.IssueDto;
 import org.sonar.db.rule.RuleDto;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.tuple;
 import static org.mockito.Mockito.mock;
 import static org.sonar.api.utils.DateUtils.parseDate;
-import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 
 public class ProjectTrackerBaseLazyInputTest {
 
index 2e533c2b2639bb894373b710940bed51a15de74b..188dbb563106450b8f125b3cad3aee3908d2d815 100644 (file)
@@ -95,16 +95,14 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
     String projectVersion = randomAlphabetic(10);
     ComponentDto projectDto = ComponentTesting.newPrivateProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project");
     dbTester.components().insertComponent(projectDto);
-    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").setKey("MODULE_KEY:src/main/java/dir");
+    ComponentDto directoryDto = ComponentTesting.newDirectory(projectDto, "CDEF", "src/main/java/dir").setKey("PROJECT_KEY:src/main/java/dir");
     dbTester.components().insertComponent(directoryDto);
-    ComponentDto fileDto = ComponentTesting.newFileDto(moduleDto, directoryDto, "DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java");
+    ComponentDto fileDto = ComponentTesting.newFileDto(projectDto, directoryDto, "DEFG").setKey("PROJECT_KEY:src/main/java/dir/Foo.java");
     dbTester.components().insertComponent(fileDto);
     dbTester.getSession().commit();
 
-    Component file = ReportComponent.builder(Component.Type.FILE, 3).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java").build();
-    Component directory = ReportComponent.builder(Component.Type.DIRECTORY, 2).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir").addChildren(file).build();
+    Component file = ReportComponent.builder(Component.Type.FILE, 3).setUuid("DEFG").setKey("PROJECT_KEY:src/main/java/dir/Foo.java").build();
+    Component directory = ReportComponent.builder(Component.Type.DIRECTORY, 2).setUuid("CDEF").setKey("PROJECT_KEY:src/main/java/dir").addChildren(file).build();
     String buildString = Optional.ofNullable(projectVersion).map(v -> randomAlphabetic(7)).orElse(null);
     Component project = ReportComponent.builder(Component.Type.PROJECT, 1)
       .setUuid("ABCD")
@@ -161,13 +159,10 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
     SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(projectDto);
     dbClient.snapshotDao().insert(dbTester.getSession(), projectSnapshot);
 
-    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").setKey("MODULE_KEY:src/main/java/dir");
+    ComponentDto directoryDto = ComponentTesting.newDirectory(projectDto, "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").setKey("MODULE_KEY:src/main/java/dir/Foo.java");
+    ComponentDto fileDto = ComponentTesting.newFileDto(projectDto, directoryDto, "DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java");
     dbTester.components().insertComponent(fileDto);
 
     dbTester.getSession().commit();
index 0b160377d57074f3ceadf4a5feb4a34111a7f273..28bb7d9be16ec43f39f94943579a98c658db0ae8 100644 (file)
@@ -59,7 +59,6 @@ import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 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.ComponentTesting.newDirectory;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 
 public class ReportPersistComponentsStepTest extends BaseStepTest {
 
@@ -123,8 +122,6 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(directoryDto.path()).isEqualTo("src/main/java/dir");
     assertThat(directoryDto.uuid()).isEqualTo("CDEF");
     assertThat(directoryDto.getUuidPath()).isEqualTo(UUID_PATH_SEPARATOR + projectDto.uuid() + UUID_PATH_SEPARATOR);
-    assertThat(directoryDto.moduleUuid()).isEqualTo(projectDto.uuid());
-    assertThat(directoryDto.moduleUuidPath()).isEqualTo(projectDto.moduleUuidPath());
     assertThat(directoryDto.getMainBranchProjectUuid()).isNull();
     assertThat(directoryDto.branchUuid()).isEqualTo(projectDto.uuid());
     assertThat(directoryDto.qualifier()).isEqualTo("DIR");
@@ -140,8 +137,6 @@ 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(projectDto.uuid());
-    assertThat(fileDto.moduleUuidPath()).isEqualTo(projectDto.moduleUuidPath());
     assertThat(fileDto.getMainBranchProjectUuid()).isNull();
     assertThat(fileDto.branchUuid()).isEqualTo(projectDto.uuid());
     assertThat(fileDto.qualifier()).isEqualTo("FIL");
@@ -181,8 +176,6 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(directoryDto.path()).isEqualTo("src/main/java/dir");
     assertThat(directoryDto.uuid()).isEqualTo("CDEF");
     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(analysisMetadataHolder.getProject().getUuid());
     assertThat(directoryDto.branchUuid()).isEqualTo(branch.uuid());
     assertThat(directoryDto.qualifier()).isEqualTo("DIR");
@@ -198,8 +191,6 @@ 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(branch.uuid());
-    assertThat(fileDto.moduleUuidPath()).isEqualTo(branch.moduleUuidPath());
     assertThat(fileDto.getMainBranchProjectUuid()).isEqualTo(analysisMetadataHolder.getProject().getUuid());
     assertThat(fileDto.branchUuid()).isEqualTo(branch.uuid());
     assertThat(fileDto.qualifier()).isEqualTo("FIL");
@@ -293,38 +284,6 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(dbClient.componentDao().selectByKey(db.getSession(), PROJECT_KEY + ":src/foo").get().scope()).isEqualTo("DIR");
   }
 
-  @Test
-  public void update_module_to_directory_change_scope() {
-    ComponentDto project = prepareProject();
-    ComponentDto module = ComponentTesting.newModuleDto(project).setUuid("CDEF").setKey("MODULE_KEY").setPath("module");
-    dbClient.componentDao().insert(db.getSession(), module);
-    db.getSession().commit();
-
-    assertThat(dbClient.componentDao().selectByUuid(db.getSession(), "CDEF").get().scope()).isEqualTo("PRJ");
-
-    treeRootHolder.setRoot(
-      asTreeRoot(project)
-        .addChildren(
-          builder(DIRECTORY, 2).setUuid("CDEF").setKey(PROJECT_KEY + ":module")
-            .setName("module")
-            .addChildren(
-              builder(FILE, 3).setUuid("HIJK").setKey(PROJECT_KEY + ":module/FooTest.java")
-                .setName("module/FooTest.java")
-                .setShortName("FooTest.java")
-                .setFileAttributes(new FileAttributes(false, null, 1))
-                .build())
-            .build())
-        .build());
-
-    underTest.execute(new TestComputationStepContext());
-
-    // commit the functional transaction
-    dbClient.componentDao().applyBChangesForRootComponentUuid(db.getSession(), project.uuid());
-    db.commit();
-
-    assertThat(dbClient.componentDao().selectByUuid(db.getSession(), "CDEF").get().scope()).isEqualTo("DIR");
-  }
-
   @Test
   public void persist_only_new_components() {
     // Project and module already exists
@@ -356,16 +315,12 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
 
     ComponentDto directory = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get();
     assertThat(directory.getUuidPath()).isEqualTo(directory.getUuidPath());
-    assertThat(directory.moduleUuid()).isEqualTo(project.uuid());
-    assertThat(directory.moduleUuidPath()).isEqualTo(project.moduleUuidPath());
     assertThat(directory.branchUuid()).isEqualTo(project.uuid());
     assertThat(directory.getRootUuid()).isEqualTo(project.uuid());
     assertThat(directory.getMainBranchProjectUuid()).isNull();
 
     ComponentDto file = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java").get();
     assertThat(file.getUuidPath()).isEqualTo(file.getUuidPath());
-    assertThat(file.moduleUuid()).isEqualTo(project.uuid());
-    assertThat(file.moduleUuidPath()).isEqualTo(project.moduleUuidPath());
     assertThat(file.branchUuid()).isEqualTo(project.uuid());
     assertThat(file.getRootUuid()).isEqualTo(project.uuid());
     assertThat(file.getMainBranchProjectUuid()).isNull();
@@ -402,16 +357,12 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
 
     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.branchUuid()).isEqualTo(project.branchUuid());
     assertThat(projectReloaded.getRootUuid()).isEqualTo(project.getRootUuid());
 
     ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get();
     assertThat(directoryReloaded.uuid()).isEqualTo(directory.uuid());
     assertThat(directoryReloaded.getUuidPath()).isEqualTo(directory.getUuidPath());
-    assertThat(directoryReloaded.moduleUuid()).isEqualTo(directory.moduleUuid());
-    assertThat(directoryReloaded.moduleUuidPath()).isEqualTo(directory.moduleUuidPath());
     assertThat(directoryReloaded.branchUuid()).isEqualTo(directory.branchUuid());
     assertThat(directoryReloaded.getRootUuid()).isEqualTo(directory.getRootUuid());
     assertThat(directoryReloaded.name()).isEqualTo(directory.name());
@@ -420,63 +371,12 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     ComponentDto fileReloaded = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java").get();
     assertThat(fileReloaded.uuid()).isEqualTo(file.uuid());
     assertThat(fileReloaded.getUuidPath()).isEqualTo(file.getUuidPath());
-    assertThat(fileReloaded.moduleUuid()).isEqualTo(file.moduleUuid());
-    assertThat(fileReloaded.moduleUuidPath()).isEqualTo(file.moduleUuidPath());
     assertThat(fileReloaded.branchUuid()).isEqualTo(file.branchUuid());
     assertThat(fileReloaded.getRootUuid()).isEqualTo(file.getRootUuid());
     assertThat(fileReloaded.name()).isEqualTo(file.name());
     assertThat(fileReloaded.path()).isEqualTo(file.path());
   }
 
-  @Test
-  public void update_module_uuid_when_moving_a_module() {
-    ComponentDto project = prepareProject();
-    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")
-      .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.getKey())
-        .setName("Project")
-        .addChildren(
-          builder(DIRECTORY, 4).setUuid("CDEF").setKey("PROJECT_KEY:src/main/java/dir")
-            .setName("src/main/java/dir")
-            .addChildren(
-              builder(FILE, 5).setUuid("DEFG").setKey("PROJECT_KEY:src/main/java/dir/Foo.java")
-                .setName("src/main/java/dir/Foo.java")
-                .build())
-            .build())
-        .build());
-
-    underTest.execute(new TestComputationStepContext());
-
-    // commit the functional transaction
-    dbClient.componentDao().applyBChangesForRootComponentUuid(db.getSession(), project.uuid());
-    db.commit();
-
-    assertThat(db.countRowsOfTable("components")).isEqualTo(3);
-
-    ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get();
-    assertThat(directoryReloaded).isNotNull();
-    assertThat(directoryReloaded.uuid()).isEqualTo(directory.uuid());
-    assertThat(directoryReloaded.getUuidPath()).isEqualTo(directoryReloaded.getUuidPath());
-    assertThat(directoryReloaded.moduleUuid()).isEqualTo(project.uuid());
-    assertThat(directoryReloaded.moduleUuidPath()).isEqualTo(project.moduleUuidPath());
-    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();
-    assertThat(fileReloaded).isNotNull();
-    assertThat(fileReloaded.uuid()).isEqualTo(file.uuid());
-    assertThat(fileReloaded.getUuidPath()).isEqualTo(fileReloaded.getUuidPath());
-    assertThat(fileReloaded.moduleUuid()).isEqualTo(project.uuid());
-    assertThat(fileReloaded.moduleUuidPath()).isEqualTo(project.moduleUuidPath());
-    assertThat(fileReloaded.branchUuid()).isEqualTo(project.uuid());
-    assertThat(fileReloaded.getRootUuid()).isEqualTo(project.uuid());
-  }
-
   @Test
   public void do_not_update_created_at_on_existing_component() {
     Date oldDate = DateUtils.parseDate("2015-01-01");
@@ -540,8 +440,6 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     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.branchUuid()).isEqualTo(project.branchUuid());
     assertThat(projectReloaded.getRootUuid()).isEqualTo(project.getRootUuid());
     assertThat(projectReloaded.isEnabled()).isTrue();
@@ -549,8 +447,6 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get();
     assertThat(directoryReloaded.uuid()).isEqualTo(removedDirectory.uuid());
     assertThat(directoryReloaded.getUuidPath()).isEqualTo(removedDirectory.getUuidPath());
-    assertThat(directoryReloaded.moduleUuid()).isEqualTo(removedDirectory.moduleUuid());
-    assertThat(directoryReloaded.moduleUuidPath()).isEqualTo(removedDirectory.moduleUuidPath());
     assertThat(directoryReloaded.branchUuid()).isEqualTo(removedDirectory.branchUuid());
     assertThat(directoryReloaded.getRootUuid()).isEqualTo(removedDirectory.getRootUuid());
     assertThat(directoryReloaded.name()).isEqualTo(removedDirectory.name());
@@ -561,8 +457,6 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     ComponentDto fileReloaded = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java").get();
     assertThat(fileReloaded.uuid()).isEqualTo(removedFile.uuid());
     assertThat(fileReloaded.getUuidPath()).isEqualTo(removedFile.getUuidPath());
-    assertThat(fileReloaded.moduleUuid()).isEqualTo(removedFile.moduleUuid());
-    assertThat(fileReloaded.moduleUuidPath()).isEqualTo(removedFile.moduleUuidPath());
     assertThat(fileReloaded.branchUuid()).isEqualTo(removedFile.branchUuid());
     assertThat(fileReloaded.getRootUuid()).isEqualTo(removedFile.getRootUuid());
     assertThat(fileReloaded.name()).isEqualTo(removedFile.name());
@@ -580,14 +474,12 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
   @Test
   public void persists_existing_components_with_visibility_of_root_in_db_out_of_functional_transaction() {
     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").setKey("DIR").setPrivate(true));
+    ComponentDto dir = db.components().insertComponent(newDirectory(project, "DEFG", "Directory").setKey("DIR").setPrivate(true));
     treeRootHolder.setRoot(createSampleProjectComponentTree(project));
 
     underTest.execute(new TestComputationStepContext());
 
-    Stream.of(project.uuid(), module.uuid(), dir.uuid())
+    Stream.of(project.uuid(), dir.uuid())
       .forEach(uuid -> assertThat(dbClient.componentDao().selectByUuid(db.getSession(), uuid).get().isPrivate())
         .describedAs("for uuid " + uuid)
         .isEqualTo(true));
index cfda68e5493ddcc54521ae88a81ce88eb0b54b3c..c1e5539dac0b0349a1146948335bc7b7835742cc 100644 (file)
@@ -65,20 +65,6 @@ public class ValidateProjectStepTest {
 
   private final ValidateProjectStep underTest = new ValidateProjectStep(dbClient, treeRootHolder, analysisMetadataHolder);
 
-  @Test
-  public void dont_fail_for_long_forked_from_master_with_modules() {
-    ComponentDto masterProject = db.components().insertPublicProject();
-    dbClient.componentDao().insert(db.getSession(), ComponentTesting.newModuleDto(masterProject));
-    setBranch(BranchType.BRANCH, masterProject.uuid());
-    db.getSession().commit();
-
-    treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("DEFG")
-      .setKey("branch")
-      .build());
-
-    underTest.execute(new TestComputationStepContext());
-  }
-
   @Test
   public void not_fail_if_analysis_date_is_after_last_analysis() {
     ComponentDto project = db.components().insertPrivateProject("ABCD", c -> c.setKey(PROJECT_KEY));
index 650e9b7f298ece9f5fd96f94069463751f2f3c60..60023e2e68caf606f537d80dda891a4f1c05a947 100644 (file)
@@ -501,8 +501,6 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
     assertThat(dto.uuid()).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() + ".");
     assertThat(dto.qualifier()).isEqualTo(Qualifiers.VIEW);
     assertThat(dto.scope()).isEqualTo(Scopes.PROJECT);
     assertThat(dto.getCopyComponentUuid()).isNull();
@@ -520,8 +518,6 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
     assertThat(dto.uuid()).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() + ".");
     assertThat(dto.qualifier()).isEqualTo(Qualifiers.APP);
     assertThat(dto.scope()).isEqualTo(Scopes.PROJECT);
     assertThat(dto.getCopyComponentUuid()).isNull();
@@ -539,8 +535,6 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
     assertThat(sv1Dto.uuid()).isEqualTo(SUBVIEW_1_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() + ".");
     assertThat(sv1Dto.qualifier()).isEqualTo(Qualifiers.SUBVIEW);
     assertThat(sv1Dto.scope()).isEqualTo(Scopes.PROJECT);
     assertThat(sv1Dto.getCopyComponentUuid()).isNull();
@@ -555,8 +549,6 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
     assertThat(pv1Dto.uuid()).isEqualTo(PROJECT_VIEW_1_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() + ".");
     assertThat(pv1Dto.qualifier()).isEqualTo(Qualifiers.PROJECT);
     assertThat(pv1Dto.scope()).isEqualTo(Scopes.FILE);
     assertThat(pv1Dto.getCopyComponentUuid()).isEqualTo(project.uuid());
index 41cbe19b8dd252966e9d4c0ab8225d32d1727ab8..9d55733efa0411984d2a202b1c23be8b93d12157 100644 (file)
@@ -67,25 +67,21 @@ public class ExportAnalysesStepTest {
     .setUuid(PROJECT_UUID)
     .setUuidPath(UUID_PATH_OF_ROOT)
     .setRootUuid(PROJECT_UUID)
-    .setModuleUuid(null)
-    .setModuleUuidPath("." + 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;
-  private static final ComponentDto MODULE = new ComponentDto()
+  private static final String DIR_UUID = "DIR_UUID";
+  private static final String UUID_PATH = UUID_PATH_OF_ROOT + UUID_PATH_SEPARATOR + DIR_UUID;
+  private static final ComponentDto DIR = new ComponentDto()
     // no id yet
     .setScope(Scopes.PROJECT)
-    .setQualifier(Qualifiers.MODULE)
-    .setKey("the_module")
-    .setName("The Module")
-    .setDescription("description of module")
+    .setQualifier(Qualifiers.DIRECTORY)
+    .setKey("the_dir")
+    .setName("The Dir")
+    .setDescription("description of dir")
     .setEnabled(true)
-    .setUuid(MODULE_UUID)
-    .setUuidPath(MODULE_UUID_PATH)
-    .setRootUuid(MODULE_UUID)
-    .setModuleUuid(PROJECT_UUID)
-    .setModuleUuidPath("." + PROJECT_UUID + ".MODULE_UUID.")
+    .setUuid(DIR_UUID)
+    .setUuidPath(UUID_PATH)
+    .setRootUuid(PROJECT_UUID)
     .setBranchUuid(PROJECT_UUID);
 
   private static final String FILE_UUID = "FILE_UUID";
@@ -96,11 +92,9 @@ public class ExportAnalysesStepTest {
     .setKey("the_file")
     .setName("The File")
     .setUuid(FILE_UUID)
-    .setUuidPath(MODULE_UUID_PATH + UUID_PATH_SEPARATOR + FILE_UUID)
-    .setRootUuid(MODULE_UUID)
+    .setUuidPath(UUID_PATH + UUID_PATH_SEPARATOR + FILE_UUID)
+    .setRootUuid(PROJECT_UUID)
     .setEnabled(true)
-    .setModuleUuid(MODULE_UUID)
-    .setModuleUuidPath("." + PROJECT_UUID + ".MODULE_UUID.")
     .setBranchUuid(PROJECT_UUID);
 
   @Rule
@@ -117,7 +111,7 @@ public class ExportAnalysesStepTest {
   public void setUp() {
     ComponentDto projectDto = dbTester.components().insertPublicProject(PROJECT);
     componentRepository.register(1, projectDto.uuid(), false);
-    dbTester.getDbClient().componentDao().insert(dbTester.getSession(), MODULE, FILE);
+    dbTester.getDbClient().componentDao().insert(dbTester.getSession(), DIR, FILE);
     dbTester.commit();
     when(projectHolder.projectDto()).thenReturn(dbTester.components().getProjectDto(projectDto));
   }
index 3ddee8921bfd59e9fb88ceaa9f7a55655cedea61..6b30e38f8bc46fabe815d6beb6e243de9408ed36 100644 (file)
@@ -64,8 +64,6 @@ public class ExportBranchesStepTest {
     .setUuid(PROJECT_UUID)
     .setUuidPath(UUID_PATH_OF_ROOT)
     .setRootUuid(PROJECT_UUID)
-    .setModuleUuid(null)
-    .setModuleUuidPath("." + PROJECT_UUID + ".")
     .setBranchUuid(PROJECT_UUID);
 
   @Rule
index 9082650340dd09c01b3750b9958a47ddbf671a66..2ffca9921e56f096c6cc34e565d987c2fb4a9e50 100644 (file)
@@ -60,31 +60,11 @@ public class ExportComponentsStepTest {
     .setUuid(PROJECT_UUID)
     .setRootUuid(PROJECT_UUID)
     .setUuidPath(UUID_PATH_OF_ROOT)
-    .setModuleUuid(null)
-    .setModuleUuidPath("." + PROJECT_UUID + ".")
     .setCreatedAt(new Date(1596749115856L))
     .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;
-  private static final ComponentDto MODULE = new ComponentDto()
-    // no id yet
-    .setScope(Scopes.PROJECT)
-    .setQualifier(Qualifiers.MODULE)
-    .setKey("the_module")
-    .setName("The Module")
-    .setDescription("description of module")
-    .setEnabled(true)
-    .setUuid(MODULE_UUID)
-    .setRootUuid(PROJECT_UUID)
-    .setUuidPath(MODULE_UUID_PATH)
-    .setModuleUuid(PROJECT_UUID)
-    .setModuleUuidPath("." + PROJECT_UUID + ".MODULE_UUID.")
-    .setCreatedAt(new Date(1596749132539L))
-    .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;
+  private static final String FILE_UUID_PATH = PROJECT_UUID + FILE_UUID + UUID_PATH_SEPARATOR;
   private static final ComponentDto FILE = new ComponentDto()
     // no id yet
     .setScope(Scopes.FILE)
@@ -92,11 +72,9 @@ public class ExportComponentsStepTest {
     .setKey("the_file")
     .setName("The File")
     .setUuid(FILE_UUID)
-    .setRootUuid(MODULE_UUID)
+    .setRootUuid(PROJECT_UUID)
     .setUuidPath(FILE_UUID_PATH)
     .setEnabled(true)
-    .setModuleUuid(MODULE_UUID)
-    .setModuleUuidPath("." + PROJECT_UUID + ".MODULE_UUID.")
     .setCreatedAt(new Date(1596749148406L))
     .setBranchUuid(PROJECT_UUID);
 
@@ -118,25 +96,24 @@ public class ExportComponentsStepTest {
   @Test
   public void export_components_including_project() {
     dbTester.components().insertPublicProject(PROJECT);
-    dbTester.getDbClient().componentDao().insert(dbTester.getSession(), MODULE, FILE);
+    dbTester.getDbClient().componentDao().insert(dbTester.getSession(), FILE);
     dbTester.commit();
     when(projectHolder.projectDto()).thenReturn(dbTester.components().getProjectDto(PROJECT));
 
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("3 components exported");
+    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("2 components exported");
     List<ProjectDump.Component> components = dumpWriter.getWrittenMessagesOf(DumpElement.COMPONENTS);
     assertThat(components).extracting(ProjectDump.Component::getQualifier, ProjectDump.Component::getUuid, ProjectDump.Component::getUuidPath)
       .containsExactlyInAnyOrder(
         tuple(Qualifiers.FILE, FILE_UUID, FILE_UUID_PATH),
-        tuple(Qualifiers.MODULE, MODULE_UUID, MODULE_UUID_PATH),
         tuple(Qualifiers.PROJECT, PROJECT_UUID, UUID_PATH_OF_ROOT));
   }
 
   @Test
   public void execute_register_all_components_uuids_as_their_id_in_ComponentRepository() {
     dbTester.components().insertPublicProject(PROJECT);
-    dbTester.getDbClient().componentDao().insert(dbTester.getSession(), MODULE, FILE);
+    dbTester.getDbClient().componentDao().insert(dbTester.getSession(), FILE);
     dbTester.commit();
     when(projectHolder.projectDto()).thenReturn(dbTester.components().getProjectDto(PROJECT));
 
@@ -144,14 +121,13 @@ public class ExportComponentsStepTest {
 
     assertThat(ImmutableSet.of(
       componentRepository.getRef(PROJECT.uuid()),
-      componentRepository.getRef(MODULE.uuid()),
-      componentRepository.getRef(FILE.uuid()))).containsExactlyInAnyOrder(1L, 2L, 3L);
+      componentRepository.getRef(FILE.uuid()))).containsExactlyInAnyOrder(1L, 2L);
   }
 
   @Test
   public void throws_ISE_if_error() {
     dbTester.components().insertPublicProject(PROJECT);
-    dbTester.getDbClient().componentDao().insert(dbTester.getSession(), MODULE, FILE);
+    dbTester.getDbClient().componentDao().insert(dbTester.getSession(), FILE);
     dbTester.commit();
     when(projectHolder.projectDto()).thenReturn(dbTester.components().getProjectDto(PROJECT));
     dumpWriter.failIfMoreThan(1, DumpElement.COMPONENTS);
index 863a8703edf9bf1f2fac2e7e6e127a0d739b056b..04e42d903a9ce9d68b28264a3b420fafaee623b6 100644 (file)
@@ -68,8 +68,6 @@ public class ExportAdHocRulesStepTest {
     .setUuid(PROJECT_UUID)
     .setUuidPath(UUID_PATH_OF_ROOT)
     .setRootUuid(PROJECT_UUID)
-    .setModuleUuid(null)
-    .setModuleUuidPath("." + PROJECT_UUID + ".")
     .setBranchUuid(PROJECT_UUID);
 
   private static final List<BranchDto> BRANCHES = ImmutableList.of(
index c084ffb6ac5d694de083352270715a037dfcb661..9ebb1558a658d8c05daeb12a47847c3dd52d9bdf 100644 (file)
@@ -56,8 +56,6 @@ public class ExportLinksStepTest {
     .setUuid(PROJECT_UUID)
     .setRootUuid(PROJECT_UUID)
     .setUuidPath(UUID_PATH_OF_ROOT)
-    .setModuleUuid(null)
-    .setModuleUuidPath("." + PROJECT_UUID + ".")
     .setBranchUuid(PROJECT_UUID);
 
   @Rule
index fc223dc7f2ad943423406c16a5c40c0d5ff27540..9d2100f5bf7d9f9a1f0e4d964442ed1819f81d4a 100644 (file)
@@ -59,7 +59,6 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoInteractions;
 import static org.mockito.Mockito.when;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 
 public class ReportAnalysisFailureNotificationExecutionListenerTest {
   @Rule
@@ -161,15 +160,14 @@ public class ReportAnalysisFailureNotificationExecutionListenerTest {
   public void onEnd_fails_with_IAE_if_component_is_not_a_project() {
     when(ceTaskMock.getType()).thenReturn(CeTaskTypes.REPORT);
     ComponentDto project = dbTester.components().insertPrivateProject();
-    ComponentDto module = dbTester.components().insertComponent(newModuleDto(project));
-    ComponentDto directory = dbTester.components().insertComponent(newDirectory(module, randomAlphanumeric(12)));
+    ComponentDto directory = dbTester.components().insertComponent(newDirectory(project, randomAlphanumeric(12)));
     ComponentDto file = dbTester.components().insertComponent(ComponentTesting.newFileDto(project));
     ComponentDto view = dbTester.components().insertComponent(ComponentTesting.newPortfolio());
     ComponentDto subView = dbTester.components().insertComponent(ComponentTesting.newSubPortfolio(view));
     ComponentDto projectCopy = dbTester.components().insertComponent(ComponentTesting.newProjectCopy(project, subView));
     ComponentDto application = dbTester.components().insertComponent(ComponentTesting.newApplication());
 
-    Arrays.asList(module, directory, file, view, subView, projectCopy, application)
+    Arrays.asList(directory, file, view, subView, projectCopy, application)
       .forEach(component -> {
 
       when(ceTaskMock.getComponent()).thenReturn(Optional.of(new CeTask.Component(component.uuid(), null, null)));
index 5a16792cbe57c82de56ad8fa89770961e2d24cdb..419dabee042c9e0713c5c83188f966b467e429ae 100644 (file)
@@ -247,9 +247,9 @@ public class ComponentDao implements Dao {
       i -> i);
   }
 
-  public List<String> selectProjectsFromView(DbSession session, String viewUuid, String projectViewUuid) {
+  public List<String> selectProjectsFromView(DbSession session, String viewUuid, String rootViewUuid) {
     var escapedViewUuid = viewUuid.replace("_", "\\_").replace("%", "\\%");
-    return mapper(session).selectProjectsFromView("%." + escapedViewUuid + ".%", projectViewUuid);
+    return mapper(session).selectProjectsFromView("%." + escapedViewUuid + ".%", rootViewUuid);
   }
 
   /**
index d67620408f51c958032fe9e59ccd24391fd9d28d..a9a8bd3b63ff5ca4226a0f52e887651947828f4e 100644 (file)
@@ -67,8 +67,7 @@ public class ComponentDto {
    * order to support LIKE conditions when requesting descendants of a component
    * and to avoid Oracle NULL on root components.
    * Example:
-   * - on root module: UUID="1" UUID_PATH="."
-   * - on module: UUID="2" UUID_PATH=".1."
+   * - on root: UUID="1" UUID_PATH="."
    * - on directory: UUID="3" UUID_PATH=".1.2."
    * - on file: UUID="4" UUID_PATH=".1.2.3."
    * - on view: UUID="5" UUID_PATH="."
@@ -81,23 +80,22 @@ public class ComponentDto {
   /**
    * Non-null UUID of root component. Equals UUID column on root components
    * Example:
-   * - on root module: UUID="1" PROJECT_UUID="1"
-   * - on module: UUID="2" PROJECT_UUID="1"
+   * - on root: UUID="1" PROJECT_UUID="1"
    * - on directory: UUID="3" PROJECT_UUID="1"
    * - on file: UUID="4" PROJECT_UUID="1"
    * - on view: UUID="5" PROJECT_UUID="5"
    * - on sub-view: UUID="6" PROJECT_UUID="5"
-  */
+   */
   private String branchUuid;
 
   /**
    * Badly named, it is not the root !
-   * - on root module: UUID="1" ROOT_UUID="1"
-   * - on modules, whatever depth, value is the root module: UUID="2" ROOT_UUID="1"
+   * - on root: UUID="1" ROOT_UUID="1"
    * - on directory, value is the closest module: UUID="3" ROOT_UUID="2"
    * - on file, value is the closest module: UUID="4" ROOT_UUID="2"
    * - on view: UUID="5" ROOT_UUID="5"
    * - on sub-view: UUID="6" ROOT_UUID="5"
+   *
    * @since 6.0
    */
   private String rootUuid;
@@ -106,13 +104,10 @@ public class ComponentDto {
    * On non-main branches only, {@link #uuid} of the main branch that represents
    * the project ({@link #qualifier}="TRK").
    * It is propagated to all the components of the branch.
-   *
    * Value is null on the main-branch components and on other kinds of components
    * (applications, portfolios).
-   *
    * Value must be used for loading settings, checking permissions, running webhooks,
    * selecting Quality profiles/gates and any other project-related operations.
-   *
    * Example:
    * - project P : kee=P, uuid=U1, qualifier=TRK, project_uuid=U1, main_branch_project_uuid=NULL
    * - file F of project P : kee=P:F, uuid=U2, qualifier=FIL, project_uuid=U1, main_branch_project_uuid=NULL
@@ -122,8 +117,6 @@ public class ComponentDto {
   @Nullable
   private String mainBranchProjectUuid;
 
-  private String moduleUuid;
-  private String moduleUuidPath;
   private String copyComponentUuid;
   private String scope;
   private String qualifier;
@@ -215,31 +208,6 @@ public class ComponentDto {
     return UUID_PATH_OF_ROOT.equals(uuidPath);
   }
 
-  /**
-   * Return the direct module of a component. Will be null on projects
-   */
-  @CheckForNull
-  public String moduleUuid() {
-    return moduleUuid;
-  }
-
-  public ComponentDto setModuleUuid(@Nullable String moduleUuid) {
-    this.moduleUuid = moduleUuid;
-    return this;
-  }
-
-  /**
-   * Return the path from the project to the last modules
-   */
-  public String moduleUuidPath() {
-    return moduleUuidPath;
-  }
-
-  public ComponentDto setModuleUuidPath(String moduleUuidPath) {
-    this.moduleUuidPath = moduleUuidPath;
-    return this;
-  }
-
   @CheckForNull
   public String path() {
     return path;
@@ -289,7 +257,7 @@ public class ComponentDto {
   }
 
   /**
-   * Use {@link #branchUuid()}, {@link #moduleUuid()} or {@link #moduleUuidPath()}
+   * Use {@link #branchUuid()}
    */
   @Deprecated
   public String getRootUuid() {
@@ -340,7 +308,7 @@ public class ComponentDto {
   }
 
   public boolean isRootProject() {
-    return moduleUuid == null && Scopes.PROJECT.equals(scope);
+    return uuid.equals(branchUuid) && Scopes.PROJECT.equals(scope);
   }
 
   public boolean isPrivate() {
@@ -379,8 +347,6 @@ public class ComponentDto {
       .append("scope", scope)
       .append("qualifier", qualifier)
       .append("branchUuid", branchUuid)
-      .append("moduleUuid", moduleUuid)
-      .append("moduleUuidPath", moduleUuidPath)
       .append("rootUuid", rootUuid)
       .append("mainBranchProjectUuid", mainBranchProjectUuid)
       .append("copyComponentUuid", copyComponentUuid)
@@ -401,8 +367,6 @@ public class ComponentDto {
     copy.branchUuid = branchUuid;
     copy.rootUuid = rootUuid;
     copy.mainBranchProjectUuid = mainBranchProjectUuid;
-    copy.moduleUuid = moduleUuid;
-    copy.moduleUuidPath = moduleUuidPath;
     copy.copyComponentUuid = copyComponentUuid;
     copy.scope = scope;
     copy.qualifier = qualifier;
index 59dfcac67865459be6bfb68507bc54fd5141f488..3de18dbfde8b5496c795a712d8d0629a7cfd8bf2 100644 (file)
@@ -97,7 +97,7 @@ public interface ComponentMapper {
   /**
    * Return technical projects from a view or a sub-view
    */
-  List<String> selectProjectsFromView(@Param("viewUuidLikeQuery") String viewUuidLikeQuery, @Param("projectViewUuid") String projectViewUuid);
+  List<String> selectProjectsFromView(@Param("viewUuidLikeQuery") String viewUuidLikeQuery, @Param("rootViewUuid") String rootViewUuid);
 
   void scrollForIndexing(@Param("projectUuid") @Nullable String projectUuid, ResultHandler<ComponentDto> handler);
 
index 2c5f95dc0ebb4485cb20cf4e654bf8519c84c185..039dd43cc3cc08e28e8600526684fce8357b053f 100644 (file)
@@ -40,8 +40,6 @@ public class ComponentUpdateDto {
   private String bUuidPath;
   private String bLanguage;
   private String bLongName;
-  private String bModuleUuid;
-  private String bModuleUuidPath;
   private String bName;
   private String bPath;
   private String bQualifier;
@@ -91,16 +89,6 @@ public class ComponentUpdateDto {
     return bLongName;
   }
 
-  @CheckForNull
-  public String getBModuleUuid() {
-    return bModuleUuid;
-  }
-
-  @CheckForNull
-  public String getBModuleUuidPath() {
-    return bModuleUuidPath;
-  }
-
   @CheckForNull
   public String getBName() {
     return bName;
@@ -156,16 +144,6 @@ public class ComponentUpdateDto {
     return this;
   }
 
-  public ComponentUpdateDto setBModuleUuid(@Nullable String s) {
-    this.bModuleUuid = s;
-    return this;
-  }
-
-  public ComponentUpdateDto setBModuleUuidPath(@Nullable String s) {
-    this.bModuleUuidPath = s;
-    return this;
-  }
-
   public ComponentUpdateDto setBPath(@Nullable String s) {
     this.bPath = s;
     return this;
@@ -195,8 +173,6 @@ public class ComponentUpdateDto {
       .setBUuidPath(from.getUuidPath())
       .setBLanguage(from.language())
       .setBLongName(from.longName())
-      .setBModuleUuid(from.moduleUuid())
-      .setBModuleUuidPath(from.moduleUuidPath())
       .setBName(from.name())
       .setBPath(from.path())
       // We don't have a b_scope. The applyBChangesForRootComponentUuid query is using a case ... when to infer scope from the qualifier
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentWithModuleUuidDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentWithModuleUuidDto.java
deleted file mode 100644 (file)
index 0324b4e..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 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;
-
-import javax.annotation.concurrent.Immutable;
-
-@Immutable
-public class ComponentWithModuleUuidDto {
-  private final String uuid;
-  private final String moduleUuid;
-  private final String path;
-  private final String scope;
-
-  public ComponentWithModuleUuidDto(String uuid, String moduleUuid, String path, String scope) {
-    this.uuid = uuid;
-    this.moduleUuid = moduleUuid;
-    this.path = path;
-    this.scope = scope;
-  }
-
-  public String path() {
-    return path;
-  }
-
-  public String moduleUuid() {
-    return moduleUuid;
-  }
-
-  public String uuid() {
-    return uuid;
-  }
-
-  public String scope() {
-    return scope;
-  }
-}
index 557b396810bce2d0e1fe61b8fd2cba8a9a0fc453..c5524085b566d4031eb3c6158091e053837ce960 100644 (file)
@@ -24,7 +24,6 @@ import javax.annotation.CheckForNull;
 public class FilePathWithHashDto {
 
   private String uuid;
-  private String moduleUuid;
   private String path;
   private String srcHash;
   private String revision;
@@ -37,14 +36,6 @@ public class FilePathWithHashDto {
     this.srcHash = srcHash;
   }
 
-  public String getModuleUuid() {
-    return moduleUuid;
-  }
-
-  public void setModuleUuid(String moduleUuid) {
-    this.moduleUuid = moduleUuid;
-  }
-
   @CheckForNull
   public String getPath() {
     return path;
index f0475eeac328e9ed48cf0ce533e5faa044a083df..450f57712cb6956a7bf695fc2945bcfa37471988 100644 (file)
@@ -32,8 +32,6 @@ public class ResourceDto {
 
   private String uuid;
   private String projectUuid;
-  private String moduleUuid;
-  private String moduleUuidPath;
   private String key;
   private String deprecatedKey;
   private String name;
@@ -66,24 +64,6 @@ public class ResourceDto {
     return this;
   }
 
-  public String getModuleUuid() {
-    return moduleUuid;
-  }
-
-  public ResourceDto setModuleUuid(String moduleUuid) {
-    this.moduleUuid = moduleUuid;
-    return this;
-  }
-
-  public String getModuleUuidPath() {
-    return moduleUuidPath;
-  }
-
-  public ResourceDto setModuleUuidPath(String moduleUuidPath) {
-    this.moduleUuidPath = moduleUuidPath;
-    return this;
-  }
-
   public String getName() {
     return name;
   }
index a58b9962efcc524830cf6adfed959711657445b1..de6cd440a312b514fc613bedcc36a1ceb31cf760 100644 (file)
@@ -85,15 +85,6 @@ public class IssueDao implements Dao {
     return mapper(session).selectComponentUuidsOfOpenIssuesForProjectUuid(projectUuid);
   }
 
-  public List<IssueDto> selectNonClosedByComponentUuidExcludingExternalsAndSecurityHotspots(DbSession dbSession, String componentUuid) {
-    return mapper(dbSession).selectNonClosedByComponentUuidExcludingExternals(componentUuid);
-  }
-
-  public List<IssueDto> selectNonClosedByModuleOrProjectExcludingExternalsAndSecurityHotspots(DbSession dbSession, ComponentDto module) {
-    String likeModuleUuidPath = buildLikeValue(module.moduleUuidPath(), WildcardPosition.AFTER);
-    return mapper(dbSession).selectNonClosedByModuleOrProject(module.branchUuid(), likeModuleUuidPath);
-  }
-
   public List<PrIssueDto> selectOpenByComponentUuids(DbSession dbSession, Collection<String> componentUuids) {
     return executeLargeInputs(componentUuids, mapper(dbSession)::selectOpenByComponentUuids);
   }
index 667950fe28281b95993331a10a329d0e11bd364b..10a8a1620c4149887754601617a9d11bae7076df 100644 (file)
@@ -94,7 +94,6 @@ public final class IssueDto implements Serializable {
   private boolean isExternal;
   private String language;
   private String componentKey;
-  private String moduleUuidPath;
   private String projectKey;
   private String filePath;
   private String tags;
@@ -131,7 +130,6 @@ public final class IssueDto implements Serializable {
       .setRuleDescriptionContextKey(issue.getRuleDescriptionContextKey().orElse(null))
       .setComponentUuid(issue.componentUuid())
       .setComponentKey(issue.componentKey())
-      .setModuleUuidPath(issue.moduleUuidPath())
       .setProjectUuid(issue.projectUuid())
       .setProjectKey(issue.projectKey())
       .setAuthorLogin(issue.authorLogin())
@@ -180,7 +178,6 @@ public final class IssueDto implements Serializable {
       .setRuleDescriptionContextKey(issue.getRuleDescriptionContextKey().orElse(null))
       .setComponentUuid(issue.componentUuid())
       .setComponentKey(issue.componentKey())
-      .setModuleUuidPath(issue.moduleUuidPath())
       .setProjectUuid(issue.projectUuid())
       .setProjectKey(issue.projectKey())
       .setIssueCreationDate(issue.creationDate())
@@ -210,7 +207,6 @@ public final class IssueDto implements Serializable {
   public IssueDto setComponent(ComponentDto component) {
     this.componentKey = component.getKey();
     this.componentUuid = component.uuid();
-    this.moduleUuidPath = component.moduleUuidPath();
     this.filePath = component.path();
     return this;
   }
@@ -556,21 +552,6 @@ public final class IssueDto implements Serializable {
     return this;
   }
 
-  @CheckForNull
-  public String getModuleUuidPath() {
-    return moduleUuidPath;
-  }
-
-  /**
-   * Should only be used to persist in E/S
-   * <p/>
-   * Please use {@link #setComponent(ComponentDto)} instead
-   */
-  public IssueDto setModuleUuidPath(@Nullable String moduleUuidPath) {
-    this.moduleUuidPath = moduleUuidPath;
-    return this;
-  }
-
   /**
    * Used by the issue tracking mechanism, but it should used the component uuid instead
    */
@@ -763,7 +744,6 @@ public final class IssueDto implements Serializable {
     issue.setAssigneeUuid(assigneeUuid);
     issue.setComponentKey(componentKey);
     issue.setComponentUuid(componentUuid);
-    issue.setModuleUuidPath(moduleUuidPath);
     issue.setProjectUuid(projectUuid);
     issue.setProjectKey(projectKey);
     issue.setManualSeverity(manualSeverity);
index 32006f536d311adb1179d593281c37c7cffbf731..9475fec4707f7cbf7c5bc490575e24c18d12a9d0 100644 (file)
@@ -70,10 +70,6 @@ public interface IssueMapper {
 
   void scrollClosedByComponentUuid(@Param("componentUuid") String componentUuid, @Param("closeDateAfter") long closeDateAfter, ResultHandler<IssueDto> handler);
 
-  List<IssueDto> selectNonClosedByComponentUuidExcludingExternals(@Param("componentUuid") String componentUuid);
-
-  List<IssueDto> selectNonClosedByModuleOrProject(@Param("projectUuid") String projectUuid, @Param("likeModuleUuidPath") String likeModuleUuidPath);
-
   Collection<IssueGroupDto> selectIssueGroupsByComponent(@Param("component") ComponentDto component, @Param("leakPeriodBeginningDate") long leakPeriodBeginningDate);
 
   List<IssueDto> selectByBranch(@Param("keys") Set<String> keys, @Nullable @Param("changedSince") Long changedSince);
index a861ad40e69f2f82de31b6e659929b73078b4246..37f8c42743cac9a36d07a1c87d0ff61d50a8463e 100644 (file)
@@ -224,13 +224,13 @@ class PurgeCommands {
     profiler.stop();
   }
 
-  void deleteByRootAndModulesOrSubviews(List<String> rootAndModulesOrSubviewsUuids) {
-    if (rootAndModulesOrSubviewsUuids.isEmpty()) {
+  void deleteByRootAndSubviews(List<String> rootAndSubviewsUuids) {
+    if (rootAndSubviewsUuids.isEmpty()) {
       return;
     }
-    List<List<String>> uuidsPartitions = Lists.partition(rootAndModulesOrSubviewsUuids, MAX_RESOURCES_PER_QUERY);
+    List<List<String>> uuidsPartitions = Lists.partition(rootAndSubviewsUuids, MAX_RESOURCES_PER_QUERY);
 
-    profiler.start("deleteByRootAndModulesOrSubviews (properties)");
+    profiler.start("deleteByRootAndSubviews (properties)");
     uuidsPartitions.forEach(purgeMapper::deletePropertiesByComponentUuids);
     session.commit();
     profiler.stop();
index 782981eacad9b14a5a36e754b9a7166d3e462dcc..f4c7fc9a610bee65334e8588d9c286d4984854c6 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.db.purge;
 
-import com.google.common.collect.ImmutableSet;
 import java.util.Collection;
 import java.util.Date;
 import java.util.List;
@@ -48,8 +47,8 @@ import static org.sonar.db.DatabaseUtils.executeLargeInputs;
 
 public class PurgeDao implements Dao {
   private static final Logger LOG = Loggers.get(PurgeDao.class);
-  private static final Set<String> QUALIFIERS_PROJECT_VIEW = ImmutableSet.of("TRK", "VW");
-  private static final Set<String> QUALIFIERS_MODULE_SUBVIEW = ImmutableSet.of("BRC", "SVW");
+  private static final Set<String> QUALIFIERS_PROJECT_VIEW = Set.of("TRK", "VW");
+  private static final Set<String> QUALIFIER_SUBVIEW = Set.of("SVW");
   private static final String SCOPE_PROJECT = "PRJ";
 
   private final System2 system2;
@@ -219,11 +218,11 @@ public class PurgeDao implements Dao {
   }
 
   private static void deleteRootComponent(String rootUuid, PurgeMapper mapper, PurgeCommands commands) {
-    List<String> rootAndModulesOrSubviews = mapper.selectRootAndModulesOrSubviewsByProjectUuid(rootUuid);
+    List<String> rootAndSubviews = mapper.selectRootAndSubviewsByProjectUuid(rootUuid);
     commands.deleteLinks(rootUuid);
     commands.deleteScannerCache(rootUuid);
     commands.deleteAnalyses(rootUuid);
-    commands.deleteByRootAndModulesOrSubviews(rootAndModulesOrSubviews);
+    commands.deleteByRootAndSubviews(rootAndSubviews);
     commands.deleteIssues(rootUuid);
     commands.deleteFileSources(rootUuid);
     commands.deleteCeActivity(rootUuid);
@@ -268,10 +267,10 @@ public class PurgeDao implements Dao {
 
   private static void deleteNonRootComponentsInView(Set<ComponentDto> nonRootComponents, PurgeCommands purgeCommands) {
     List<String> subviewsOrProjectCopies = nonRootComponents.stream()
-      .filter(PurgeDao::isModuleOrSubview)
+      .filter(PurgeDao::isSubview)
       .map(ComponentDto::uuid)
       .collect(MoreCollectors.toList());
-    purgeCommands.deleteByRootAndModulesOrSubviews(subviewsOrProjectCopies);
+    purgeCommands.deleteByRootAndSubviews(subviewsOrProjectCopies);
     List<String> nonRootComponentUuids = nonRootComponents.stream().map(ComponentDto::uuid).collect(MoreCollectors.toList(nonRootComponents.size()));
     purgeCommands.deleteComponentMeasures(nonRootComponentUuids);
     purgeCommands.deleteComponents(nonRootComponentUuids);
@@ -281,8 +280,8 @@ public class PurgeDao implements Dao {
     return !(SCOPE_PROJECT.equals(dto.scope()) && QUALIFIERS_PROJECT_VIEW.contains(dto.qualifier()));
   }
 
-  private static boolean isModuleOrSubview(ComponentDto dto) {
-    return SCOPE_PROJECT.equals(dto.scope()) && QUALIFIERS_MODULE_SUBVIEW.contains(dto.qualifier());
+  private static boolean isSubview(ComponentDto dto) {
+    return SCOPE_PROJECT.equals(dto.scope()) && QUALIFIER_SUBVIEW.contains(dto.qualifier());
   }
 
   public void deleteAnalyses(DbSession session, PurgeProfiler profiler, List<String> analysisUuids) {
index d7b162ce1af8799c452121ccf0875a175b3b47f5..d0baa30919665481826663a3355aa84403f68700 100644 (file)
@@ -30,9 +30,9 @@ public interface PurgeMapper {
   List<String> selectAnalysisUuids(PurgeSnapshotQuery query);
 
   /**
-   * Returns the list of modules/subviews and the application/view/project for the specified project_uuid.
+   * Returns the list of subviews and the application/view/project for the specified project_uuid.
    */
-  List<String> selectRootAndModulesOrSubviewsByProjectUuid(@Param("rootUuid") String rootUuid);
+  List<String> selectRootAndSubviewsByProjectUuid(@Param("rootUuid") String rootUuid);
 
   Set<String> selectDisabledComponentsWithFileSource(@Param("branchUuid") String branchUuid);
 
index f345637061b13424654e4162787b3963c0713885..22b2c021e1e824fcfd339daa64d6d843fad276f5 100644 (file)
@@ -6,8 +6,6 @@
     p.uuid as uuid,
     p.uuid_path as uuidPath,
     p.branch_uuid as branchUuid,
-    p.module_uuid as moduleUuid,
-    p.module_uuid_path as moduleUuidPath,
     p.main_branch_project_uuid as mainBranchProjectUuid,
     p.kee as kee,
     p.name as name,
@@ -58,8 +56,6 @@
           p.uuid as uuid,
           p.uuid_path as uuidPath,
           p.branch_uuid as branchUuid,
-          p.module_uuid as moduleUuid,
-          p.module_uuid_path as moduleUuidPath,
           p.main_branch_project_uuid as mainBranchProjectUuid,
           p.kee as kee,
           case
     SELECT
       p.uuid,
       p.path,
-      p.module_uuid as moduleUuid,
       fs.src_hash as srcHash,
       fs.revision
     FROM components root
     from components p
     where
       p.enabled = ${_true}
-      and p.branch_uuid = #{projectViewUuid,jdbcType=VARCHAR}
+      and p.branch_uuid = #{rootViewUuid,jdbcType=VARCHAR}
     <choose>
       <when test="_databaseId == 'mssql'">
-        and p.module_uuid_path like #{viewUuidLikeQuery,jdbcType=VARCHAR} {escape '\'}
+        and p.uuid_path like #{viewUuidLikeQuery,jdbcType=VARCHAR} {escape '\'}
       </when>
       <otherwise>
-        and p.module_uuid_path like #{viewUuidLikeQuery,jdbcType=VARCHAR} ESCAPE '\'
+        and p.uuid_path like #{viewUuidLikeQuery,jdbcType=VARCHAR} ESCAPE '\'
       </otherwise>
     </choose>
       and p.qualifier = 'TRK'
       uuid,
       uuid_path,
       branch_uuid,
-      module_uuid,
-      module_uuid_path,
       main_branch_project_uuid,
       name,
       long_name,
       b_enabled,
       b_language,
       b_long_name,
-      b_module_uuid,
-      b_module_uuid_path,
       b_name,
       b_path,
       b_qualifier
     #{uuid,jdbcType=VARCHAR},
     #{uuidPath,jdbcType=VARCHAR},
     #{branchUuid,jdbcType=VARCHAR},
-    #{moduleUuid,jdbcType=VARCHAR},
-    #{moduleUuidPath,jdbcType=VARCHAR},
     #{mainBranchProjectUuid, jdbcType=VARCHAR},
     #{name,jdbcType=VARCHAR},
     #{longName,jdbcType=VARCHAR},
     null,
     null,
     null,
-    null,
-    null,
     null
     )
   </insert>
     b_uuid_path = #{bUuidPath,jdbcType=VARCHAR},
     b_language = #{bLanguage,jdbcType=VARCHAR},
     b_long_name = #{bLongName,jdbcType=VARCHAR},
-    b_module_uuid = #{bModuleUuid,jdbcType=VARCHAR},
-    b_module_uuid_path = #{bModuleUuidPath,jdbcType=VARCHAR},
     b_name = #{bName,jdbcType=VARCHAR},
     b_path = #{bPath,jdbcType=VARCHAR},
     b_qualifier = #{bQualifier,jdbcType=VARCHAR}
     b_uuid_path = uuid_path,
     b_language = language,
     b_long_name = long_name,
-    b_module_uuid = module_uuid,
-    b_module_uuid_path = module_uuid_path,
     b_name = name,
     b_path = path,
     b_qualifier = qualifier
     uuid_path = b_uuid_path,
     language = b_language,
     long_name = b_long_name,
-    module_uuid = b_module_uuid,
-    module_uuid_path = b_module_uuid_path,
     name = b_name,
     path = b_path,
     qualifier = b_qualifier,
     b_enabled = ${_false},
     b_language = null,
     b_long_name = null,
-    b_module_uuid = null,
-    b_module_uuid_path = null,
     b_name = null,
     b_path = null,
     b_qualifier = null
index b9398c4a9797effca72724d7ce541de1e3583222..83ea44866933155822fe0b5e6f6da9dc0d2bc58f 100644 (file)
@@ -34,7 +34,6 @@
     r.security_standards as securityStandards,
     p.kee as componentKey,
     i.component_uuid as componentUuid,
-    p.module_uuid_path as moduleUuidPath,
     p.path as filePath,
     root.kee as projectKey,
     i.project_uuid as projectUuid,
     i.status &lt;&gt; 'CLOSED'
   </select>
 
-  <select id="selectNonClosedByComponentUuidExcludingExternals" parameterType="String" resultType="Issue">
-    select
-    <include refid="issueColumns"/>
-    from issues i
-    inner join rules r on r.uuid=i.rule_uuid
-    inner join components p on p.uuid=i.component_uuid
-    inner join components root on root.uuid=i.project_uuid
-    left join new_code_reference_issues n on i.kee = n.issue_key
-    where
-    (r.is_external is NULL or r.is_external = ${_false}) and
-    i.component_uuid = #{componentUuid,jdbcType=VARCHAR} and
-    i.status &lt;&gt; 'CLOSED' and
-    i.issue_type &lt;&gt; 4
-  </select>
-
   <select id="scrollClosedByComponentUuid" resultType="Issue" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY">
     select
       <include refid="issueColumns"/>,
       and i.status &lt;&gt; 'CLOSED'
   </select>
 
-  <select id="selectNonClosedByModuleOrProject" parameterType="map" resultType="Issue">
-    select
-    <include refid="issueColumns"/>
-    from issues i
-    inner join rules r on r.uuid = i.rule_uuid
-    inner join components p on p.uuid = i.component_uuid
-    inner join components root on root.uuid = i.project_uuid
-    left join new_code_reference_issues n on i.kee = n.issue_key
-    where
-    (r.is_external is NULL or r.is_external = ${_false}) and
-    i.project_uuid = #{projectUuid, jdbcType=VARCHAR} and
-    p.module_uuid_path like  #{likeModuleUuidPath, jdbcType=VARCHAR} escape '/' and
-    i.status &lt;&gt; 'CLOSED' and
-    i.issue_type &lt;&gt; 4
-  </select>
-
   <select id="selectIssueGroupsByComponent" resultType="org.sonar.db.issue.IssueGroupDto" parameterType="map">
     select i.issue_type as ruleType, i.severity as severity, i.resolution as resolution, i.status as status, sum(i.effort) as effort, count(i.issue_type) as "count",
     <if test="leakPeriodBeginningDate &gt;= 0">
index 6105013fc92bfd0bf8707c240ad4603f45d2acac..6e93cafe2a498533b984d0bfe0c894fe0e40af1d 100644 (file)
@@ -63,7 +63,7 @@
 
   </select>
 
-  <select id="selectRootAndModulesOrSubviewsByProjectUuid" resultType="String" parameterType="String">
+  <select id="selectRootAndSubviewsByProjectUuid" resultType="String" parameterType="String">
     select
        p.uuid
     from
@@ -71,7 +71,7 @@
     where
       (
         p.branch_uuid=#{rootUuid,jdbcType=VARCHAR}
-        and p.scope = 'PRJ' and p.qualifier in ('SVW','BRC')
+        and p.scope = 'PRJ' and p.qualifier = 'SVW'
       )
       or (
         uuid=#{rootUuid,jdbcType=VARCHAR}
index 4a387471810c165793bbbf53fe174859e0f8919c..cbafbb3785bb59b9ed9492efc7e4197afc03d6bc 100644 (file)
@@ -217,8 +217,6 @@ CREATE TABLE "COMPONENTS"(
     "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),
@@ -230,11 +228,8 @@ CREATE TABLE "COMPONENTS"(
     "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 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 "IDX_MAIN_BRANCH_PRJ_UUID" ON "COMPONENTS"("MAIN_BRANCH_PROJECT_UUID" NULLS FIRST);
index bfb266430abf2ceff5c1f95f7e240a406feb1afb..f7f739e8820a6501bb25b94c8f3a6ff9d5c8206a 100644 (file)
@@ -90,7 +90,6 @@ import static org.sonar.db.component.ComponentTesting.newBranchComponent;
 import static org.sonar.db.component.ComponentTesting.newBranchDto;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.component.ComponentTesting.newPortfolio;
 import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newProjectCopy;
@@ -102,7 +101,7 @@ import static org.sonar.db.component.ComponentTreeQuery.Strategy.LEAVES;
 public class ComponentDaoTest {
 
   private static final String PROJECT_UUID = "project-uuid";
-  private static final String MODULE_UUID = "module-uuid";
+  private static final String DIR_UUID = "dir-uuid";
   private static final String FILE_1_UUID = "file-1-uuid";
   private static final String FILE_2_UUID = "file-2-uuid";
   private static final String FILE_3_UUID = "file-3-uuid";
@@ -139,8 +138,6 @@ public class ComponentDaoTest {
     assertThat(result).isNotNull();
     assertThat(result.uuid()).isEqualTo(project.uuid());
     assertThat(result.getUuidPath()).isEqualTo(".");
-    assertThat(result.moduleUuid()).isNull();
-    assertThat(result.moduleUuidPath()).isEqualTo("." + project.uuid() + ".");
     assertThat(result.branchUuid()).isEqualTo(project.uuid());
     assertThat(result.getKey()).isEqualTo("org.struts:struts");
     assertThat(result.path()).isNull();
@@ -168,8 +165,6 @@ public class ComponentDaoTest {
 
     ComponentDto result = underTest.selectByUuid(dbSession, projectCopy.uuid()).get();
     assertThat(result.uuid()).isEqualTo(projectCopy.uuid());
-    assertThat(result.moduleUuid()).isEqualTo(view.uuid());
-    assertThat(result.moduleUuidPath()).isEqualTo("." + view.uuid() + ".");
     assertThat(result.branchUuid()).isEqualTo(view.uuid());
     assertThat(result.getKey()).isEqualTo(view.getKey() + project.getKey());
     assertThat(result.path()).isNull();
@@ -388,12 +383,10 @@ public class ComponentDaoTest {
   @Test
   public void select_component_keys_by_qualifiers() {
     ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto directory = db.components().insertComponent(newDirectory(module, "src"));
+    ComponentDto directory = db.components().insertComponent(newDirectory(project, "src"));
     ComponentDto file = db.components().insertComponent(newFileDto(directory));
 
     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();
@@ -411,32 +404,18 @@ public class ComponentDaoTest {
   public void find_sub_projects_by_component_keys() {
     ComponentDto project = db.components().insertPrivateProject();
     ComponentDto removedProject = db.components().insertPrivateProject(p -> p.setEnabled(false));
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto removedModule = db.components().insertComponent(newModuleDto(project).setEnabled(false));
-    ComponentDto subModule = db.components().insertComponent(newModuleDto(module));
-    ComponentDto removedSubModule = db.components().insertComponent(newModuleDto(module).setEnabled(false));
-    ComponentDto directory = db.components().insertComponent(newDirectory(subModule, "src"));
-    ComponentDto removedDirectory = db.components().insertComponent(newDirectory(subModule, "src2").setEnabled(false));
-    ComponentDto file = db.components().insertComponent(newFileDto(subModule, directory));
-    ComponentDto removedFile = db.components().insertComponent(newFileDto(subModule, directory).setEnabled(false));
+    ComponentDto directory = db.components().insertComponent(newDirectory(project, "src"));
+    ComponentDto removedDirectory = db.components().insertComponent(newDirectory(project, "src2").setEnabled(false));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, directory));
+    ComponentDto removedFile = db.components().insertComponent(newFileDto(project, directory).setEnabled(false));
 
     // Sub project of a file
     assertThat(underTest.selectSubProjectsByComponentUuids(dbSession, singletonList(file.uuid())))
       .extracting(ComponentDto::getKey)
-      .containsExactlyInAnyOrder(subModule.getKey());
+      .containsExactlyInAnyOrder(project.getKey());
 
     // Sub project of a directory
     assertThat(underTest.selectSubProjectsByComponentUuids(dbSession, singletonList(directory.uuid())))
-      .extracting(ComponentDto::uuid)
-      .containsExactlyInAnyOrder(subModule.uuid());
-
-    // Sub project of a sub module
-    assertThat(underTest.selectSubProjectsByComponentUuids(dbSession, singletonList(subModule.uuid())))
-      .extracting(ComponentDto::uuid)
-      .containsExactlyInAnyOrder(module.uuid());
-
-    // Sub project of a module
-    assertThat(underTest.selectSubProjectsByComponentUuids(dbSession, singletonList(module.uuid())))
       .extracting(ComponentDto::uuid)
       .containsExactlyInAnyOrder(project.uuid());
 
@@ -445,39 +424,22 @@ public class ComponentDaoTest {
       .extracting(ComponentDto::uuid)
       .containsExactlyInAnyOrder(project.uuid());
 
-    // SUb projects of a component and a sub module
-    assertThat(underTest.selectSubProjectsByComponentUuids(dbSession, asList(file.uuid(), subModule.uuid())))
-      .extracting(ComponentDto::uuid)
-      .containsExactlyInAnyOrder(subModule.uuid(), module.uuid());
-
     assertThat(underTest.selectSubProjectsByComponentUuids(dbSession, singletonList("unknown"))).isEmpty();
-
     assertThat(underTest.selectSubProjectsByComponentUuids(dbSession, Collections.emptyList())).isEmpty();
   }
 
   @Test
   public void select_enabled_files_from_project() {
     ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto fileDirectlyOnModule = db.components().insertComponent(newFileDto(module));
-    FileSourceDto fileSourceDirectlyOnModule = db.fileSources().insertFileSource(fileDirectlyOnModule);
-    ComponentDto subModule = db.components().insertComponent(newModuleDto(module));
-    ComponentDto directory = db.components().insertComponent(newDirectory(subModule, "src"));
-    ComponentDto file = db.components().insertComponent(newFileDto(subModule, directory));
+    ComponentDto directory = db.components().insertComponent(newDirectory(project, "src"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, directory));
     FileSourceDto fileSource = db.fileSources().insertFileSource(file);
 
     // From root project
     assertThat(underTest.selectEnabledFilesFromProject(dbSession, project.uuid()))
-      .extracting(FilePathWithHashDto::getUuid, FilePathWithHashDto::getModuleUuid, FilePathWithHashDto::getSrcHash, FilePathWithHashDto::getPath, FilePathWithHashDto::getRevision)
+      .extracting(FilePathWithHashDto::getUuid, FilePathWithHashDto::getSrcHash, FilePathWithHashDto::getPath, FilePathWithHashDto::getRevision)
       .containsExactlyInAnyOrder(
-        tuple(fileDirectlyOnModule.uuid(), module.uuid(), fileSourceDirectlyOnModule.getSrcHash(), fileDirectlyOnModule.path(), fileSourceDirectlyOnModule.getRevision()),
-        tuple(file.uuid(), subModule.uuid(), fileSource.getSrcHash(), file.path(), fileSource.getRevision()));
-
-    // From module
-    assertThat(underTest.selectEnabledFilesFromProject(dbSession, module.uuid())).isEmpty();
-
-    // From sub module
-    assertThat(underTest.selectEnabledFilesFromProject(dbSession, subModule.uuid())).isEmpty();
+        tuple(file.uuid(), fileSource.getSrcHash(), file.path(), fileSource.getRevision()));
 
     // From directory
     assertThat(underTest.selectEnabledFilesFromProject(dbSession, directory.uuid())).isEmpty();
@@ -489,20 +451,15 @@ public class ComponentDaoTest {
   public void select_by_branch_uuid() {
     ComponentDto project = db.components().insertPrivateProject();
     ComponentDto removedProject = db.components().insertPrivateProject(p -> p.setEnabled(false));
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto removedModule = db.components().insertComponent(newModuleDto(project).setEnabled(false));
-    ComponentDto subModule = db.components().insertComponent(newModuleDto(module));
-    ComponentDto removedSubModule = db.components().insertComponent(newModuleDto(module).setEnabled(false));
-    ComponentDto directory = db.components().insertComponent(newDirectory(subModule, "src"));
-    ComponentDto removedDirectory = db.components().insertComponent(newDirectory(subModule, "src2").setEnabled(false));
-    ComponentDto file = db.components().insertComponent(newFileDto(subModule, directory));
-    ComponentDto removedFile = db.components().insertComponent(newFileDto(subModule, directory).setEnabled(false));
+    ComponentDto directory = db.components().insertComponent(newDirectory(project, "src"));
+    ComponentDto removedDirectory = db.components().insertComponent(newDirectory(project, "src2").setEnabled(false));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, directory));
+    ComponentDto removedFile = db.components().insertComponent(newFileDto(project, directory).setEnabled(false));
 
     // Removed components are included
     assertThat(underTest.selectByBranchUuid(project.uuid(), dbSession))
       .extracting(ComponentDto::getKey)
-      .containsExactlyInAnyOrder(project.getKey(), module.getKey(), removedModule.getKey(), subModule.getKey(), removedSubModule.getKey(),
-        directory.getKey(), removedDirectory.getKey(), file.getKey(), removedFile.getKey());
+      .containsExactlyInAnyOrder(project.getKey(), directory.getKey(), removedDirectory.getKey(), file.getKey(), removedFile.getKey());
 
     assertThat(underTest.selectByBranchUuid("UNKNOWN", dbSession)).isEmpty();
   }
@@ -512,24 +469,16 @@ public class ComponentDaoTest {
     ComponentDto project = db.components().insertPrivateProject();
     ComponentDto branch = db.components().insertProjectBranch(project);
     ComponentDto removedProject = db.components().insertPrivateProject(p -> p.setEnabled(false));
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto removedModule = db.components().insertComponent(newModuleDto(project).setEnabled(false));
-    ComponentDto subModule = db.components().insertComponent(newModuleDto(module));
-    ComponentDto removedSubModule = db.components().insertComponent(newModuleDto(module).setEnabled(false));
-    ComponentDto directory = db.components().insertComponent(newDirectory(subModule, "src"));
-    ComponentDto removedDirectory = db.components().insertComponent(newDirectory(subModule, "src2").setEnabled(false));
-    ComponentDto file = db.components().insertComponent(newFileDto(subModule, directory));
-    ComponentDto removedFile = db.components().insertComponent(newFileDto(subModule, directory).setEnabled(false));
+    ComponentDto directory = db.components().insertComponent(newDirectory(project, "src"));
+    ComponentDto removedDirectory = db.components().insertComponent(newDirectory(project, "src2").setEnabled(false));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, directory));
+    ComponentDto removedFile = db.components().insertComponent(newFileDto(project, directory).setEnabled(false));
 
     Map<String, String> uuidsByKey = underTest.selectUuidsByKeyFromProjectKey(dbSession, project.getKey())
       .stream().collect(Collectors.toMap(KeyWithUuidDto::key, KeyWithUuidDto::uuid));
 
     assertThat(uuidsByKey).containsOnly(
       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()),
@@ -542,10 +491,8 @@ public class ComponentDaoTest {
     ComponentDto project = db.components().insertPrivateProject();
     ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey(branchKey));
     ComponentDto pr = db.components().insertProjectBranch(project, b -> b.setKey(branchKey).setBranchType(PULL_REQUEST));
-    ComponentDto module = db.components().insertComponent(newModuleDto(branch));
-    ComponentDto subModule = db.components().insertComponent(newModuleDto(module));
-    ComponentDto directory = db.components().insertComponent(newDirectory(subModule, "src"));
-    ComponentDto file = db.components().insertComponent(newFileDto(subModule, directory));
+    ComponentDto directory = db.components().insertComponent(newDirectory(branch, "src"));
+    ComponentDto file = db.components().insertComponent(newFileDto(branch, directory));
     ComponentDto projectFile = db.components().insertComponent(newFileDto(project, directory));
 
     Map<String, String> uuidsByKey = underTest.selectUuidsByKeyFromProjectKeyAndBranch(dbSession, project.getKey(), branchKey)
@@ -553,8 +500,6 @@ public class ComponentDaoTest {
 
     assertThat(uuidsByKey).containsOnly(
       entry(branch.getKey(), branch.uuid()),
-      entry(module.getKey(), module.uuid()),
-      entry(subModule.getKey(), subModule.uuid()),
       entry(directory.getKey(), directory.uuid()),
       entry(file.getKey(), file.uuid()));
   }
@@ -565,10 +510,8 @@ public class ComponentDaoTest {
     ComponentDto project = db.components().insertPrivateProject();
     ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey(prKey).setBranchType(PULL_REQUEST));
     ComponentDto pr = db.components().insertProjectBranch(project, b -> b.setKey(prKey).setBranchType(BRANCH));
-    ComponentDto module = db.components().insertComponent(newModuleDto(branch));
-    ComponentDto subModule = db.components().insertComponent(newModuleDto(module));
-    ComponentDto directory = db.components().insertComponent(newDirectory(subModule, "src"));
-    ComponentDto file = db.components().insertComponent(newFileDto(subModule, directory));
+    ComponentDto directory = db.components().insertComponent(newDirectory(branch, "src"));
+    ComponentDto file = db.components().insertComponent(newFileDto(branch, directory));
     ComponentDto projectFile = db.components().insertComponent(newFileDto(project, directory));
 
     Map<String, String> uuidsByKey = underTest.selectUuidsByKeyFromProjectKeyAndPullRequest(dbSession, project.getKey(), prKey)
@@ -576,8 +519,6 @@ public class ComponentDaoTest {
 
     assertThat(uuidsByKey).containsOnly(
       entry(branch.getKey(), branch.uuid()),
-      entry(module.getKey(), module.uuid()),
-      entry(subModule.getKey(), subModule.uuid()),
       entry(directory.getKey(), directory.uuid()),
       entry(file.getKey(), file.uuid()));
   }
@@ -1081,18 +1022,14 @@ public class ComponentDaoTest {
   public void selectByProjectUuid() {
     ComponentDto project = db.components().insertPrivateProject();
     ComponentDto removedProject = db.components().insertPrivateProject(p -> p.setEnabled(false));
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto removedModule = db.components().insertComponent(newModuleDto(project).setEnabled(false));
-    ComponentDto subModule = db.components().insertComponent(newModuleDto(module));
-    ComponentDto removedSubModule = db.components().insertComponent(newModuleDto(module).setEnabled(false));
-    ComponentDto directory = db.components().insertComponent(newDirectory(subModule, "src"));
-    ComponentDto removedDirectory = db.components().insertComponent(newDirectory(subModule, "src2").setEnabled(false));
-    ComponentDto file = db.components().insertComponent(newFileDto(subModule, directory));
-    ComponentDto removedFile = db.components().insertComponent(newFileDto(subModule, directory).setEnabled(false));
+    ComponentDto directory = db.components().insertComponent(newDirectory(project, "src"));
+    ComponentDto removedDirectory = db.components().insertComponent(newDirectory(project, "src2").setEnabled(false));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, directory));
+    ComponentDto removedFile = db.components().insertComponent(newFileDto(project, directory).setEnabled(false));
 
     assertThat(underTest.selectByBranchUuid(project.uuid(), dbSession))
       .extracting(ComponentDto::uuid)
-      .containsExactlyInAnyOrder(project.uuid(), module.uuid(), removedModule.uuid(), subModule.uuid(), removedSubModule.uuid(), directory.uuid(), removedDirectory.uuid(),
+      .containsExactlyInAnyOrder(project.uuid(), directory.uuid(), removedDirectory.uuid(),
         file.uuid(),
         removedFile.uuid());
   }
@@ -1124,19 +1061,16 @@ public class ComponentDaoTest {
   private ListAssert<String> assertSelectForIndexing(@Nullable String projectUuid) {
     ComponentDto project = db.components().insertPrivateProject("U1");
     ComponentDto removedProject = db.components().insertPrivateProject(p -> p.setEnabled(false));
-    ComponentDto module = db.components().insertComponent(newModuleDto("U2", project));
-    ComponentDto removedModule = db.components().insertComponent(newModuleDto(project).setEnabled(false));
-    ComponentDto directory = db.components().insertComponent(newDirectory(module, "U3", "src"));
-    ComponentDto removedDirectory = db.components().insertComponent(newDirectory(module, "src2").setEnabled(false));
-    ComponentDto file = db.components().insertComponent(newFileDto(module, directory, "U4"));
-    ComponentDto removedFile = db.components().insertComponent(newFileDto(module, directory).setEnabled(false));
+    ComponentDto directory = db.components().insertComponent(newDirectory(project, "U3", "src"));
+    ComponentDto removedDirectory = db.components().insertComponent(newDirectory(project, "src2").setEnabled(false));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, directory, "U4"));
+    ComponentDto removedFile = db.components().insertComponent(newFileDto(project, directory).setEnabled(false));
 
     ComponentDto view = db.components().insertPublicPortfolio("VW1", p -> {
     });
     db.components().insertComponent(newProjectCopy("COPY8", project, view));
 
     ComponentDto project2 = db.components().insertPrivateProject("U5");
-    ComponentDto moduleOnProject2 = db.components().insertComponent(newModuleDto("U6", project2));
 
     List<ComponentDto> components = new ArrayList<>();
     underTest.scrollForIndexing(dbSession, projectUuid,
@@ -1158,8 +1092,6 @@ public class ComponentDaoTest {
       .setBUuidPath("uuid_path")
       .setBLanguage("lang")
       .setBLongName("longName")
-      .setBModuleUuid("moduleUuid")
-      .setBModuleUuidPath("moduleUuidPath")
       .setBName("name")
       .setBPath("path")
       .setBQualifier("qualifier"), "qualifier");
@@ -1176,8 +1108,6 @@ public class ComponentDaoTest {
       .containsEntry("bUuidPath", "uuid_path")
       .containsEntry("bLanguage", "lang")
       .containsEntry("bLongName", "longName")
-      .containsEntry("bModuleUuid", "moduleUuid")
-      .containsEntry("bModuleUuidPath", "moduleUuidPath")
       .containsEntry("bName", "name")
       .containsEntry("bPath", "path")
       .containsEntry("bQualifier", "qualifier");
@@ -1204,8 +1134,6 @@ public class ComponentDaoTest {
       .containsEntry("bUuidPath", dto1.getUuidPath())
       .containsEntry("bLanguage", dto1.language())
       .containsEntry("bLongName", dto1.longName())
-      .containsEntry("bModuleUuid", dto1.moduleUuid())
-      .containsEntry("bModuleUuidPath", dto1.moduleUuidPath())
       .containsEntry("bName", dto1.name())
       .containsEntry("bPath", dto1.path())
       .containsEntry("bQualifier", dto1.qualifier());
@@ -1221,8 +1149,6 @@ public class ComponentDaoTest {
       .containsEntry("bUuidPath", dto2.getUuidPath())
       .containsEntry("bLanguage", dto2.language())
       .containsEntry("bLongName", dto2.longName())
-      .containsEntry("bModuleUuid", dto2.moduleUuid())
-      .containsEntry("bModuleUuidPath", dto2.moduleUuidPath())
       .containsEntry("bName", dto2.name())
       .containsEntry("bPath", dto2.path())
       .containsEntry("bQualifier", dto2.qualifier());
@@ -1234,8 +1160,7 @@ public class ComponentDaoTest {
   private Map<String, Object> selectBColumnsForUuid(String uuid) {
     return db.selectFirst(
       "select b_changed as \"bChanged\", deprecated_kee as \"bKey\", b_copy_component_uuid as \"bCopyComponentUuid\", b_description as \"bDescription\", " +
-        "b_enabled as \"bEnabled\", b_uuid_path as \"bUuidPath\", b_language as \"bLanguage\", b_long_name as \"bLongName\"," +
-        "b_module_uuid as \"bModuleUuid\", b_module_uuid_path as \"bModuleUuidPath\", b_name as \"bName\", " +
+        "b_enabled as \"bEnabled\", b_uuid_path as \"bUuidPath\", b_language as \"bLanguage\", b_long_name as \"bLongName\", b_name as \"bName\", " +
         "b_path as \"bPath\", b_qualifier as \"bQualifier\" " +
         "from components where uuid='" + uuid + "'");
   }
@@ -1549,12 +1474,12 @@ public class ComponentDaoTest {
 
   @Test
   public void selectAncestors() {
-    // project -> module -> file
+    // project -> dir -> file
     ComponentDto project = newPrivateProjectDto(PROJECT_UUID);
     db.components().insertProjectAndSnapshot(project);
-    ComponentDto module = newModuleDto(MODULE_UUID, project);
-    db.components().insertComponent(module);
-    ComponentDto file = newFileDto(module, null, FILE_1_UUID);
+    ComponentDto dir = newDirectory(project, DIR_UUID, "path");
+    db.components().insertComponent(dir);
+    ComponentDto file = newFileDto(dir, null, FILE_1_UUID);
     db.components().insertComponent(file);
     db.commit();
 
@@ -1562,69 +1487,69 @@ public class ComponentDaoTest {
     List<ComponentDto> ancestors = underTest.selectAncestors(dbSession, project);
     assertThat(ancestors).isEmpty();
 
-    // ancestors of module
-    ancestors = underTest.selectAncestors(dbSession, module);
+    // ancestors of dir
+    ancestors = underTest.selectAncestors(dbSession, dir);
     assertThat(ancestors).extracting("uuid").containsExactly(PROJECT_UUID);
 
     // ancestors of file
     ancestors = underTest.selectAncestors(dbSession, file);
-    assertThat(ancestors).extracting("uuid").containsExactly(PROJECT_UUID, MODULE_UUID);
+    assertThat(ancestors).extracting("uuid").containsExactly(PROJECT_UUID, DIR_UUID);
   }
 
   @Test
   public void select_children() {
     ComponentDto project = newPrivateProjectDto(PROJECT_UUID);
     db.components().insertProjectAndSnapshot(project);
-    ComponentDto module = newModuleDto(MODULE_UUID, project);
-    db.components().insertComponent(module);
+    ComponentDto dir = newDirectory(project, DIR_UUID, "path");
+    db.components().insertComponent(dir);
     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).setKey("file-key-2").setName("File Two");
-    db.components().insertComponent(file1InModule);
-    ComponentDto file2InModule = newFileDto(module, null, FILE_3_UUID).setKey("file-key-3").setName("File Three");
-    db.components().insertComponent(file2InModule);
+    ComponentDto file1InDir = newFileDto(dir, null, FILE_2_UUID).setKey("file-key-2").setName("File Two");
+    db.components().insertComponent(file1InDir);
+    ComponentDto file2InDir = newFileDto(dir, null, FILE_3_UUID).setKey("file-key-3").setName("File Three");
+    db.components().insertComponent(file2InDir);
     db.commit();
 
     // test children of root
-    assertThat(underTest.selectChildren(dbSession, project.uuid(), List.of(project))).extracting("uuid").containsOnly(FILE_1_UUID, MODULE_UUID);
+    assertThat(underTest.selectChildren(dbSession, project.uuid(), List.of(project))).extracting("uuid").containsOnly(FILE_1_UUID, DIR_UUID);
 
-    // test children of intermediate component (module here)
-    assertThat(underTest.selectChildren(dbSession, project.uuid(), List.of(module))).extracting("uuid").containsOnly(FILE_2_UUID, FILE_3_UUID);
+    // test children of intermediate component (dir here)
+    assertThat(underTest.selectChildren(dbSession, project.uuid(), List.of(dir))).extracting("uuid").containsOnly(FILE_2_UUID, FILE_3_UUID);
 
     // test children of leaf component (file here)
     assertThat(underTest.selectChildren(dbSession, project.uuid(), List.of(fileInProject))).isEmpty();
 
     // test children of 2 components
-    assertThat(underTest.selectChildren(dbSession, project.uuid(), List.of(project, module))).extracting("uuid").containsOnly(FILE_1_UUID, MODULE_UUID, FILE_2_UUID, FILE_3_UUID);
+    assertThat(underTest.selectChildren(dbSession, project.uuid(), List.of(project, dir))).extracting("uuid").containsOnly(FILE_1_UUID, DIR_UUID, FILE_2_UUID, FILE_3_UUID);
   }
 
   @Test
   public void select_descendants_with_children_strategy() {
-    // project has 2 children: module and file 1. Other files are part of module.
+    // project has 2 children: dir and file 1. Other files are part of dir.
     ComponentDto project = newPrivateProjectDto(PROJECT_UUID);
     db.components().insertProjectAndSnapshot(project);
-    ComponentDto module = newModuleDto(MODULE_UUID, project);
-    db.components().insertComponent(module);
+    ComponentDto dir = newDirectory(project, DIR_UUID, "dir");
+    db.components().insertComponent(dir);
     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).setKey("file-key-2").setName("File Two");
-    db.components().insertComponent(file1InModule);
-    ComponentDto file2InModule = newFileDto(module, null, FILE_3_UUID).setKey("file-key-3").setName("File Three");
-    db.components().insertComponent(file2InModule);
+    ComponentDto file1InDir = newFileDto(project, dir, FILE_2_UUID).setKey("file-key-2").setName("File Two");
+    db.components().insertComponent(file1InDir);
+    ComponentDto file2InDir = newFileDto(project, dir, FILE_3_UUID).setKey("file-key-3").setName("File Three");
+    db.components().insertComponent(file2InDir);
     db.commit();
 
     // test children of root
     ComponentTreeQuery query = newTreeQuery(PROJECT_UUID).build();
     List<ComponentDto> children = underTest.selectDescendants(dbSession, query);
-    assertThat(children).extracting("uuid").containsOnly(FILE_1_UUID, MODULE_UUID);
+    assertThat(children).extracting("uuid").containsOnly(FILE_1_UUID, DIR_UUID);
 
     // test children of root, filtered by qualifier
-    query = newTreeQuery(PROJECT_UUID).setQualifiers(asList(Qualifiers.MODULE)).build();
+    query = newTreeQuery(PROJECT_UUID).setQualifiers(asList(Qualifiers.DIRECTORY)).build();
     children = underTest.selectDescendants(dbSession, query);
-    assertThat(children).extracting("uuid").containsOnly(MODULE_UUID);
+    assertThat(children).extracting("uuid").containsOnly(DIR_UUID);
 
-    // test children of intermediate component (module here), default ordering by
-    query = newTreeQuery(MODULE_UUID).build();
+    // test children of intermediate component (dir here), default ordering by
+    query = newTreeQuery(DIR_UUID).build();
     assertThat(underTest.selectDescendants(dbSession, query)).extracting("uuid").containsOnly(FILE_2_UUID, FILE_3_UUID);
 
     // test children of leaf component (file here)
@@ -1647,12 +1572,12 @@ public class ComponentDaoTest {
     query = newTreeQuery(PROJECT_UUID).setNameOrKeyQuery("does-not-exist").build();
     assertThat(underTest.selectDescendants(dbSession, query)).isEmpty();
 
-    // test children of intermediate component (module here), matching name
-    query = newTreeQuery(MODULE_UUID).setNameOrKeyQuery("Two").build();
+    // test children of intermediate component (dir here), matching name
+    query = newTreeQuery(DIR_UUID).setNameOrKeyQuery("Two").build();
     assertThat(underTest.selectDescendants(dbSession, query)).extracting("uuid").containsOnly(FILE_2_UUID);
 
-    // test children of intermediate component (module here), without matching name
-    query = newTreeQuery(MODULE_UUID).setNameOrKeyQuery("does-not-exist").build();
+    // test children of intermediate component (dir here), without matching name
+    query = newTreeQuery(DIR_UUID).setNameOrKeyQuery("does-not-exist").build();
     assertThat(underTest.selectDescendants(dbSession, query)).isEmpty();
 
     // test children of leaf component (file here)
@@ -1668,17 +1593,17 @@ public class ComponentDaoTest {
     assertThat(underTest.selectDescendants(dbSession, query))
       .extracting(ComponentDto::uuid)
       .containsExactlyInAnyOrder(fileInProject.uuid());
-    query = newTreeQuery(project.uuid()).setScopes(asList(Scopes.PROJECT)).build();
+    query = newTreeQuery(project.uuid()).setScopes(asList(Scopes.DIRECTORY)).build();
     assertThat(underTest.selectDescendants(dbSession, query))
       .extracting(ComponentDto::uuid)
-      .containsExactlyInAnyOrder(module.uuid());
+      .containsExactlyInAnyOrder(dir.uuid());
   }
 
   @Test
   public void select_descendants_with_leaves_strategy() {
     ComponentDto project = newPrivateProjectDto(PROJECT_UUID);
     db.components().insertProjectAndSnapshot(project);
-    db.components().insertComponent(newModuleDto("module-1-uuid", project));
+    db.components().insertComponent(newDirectory(project, "dir-1-uuid", "dir"));
     db.components().insertComponent(newFileDto(project, null, "file-1-uuid"));
     db.components().insertComponent(newFileDto(project, null, "file-2-uuid"));
     db.commit();
@@ -1686,7 +1611,7 @@ public class ComponentDaoTest {
     ComponentTreeQuery query = newTreeQuery(PROJECT_UUID).setStrategy(LEAVES).build();
 
     List<ComponentDto> result = underTest.selectDescendants(dbSession, query);
-    assertThat(result).extracting("uuid").containsOnly("file-1-uuid", "file-2-uuid", "module-1-uuid");
+    assertThat(result).extracting("uuid").containsOnly("file-1-uuid", "file-2-uuid", "dir-1-uuid");
   }
 
   @Test
index 36efb4eddb8d665d0984b31dad6f7908da974fa1..102931506c72b07cc3e720b65b77697592b3b590 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.db.component;
 
 import org.junit.Test;
-import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.resources.Scopes;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -77,9 +76,9 @@ public class ComponentDtoTest {
 
   @Test
   public void is_root_project() {
-    assertThat(new ComponentDto().setModuleUuid("ABCD").isRootProject()).isFalse();
-    assertThat(new ComponentDto().setModuleUuid("ABCD").setScope(Scopes.DIRECTORY).isRootProject()).isFalse();
-    assertThat(new ComponentDto().setModuleUuid(null).setScope(Scopes.PROJECT).setQualifier(Qualifiers.PROJECT).isRootProject()).isTrue();
+    assertThat(new ComponentDto().setUuid("uuid").setBranchUuid("branch").isRootProject()).isFalse();
+    assertThat(new ComponentDto().setScope(Scopes.DIRECTORY).setUuid("uuid").setBranchUuid("uuid").isRootProject()).isFalse();
+    assertThat(new ComponentDto().setScope(Scopes.PROJECT).setUuid("uuid").setBranchUuid("uuid").isRootProject()).isTrue();
   }
 
   @Test
@@ -93,11 +92,11 @@ public class ComponentDtoTest {
     ComponentDto project = ComponentTesting.newPrivateProjectDto().setUuidPath(ComponentDto.UUID_PATH_OF_ROOT);
     assertThat(project.getUuidPathLikeIncludingSelf()).isEqualTo("." + project.uuid() + ".%");
 
-    ComponentDto module = ComponentTesting.newModuleDto(project);
-    assertThat(module.getUuidPathLikeIncludingSelf()).isEqualTo("." + project.uuid() + "." + module.uuid() + ".%");
+    ComponentDto dir = ComponentTesting.newDirectory(project, "path");
+    assertThat(dir.getUuidPathLikeIncludingSelf()).isEqualTo("." + project.uuid() + "." + dir.uuid() + ".%");
 
-    ComponentDto file = ComponentTesting.newFileDto(module);
-    assertThat(file.getUuidPathLikeIncludingSelf()).isEqualTo("." + project.uuid() + "." + module.uuid() + "." + file.uuid() + ".%");
+    ComponentDto file = ComponentTesting.newFileDto(project, dir);
+    assertThat(file.getUuidPathLikeIncludingSelf()).isEqualTo("." + project.uuid() + "." + dir.uuid() + "." + file.uuid() + ".%");
   }
 
   @Test
index 41d48049e5b15bc025425b0a9229e54a922b1bf6..a1c28e8dc87b6d196a1dfc90ccf71de3a0caf697 100644 (file)
@@ -43,7 +43,6 @@ import static org.sonar.db.component.BranchType.PULL_REQUEST;
 import static org.sonar.db.component.ComponentKeyUpdaterDao.computeNewKey;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 
 public class ComponentKeyUpdaterDaoTest {
@@ -60,20 +59,16 @@ public class ComponentKeyUpdaterDaoTest {
   public void updateKey_changes_the_key_of_tree_of_components() {
     populateSomeData();
 
-    underTest.updateKey(dbSession, "B", "struts:core");
+    underTest.updateKey(dbSession, "A", "struts:core");
     dbSession.commit();
 
     assertThat(db.select("select uuid as \"UUID\", kee as \"KEE\" from components"))
       .extracting(t -> t.get("UUID"), t -> t.get("KEE"))
       .containsOnly(
-        Tuple.tuple("A", "org.struts:struts"),
-        Tuple.tuple("B", "struts:core"),
-        Tuple.tuple("C", "struts:core:/src/org/struts"),
-        Tuple.tuple("D", "struts:core:/src/org/struts/RequestContext.java"),
-        Tuple.tuple("E", "org.struts:struts-ui"),
-        Tuple.tuple("F", "org.struts:struts-ui:/src/org/struts"),
-        Tuple.tuple("G", "org.struts:struts-ui:/src/org/struts/RequestContext.java"),
-        Tuple.tuple("H", "foo:struts-core"));
+        Tuple.tuple("A", "struts:core"),
+        Tuple.tuple("B", "struts:core:/src/org/struts"),
+        Tuple.tuple("C", "struts:core:/src/org/struts/RequestContext.java"),
+        Tuple.tuple("D", "foo:struts-core"));
   }
 
   @Test
@@ -155,9 +150,9 @@ public class ComponentKeyUpdaterDaoTest {
   public void updateKey_throws_IAE_if_component_with_specified_key_does_not_exist() {
     populateSomeData();
 
-    assertThatThrownBy(() -> underTest.updateKey(dbSession, "B", "org.struts:struts-ui"))
+    assertThatThrownBy(() -> underTest.updateKey(dbSession, "A", "foo:struts-core"))
       .isInstanceOf(IllegalArgumentException.class)
-      .hasMessage("Impossible to update key: a component with key \"org.struts:struts-ui\" already exists.");
+      .hasMessage("Impossible to update key: a component with key \"foo:struts-core\" already exists.");
   }
 
   @Test
@@ -190,12 +185,8 @@ public class ComponentKeyUpdaterDaoTest {
 
   private void populateSomeData() {
     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).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).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"));
+    ComponentDto directory1 = db.components().insertComponent(newDirectory(project1, "/src/org/struts").setUuid("B"));
+    db.components().insertComponent(ComponentTesting.newFileDto(project1, directory1).setKey("org.struts:struts:/src/org/struts/RequestContext.java").setUuid("C"));
+    ComponentDto project2 = db.components().insertPublicProject(t -> t.setKey("foo:struts-core").setUuid("D"));
   }
 }
index 789584f4406ac7b09748d3b4f241c3cab820853e..3f99ac188aa64f5f8535bc4f2bc8fa884bc911d1 100644 (file)
@@ -103,11 +103,11 @@ public class ScrollForFileMoveComponentDaoTest {
   @Test
   public void scrollAllFilesForFileMove_scrolls_files_of_project() {
     ComponentDto project = random.nextBoolean() ? db.components().insertPrivateProject() : db.components().insertPublicProject();
-    ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project));
-    ComponentDto module2 = db.components().insertComponent(ComponentTesting.newModuleDto(module1));
+    ComponentDto dir1 = db.components().insertComponent(ComponentTesting.newDirectory(project, "path"));
+    ComponentDto dir2 = db.components().insertComponent(ComponentTesting.newDirectory(dir1, "path2"));
     ComponentAndSource file1 = insertFileAndSource(project, FILE);
-    ComponentAndSource file2 = insertFileAndSource(module1, FILE);
-    ComponentAndSource file3 = insertFileAndSource(module2, FILE);
+    ComponentAndSource file2 = insertFileAndSource(dir1, FILE);
+    ComponentAndSource file3 = insertFileAndSource(dir2, FILE);
     RecordingResultHandler resultHandler = new RecordingResultHandler();
 
     underTest.scrollAllFilesForFileMove(dbSession, project.uuid(), resultHandler);
@@ -177,11 +177,9 @@ public class ScrollForFileMoveComponentDaoTest {
   public void scrollAllFilesForFileMove_ignores_non_file_and_non_ut_component_with_source() {
     ComponentDto project = random.nextBoolean() ? db.components().insertPrivateProject() : db.components().insertPublicProject();
     db.fileSources().insertFileSource(project);
-    ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project));
-    db.fileSources().insertFileSource(module);
-    ComponentDto dir = db.components().insertComponent(ComponentTesting.newDirectory(module, "foo"));
+    ComponentDto dir = db.components().insertComponent(ComponentTesting.newDirectory(project, "foo"));
     db.fileSources().insertFileSource(dir);
-    ComponentAndSource file = insertFileAndSource(module, FILE);
+    ComponentAndSource file = insertFileAndSource(project, FILE);
     ComponentAndSource ut = insertFileAndSource(dir, UNIT_TEST_FILE);
     ComponentDto portfolio = random.nextBoolean() ? db.components().insertPublicPortfolio() : db.components().insertPrivatePortfolio();
     db.fileSources().insertFileSource(portfolio);
index 74d0d4309bb501bde2c212dd0b791c07c585ae09..c39707eefb20d18cc6ae285c5af5a5927e9e41a8 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.db.issue;
 
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -36,14 +35,12 @@ import org.sonar.db.RowNotFoundException;
 import org.sonar.db.component.BranchType;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.ComponentTesting;
-import org.sonar.db.component.ComponentUpdateDto;
 import org.sonar.db.protobuf.DbIssues;
 import org.sonar.db.rule.RuleDto;
 import org.sonar.db.rule.RuleTesting;
 
 import static java.util.Arrays.asList;
 import static java.util.Collections.emptyList;
-import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
 import static org.apache.commons.lang.math.RandomUtils.nextInt;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -52,16 +49,13 @@ import static org.junit.Assert.assertFalse;
 import static org.sonar.api.issue.Issue.RESOLUTION_FALSE_POSITIVE;
 import static org.sonar.api.issue.Issue.RESOLUTION_FIXED;
 import static org.sonar.api.issue.Issue.RESOLUTION_WONT_FIX;
-import static org.sonar.api.issue.Issue.STATUSES;
 import static org.sonar.api.issue.Issue.STATUS_CLOSED;
 import static org.sonar.api.issue.Issue.STATUS_CONFIRMED;
 import static org.sonar.api.issue.Issue.STATUS_OPEN;
 import static org.sonar.api.issue.Issue.STATUS_REOPENED;
 import static org.sonar.api.issue.Issue.STATUS_RESOLVED;
 import static org.sonar.api.issue.Issue.STATUS_REVIEWED;
-import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.issue.IssueTesting.newCodeReferenceIssue;
 import static org.sonar.db.protobuf.DbIssues.MessageFormattingType.CODE;
 
@@ -287,65 +281,6 @@ public class IssueDaoTest {
     assertThat(issues).extracting("key").containsOnly("I1", "I2");
   }
 
-  @Test
-  public void scrollNonClosedByComponentUuid() {
-    RuleDto rule = db.rules().insert();
-    ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto file = db.components().insertComponent(newFileDto(project));
-    IssueDto openIssue1OnFile = db.issues().insert(rule, project, file, i -> i.setStatus("OPEN").setResolution(null).setType(randomRuleTypeExceptHotspot()));
-    IssueDto openIssue2OnFile = db.issues().insert(rule, project, file, i -> i.setStatus("OPEN").setResolution(null).setType(randomRuleTypeExceptHotspot()));
-    IssueDto closedIssueOnFile = db.issues().insert(rule, project, file, i -> i.setStatus("CLOSED").setResolution("FIXED").setType(randomRuleTypeExceptHotspot()));
-    IssueDto openIssueOnProject = db.issues().insert(rule, project, project, i -> i.setStatus("OPEN").setResolution(null).setType(randomRuleTypeExceptHotspot()));
-
-    IssueDto securityHotspot = db.issues().insert(rule, project, file, i -> i.setType(RuleType.SECURITY_HOTSPOT));
-
-    RuleDto external = db.rules().insert(ruleDefinitionDto -> ruleDefinitionDto.setIsExternal(true));
-    IssueDto issueFromExteralruleOnFile = db.issues().insert(external, project, file, i -> i.setKee("ON_FILE_FROM_EXTERNAL").setType(randomRuleTypeExceptHotspot()));
-
-    assertThat(underTest.selectNonClosedByComponentUuidExcludingExternalsAndSecurityHotspots(db.getSession(), file.uuid()))
-      .extracting(IssueDto::getKey)
-      .containsExactlyInAnyOrder(Arrays.stream(new IssueDto[] {openIssue1OnFile, openIssue2OnFile}).map(IssueDto::getKey).toArray(String[]::new));
-
-    assertThat(underTest.selectNonClosedByComponentUuidExcludingExternalsAndSecurityHotspots(db.getSession(), project.uuid()))
-      .extracting(IssueDto::getKey)
-      .containsExactlyInAnyOrder(Arrays.stream(new IssueDto[] {openIssueOnProject}).map(IssueDto::getKey).toArray(String[]::new));
-
-    assertThat(underTest.selectNonClosedByComponentUuidExcludingExternalsAndSecurityHotspots(db.getSession(), "does_not_exist")).isEmpty();
-  }
-
-  @Test
-  public void scrollNonClosedByModuleOrProject() {
-    RuleDto rule = db.rules().insert();
-    ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto anotherProject = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto file = db.components().insertComponent(newFileDto(module));
-    IssueDto openIssue1OnFile = db.issues().insert(rule, project, file, i -> i.setStatus("OPEN").setResolution(null).setType(randomRuleTypeExceptHotspot()));
-    IssueDto openIssue2OnFile = db.issues().insert(rule, project, file, i -> i.setStatus("OPEN").setResolution(null).setType(randomRuleTypeExceptHotspot()));
-    IssueDto closedIssueOnFile = db.issues().insert(rule, project, file, i -> i.setStatus("CLOSED").setResolution("FIXED").setType(randomRuleTypeExceptHotspot()));
-    IssueDto openIssueOnModule = db.issues().insert(rule, project, module, i -> i.setStatus("OPEN").setResolution(null).setType(randomRuleTypeExceptHotspot()));
-    IssueDto openIssueOnProject = db.issues().insert(rule, project, project, i -> i.setStatus("OPEN").setResolution(null).setType(randomRuleTypeExceptHotspot()));
-    IssueDto openIssueOnAnotherProject = db.issues().insert(rule, anotherProject, anotherProject,
-      i -> i.setStatus("OPEN").setResolution(null).setType(randomRuleTypeExceptHotspot()));
-
-    IssueDto securityHotspot = db.issues().insert(rule, project, file, i -> i.setType(RuleType.SECURITY_HOTSPOT));
-
-    RuleDto external = db.rules().insert(ruleDefinitionDto -> ruleDefinitionDto.setIsExternal(true));
-    IssueDto issueFromExteralruleOnFile = db.issues().insert(external, project, file, i -> i.setKee("ON_FILE_FROM_EXTERNAL").setType(randomRuleTypeExceptHotspot()));
-
-    assertThat(underTest.selectNonClosedByModuleOrProjectExcludingExternalsAndSecurityHotspots(db.getSession(), project))
-      .extracting(IssueDto::getKey)
-      .containsExactlyInAnyOrder(
-        Arrays.stream(new IssueDto[] {openIssue1OnFile, openIssue2OnFile, openIssueOnModule, openIssueOnProject}).map(IssueDto::getKey).toArray(String[]::new));
-
-    assertThat(underTest.selectNonClosedByModuleOrProjectExcludingExternalsAndSecurityHotspots(db.getSession(), module))
-      .extracting(IssueDto::getKey)
-      .containsExactlyInAnyOrder(Arrays.stream(new IssueDto[] {openIssue1OnFile, openIssue2OnFile, openIssueOnModule}).map(IssueDto::getKey).toArray(String[]::new));
-
-    ComponentDto notPersisted = ComponentTesting.newPrivateProjectDto();
-    assertThat(underTest.selectNonClosedByModuleOrProjectExcludingExternalsAndSecurityHotspots(db.getSession(), notPersisted)).isEmpty();
-  }
-
   @Test
   public void selectOpenByComponentUuid() {
     RuleDto rule = db.rules().insert();
index ed147d5a838a548f6ea71f034b3da8a0af3b91c3..e7ecde672662bb72f4332dd1cfb1e2bb5ea72830 100644 (file)
@@ -61,7 +61,6 @@ public class IssueDtoTest {
       .setComponentKey("org.sonar.sample:Sample")
       .setComponentUuid("CDEF")
       .setProjectUuid("GHIJ")
-      .setModuleUuidPath("ABCD.BCDE.")
       .setProjectKey("org.sonar.sample")
       .setStatus(Issue.STATUS_CLOSED)
       .setResolution(Issue.RESOLUTION_FALSE_POSITIVE)
@@ -87,7 +86,6 @@ public class IssueDtoTest {
     assertThat(issue.componentUuid()).isEqualTo("CDEF");
     assertThat(issue.projectUuid()).isEqualTo("GHIJ");
     assertThat(issue.componentKey()).isEqualTo("org.sonar.sample:Sample");
-    assertThat(issue.moduleUuidPath()).isEqualTo("ABCD.BCDE.");
     assertThat(issue.projectKey()).isEqualTo("org.sonar.sample");
     assertThat(issue.status()).isEqualTo(Issue.STATUS_CLOSED);
     assertThat(issue.resolution()).isEqualTo(Issue.RESOLUTION_FALSE_POSITIVE);
@@ -169,10 +167,8 @@ public class IssueDtoTest {
 
     assertThat(issueDto).extracting(IssueDto::isManualSeverity, IssueDto::getChecksum, IssueDto::getAssigneeUuid,
       IssueDto::isExternal, IssueDto::getComponentUuid, IssueDto::getComponentKey,
-      IssueDto::getModuleUuidPath, IssueDto::getProjectUuid, IssueDto::getProjectKey,
-      IssueDto::getRuleUuid)
-      .containsExactly(true, "123", "123", true, "123", "componentKey",
-        "path/to/module/uuid", "123", "projectKey", "ruleUuid");
+      IssueDto::getProjectUuid, IssueDto::getProjectKey, IssueDto::getRuleUuid)
+      .containsExactly(true, "123", "123", true, "123", "componentKey", "123", "projectKey", "ruleUuid");
 
     assertThat(issueDto.isQuickFixAvailable()).isTrue();
     assertThat(issueDto.isNewCodeReferenceIssue()).isTrue();
@@ -201,10 +197,8 @@ public class IssueDtoTest {
       .containsExactly(Set.of("todo"), "admin");
 
     assertThat(issueDto).extracting(IssueDto::isManualSeverity, IssueDto::getChecksum, IssueDto::getAssigneeUuid,
-      IssueDto::isExternal, IssueDto::getComponentUuid, IssueDto::getComponentKey,
-      IssueDto::getModuleUuidPath, IssueDto::getProjectUuid, IssueDto::getProjectKey)
-      .containsExactly(true, "123", "123", true, "123", "componentKey",
-        "path/to/module/uuid", "123", "projectKey");
+      IssueDto::isExternal, IssueDto::getComponentUuid, IssueDto::getComponentKey, IssueDto::getProjectUuid, IssueDto::getProjectKey)
+      .containsExactly(true, "123", "123", true, "123", "componentKey", "123", "projectKey");
 
     assertThat(issueDto.isQuickFixAvailable()).isTrue();
     assertThat(issueDto.isNewCodeReferenceIssue()).isTrue();
@@ -230,7 +224,6 @@ public class IssueDtoTest {
       .setTags(List.of("todo"))
       .setComponentUuid("123")
       .setComponentKey("componentKey")
-      .setModuleUuidPath("path/to/module/uuid")
       .setProjectUuid("123")
       .setProjectKey("projectKey")
       .setAuthorLogin("admin")
index 1443252351065799f526e2acdb6bd72487bf5de8..a510974eb308c8a15ba9445011210cfc0a323396 100644 (file)
@@ -512,10 +512,9 @@ public class IssueMapperTest {
 
   private ComponentDto randomComponent() {
     ComponentDto project = dbTester.components().insertPublicProject();
-    ComponentDto module = dbTester.components().insertComponent(ComponentTesting.newModuleDto(project));
     ComponentDto dir = dbTester.components().insertComponent(ComponentTesting.newDirectory(project, "foo"));
-    ComponentDto file = dbTester.components().insertComponent(ComponentTesting.newFileDto(project));
-    ComponentDto[] components = new ComponentDto[] {project, module, dir, file};
+    ComponentDto file = dbTester.components().insertComponent(ComponentTesting.newFileDto(project, dir));
+    ComponentDto[] components = new ComponentDto[] {project, dir, file};
     return components[random.nextInt(components.length)];
   }
 
index 2ba89f513bcacbc6dc5f57dd642311ec08506af5..bc768ddfe9e1f760661a676c452f18b47ea14549 100644 (file)
@@ -37,8 +37,8 @@ import org.sonar.db.metric.MetricDto;
 import static java.util.Collections.singletonList;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.api.utils.DateUtils.parseDate;
+import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 
 public class MeasureDaoTest {
@@ -47,7 +47,6 @@ public class MeasureDaoTest {
   private MetricDto complexity;
   private MetricDto ncloc;
 
-
   @Rule
   public DbTester db = DbTester.create(System2.INSTANCE);
   private DbClient dbClient = db.getDbClient();
@@ -57,8 +56,8 @@ public class MeasureDaoTest {
 
   @Before
   public void before() {
-    coverage =db.measures().insertMetric(m -> m.setKey("coverage"));
-    complexity = db.measures().insertMetric(m -> m.setKey( "complexity"));
+    coverage = db.measures().insertMetric(m -> m.setKey("coverage"));
+    complexity = db.measures().insertMetric(m -> m.setKey("complexity"));
     ncloc = db.measures().insertMetric(m -> m.setKey("ncloc"));
   }
 
@@ -110,9 +109,9 @@ public class MeasureDaoTest {
   @Test
   public void test_selects() {
     ComponentDto project1 = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project1));
-    db.components().insertComponent(newFileDto(module).setUuid("C1"));
-    db.components().insertComponent(newFileDto(module).setUuid("C2"));
+    ComponentDto dir = db.components().insertComponent(newDirectory(project1, "path"));
+    db.components().insertComponent(newFileDto(dir).setUuid("C1"));
+    db.components().insertComponent(newFileDto(dir).setUuid("C2"));
     SnapshotDto lastAnalysis = insertAnalysis(project1.uuid(), true);
     SnapshotDto pastAnalysis = insertAnalysis(project1.uuid(), false);
 
@@ -141,11 +140,11 @@ public class MeasureDaoTest {
     verifyNoMeasure("MISSING_COMPONENT", ncloc.getKey(), pastAnalysis.getUuid());
 
     // ncloc measure of component C1 of last analysis
-    verifyMeasure("C1",  ncloc.getKey(), "M2");
+    verifyMeasure("C1", ncloc.getKey(), "M2");
     // ncloc measure of component C1 of non last analysis
-    verifyMeasure("C1",  ncloc.getKey(), pastAnalysis.getUuid(), "M1");
+    verifyMeasure("C1", ncloc.getKey(), pastAnalysis.getUuid(), "M1");
     // ncloc measure of component C1 of last analysis by UUID
-    verifyMeasure("C1",  ncloc.getKey(), lastAnalysis.getUuid(), "M2");
+    verifyMeasure("C1", ncloc.getKey(), lastAnalysis.getUuid(), "M2");
 
     // missing measure of component C1 of last analysis
     verifyNoMeasure("C1", complexity.getKey());
@@ -155,10 +154,10 @@ public class MeasureDaoTest {
     verifyNoMeasure("C1", complexity.getKey(), lastAnalysis.getUuid());
 
     // projects measures of last analysis
-    verifyMeasure(project1.uuid(),  ncloc.getKey(), "P1_M1");
+    verifyMeasure(project1.uuid(), ncloc.getKey(), "P1_M1");
 
     // projects measures of none last analysis
-    verifyMeasure(project1.uuid(),  ncloc.getKey(), pastAnalysis.getUuid(), "P1_M3");
+    verifyMeasure(project1.uuid(), ncloc.getKey(), pastAnalysis.getUuid(), "P1_M3");
   }
 
   @Test
index f9551734eb7a73e236474ce9d572810807e1bd37..783c99e7f5f7f644a4f0ab03ce3f4f15ea6d7622 100644 (file)
@@ -137,11 +137,9 @@ public class PurgeCommandsTest {
     dbTester.components().insertComponent(project);
     ComponentDto otherProject = dbTester.components().insertPrivateProject();
     Stream.of(project, otherProject).forEach(prj -> {
-      ComponentDto module = dbTester.components().insertComponent(ComponentTesting.newModuleDto(prj));
-      ComponentDto directory1 = dbTester.components().insertComponent(ComponentTesting.newDirectory(module, "a"));
+      ComponentDto directory1 = dbTester.components().insertComponent(ComponentTesting.newDirectory(prj, "a"));
       ComponentDto directory2 = dbTester.components().insertComponent(ComponentTesting.newDirectory(prj, "b"));
       dbTester.components().insertComponent(newFileDto(prj));
-      dbTester.components().insertComponent(newFileDto(module));
       dbTester.components().insertComponent(newFileDto(directory1));
       dbTester.components().insertComponent(newFileDto(directory2));
     });
@@ -149,7 +147,7 @@ public class PurgeCommandsTest {
     underTest.deleteComponents(project.uuid());
 
     assertThat(countComponentOfRoot(project)).isZero();
-    assertThat(countComponentOfRoot(otherProject)).isEqualTo(8);
+    assertThat(countComponentOfRoot(otherProject)).isEqualTo(6);
   }
 
   @Test
@@ -158,18 +156,16 @@ public class PurgeCommandsTest {
     dbTester.components().insertComponent(project);
     ComponentDto branch = dbTester.components().insertProjectBranch(project);
     Stream.of(project, branch).forEach(prj -> {
-      ComponentDto module = dbTester.components().insertComponent(ComponentTesting.newModuleDto(prj));
-      ComponentDto directory1 = dbTester.components().insertComponent(ComponentTesting.newDirectory(module, "a"));
+      ComponentDto directory1 = dbTester.components().insertComponent(ComponentTesting.newDirectory(prj, "a"));
       ComponentDto directory2 = dbTester.components().insertComponent(ComponentTesting.newDirectory(prj, "b"));
       dbTester.components().insertComponent(newFileDto(prj));
-      dbTester.components().insertComponent(newFileDto(module));
       dbTester.components().insertComponent(newFileDto(directory1));
       dbTester.components().insertComponent(newFileDto(directory2));
     });
 
     underTest.deleteComponentsByMainBranchProjectUuid(project.uuid());
 
-    assertThat(countComponentOfRoot(project)).isEqualTo(8);
+    assertThat(countComponentOfRoot(project)).isEqualTo(6);
     assertThat(countComponentOfRoot(branch)).isZero();
   }
 
@@ -866,14 +862,14 @@ public class PurgeCommandsTest {
 
   @DataProvider
   public static Object[] projects() {
-    return new Object[]{
+    return new Object[] {
       ComponentTesting.newPrivateProjectDto(), ComponentTesting.newPublicProjectDto(),
     };
   }
 
   @DataProvider
   public static Object[] views() {
-    return new Object[]{
+    return new Object[] {
       ComponentTesting.newPortfolio(), ComponentTesting.newApplication()
     };
   }
index b34270f999fa3bb5b9b51bb7478c9a1456252129..f9c3fc6cc3227c3ab5556bfe9ad866707791be8a 100644 (file)
@@ -102,7 +102,6 @@ import static org.sonar.db.ce.CeTaskTypes.REPORT;
 import static org.sonar.db.component.ComponentTesting.newBranchDto;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.component.ComponentTesting.newProjectCopy;
 import static org.sonar.db.component.ComponentTesting.newSubPortfolio;
 import static org.sonar.db.component.SnapshotDto.STATUS_PROCESSED;
@@ -219,12 +218,9 @@ public class PurgeDaoTest {
     // pull request with other components and issues, updated 31 days ago
     ComponentDto pullRequest = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.PULL_REQUEST));
     db.components().insertSnapshot(pullRequest, dto -> dto.setCreatedAt(DateUtils.addDays(new Date(), -31).getTime()));
-    ComponentDto module = db.components().insertComponent(newModuleDto(pullRequest));
-    ComponentDto subModule = db.components().insertComponent(newModuleDto(module));
-    ComponentDto file = db.components().insertComponent(newFileDto(subModule));
+    ComponentDto dir = db.components().insertComponent(newDirectory(pullRequest, "path"));
+    ComponentDto file = db.components().insertComponent(newFileDto(pullRequest, dir));
     db.issues().insert(rule, pullRequest, file);
-    db.issues().insert(rule, pullRequest, subModule);
-    db.issues().insert(rule, pullRequest, module);
 
     underTest.purge(dbSession, newConfigurationWith30Days(System2.INSTANCE, project.uuid(), project.uuid()), PurgeListener.EMPTY, new PurgeProfiler());
     dbSession.commit();
@@ -274,11 +270,10 @@ public class PurgeDaoTest {
     db.components().insertSnapshot(project);
     db.components().insertSnapshot(project, s -> s.setLast(false));
 
-    ComponentDto module = db.components().insertComponent(newModuleDto(project).setEnabled(false));
-    ComponentDto dir = db.components().insertComponent(newDirectory(module, "sub").setEnabled(false));
-    ComponentDto srcFile = db.components().insertComponent(newFileDto(module, dir).setEnabled(false));
-    ComponentDto testFile = db.components().insertComponent(newFileDto(module, dir).setEnabled(false));
-    ComponentDto enabledFile = db.components().insertComponent(newFileDto(module, dir).setEnabled(true));
+    ComponentDto dir = db.components().insertComponent(newDirectory(project, "sub").setEnabled(false));
+    ComponentDto srcFile = db.components().insertComponent(newFileDto(project, dir).setEnabled(false));
+    ComponentDto testFile = db.components().insertComponent(newFileDto(project, dir).setEnabled(false));
+    ComponentDto enabledFile = db.components().insertComponent(newFileDto(project, dir).setEnabled(true));
     IssueDto openOnFile = db.issues().insert(rule, project, srcFile, issue -> issue.setStatus("OPEN"));
     IssueDto confirmOnFile = db.issues().insert(rule, project, srcFile, issue -> issue.setStatus("CONFIRM"));
     IssueDto openOnDir = db.issues().insert(rule, project, dir, issue -> issue.setStatus("OPEN"));
@@ -309,7 +304,7 @@ public class PurgeDaoTest {
     PurgeListener purgeListener = mock(PurgeListener.class);
 
     // back to present
-    Set<String> selectedComponentUuids = ImmutableSet.of(module.uuid(), srcFile.uuid(), testFile.uuid());
+    Set<String> selectedComponentUuids = ImmutableSet.of(srcFile.uuid(), testFile.uuid());
     underTest.purge(dbSession, newConfigurationWith30Days(system2, project.uuid(), project.uuid(), selectedComponentUuids),
       purgeListener, new PurgeProfiler());
     dbSession.commit();
@@ -552,8 +547,7 @@ public class PurgeDaoTest {
   public void delete_project_and_associated_data() {
     RuleDto rule = db.rules().insert();
     ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto directory = db.components().insertComponent(newDirectory(module, "a/b"));
+    ComponentDto directory = db.components().insertComponent(newDirectory(project, "a/b"));
     ComponentDto file = db.components().insertComponent(newFileDto(directory));
     SnapshotDto analysis = db.components().insertSnapshot(project);
     IssueDto issue1 = db.issues().insert(rule, project, file);
@@ -563,8 +557,7 @@ public class PurgeDaoTest {
     db.issues().insertNewCodeReferenceIssue(newCodeReferenceIssue(issue1));
 
     ComponentDto otherProject = db.components().insertPrivateProject();
-    ComponentDto otherModule = db.components().insertComponent(newModuleDto(otherProject));
-    ComponentDto otherDirectory = db.components().insertComponent(newDirectory(otherModule, "a/b"));
+    ComponentDto otherDirectory = db.components().insertComponent(newDirectory(otherProject, "a/b"));
     ComponentDto otherFile = db.components().insertComponent(newFileDto(otherDirectory));
     SnapshotDto otherAnalysis = db.components().insertSnapshot(otherProject);
     IssueDto otherIssue1 = db.issues().insert(rule, otherProject, otherFile);
@@ -576,7 +569,7 @@ public class PurgeDaoTest {
     underTest.deleteProject(dbSession, project.uuid(), project.qualifier(), project.name(), project.getKey());
     dbSession.commit();
 
-    assertThat(uuidsIn("components")).containsOnly(otherProject.uuid(), otherModule.uuid(), otherDirectory.uuid(), otherFile.uuid());
+    assertThat(uuidsIn("components")).containsOnly(otherProject.uuid(), otherDirectory.uuid(), otherFile.uuid());
     assertThat(uuidsIn("projects")).containsOnly(otherProject.uuid());
     assertThat(uuidsIn("snapshots")).containsOnly(otherAnalysis.getUuid());
     assertThat(uuidsIn("issues", "kee")).containsOnly(otherIssue1.getKey(), otherIssue2.getKey());
@@ -1070,12 +1063,10 @@ public class PurgeDaoTest {
     RuleDto rule = db.rules().insert();
     ComponentDto project = db.components().insertPublicProject();
     ComponentDto branch = db.components().insertProjectBranch(project);
-    ComponentDto module = db.components().insertComponent(newModuleDto(branch));
-    ComponentDto subModule = db.components().insertComponent(newModuleDto(module));
-    ComponentDto file = db.components().insertComponent(newFileDto(subModule));
+    ComponentDto dir = db.components().insertComponent(newDirectory(branch, "path"));
+    ComponentDto file = db.components().insertComponent(newFileDto(branch, dir));
     db.issues().insert(rule, branch, file);
-    db.issues().insert(rule, branch, subModule);
-    db.issues().insert(rule, branch, module);
+    db.issues().insert(rule, branch, dir);
     return project;
   }
 
@@ -1132,8 +1123,8 @@ public class PurgeDaoTest {
     RuleDto rule = db.rules().insert();
     ComponentDto project = db.components().insertPublicProject();
 
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto file = db.components().insertComponent(newFileDto(module));
+    ComponentDto dir = db.components().insertComponent(newDirectory(project, "path"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, dir));
 
     IssueDto oldClosed = db.issues().insert(rule, project, file, issue -> {
       issue.setStatus("CLOSED");
@@ -1521,19 +1512,19 @@ public class PurgeDaoTest {
     MetricDto metric = db.measures().insertMetric();
 
     ComponentDto project1 = db.components().insertPublicProject();
-    ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project1));
+    ComponentDto dir1 = db.components().insertComponent(newDirectory(project1, "path"));
     db.measures().insertLiveMeasure(project1, metric);
-    db.measures().insertLiveMeasure(module1, metric);
+    db.measures().insertLiveMeasure(dir1, metric);
 
     ComponentDto project2 = db.components().insertPublicProject();
-    ComponentDto module2 = db.components().insertComponent(ComponentTesting.newModuleDto(project2));
+    ComponentDto dir2 = db.components().insertComponent(newDirectory(project2, "path"));
     db.measures().insertLiveMeasure(project2, metric);
-    db.measures().insertLiveMeasure(module2, metric);
+    db.measures().insertLiveMeasure(dir2, metric);
 
     underTest.deleteProject(dbSession, project1.uuid(), project1.qualifier(), project1.name(), project1.getKey());
 
-    assertThat(dbClient.liveMeasureDao().selectByComponentUuidsAndMetricUuids(dbSession, asList(project1.uuid(), module1.uuid()), asList(metric.getUuid()))).isEmpty();
-    assertThat(dbClient.liveMeasureDao().selectByComponentUuidsAndMetricUuids(dbSession, asList(project2.uuid(), module2.uuid()), asList(metric.getUuid()))).hasSize(2);
+    assertThat(dbClient.liveMeasureDao().selectByComponentUuidsAndMetricUuids(dbSession, asList(project1.uuid(), dir1.uuid()), asList(metric.getUuid()))).isEmpty();
+    assertThat(dbClient.liveMeasureDao().selectByComponentUuidsAndMetricUuids(dbSession, asList(project2.uuid(), dir2.uuid()), asList(metric.getUuid()))).hasSize(2);
   }
 
   private void verifyNoEffect(ComponentDto firstRoot, ComponentDto... otherRoots) {
@@ -1549,18 +1540,15 @@ public class PurgeDaoTest {
   @Test
   public void deleteNonRootComponents_deletes_only_non_root_components_of_a_project_from_table_components() {
     ComponentDto project = new Random().nextBoolean() ? db.components().insertPublicProject() : db.components().insertPrivateProject();
-    ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project));
-    ComponentDto module2 = db.components().insertComponent(ComponentTesting.newModuleDto(module1));
-    ComponentDto dir1 = db.components().insertComponent(newDirectory(module1, "A/B"));
+    ComponentDto dir1 = db.components().insertComponent(newDirectory(project, "A/B"));
+    ComponentDto file1 = db.components().insertComponent(newFileDto(project, dir1));
 
     List<ComponentDto> components = asList(
       project,
-      module1,
-      module2,
       dir1,
-      db.components().insertComponent(newDirectory(module2, "A/C")),
+      file1,
       db.components().insertComponent(newFileDto(dir1)),
-      db.components().insertComponent(newFileDto(module2)),
+      db.components().insertComponent(newFileDto(file1)),
       db.components().insertComponent(newFileDto(project)));
     Collections.shuffle(components);
 
@@ -1599,21 +1587,19 @@ public class PurgeDaoTest {
   @Test
   public void deleteNonRootComponents_deletes_only_specified_non_root_components_of_a_project_from_table_components() {
     ComponentDto project = new Random().nextBoolean() ? db.components().insertPublicProject() : db.components().insertPrivateProject();
-    ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project));
-    ComponentDto module2 = db.components().insertComponent(ComponentTesting.newModuleDto(module1));
-    ComponentDto dir1 = db.components().insertComponent(newDirectory(module1, "A/B"));
-    ComponentDto dir2 = db.components().insertComponent(newDirectory(module2, "A/C"));
-    ComponentDto file1 = db.components().insertComponent(newFileDto(dir1));
-    ComponentDto file2 = db.components().insertComponent(newFileDto(module2));
+    ComponentDto dir1 = db.components().insertComponent(newDirectory(project, "A/B"));
+    ComponentDto dir2 = db.components().insertComponent(newDirectory(project, "A/C"));
+    ComponentDto file1 = db.components().insertComponent(newFileDto(project, dir1));
+    ComponentDto file2 = db.components().insertComponent(newFileDto(project));
     ComponentDto file3 = db.components().insertComponent(newFileDto(project));
 
     underTest.deleteNonRootComponentsInView(dbSession, singletonList(file3));
     assertThat(uuidsIn("components"))
-      .containsOnly(project.uuid(), module1.uuid(), module2.uuid(), dir1.uuid(), dir2.uuid(), file1.uuid(), file2.uuid());
+      .containsOnly(project.uuid(), dir1.uuid(), dir2.uuid(), file1.uuid(), file2.uuid());
 
-    underTest.deleteNonRootComponentsInView(dbSession, asList(module1, dir2, file1));
+    underTest.deleteNonRootComponentsInView(dbSession, asList(dir2, file1));
     assertThat(uuidsIn("components"))
-      .containsOnly(project.uuid(), module2.uuid(), dir1.uuid(), file2.uuid());
+      .containsOnly(project.uuid(), dir1.uuid(), file2.uuid());
   }
 
   @Test
@@ -1915,12 +1901,9 @@ public class PurgeDaoTest {
 
   private void addComponentsSnapshotsAndIssuesToBranch(ComponentDto branch, RuleDto rule, int branchAge) {
     db.components().insertSnapshot(branch, dto -> dto.setCreatedAt(DateUtils.addDays(new Date(), -branchAge).getTime()));
-    ComponentDto module = db.components().insertComponent(newModuleDto(branch));
-    ComponentDto subModule = db.components().insertComponent(newModuleDto(module));
-    ComponentDto file = db.components().insertComponent(newFileDto(subModule));
+    ComponentDto dir = db.components().insertComponent(newDirectory(branch, "path"));
+    ComponentDto file = db.components().insertComponent(newFileDto(branch, dir));
     db.issues().insert(rule, branch, file);
-    db.issues().insert(rule, branch, subModule);
-    db.issues().insert(rule, branch, module);
   }
 
 }
index 133b7864f267ac4a515ac020bf377fca28ea2070..5a0d001d5888c85fdd459cd35cdebd9e93e64527 100644 (file)
@@ -54,113 +54,93 @@ public class PurgeMapperTest {
   }
 
   @Test
-  public void selectRootAndModulesOrSubviewsByProjectUuid_returns_empty_when_table_is_empty() {
-    assertThat(purgeMapper.selectRootAndModulesOrSubviewsByProjectUuid("foo")).isEmpty();
+  public void selectRootAndSubviewsByProjectUuid_returns_empty_when_table_is_empty() {
+    assertThat(purgeMapper.selectRootAndSubviewsByProjectUuid("foo")).isEmpty();
   }
 
   @Test
-  public void selectRootAndModulesOrSubviewsByProjectUuid_returns_project_with_specified_uuid() {
+  public void selectRootAndSubviewsByProjectUuid_returns_project_with_specified_uuid() {
     ComponentDto project = randomPublicOrPrivateProject();
 
-    assertThat(purgeMapper.selectRootAndModulesOrSubviewsByProjectUuid(project.uuid()))
+    assertThat(purgeMapper.selectRootAndSubviewsByProjectUuid(project.uuid()))
       .containsOnly(project.uuid());
   }
 
-  @Test
-  public void selectRootAndModulesOrSubviewsByProjectUuid_returns_modules_with_specified_project_uuid_and_project() {
-    ComponentDto project = randomPublicOrPrivateProject();
-    ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project));
-    ComponentDto module2 = db.components().insertComponent(ComponentTesting.newModuleDto(project));
-    ComponentDto module3 = db.components().insertComponent(ComponentTesting.newModuleDto(project));
-
-    assertThat(purgeMapper.selectRootAndModulesOrSubviewsByProjectUuid(project.uuid()))
-      .containsOnly(project.uuid(), module1.uuid(), module2.uuid(), module3.uuid());
-  }
-
   private ComponentDto randomPublicOrPrivateProject() {
     return new Random().nextBoolean() ? db.components().insertPrivateProject() : db.components().insertPublicProject();
   }
 
   @Test
-  public void selectRootAndModulesOrSubviewsByProjectUuid_returns_view_with_specified_uuid() {
+  public void selectRootAndSubviewsByProjectUuid_returns_view_with_specified_uuid() {
     ComponentDto view = db.components().insertPrivatePortfolio();
 
-    assertThat(purgeMapper.selectRootAndModulesOrSubviewsByProjectUuid(view.uuid()))
+    assertThat(purgeMapper.selectRootAndSubviewsByProjectUuid(view.uuid()))
       .containsOnly(view.uuid());
   }
 
   @Test
-  public void selectRootAndModulesOrSubviewsByProjectUuid_returns_application_with_specified_uuid() {
+  public void selectRootAndSubviewsByProjectUuid_returns_application_with_specified_uuid() {
     ComponentDto view = db.components().insertPublicApplication();
 
-    assertThat(purgeMapper.selectRootAndModulesOrSubviewsByProjectUuid(view.uuid()))
+    assertThat(purgeMapper.selectRootAndSubviewsByProjectUuid(view.uuid()))
       .containsOnly(view.uuid());
   }
 
   @Test
-  public void selectRootAndModulesOrSubviewsByProjectUuid_returns_subviews_with_specified_project_uuid_and_view() {
+  public void selectRootAndSubviewsByProjectUuid_returns_subviews_with_specified_project_uuid_and_view() {
     ComponentDto view = db.components().insertPublicPortfolio();
     ComponentDto subview1 = db.components().insertComponent(ComponentTesting.newSubPortfolio(view));
     ComponentDto subview2 = db.components().insertComponent(ComponentTesting.newSubPortfolio(view));
     ComponentDto subview3 = db.components().insertComponent(ComponentTesting.newSubPortfolio(view));
 
-    assertThat(purgeMapper.selectRootAndModulesOrSubviewsByProjectUuid(view.uuid()))
+    assertThat(purgeMapper.selectRootAndSubviewsByProjectUuid(view.uuid()))
       .containsOnly(view.uuid(), subview1.uuid(), subview2.uuid(), subview3.uuid());
   }
 
   @Test
-  public void selectRootAndModulesOrSubviewsByProjectUuid_does_not_return_project_copy_with_specified_project_uuid() {
+  public void selectRootAndSubviewsByProjectUuid_does_not_return_project_copy_with_specified_project_uuid() {
     ComponentDto privateProject = db.components().insertPrivateProject();
     ComponentDto view = db.components().insertPrivatePortfolio();
     db.components().insertComponent(ComponentTesting.newProjectCopy("a", view, privateProject));
 
-    assertThat(purgeMapper.selectRootAndModulesOrSubviewsByProjectUuid(view.uuid()))
+    assertThat(purgeMapper.selectRootAndSubviewsByProjectUuid(view.uuid()))
       .containsOnly(view.uuid());
   }
 
   @Test
-  public void selectRootAndModulesOrSubviewsByProjectUuid_does_not_return_module_with_specified_uuid() {
-    ComponentDto privateProject = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(privateProject));
-
-    assertThat(purgeMapper.selectRootAndModulesOrSubviewsByProjectUuid(module.uuid()))
-      .isEmpty();
-  }
-
-  @Test
-  public void selectRootAndModulesOrSubviewsByProjectUuid_does_not_return_directory_with_specified_uuid() {
+  public void selectRootAndSubviewsByProjectUuid_does_not_return_directory_with_specified_uuid() {
     ComponentDto privateProject = db.components().insertPrivateProject();
     ComponentDto directory = db.components().insertComponent(ComponentTesting.newDirectory(privateProject, "A/B"));
 
-    assertThat(purgeMapper.selectRootAndModulesOrSubviewsByProjectUuid(directory.uuid()))
+    assertThat(purgeMapper.selectRootAndSubviewsByProjectUuid(directory.uuid()))
       .isEmpty();
   }
 
   @Test
-  public void selectRootAndModulesOrSubviewsByProjectUuid_does_not_return_file_with_specified_uuid() {
+  public void selectRootAndSubviewsByProjectUuid_does_not_return_file_with_specified_uuid() {
     ComponentDto privateProject = db.components().insertPrivateProject();
     ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(privateProject));
 
-    assertThat(purgeMapper.selectRootAndModulesOrSubviewsByProjectUuid(file.uuid()))
+    assertThat(purgeMapper.selectRootAndSubviewsByProjectUuid(file.uuid()))
       .isEmpty();
   }
 
   @Test
-  public void selectRootAndModulesOrSubviewsByProjectUuid_does_not_return_subview_with_specified_uuid() {
+  public void selectRootAndSubviewsByProjectUuid_does_not_return_subview_with_specified_uuid() {
     ComponentDto view = db.components().insertPrivatePortfolio();
     ComponentDto subview = db.components().insertComponent(ComponentTesting.newSubPortfolio(view));
 
-    assertThat(purgeMapper.selectRootAndModulesOrSubviewsByProjectUuid(subview.uuid()))
+    assertThat(purgeMapper.selectRootAndSubviewsByProjectUuid(subview.uuid()))
       .isEmpty();
   }
 
   @Test
-  public void selectRootAndModulesOrSubviewsByProjectUuid_does_not_return_technicalCopy_with_specified_uuid() {
+  public void selectRootAndSubviewsByProjectUuid_does_not_return_technicalCopy_with_specified_uuid() {
     ComponentDto privateProject = db.components().insertPrivateProject();
     ComponentDto view = db.components().insertPrivatePortfolio();
     ComponentDto technicalCopy = db.components().insertComponent(ComponentTesting.newProjectCopy("a", view, privateProject));
 
-    assertThat(purgeMapper.selectRootAndModulesOrSubviewsByProjectUuid(technicalCopy.uuid()))
+    assertThat(purgeMapper.selectRootAndSubviewsByProjectUuid(technicalCopy.uuid()))
       .isEmpty();
   }
 }
index 72f7e41b1e7772c2dea55a9da2aea02a0ecb0ec9..65f91d21f701715f0b425258ddb0e00a62f57cb9 100644 (file)
@@ -30,24 +30,23 @@ import static com.google.common.base.Preconditions.checkArgument;
 import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
 import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 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;
 
 public class ComponentTesting {
 
-  public static ComponentDto newFileDto(ComponentDto subProjectOrProject) {
-    return newFileDto(subProjectOrProject, null);
+  public static ComponentDto newFileDto(ComponentDto project) {
+    return newFileDto(project, null);
   }
 
-  public static ComponentDto newFileDto(ComponentDto subProjectOrProject, @Nullable ComponentDto directory) {
-    return newFileDto(subProjectOrProject, directory, Uuids.createFast());
+  public static ComponentDto newFileDto(ComponentDto project, @Nullable ComponentDto directory) {
+    return newFileDto(project, directory, Uuids.createFast());
   }
 
-  public static ComponentDto newFileDto(ComponentDto module, @Nullable ComponentDto directory, String fileUuid) {
+  public static ComponentDto newFileDto(ComponentDto project, @Nullable ComponentDto directory, String fileUuid) {
     String filename = "NAME_" + fileUuid;
-    String path = directory != null ? directory.path() + "/" + filename : module.path() + "/" + filename;
-    return newChildComponent(fileUuid, module, directory == null ? module : directory)
+    String path = directory != null ? directory.path() + "/" + filename : project.path() + "/" + filename;
+    return newChildComponent(fileUuid, project, directory == null ? project : directory)
       .setKey("FILE_KEY_" + fileUuid)
       .setName(filename)
       .setLongName(path)
@@ -58,13 +57,13 @@ public class ComponentTesting {
       .setLanguage("xoo");
   }
 
-  public static ComponentDto newDirectory(ComponentDto module, String path) {
-    return newDirectory(module, Uuids.createFast(), path);
+  public static ComponentDto newDirectory(ComponentDto project, String path) {
+    return newDirectory(project, Uuids.createFast(), path);
   }
 
-  public static ComponentDto newDirectory(ComponentDto module, String uuid, String path) {
-    String key = !path.equals("/") ? module.getKey() + ":" + path : module.getKey() + ":/";
-    return newChildComponent(uuid, module, module)
+  public static ComponentDto newDirectory(ComponentDto project, String uuid, String path) {
+    String key = !path.equals("/") ? project.getKey() + ":" + path : project.getKey() + ":/";
+    return newChildComponent(uuid, project, project)
       .setKey(key)
       .setName(path)
       .setLongName(path)
@@ -74,7 +73,7 @@ public class ComponentTesting {
   }
 
   public static ComponentDto newSubPortfolio(ComponentDto portfolioOrSubPortfolio, String uuid, String key) {
-    return newModuleDto(uuid, portfolioOrSubPortfolio)
+    return newChildComponent(uuid, portfolioOrSubPortfolio, portfolioOrSubPortfolio)
       .setKey(key)
       .setName(key)
       .setLongName(key)
@@ -88,22 +87,6 @@ public class ComponentTesting {
     return newSubPortfolio(viewOrSubView, uuid, "KEY_" + uuid);
   }
 
-  public static ComponentDto newModuleDto(String uuid, ComponentDto parentModuleOrProject) {
-    return newChildComponent(uuid, parentModuleOrProject, parentModuleOrProject)
-      .setModuleUuidPath(parentModuleOrProject.moduleUuidPath() + uuid + UUID_PATH_SEPARATOR)
-      .setKey("MODULE_KEY_" + uuid)
-      .setName("NAME_" + uuid)
-      .setLongName("LONG_NAME_" + uuid)
-      .setPath("module")
-      .setScope(Scopes.PROJECT)
-      .setQualifier(Qualifiers.MODULE)
-      .setLanguage(null);
-  }
-
-  public static ComponentDto newModuleDto(ComponentDto subProjectOrProject) {
-    return newModuleDto(Uuids.createFast(), subProjectOrProject);
-  }
-
   public static ComponentDto newPrivateProjectDto() {
     return newProjectDto(Uuids.createFast(), true);
   }
@@ -125,7 +108,6 @@ public class ComponentTesting {
       .setUuid(uuid)
       .setUuidPath(UUID_PATH_OF_ROOT)
       .setBranchUuid(uuid)
-      .setModuleUuidPath(UUID_PATH_SEPARATOR + uuid + UUID_PATH_SEPARATOR)
       .setRootUuid(uuid)
       .setKey("KEY_" + uuid)
       .setName("NAME_" + uuid)
@@ -183,22 +165,20 @@ public class ComponentTesting {
       .setLanguage(null);
   }
 
-  public static ComponentDto newChildComponent(String uuid, ComponentDto moduleOrProject, ComponentDto parent) {
-    checkArgument(moduleOrProject.isPrivate() == parent.isPrivate(),
+  public static ComponentDto newChildComponent(String uuid, ComponentDto project, ComponentDto parent) {
+    checkArgument(project.isPrivate() == parent.isPrivate(),
       "private flag inconsistent between moduleOrProject (%s) and parent (%s)",
-      moduleOrProject.isPrivate(), parent.isPrivate());
+      project.isPrivate(), parent.isPrivate());
     return new ComponentDto()
       .setUuid(uuid)
       .setUuidPath(formatUuidPathFromParent(parent))
       .setKey(uuid)
-      .setBranchUuid(moduleOrProject.branchUuid())
-      .setRootUuid(moduleOrProject.uuid())
-      .setModuleUuid(moduleOrProject.uuid())
-      .setModuleUuidPath(moduleOrProject.moduleUuidPath())
-      .setMainBranchProjectUuid(moduleOrProject.getMainBranchProjectUuid())
+      .setBranchUuid(project.branchUuid())
+      .setRootUuid(project.uuid())
+      .setMainBranchProjectUuid(project.getMainBranchProjectUuid())
       .setCreatedAt(new Date())
       .setEnabled(true)
-      .setPrivate(moduleOrProject.isPrivate());
+      .setPrivate(project.isPrivate());
   }
 
   public static BranchDto newBranchDto(@Nullable String projectUuid, BranchType branchType) {
@@ -233,7 +213,6 @@ public class ComponentTesting {
       .setUuid(uuid)
       .setUuidPath(UUID_PATH_OF_ROOT)
       .setBranchUuid(uuid)
-      .setModuleUuidPath(UUID_PATH_SEPARATOR + uuid + UUID_PATH_SEPARATOR)
       .setRootUuid(uuid)
       .setKey(project.getKey())
       .setMainBranchProjectUuid(project.getUuid())
@@ -256,7 +235,6 @@ public class ComponentTesting {
       .setUuid(uuid)
       .setUuidPath(UUID_PATH_OF_ROOT)
       .setBranchUuid(uuid)
-      .setModuleUuidPath(UUID_PATH_SEPARATOR + uuid + UUID_PATH_SEPARATOR)
       .setRootUuid(uuid)
       .setKey(project.getKey())
       .setMainBranchProjectUuid(project.uuid())
index 0b31c5be60ae155322619c1ac463f50227b395cb..e5c07c0a073c91c9bd86d925b44b3f3f2bb3cb66 100644 (file)
@@ -22,7 +22,7 @@ package org.sonar.server.platform.db.migration.version.v100;
 import org.sonar.server.platform.db.migration.step.MigrationStepRegistry;
 import org.sonar.server.platform.db.migration.version.DbVersion;
 
-// ignoring bad number formating, as it's indented that we align the migration numbers to SQ versions
+// ignoring bad number formatting, as it's indented that we align the migration numbers to SQ versions
 @SuppressWarnings("java:S3937")
 public class DbVersion100 implements DbVersion {
 
@@ -42,6 +42,11 @@ public class DbVersion100 implements DbVersion {
   public void addSteps(MigrationStepRegistry registry) {
     registry
       .add(10_0_000, "Remove orphan rules in Quality Profiles", RemoveOrphanRulesFromQualityProfiles.class)
+      .add(10_0_001, "Drop index 'projects_module_uuid' in the 'Components' table", DropIndexProjectsModuleUuidInComponents.class)
+      .add(10_0_002, "Drop column 'module_uuid' in the 'Components' table", DropModuleUuidInComponents.class)
+      .add(10_0_003, "Drop column 'module_uuid_path' in the 'Components' table", DropModuleUuidPathInComponents.class)
+      .add(10_0_004, "Drop column 'b_module_uuid' in the 'Components' table", DropBModuleUuidInComponents.class)
+      .add(10_0_005, "Drop column 'b_module_uuid_path' in the 'Components' table", DropBModuleUuidPathInComponents.class)
     ;
   }
 }
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidInComponents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidInComponents.java
new file mode 100644 (file)
index 0000000..e00a442
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.v100;
+
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DropColumnChange;
+
+public class DropBModuleUuidInComponents extends DropColumnChange {
+  private static final String COLUMN_NAME = "b_module_uuid";
+  private static final String TABLE_NAME = "components";
+
+  public DropBModuleUuidInComponents(Database db) {
+    super(db, TABLE_NAME, COLUMN_NAME);
+  }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidPathInComponents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidPathInComponents.java
new file mode 100644 (file)
index 0000000..fd65f97
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.v100;
+
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DropColumnChange;
+
+public class DropBModuleUuidPathInComponents extends DropColumnChange {
+  private static final String COLUMN_NAME = "b_module_uuid_path";
+  private static final String TABLE_NAME = "components";
+
+  public DropBModuleUuidPathInComponents(Database db) {
+    super(db, TABLE_NAME, COLUMN_NAME);
+  }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsModuleUuidInComponents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsModuleUuidInComponents.java
new file mode 100644 (file)
index 0000000..49e8985
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.v100;
+
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DropIndexChange;
+
+public class DropIndexProjectsModuleUuidInComponents extends DropIndexChange {
+  private static final String INDEX_NAME = "projects_module_uuid";
+  private static final String TABLE_NAME = "components";
+
+  public DropIndexProjectsModuleUuidInComponents(Database db) {
+    super(db, INDEX_NAME, TABLE_NAME);
+  }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidInComponents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidInComponents.java
new file mode 100644 (file)
index 0000000..af6816e
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.v100;
+
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DropColumnChange;
+
+public class DropModuleUuidInComponents extends DropColumnChange {
+  private static final String COLUMN_NAME = "module_uuid";
+  private static final String TABLE_NAME = "components";
+
+  public DropModuleUuidInComponents(Database db) {
+    super(db, TABLE_NAME, COLUMN_NAME);
+  }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidPathInComponents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidPathInComponents.java
new file mode 100644 (file)
index 0000000..c90ab17
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.v100;
+
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DropColumnChange;
+
+public class DropModuleUuidPathInComponents extends DropColumnChange {
+  private static final String COLUMN_NAME = "module_uuid_path";
+  private static final String TABLE_NAME = "components";
+
+  public DropModuleUuidPathInComponents(Database db) {
+    super(db, TABLE_NAME, COLUMN_NAME);
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidInComponentsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidInComponentsTest.java
new file mode 100644 (file)
index 0000000..dbfd8b1
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.v100;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropBModuleUuidInComponentsTest {
+  private static final String TABLE_NAME = "components";
+  private static final String COLUMN_NAME = "b_module_uuid";
+
+  @Rule
+  public final CoreDbTester db = CoreDbTester.createForSchema(DropBModuleUuidInComponentsTest.class, "schema.sql");
+  private final DdlChange underTest = new DropBModuleUuidInComponents(db.database());
+
+  @Test
+  public void drops_column() throws SQLException {
+    db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 50, true);
+    underTest.execute();
+    db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+  }
+
+  @Test
+  public void migration_is_reentrant() throws SQLException {
+    db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 50, true);
+    underTest.execute();
+    underTest.execute();
+    db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidPathInComponentsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidPathInComponentsTest.java
new file mode 100644 (file)
index 0000000..02bf8ac
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.v100;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropBModuleUuidPathInComponentsTest {
+  private static final String TABLE_NAME = "components";
+  private static final String COLUMN_NAME = "b_module_uuid_path";
+
+  @Rule
+  public final CoreDbTester db = CoreDbTester.createForSchema(DropBModuleUuidPathInComponentsTest.class, "schema.sql");
+  private final DdlChange underTest = new DropBModuleUuidPathInComponents(db.database());
+
+  @Test
+  public void drops_column() throws SQLException {
+    db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 1500, true);
+    underTest.execute();
+    db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+  }
+
+  @Test
+  public void migration_is_reentrant() throws SQLException {
+    db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 1500, true);
+    underTest.execute();
+    underTest.execute();
+    db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsModuleUuidInComponentsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsModuleUuidInComponentsTest.java
new file mode 100644 (file)
index 0000000..663b1ba
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.v100;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropIndexProjectsModuleUuidInComponentsTest {
+  private static final String TABLE_NAME = "components";
+  private static final String COLUMN_NAME = "module_uuid";
+  private static final String INDEX_NAME = "projects_module_uuid";
+
+  @Rule
+  public final CoreDbTester db = CoreDbTester.createForSchema(DropIndexProjectsModuleUuidInComponentsTest.class, "schema.sql");
+  private final DdlChange underTest = new DropIndexProjectsModuleUuidInComponents(db.database());
+
+  @Test
+  public void drops_index() throws SQLException {
+    db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
+    underTest.execute();
+    db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);
+  }
+
+  @Test
+  public void migration_is_reentrant() throws SQLException {
+    db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
+    underTest.execute();
+    underTest.execute();
+    db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidInComponentsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidInComponentsTest.java
new file mode 100644 (file)
index 0000000..0fcf618
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.v100;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropModuleUuidInComponentsTest {
+  private static final String TABLE_NAME = "components";
+  private static final String COLUMN_NAME = "module_uuid";
+
+  @Rule
+  public final CoreDbTester db = CoreDbTester.createForSchema(DropModuleUuidInComponentsTest.class, "schema.sql");
+  private final DdlChange underTest = new DropModuleUuidInComponents(db.database());
+
+  @Test
+  public void drops_column() throws SQLException {
+    db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 50, true);
+    underTest.execute();
+    db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+  }
+
+  @Test
+  public void migration_is_reentrant() throws SQLException {
+    db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 50, true);
+    underTest.execute();
+    underTest.execute();
+    db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidPathInComponentsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidPathInComponentsTest.java
new file mode 100644 (file)
index 0000000..11be58a
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.v100;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropModuleUuidPathInComponentsTest {
+  private static final String TABLE_NAME = "components";
+  private static final String COLUMN_NAME = "module_uuid_path";
+
+  @Rule
+  public final CoreDbTester db = CoreDbTester.createForSchema(DropModuleUuidPathInComponentsTest.class, "schema.sql");
+  private final DdlChange underTest = new DropModuleUuidPathInComponents(db.database());
+
+  @Test
+  public void drops_column() throws SQLException {
+    db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 1500, true);
+    underTest.execute();
+    db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+  }
+
+  @Test
+  public void migration_is_reentrant() throws SQLException {
+    db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 1500, true);
+    underTest.execute();
+    underTest.execute();
+    db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+  }
+}
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidInComponentsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidInComponentsTest/schema.sql
new file mode 100644 (file)
index 0000000..22f6a21
--- /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 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 UNIQUE INDEX "COMPONENTS_KEE_BRANCH_UUID" ON "COMPONENTS"("KEE" NULLS FIRST, "BRANCH_UUID" NULLS FIRST);
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidPathInComponentsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidPathInComponentsTest/schema.sql
new file mode 100644 (file)
index 0000000..22f6a21
--- /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 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 UNIQUE INDEX "COMPONENTS_KEE_BRANCH_UUID" ON "COMPONENTS"("KEE" NULLS FIRST, "BRANCH_UUID" NULLS FIRST);
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsModuleUuidInComponentsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsModuleUuidInComponentsTest/schema.sql
new file mode 100644 (file)
index 0000000..4d80e3a
--- /dev/null
@@ -0,0 +1,42 @@
+
+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 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 "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 UNIQUE INDEX "COMPONENTS_KEE_BRANCH_UUID" ON "COMPONENTS"("KEE" NULLS FIRST, "BRANCH_UUID" NULLS FIRST);
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidInComponentsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidInComponentsTest/schema.sql
new file mode 100644 (file)
index 0000000..22f6a21
--- /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 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 UNIQUE INDEX "COMPONENTS_KEE_BRANCH_UUID" ON "COMPONENTS"("KEE" NULLS FIRST, "BRANCH_UUID" NULLS FIRST);
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidPathInComponentsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidPathInComponentsTest/schema.sql
new file mode 100644 (file)
index 0000000..22f6a21
--- /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 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 UNIQUE INDEX "COMPONENTS_KEE_BRANCH_UUID" ON "COMPONENTS"("KEE" NULLS FIRST, "BRANCH_UUID" NULLS FIRST);
index 40d7e8f875cb825ad73acec14dd787a9e8f9c809..5f0512d311ea6a8a0b1a552b16949f8b1ab70a7d 100644 (file)
@@ -416,7 +416,6 @@ public class IssueFieldsSetter {
 
     // other fields (such as module, modulePath, componentKey) are read-only and set/reset for consistency only
     issue.setComponentKey(newComponentKey);
-    issue.setModuleUuidPath(null);
   }
 
   private static boolean relevantDateDifference(@Nullable Date left, @Nullable Date right) {
index 288ceae51bc33b9d88adbc0355ac25ae083b6950..a490dc62a44b47577d04950692374220fe756813 100644 (file)
@@ -58,10 +58,6 @@ public class IssueDoc extends BaseDoc {
     return getField(IssueIndexDefinition.FIELD_ISSUE_COMPONENT_UUID);
   }
 
-  public String modulePath() {
-    return getField(IssueIndexDefinition.FIELD_ISSUE_MODULE_PATH);
-  }
-
   public String projectUuid() {
     return getField(IssueIndexDefinition.FIELD_ISSUE_PROJECT_UUID);
   }
@@ -255,11 +251,6 @@ public class IssueDoc extends BaseDoc {
     return this;
   }
 
-  public IssueDoc setModuleUuidPath(@Nullable String s) {
-    setField(IssueIndexDefinition.FIELD_ISSUE_MODULE_PATH, s);
-    return this;
-  }
-
   @CheckForNull
   public Collection<String> getTags() {
     return getNullableField(IssueIndexDefinition.FIELD_ISSUE_TAGS);
index 39779bfe787ee7f282410c54512edf72efc81182..65368181f95fbfaac043b348c2366da73bd964f3 100644 (file)
@@ -61,7 +61,6 @@ public class IssueIndexDefinition implements IndexDefinition {
   public static final String FIELD_ISSUE_SCOPE = "scope";
   public static final String FIELD_ISSUE_LANGUAGE = "language";
   public static final String FIELD_ISSUE_LINE = "line";
-  public static final String FIELD_ISSUE_MODULE_PATH = "modulePath";
 
   /**
    * The (real) project, equivalent of projects.main_branch_project_uuid | projects.project_uuid, so
@@ -156,7 +155,6 @@ public class IssueIndexDefinition implements IndexDefinition {
     mapping.keywordFieldBuilder(FIELD_ISSUE_SCOPE).disableNorms().build();
     mapping.keywordFieldBuilder(FIELD_ISSUE_LANGUAGE).disableNorms().build();
     mapping.createIntegerField(FIELD_ISSUE_LINE);
-    mapping.createUuidPathField(FIELD_ISSUE_MODULE_PATH);
     mapping.keywordFieldBuilder(FIELD_ISSUE_PROJECT_UUID).disableNorms().addSubFields(SORTABLE_ANALYZER).build();
     mapping.keywordFieldBuilder(FIELD_ISSUE_BRANCH_UUID).disableNorms().build();
     mapping.createBooleanField(FIELD_ISSUE_IS_MAIN_BRANCH);
index 1495466750822028e5c4361639fc05e1d2a99512..a7101901c6c1944748f74c948133a87c007f543f 100644 (file)
@@ -71,7 +71,6 @@ class IssueIteratorForSingleChunk implements IssueIterator {
     "r.uuid",
     "r.language",
     "c.uuid",
-    "c.module_uuid_path",
     "c.path",
     "c.scope",
     "c.branch_uuid",
@@ -210,14 +209,12 @@ class IssueIteratorForSingleChunk implements IssueIterator {
       doc.setRuleUuid(rs.getString(12));
       doc.setLanguage(rs.getString(13));
       doc.setComponentUuid(rs.getString(14));
-      String moduleUuidPath = rs.getString(15);
-      doc.setModuleUuidPath(moduleUuidPath);
-      String scope = rs.getString(17);
-      String filePath = extractFilePath(rs.getString(16), scope);
+      String scope = rs.getString(16);
+      String filePath = extractFilePath(rs.getString(15), scope);
       doc.setFilePath(filePath);
       doc.setDirectoryPath(extractDirPath(doc.filePath(), scope));
-      String branchUuid = rs.getString(18);
-      String mainBranchProjectUuid = DatabaseUtils.getString(rs, 19);
+      String branchUuid = rs.getString(17);
+      String mainBranchProjectUuid = DatabaseUtils.getString(rs, 18);
       doc.setBranchUuid(branchUuid);
       if (mainBranchProjectUuid == null) {
         doc.setProjectUuid(branchUuid);
@@ -226,11 +223,11 @@ class IssueIteratorForSingleChunk implements IssueIterator {
         doc.setProjectUuid(mainBranchProjectUuid);
         doc.setIsMainBranch(false);
       }
-      String tags = rs.getString(20);
+      String tags = rs.getString(19);
       doc.setTags(IssueIteratorForSingleChunk.TAGS_SPLITTER.splitToList(tags == null ? "" : tags));
-      doc.setType(RuleType.valueOf(rs.getInt(21)));
+      doc.setType(RuleType.valueOf(rs.getInt(20)));
 
-      SecurityStandards securityStandards = fromSecurityStandards(deserializeSecurityStandardsString(rs.getString(22)));
+      SecurityStandards securityStandards = fromSecurityStandards(deserializeSecurityStandardsString(rs.getString(21)));
       SecurityStandards.SQCategory sqCategory = securityStandards.getSqCategory();
       doc.setOwaspTop10(securityStandards.getOwaspTop10());
       doc.setOwaspTop10For2021(securityStandards.getOwaspTop10For2021());
@@ -242,8 +239,8 @@ class IssueIteratorForSingleChunk implements IssueIterator {
       doc.setSonarSourceSecurityCategory(sqCategory);
       doc.setVulnerabilityProbability(sqCategory.getVulnerability());
 
-      doc.setScope(Qualifiers.UNIT_TEST_FILE.equals(rs.getString(23)) ? IssueScope.TEST : IssueScope.MAIN);
-      doc.setIsNewCodeReference(!isNullOrEmpty(rs.getString(24)));
+      doc.setScope(Qualifiers.UNIT_TEST_FILE.equals(rs.getString(22)) ? IssueScope.TEST : IssueScope.MAIN);
+      doc.setIsNewCodeReference(!isNullOrEmpty(rs.getString(23)));
       return doc;
     }
 
index 4961d22d732ea56986dc19245e20c6b848d235ad..1131ff60784bf885b2c1b0d4fc94b4f37f86c174 100644 (file)
@@ -86,11 +86,11 @@ public class ViewIndexer implements ResilientIndexer {
    */
   public void index(String rootViewUuid) {
     try (DbSession dbSession = dbClient.openSession(false)) {
-      Map<String, String> viewAndProjectViewUuidMap = new HashMap<>();
+      Map<String, String> viewAndRootViewUuidMap = new HashMap<>();
       for (ComponentDto viewOrSubView : dbClient.componentDao().selectEnabledViewsFromRootView(dbSession, rootViewUuid)) {
-        viewAndProjectViewUuidMap.put(viewOrSubView.uuid(), viewOrSubView.branchUuid());
+        viewAndRootViewUuidMap.put(viewOrSubView.uuid(), viewOrSubView.branchUuid());
       }
-      index(dbSession, viewAndProjectViewUuidMap, true, Size.REGULAR);
+      index(dbSession, viewAndRootViewUuidMap, true, Size.REGULAR);
     }
   }
 
@@ -106,10 +106,10 @@ public class ViewIndexer implements ResilientIndexer {
     bulk.stop();
   }
 
-  private void index(DbSession dbSession, Map<String, String> viewAndProjectViewUuidMap, boolean needClearCache, Size bulkSize) {
+  private void index(DbSession dbSession, Map<String, String> viewAndRootViewUuidMap, boolean needClearCache, Size bulkSize) {
     BulkIndexer bulk = new BulkIndexer(esClient, TYPE_VIEW, bulkSize);
     bulk.start();
-    for (Map.Entry<String, String> entry : viewAndProjectViewUuidMap.entrySet()) {
+    for (Map.Entry<String, String> entry : viewAndRootViewUuidMap.entrySet()) {
       String viewUuid = entry.getKey();
       List<String> projects = dbClient.componentDao().selectProjectsFromView(dbSession, viewUuid, entry.getValue());
       doIndex(bulk, new ViewDoc()
index f2e651faae549916a245028bf52deebf538a1c19..8ed1a664a7c1ac283dcef58554a9ec596e4c07ad 100644 (file)
@@ -44,17 +44,6 @@ public class ProjectIndexersImplTest {
     assertThat(underTest.calls).containsExactly(project.uuid());
   }
 
-  @Test
-  public void commitAndIndex_of_module_indexes_the_project() {
-    ComponentDto project = ComponentTesting.newPublicProjectDto();
-    ComponentDto module = ComponentTesting.newModuleDto(project);
-
-    FakeIndexers underTest = new FakeIndexers();
-    underTest.commitAndIndexComponents(mock(DbSession.class), singletonList(module), Cause.PROJECT_CREATION);
-
-    assertThat(underTest.calls).containsExactly(project.uuid());
-  }
-
   private static class FakeIndexers implements ProjectIndexers {
     private final List<String> calls = new ArrayList<>();
 
index a287d9708ae06c11d5884bfca676e98f7be5efb6..8147a036654d8a410c527b3930b1b1244a1b123b 100644 (file)
@@ -36,7 +36,6 @@ import org.sonar.db.rule.RuleDto;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.issue.IssueTesting.newCodeReferenceIssue;
 
 public class IssueIteratorFactoryTest {
@@ -86,7 +85,6 @@ public class IssueIteratorFactoryTest {
     assertThat(issue.ruleUuid()).isEqualTo(rule.getUuid());
     assertThat(issue.componentUuid()).isEqualTo(file.uuid());
     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");
     assertThat(issue.getTags()).containsOnly("tag1", "tag2", "tag3");
@@ -98,9 +96,8 @@ public class IssueIteratorFactoryTest {
   public void iterator_over_issues() {
     RuleDto rule = dbTester.rules().insert();
     ComponentDto project = dbTester.components().insertPrivateProject();
-    ComponentDto module = dbTester.components().insertComponent(newModuleDto(project));
-    ComponentDto directory = dbTester.components().insertComponent(newDirectory(module, "src/main/java"));
-    ComponentDto file = dbTester.components().insertComponent(newFileDto(module, directory)
+    ComponentDto directory = dbTester.components().insertComponent(newDirectory(project, "src/main/java"));
+    ComponentDto file = dbTester.components().insertComponent(newFileDto(directory, directory)
       .setPath("src/main/java/Action.java"));
     IssueDto fileIssue = dbTester.issues().insert(rule, project, file,
       t -> t
@@ -108,7 +105,7 @@ public class IssueIteratorFactoryTest {
         .setAuthorLogin("guy2")
         .setEffort(10L)
         .setType(1));
-    IssueDto moduleIssue = dbTester.issues().insert(rule, project, module, t -> t
+    IssueDto moduleIssue = dbTester.issues().insert(rule, project, file, t -> t
       .setAssigneeUuid("uuid-of-guy2")
       .setAuthorLogin("guy2")
       .setRuleUuid(rule.getUuid()));
@@ -130,15 +127,15 @@ public class IssueIteratorFactoryTest {
   public void iterator_over_issue_from_project() {
     RuleDto rule = dbTester.rules().insert();
     ComponentDto project1 = dbTester.components().insertPrivateProject();
-    ComponentDto module1 = dbTester.components().insertComponent(newModuleDto(project1));
-    ComponentDto file1 = dbTester.components().insertComponent(newFileDto(module1));
-    String[] project1IssueKeys = Stream.of(project1, module1, file1)
+    ComponentDto dir = dbTester.components().insertComponent(newDirectory(project1, "path"));
+    ComponentDto file1 = dbTester.components().insertComponent(newFileDto(project1, dir));
+    String[] project1IssueKeys = Stream.of(project1, dir, file1)
       .map(project1Component -> dbTester.issues().insert(rule, project1, project1Component).getKey())
       .toArray(String[]::new);
     ComponentDto project2 = dbTester.components().insertPrivateProject();
-    ComponentDto module2 = dbTester.components().insertComponent(newModuleDto(project2));
-    ComponentDto file2 = dbTester.components().insertComponent(newFileDto(module2));
-    String[] project2IssueKeys = Stream.of(project2, module2, file2)
+    ComponentDto dir2 = dbTester.components().insertComponent(newDirectory(project2, "path"));
+    ComponentDto file2 = dbTester.components().insertComponent(newFileDto(project2, dir2));
+    String[] project2IssueKeys = Stream.of(project2, dir2, file2)
       .map(project2Component -> dbTester.issues().insert(rule, project2, project2Component).getKey())
       .toArray(String[]::new);
 
@@ -154,20 +151,17 @@ public class IssueIteratorFactoryTest {
   public void extract_directory_path() {
     RuleDto rule = dbTester.rules().insert();
     ComponentDto project = dbTester.components().insertPrivateProject();
-    ComponentDto module = dbTester.components().insertComponent(newModuleDto(project));
-    ComponentDto fileInRootDir = dbTester.components().insertComponent(newFileDto(module).setPath("pom.xml"));
-    ComponentDto fileInSubDir = dbTester.components().insertComponent(newFileDto(module).setPath("src/main/java/Action.java"));
+    ComponentDto fileInRootDir = dbTester.components().insertComponent(newFileDto(project).setPath("pom.xml"));
+    ComponentDto fileInSubDir = dbTester.components().insertComponent(newFileDto(project).setPath("src/main/java/Action.java"));
     IssueDto projectIssue = dbTester.issues().insert(rule, project, project);
     IssueDto fileInSubDirIssue = dbTester.issues().insert(rule, project, fileInSubDir);
     IssueDto fileInRootDirIssue = dbTester.issues().insert(rule, project, fileInRootDir);
-    IssueDto moduleIssue = dbTester.issues().insert(rule, project, module);
 
     Map<String, IssueDoc> issuesByKey = issuesByKey();
 
-    assertThat(issuesByKey).hasSize(4);
+    assertThat(issuesByKey).hasSize(3);
     assertThat(issuesByKey.get(fileInSubDirIssue.getKey()).directoryPath()).isEqualTo("src/main/java");
     assertThat(issuesByKey.get(fileInRootDirIssue.getKey()).directoryPath()).isEqualTo("/");
-    assertThat(issuesByKey.get(moduleIssue.getKey()).directoryPath()).isNull();
     assertThat(issuesByKey.get(projectIssue.getKey()).directoryPath()).isNull();
   }
 
@@ -175,20 +169,17 @@ public class IssueIteratorFactoryTest {
   public void extract_file_path() {
     RuleDto rule = dbTester.rules().insert();
     ComponentDto project = dbTester.components().insertPrivateProject();
-    ComponentDto module = dbTester.components().insertComponent(newModuleDto(project));
-    ComponentDto fileInRootDir = dbTester.components().insertComponent(newFileDto(module).setPath("pom.xml"));
-    ComponentDto fileInSubDir = dbTester.components().insertComponent(newFileDto(module).setPath("src/main/java/Action.java"));
+    ComponentDto fileInRootDir = dbTester.components().insertComponent(newFileDto(project).setPath("pom.xml"));
+    ComponentDto fileInSubDir = dbTester.components().insertComponent(newFileDto(project).setPath("src/main/java/Action.java"));
     IssueDto projectIssue = dbTester.issues().insert(rule, project, project);
     IssueDto fileInSubDirIssue = dbTester.issues().insert(rule, project, fileInSubDir);
     IssueDto fileInRootDirIssue = dbTester.issues().insert(rule, project, fileInRootDir);
-    IssueDto moduleIssue = dbTester.issues().insert(rule, project, module);
 
     Map<String, IssueDoc> issuesByKey = issuesByKey();
 
-    assertThat(issuesByKey).hasSize(4);
+    assertThat(issuesByKey).hasSize(3);
     assertThat(issuesByKey.get(fileInSubDirIssue.getKey()).filePath()).isEqualTo("src/main/java/Action.java");
     assertThat(issuesByKey.get(fileInRootDirIssue.getKey()).filePath()).isEqualTo("pom.xml");
-    assertThat(issuesByKey.get(moduleIssue.getKey()).filePath()).isNull();
     assertThat(issuesByKey.get(projectIssue.getKey()).filePath()).isNull();
   }
 
index 774f82797e85aff30a66318e18b71894aeafaf0d..d9556e15e378737d3440657c0f9ea4ff882eed88 100644 (file)
@@ -47,7 +47,6 @@ public class IssueDocTesting {
       .setKey(key)
       .setBranchUuid(componentDto.branchUuid())
       .setComponentUuid(componentDto.uuid())
-      .setModuleUuidPath(componentDto.moduleUuidPath())
       .setProjectUuid(mainBranchProjectUuid == null ? componentDto.branchUuid() : mainBranchProjectUuid)
       // File path make no sens on modules and projects
       .setFilePath(!componentDto.scope().equals(Scopes.PROJECT) ? componentDto.path() : null)
@@ -67,7 +66,6 @@ public class IssueDocTesting {
     doc.setComponentUuid(Uuids.createFast());
     doc.setFilePath("filePath_" + randomAlphabetic(5));
     doc.setDirectoryPath("directory_" + randomAlphabetic(5));
-    doc.setModuleUuidPath(Uuids.createFast());
     doc.setProjectUuid(Uuids.createFast());
     doc.setLine(nextInt(1_000) + 1);
     doc.setStatus(STATUS_OPEN);
index ab82344352366f74c97986f08e44a1f3484748b4..acc06c89066cbfde1d7028d05c8ac8c218728bfc 100644 (file)
@@ -155,7 +155,6 @@ import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_IS_M
 import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_KEY;
 import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_LANGUAGE;
 import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_LINE;
-import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_MODULE_PATH;
 import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_NEW_CODE_REFERENCE;
 import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_OWASP_ASVS_40;
 import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_OWASP_TOP_10;
@@ -593,9 +592,6 @@ public class IssueIndex {
       filters.addFilter(
         FIELD_ISSUE_PROJECT_UUID, new SimpleFieldFilterScope(FIELD_ISSUE_PROJECT_UUID),
         createTermsFilter(FIELD_ISSUE_PROJECT_UUID, query.projectUuids()));
-      filters.addFilter(
-        "__module", new SimpleFieldFilterScope(FIELD_ISSUE_MODULE_PATH),
-        createTermsFilter(FIELD_ISSUE_MODULE_PATH, query.moduleRootUuids()));
       filters.addFilter(
         FIELD_ISSUE_DIRECTORY_PATH, new SimpleFieldFilterScope(FIELD_ISSUE_DIRECTORY_PATH),
         createTermsFilter(FIELD_ISSUE_DIRECTORY_PATH, query.directories()));
index 50c29e94f5d1bb5abf920994e5fc0cf116a9b2f3..acb8449f7c471ae6a9a9f307766cfd421a584652 100644 (file)
@@ -67,7 +67,6 @@ public class IssueQuery {
   private final Collection<String> statuses;
   private final Collection<String> resolutions;
   private final Collection<String> components;
-  private final Collection<String> moduleRoots;
   private final Collection<String> projects;
   private final Collection<String> directories;
   private final Collection<String> files;
@@ -111,7 +110,6 @@ public class IssueQuery {
     this.statuses = defaultCollection(builder.statuses);
     this.resolutions = defaultCollection(builder.resolutions);
     this.components = defaultCollection(builder.components);
-    this.moduleRoots = defaultCollection(builder.moduleRoots);
     this.projects = defaultCollection(builder.projects);
     this.directories = defaultCollection(builder.directories);
     this.files = defaultCollection(builder.files);
@@ -170,9 +168,6 @@ public class IssueQuery {
     return components;
   }
 
-  public Collection<String> moduleRootUuids() {
-    return moduleRoots;
-  }
 
   public Collection<String> projectUuids() {
     return projects;
@@ -345,7 +340,6 @@ public class IssueQuery {
     private Collection<String> statuses;
     private Collection<String> resolutions;
     private Collection<String> components;
-    private Collection<String> moduleRoots;
     private Collection<String> projects;
     private Collection<String> directories;
     private Collection<String> files;
@@ -412,11 +406,6 @@ public class IssueQuery {
       return this;
     }
 
-    public Builder moduleRootUuids(@Nullable Collection<String> l) {
-      this.moduleRoots = l;
-      return this;
-    }
-
     public Builder projectUuids(@Nullable Collection<String> l) {
       this.projects = l;
       return this;
index fa41d7b28f1600994be8c960b2537cf2b630d12a..c2ebee547f2e513f8ba4a91077ab93d2310f8871 100644 (file)
@@ -331,9 +331,6 @@ public class IssueQueryFactory {
       case Qualifiers.PROJECT:
         builder.projectUuids(components.stream().map(IssueQueryFactory::toProjectUuid).collect(toList()));
         break;
-      case Qualifiers.MODULE:
-        builder.moduleRootUuids(components.stream().map(ComponentDto::uuid).collect(toList()));
-        break;
       case Qualifiers.DIRECTORY:
         addDirectories(builder, components);
         break;
index e2c4bc0252fe5f3e7d329ec2be7e910d60e28dbf..6c202a81c33edd9181548093eda33d972d868744 100644 (file)
@@ -44,7 +44,6 @@ import static org.sonar.api.utils.DateUtils.addDays;
 import static org.sonar.api.utils.DateUtils.parseDate;
 import static org.sonar.api.utils.DateUtils.parseDateTime;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.rule.RuleTesting.newRule;
 import static org.sonar.server.issue.IssueDocTesting.newDoc;
@@ -67,46 +66,30 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon {
   @Test
   public void filter_by_projects() {
     ComponentDto project = newPrivateProjectDto();
-    ComponentDto module = newModuleDto(project);
-    ComponentDto subModule = newModuleDto(module);
 
     indexIssues(
       newDoc("I1", project),
-      newDoc("I2", newFileDto(project, null)),
-      newDoc("I3", module),
-      newDoc("I4", newFileDto(module, null)),
-      newDoc("I5", subModule),
-      newDoc("I6", newFileDto(subModule, null)));
+      newDoc("I2", newFileDto(project, null)));
 
-    assertThatSearchReturnsOnly(IssueQuery.builder().projectUuids(singletonList(project.uuid())), "I1", "I2", "I3", "I4", "I5", "I6");
+    assertThatSearchReturnsOnly(IssueQuery.builder().projectUuids(singletonList(project.uuid())), "I1", "I2");
     assertThatSearchReturnsEmpty(IssueQuery.builder().projectUuids(singletonList("unknown")));
   }
 
   @Test
   public void filter_by_components_on_contextualized_search() {
     ComponentDto project = newPrivateProjectDto();
-    ComponentDto module = newModuleDto(project);
-    ComponentDto subModule = newModuleDto(module);
     ComponentDto file1 = newFileDto(project, null);
-    ComponentDto file2 = newFileDto(module, null);
-    ComponentDto file3 = newFileDto(subModule, null);
     String view = "ABCD";
     indexView(view, singletonList(project.uuid()));
 
     indexIssues(
       newDoc("I1", project),
-      newDoc("I2", file1),
-      newDoc("I3", module),
-      newDoc("I4", file2),
-      newDoc("I5", subModule),
-      newDoc("I6", file3));
+      newDoc("I2", file1));
 
-    assertThatSearchReturnsOnly(IssueQuery.builder().files(asList(file1.path(), file2.path(), file3.path())), "I2", "I4", "I6");
+    assertThatSearchReturnsOnly(IssueQuery.builder().files(asList(file1.path())), "I2");
     assertThatSearchReturnsOnly(IssueQuery.builder().files(singletonList(file1.path())), "I2");
-    assertThatSearchReturnsOnly(IssueQuery.builder().moduleRootUuids(singletonList(subModule.uuid())), "I5", "I6");
-    assertThatSearchReturnsOnly(IssueQuery.builder().moduleRootUuids(singletonList(module.uuid())), "I3", "I4", "I5", "I6");
-    assertThatSearchReturnsOnly(IssueQuery.builder().projectUuids(singletonList(project.uuid())), "I1", "I2", "I3", "I4", "I5", "I6");
-    assertThatSearchReturnsOnly(IssueQuery.builder().viewUuids(singletonList(view)), "I1", "I2", "I3", "I4", "I5", "I6");
+    assertThatSearchReturnsOnly(IssueQuery.builder().projectUuids(singletonList(project.uuid())), "I1", "I2");
+    assertThatSearchReturnsOnly(IssueQuery.builder().viewUuids(singletonList(view)), "I1", "I2");
     assertThatSearchReturnsEmpty(IssueQuery.builder().projectUuids(singletonList("unknown")));
   }
 
@@ -114,26 +97,18 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon {
   public void filter_by_components_on_non_contextualized_search() {
     ComponentDto project = newPrivateProjectDto("project");
     ComponentDto file1 = newFileDto(project, null, "file1");
-    ComponentDto module = newModuleDto(project).setUuid("module");
-    ComponentDto file2 = newFileDto(module, null, "file2");
-    ComponentDto subModule = newModuleDto(module).setUuid("subModule");
-    ComponentDto file3 = newFileDto(subModule, null, "file3");
     String view = "ABCD";
     indexView(view, singletonList(project.uuid()));
 
     indexIssues(
       newDoc("I1", project),
-      newDoc("I2", file1),
-      newDoc("I3", module),
-      newDoc("I4", file2),
-      newDoc("I5", subModule),
-      newDoc("I6", file3));
+      newDoc("I2", file1));
 
     assertThatSearchReturnsEmpty(IssueQuery.builder().projectUuids(singletonList("unknown")));
-    assertThatSearchReturnsOnly(IssueQuery.builder().projectUuids(singletonList(project.uuid())), "I1", "I2", "I3", "I4", "I5", "I6");
-    assertThatSearchReturnsOnly(IssueQuery.builder().viewUuids(singletonList(view)), "I1", "I2", "I3", "I4", "I5", "I6");
+    assertThatSearchReturnsOnly(IssueQuery.builder().projectUuids(singletonList(project.uuid())), "I1", "I2");
+    assertThatSearchReturnsOnly(IssueQuery.builder().viewUuids(singletonList(view)), "I1", "I2");
     assertThatSearchReturnsOnly(IssueQuery.builder().files(singletonList(file1.path())), "I2");
-    assertThatSearchReturnsOnly(IssueQuery.builder().files(asList(file1.path(), file2.path(), file3.path())), "I2", "I4", "I6");
+    assertThatSearchReturnsOnly(IssueQuery.builder().files(asList(file1.path())), "I2");
   }
 
   @Test
@@ -223,29 +198,26 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon {
     assertThatSearchReturnsOnly(
       IssueQuery.builder().componentUuids(singletonList(branch.uuid())).projectUuids(singletonList(project.uuid())).branchUuid(branch.uuid()).mainBranch(false),
       issueOnBranch.key());
-    assertThatSearchReturnsOnly(IssueQuery.builder().projectUuids(singletonList(project.uuid())).mainBranch(null), issueOnProject.key(), issueOnBranch.key(), issueOnAnotherBranch.key());
+    assertThatSearchReturnsOnly(IssueQuery.builder().projectUuids(singletonList(project.uuid())).mainBranch(null), issueOnProject.key(), issueOnBranch.key(),
+      issueOnAnotherBranch.key());
     assertThatSearchReturnsEmpty(IssueQuery.builder().branchUuid("unknown"));
   }
 
   @Test
   public void issues_from_branch_component_children() {
     ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto projectModule = db.components().insertComponent(newModuleDto(project));
-    ComponentDto projectFile = db.components().insertComponent(newFileDto(projectModule));
+    ComponentDto projectFile = db.components().insertComponent(newFileDto(project));
     ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("my_branch"));
-    ComponentDto branchModule = db.components().insertComponent(newModuleDto(branch));
-    ComponentDto branchFile = db.components().insertComponent(newFileDto(branchModule));
+    ComponentDto branchFile = db.components().insertComponent(newFileDto(branch));
 
     indexIssues(
       newDoc("I1", project),
       newDoc("I2", projectFile),
-      newDoc("I3", projectModule),
-      newDoc("I4", branch),
-      newDoc("I5", branchModule),
-      newDoc("I6", branchFile));
+      newDoc("I3", branch),
+      newDoc("I4", branchFile));
 
-    assertThatSearchReturnsOnly(IssueQuery.builder().branchUuid(branch.uuid()).mainBranch(false), "I4", "I5", "I6");
-    assertThatSearchReturnsOnly(IssueQuery.builder().files(singletonList(branchFile.path())).branchUuid(branch.uuid()).mainBranch(false), "I6");
+    assertThatSearchReturnsOnly(IssueQuery.builder().branchUuid(branch.uuid()).mainBranch(false), "I3", "I4");
+    assertThatSearchReturnsOnly(IssueQuery.builder().files(singletonList(branchFile.path())).branchUuid(branch.uuid()).mainBranch(false), "I4");
     assertThatSearchReturnsEmpty(IssueQuery.builder().files(singletonList(branchFile.uuid())).mainBranch(false).branchUuid("unknown"));
   }
 
@@ -466,7 +438,6 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon {
       project1Issue1.key(), project2Issue2.key());
   }
 
-
   @Test
   public void filter_by_new_code_reference_branches() {
     ComponentDto project1 = newPrivateProjectDto();
index 06f1b9ad71aea42952c6745764d1904a1dd59957..a48fe2ae93c92b9657b313bc9c4069e6e55367f3 100644 (file)
@@ -58,7 +58,6 @@ import static org.sonar.api.web.UserRole.USER;
 import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.component.ComponentTesting.newProjectCopy;
 import static org.sonar.db.component.ComponentTesting.newSubPortfolio;
 import static org.sonar.db.newcodeperiod.NewCodePeriodType.REFERENCE_BRANCH;
@@ -82,7 +81,6 @@ public class IssueQueryFactoryTest {
     String ruleAdHocName = "New Name";
     UserDto user = db.users().insertUser(u -> u.setLogin("joanna"));
     ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
     ComponentDto file = db.components().insertComponent(newFileDto(project));
 
     RuleDto rule1 = ruleDbTester.insert(r -> r.setAdHocName(ruleAdHocName));
@@ -138,7 +136,6 @@ public class IssueQueryFactoryTest {
   public void create_with_rule_key_that_does_not_exist_in_the_db() {
     db.users().insertUser(u -> u.setLogin("joanna"));
     ComponentDto project = db.components().insertPrivateProject();
-    db.components().insertComponent(newModuleDto(project));
     db.components().insertComponent(newFileDto(project));
     newRule(RuleKey.of("findbugs", "NullReference"));
     SearchRequest request = new SearchRequest()
@@ -316,7 +313,6 @@ public class IssueQueryFactoryTest {
 
     assertThat(query.componentUuids()).isEmpty();
     assertThat(query.projectUuids()).isEmpty();
-    assertThat(query.moduleRootUuids()).isEmpty();
     assertThat(query.directories()).isEmpty();
     assertThat(query.files()).isEmpty();
     assertThat(query.viewUuids()).isEmpty();
@@ -491,18 +487,6 @@ public class IssueQueryFactoryTest {
     assertThat(query.onComponentOnly()).isTrue();
   }
 
-  @Test
-  public void should_search_in_tree_with_module_uuid() {
-    ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    SearchRequest request = new SearchRequest()
-      .setComponentUuids(asList(module.uuid()));
-
-    IssueQuery query = underTest.create(request);
-    assertThat(query.moduleRootUuids()).containsExactly(module.uuid());
-    assertThat(query.onComponentOnly()).isFalse();
-  }
-
   @Test
   public void param_componentUuids_enables_search_in_directory_tree() {
     ComponentDto project = db.components().insertPrivateProject();
index 37fe780dce578f7b42366a4c757a6bded71cef7c..7884d497d4f1e7f00a04bad52b04e63d5eefcae7 100644 (file)
@@ -28,7 +28,6 @@ public class BatchWsModule extends Module {
       BatchIndex.class,
       ProjectAction.class,
       ProjectDataLoader.class,
-      IssuesAction.class,
       IndexAction.class,
       FileAction.class,
       BatchWs.class);
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/IssuesAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/IssuesAction.java
deleted file mode 100644 (file)
index f9bed69..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 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.batch;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import org.sonar.api.resources.Scopes;
-import org.sonar.api.rules.RuleType;
-import org.sonar.api.server.ws.Change;
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.component.ComponentDto;
-import org.sonar.db.issue.IssueDto;
-import org.sonar.db.user.UserDto;
-import org.sonar.scanner.protocol.input.ScannerInput;
-import org.sonar.server.component.ComponentFinder;
-import org.sonar.server.user.UserSession;
-import org.sonarqube.ws.MediaTypes;
-
-import static java.lang.String.format;
-import static java.util.Optional.ofNullable;
-import static java.util.stream.Collectors.toMap;
-import static org.sonar.api.web.UserRole.USER;
-import static org.sonar.server.ws.KeyExamples.KEY_BRANCH_EXAMPLE_001;
-import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
-
-public class IssuesAction implements BatchWsAction {
-
-  private static final String PARAM_KEY = "key";
-  private static final String PARAM_BRANCH = "branch";
-
-  private final DbClient dbClient;
-  private final UserSession userSession;
-  private final ComponentFinder componentFinder;
-
-  public IssuesAction(DbClient dbClient, UserSession userSession, ComponentFinder componentFinder) {
-    this.dbClient = dbClient;
-    this.userSession = userSession;
-    this.componentFinder = componentFinder;
-  }
-
-  @Override
-  public void define(WebService.NewController controller) {
-    WebService.NewAction action = controller.createAction("issues")
-      .setDescription("Return open issues")
-      .setResponseExample(getClass().getResource("issues-example.proto"))
-      .setSince("5.1")
-      .setChangelog(new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_KEY)))
-      .setInternal(true)
-      .setDeprecatedSince("9.5")
-      .setHandler(this);
-
-    action
-      .createParam(PARAM_KEY)
-      .setRequired(true)
-      .setDescription("Project, module or file key")
-      .setExampleValue(KEY_PROJECT_EXAMPLE_001);
-
-    action
-      .createParam(PARAM_BRANCH)
-      .setSince("6.6")
-      .setDescription("Branch key")
-      .setExampleValue(KEY_BRANCH_EXAMPLE_001);
-  }
-
-  @Override
-  public void handle(Request request, Response response) throws Exception {
-    try (DbSession dbSession = dbClient.openSession(false)) {
-      ComponentDto component = loadComponent(dbSession, request);
-      userSession.checkComponentPermission(USER, component);
-
-      ScannerInput.ServerIssue.Builder responseBuilder = ScannerInput.ServerIssue.newBuilder();
-      response.stream().setMediaType(MediaTypes.PROTOBUF);
-      OutputStream output = response.stream().output();
-
-      List<IssueDto> issueDtos = new ArrayList<>();
-      switch (component.scope()) {
-        case Scopes.PROJECT:
-          issueDtos.addAll(dbClient.issueDao().selectNonClosedByModuleOrProjectExcludingExternalsAndSecurityHotspots(dbSession, component));
-          break;
-        case Scopes.FILE:
-          issueDtos.addAll(dbClient.issueDao().selectNonClosedByComponentUuidExcludingExternalsAndSecurityHotspots(dbSession, component.uuid()));
-          break;
-        default:
-          // only projects, modules and files are supported. Other types of components are not allowed.
-          throw new IllegalArgumentException(format("Component of scope '%s' is not allowed", component.scope()));
-      }
-
-      List<String> usersUuids = issueDtos.stream()
-        .filter(issue -> issue.getAssigneeUuid() != null)
-        .map(IssueDto::getAssigneeUuid)
-        .toList();
-
-      Map<String, String> userLoginsByUserUuids = dbClient.userDao().selectByUuids(dbSession, usersUuids)
-        .stream().collect(toMap(UserDto::getUuid, UserDto::getLogin));
-
-      issueDtos.forEach(issue -> {
-        issue.setAssigneeUuid(userLoginsByUserUuids.get(issue.getAssigneeUuid()));
-        handleIssue(issue, responseBuilder, output);
-      });
-    }
-  }
-
-  private static void handleIssue(IssueDto issue, ScannerInput.ServerIssue.Builder issueBuilder, OutputStream out) {
-    issueBuilder.setKey(issue.getKey());
-    ofNullable(issue.getFilePath()).ifPresent(issueBuilder::setPath);
-    issueBuilder.setRuleRepository(issue.getRuleRepo());
-    issueBuilder.setRuleKey(issue.getRule());
-    ofNullable(issue.getChecksum()).ifPresent(issueBuilder::setChecksum);
-    ofNullable(issue.getAssigneeUuid()).ifPresent(issueBuilder::setAssigneeLogin);
-    ofNullable(issue.getLine()).ifPresent(issueBuilder::setLine);
-    ofNullable(issue.getMessage()).ifPresent(issueBuilder::setMsg);
-    issueBuilder.setSeverity(org.sonar.scanner.protocol.Constants.Severity.valueOf(issue.getSeverity()));
-    issueBuilder.setManualSeverity(issue.isManualSeverity());
-    issueBuilder.setStatus(issue.getStatus());
-    ofNullable(issue.getResolution()).ifPresent(issueBuilder::setResolution);
-    issueBuilder.setType(RuleType.valueOf(issue.getType()).name());
-    issueBuilder.setCreationDate(issue.getIssueCreationTime());
-    try {
-      issueBuilder.build().writeDelimitedTo(out);
-    } catch (IOException e) {
-      throw new IllegalStateException("Unable to serialize issue", e);
-    }
-    issueBuilder.clear();
-  }
-
-  private ComponentDto loadComponent(DbSession dbSession, Request request) {
-    String componentKey = request.mandatoryParam(PARAM_KEY);
-    String branch = request.param(PARAM_BRANCH);
-    return componentFinder.getByKeyAndOptionalBranchOrPullRequest(dbSession, componentKey, branch, null);
-  }
-}
index bec02c003e8d006a3d21e4b55e7425f940cdc561..fbc2c8578785810b368fed3683426548f2b49fe5 100644 (file)
@@ -57,8 +57,7 @@ public class ProjectDataLoader {
       String pullRequest = query.getPullRequest();
       ComponentDto project = componentFinder.getByKey(session, projectKey);
       checkRequest(project.isRootProject(), "Key '%s' belongs to a component which is not a Project", projectKey);
-      boolean hasScanPerm = userSession.hasComponentPermission(UserRole.SCAN, project) ||
-        userSession.hasPermission(GlobalPermission.SCAN);
+      boolean hasScanPerm = userSession.hasComponentPermission(UserRole.SCAN, project) || userSession.hasPermission(GlobalPermission.SCAN);
       checkPermission(hasScanPerm);
       ComponentDto branchComponent = (branch == null && pullRequest == null) ? project
         : componentFinder.getByKeyAndOptionalBranchOrPullRequest(session, projectKey, branch, pullRequest);
index 3477be1c777b3034b7b5330729ed01ccbb2512fe..e6efc5b96fb310bf7673a54aba54b883c6eb4a76 100644 (file)
@@ -149,8 +149,6 @@ public class ComponentUpdater {
       .setUuid(uuid)
       .setUuidPath(ComponentDto.UUID_PATH_OF_ROOT)
       .setRootUuid(uuid)
-      .setModuleUuid(null)
-      .setModuleUuidPath(ComponentDto.UUID_PATH_SEPARATOR + uuid + ComponentDto.UUID_PATH_SEPARATOR)
       .setBranchUuid(uuid)
       .setKey(newComponent.key())
       .setName(newComponent.name())
index 99b0c7198fc67a2e21749294b9b98039c93f7a73..dfbeb1379b16752f7a6868601eb20d98fc0b7fe4 100644 (file)
@@ -27,9 +27,7 @@ public enum SuggestionCategory {
   VIEW(Qualifiers.VIEW),
   SUBVIEW(Qualifiers.SUBVIEW),
   APP(Qualifiers.APP),
-  PROJECT(Qualifiers.PROJECT),
-  FILE(Qualifiers.FILE),
-  UNIT_TEST_FILE(Qualifiers.UNIT_TEST_FILE),;
+  PROJECT(Qualifiers.PROJECT);
 
   private final String qualifier;
 
index a3b0ee6a65bcc6140ad8b9b62895f71510aa18a2..279fddd7f54141d11e1c535f67833c6fb5bb0ee2 100644 (file)
@@ -115,6 +115,7 @@ public class SuggestionsAction implements ComponentsWsAction {
       .setHandler(this)
       .setResponseExample(Resources.getResource(this.getClass(), "suggestions-example.json"))
       .setChangelog(
+        new Change("10.0", String.format("The use of 'BRC' as value for parameter '%s' is no longer supported", PARAM_MORE)),
         new Change("8.4", String.format("The use of 'DIR', 'FIL','UTS' as values for parameter '%s' is no longer supported", PARAM_MORE)),
         new Change("7.6", String.format("The use of 'BRC' as value for parameter '%s' is deprecated", PARAM_MORE)));
 
@@ -255,10 +256,6 @@ public class SuggestionsAction implements ComponentsWsAction {
   private List<String> getQualifiers(@Nullable String more) {
     Set<String> availableQualifiers = resourceTypes.getAll().stream()
       .map(ResourceType::getQualifier)
-      .filter(q -> !q.equals(Qualifiers.MODULE))
-      .filter(q -> !q.equals(Qualifiers.DIRECTORY))
-      .filter(q -> !q.equals(Qualifiers.FILE))
-      .filter(q -> !q.equals(Qualifiers.UNIT_TEST_FILE))
       .collect(MoreCollectors.toSet());
     if (more == null) {
       return stream(SuggestionCategory.values())
index a4e9a526d311dcc296817b582e19e15b9fd1d728..ab2002a6941c202fa232418fe64e4d15378bd5ad 100644 (file)
@@ -26,6 +26,7 @@ import com.google.common.collect.Ordering;
 import com.google.common.collect.TreeMultimap;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
@@ -71,10 +72,8 @@ import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
 import static org.sonar.server.ws.WsUtils.writeProtobuf;
 
 public class ValuesAction implements SettingsWsAction {
-
   private static final Splitter COMMA_SPLITTER = Splitter.on(",");
   private static final String COMMA_ENCODED_VALUE = "%2C";
-  private static final Splitter DOT_SPLITTER = Splitter.on(".").omitEmptyStrings();
   private static final Set<String> SERVER_SETTING_KEYS = Set.of(SERVER_STARTTIME, SERVER_ID);
 
   private final DbClient dbClient;
@@ -210,10 +209,14 @@ public class ValuesAction implements SettingsWsAction {
   }
 
   /**
-   * Return list of settings by component uuid, sorted from project to lowest module
+   * Return list of settings by component uuid
    */
   private Multimap<String, Setting> loadComponentSettings(DbSession dbSession, Set<String> keys, ComponentDto component) {
-    List<String> componentUuids = DOT_SPLITTER.splitToList(component.moduleUuidPath());
+    List<String> componentUuids = new LinkedList<>();
+    if (!component.uuid().equals(component.branchUuid())) {
+      componentUuids.add(component.branchUuid());
+    }
+    componentUuids.add(component.uuid());
     List<PropertyDto> properties = dbClient.propertiesDao().selectPropertiesByKeysAndComponentUuids(dbSession, keys, componentUuids);
     List<PropertyDto> propertySets = dbClient.propertiesDao().selectPropertiesByKeysAndComponentUuids(dbSession, getPropertySetKeys(properties), componentUuids);
 
index 6ad5e342188007a9a52869435d499f16f532c266..ee5851e2c40e4eac617dad25a30fa78707b19c80 100644 (file)
@@ -29,7 +29,7 @@ public class BatchWsModuleTest {
   public void verify_count_of_added_components() {
     ListContainer container = new ListContainer();
     new BatchWsModule().configure(container);
-    assertThat(container.getAddedObjects()).hasSize(7);
+    assertThat(container.getAddedObjects()).hasSize(6);
   }
 
 }
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/batch/IssuesActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/batch/IssuesActionTest.java
deleted file mode 100644 (file)
index 66a6474..0000000
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 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.batch;
-
-import java.io.IOException;
-import java.util.stream.Stream;
-import javax.annotation.Nullable;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.rules.RuleType;
-import org.sonar.api.utils.System2;
-import org.sonar.api.web.UserRole;
-import org.sonar.core.util.CloseableIterator;
-import org.sonar.core.util.Protobuf;
-import org.sonar.db.DbTester;
-import org.sonar.db.component.ComponentDto;
-import org.sonar.db.issue.IssueDto;
-import org.sonar.db.rule.RuleDto;
-import org.sonar.db.user.UserDto;
-import org.sonar.scanner.protocol.Constants.Severity;
-import org.sonar.scanner.protocol.input.ScannerInput.ServerIssue;
-import org.sonar.server.component.TestComponentFinder;
-import org.sonar.server.exceptions.ForbiddenException;
-import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.tester.UserSessionRule;
-import org.sonar.server.ws.TestRequest;
-import org.sonar.server.ws.TestResponse;
-import org.sonar.server.ws.WsActionTester;
-
-import static java.lang.String.format;
-import static org.apache.commons.lang.math.RandomUtils.nextInt;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.sonar.api.rules.RuleType.BUG;
-import static org.sonar.db.component.ComponentTesting.newDirectory;
-import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
-
-public class IssuesActionTest {
-
-  private static final RuleType[] RULE_TYPES_EXCEPT_HOTSPOT = Stream.of(RuleType.values())
-    .filter(r -> r != RuleType.SECURITY_HOTSPOT)
-    .toArray(RuleType[]::new);
-
-  private System2 system2 = System2.INSTANCE;
-
-  @Rule
-  public DbTester db = DbTester.create(system2);
-  @Rule
-  public UserSessionRule userSessionRule = UserSessionRule.standalone();
-
-  private WsActionTester tester = new WsActionTester(new IssuesAction(db.getDbClient(), userSessionRule, TestComponentFinder.from(db)));
-
-  @Test
-  public void test_nullable_fields() throws Exception {
-    RuleDto rule = db.rules().insert();
-    ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto file = db.components().insertComponent(newFileDto(module, null).setPath(null));
-    IssueDto issue = db.issues().insert(rule, project, file, i -> i.setSeverity("BLOCKER")
-      // non-null fields
-      .setStatus("OPEN")
-      .setType(BUG)
-      .setManualSeverity(true)
-
-      // all the nullable fields
-      .setResolution(null)
-      .setMessage(null)
-      .setLine(null)
-      .setChecksum(null)
-      .setAssigneeUuid(null));
-    addPermissionTo(project);
-
-    ServerIssue serverIssue = call(project.getKey());
-
-    assertThat(serverIssue.getKey()).isEqualTo(issue.getKey());
-    assertThat(serverIssue.getRuleRepository()).isEqualTo(rule.getRepositoryKey());
-    assertThat(serverIssue.getRuleKey()).isEqualTo(rule.getRuleKey());
-    assertThat(serverIssue.getStatus()).isEqualTo("OPEN");
-    assertThat(serverIssue.getSeverity()).isEqualTo(Severity.BLOCKER);
-    assertThat(serverIssue.getType()).isEqualTo(BUG.name());
-    assertThat(serverIssue.getManualSeverity()).isTrue();
-
-    assertThat(serverIssue.hasPath()).isFalse();
-    assertThat(serverIssue.hasLine()).isFalse();
-    assertThat(serverIssue.hasMsg()).isFalse();
-    assertThat(serverIssue.hasResolution()).isFalse();
-    assertThat(serverIssue.hasChecksum()).isFalse();
-    assertThat(serverIssue.hasAssigneeLogin()).isFalse();
-  }
-
-  @Test
-  public void test_fields_with_non_null_values() throws Exception {
-    UserDto user = db.users().insertUser(u -> u.setLogin("simon").setName("Simon").setEmail("simon@email.com"));
-    RuleDto rule = db.rules().insert();
-    ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto file = db.components().insertComponent(newFileDto(module, null));
-    IssueDto issue = db.issues().insert(rule, project, file, i -> i.setSeverity("BLOCKER")
-      .setStatus("OPEN")
-      .setType(BUG)
-      .setManualSeverity(true)
-      .setResolution("FIXED")
-      .setMessage("the message")
-      .setLine(10)
-      .setChecksum("ABC")
-      .setAssigneeUuid(user.getUuid()));
-    addPermissionTo(project);
-
-    ServerIssue serverIssue = call(project.getKey());
-
-    assertThat(serverIssue.getKey()).isEqualTo(issue.getKey());
-    assertThat(serverIssue.getRuleRepository()).isEqualTo(rule.getRepositoryKey());
-    assertThat(serverIssue.getRuleKey()).isEqualTo(rule.getRuleKey());
-    assertThat(serverIssue.getStatus()).isEqualTo("OPEN");
-    assertThat(serverIssue.getSeverity()).isEqualTo(Severity.BLOCKER);
-    assertThat(serverIssue.getType()).isEqualTo(BUG.name());
-    assertThat(serverIssue.getManualSeverity()).isTrue();
-    assertThat(serverIssue.getPath()).isEqualTo(file.path());
-    assertThat(serverIssue.getLine()).isEqualTo(issue.getLine());
-    assertThat(serverIssue.getMsg()).isEqualTo(issue.getMessage());
-    assertThat(serverIssue.getResolution()).isEqualTo(issue.getResolution());
-    assertThat(serverIssue.getChecksum()).isEqualTo(issue.getChecksum());
-    assertThat(serverIssue.getAssigneeLogin()).isEqualTo(user.getLogin());
-  }
-
-  @Test
-  public void return_issues_of_project() {
-    RuleDto rule = db.rules().insert();
-    ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto file = db.components().insertComponent(newFileDto(module, null));
-    IssueDto issueOnFile = db.issues().insert(rule, project, file, i -> i.setKee("ON_FILE").setType(randomRuleTypeExceptHotspot()));
-    IssueDto issueOnModule = db.issues().insert(rule, project, module, i -> i.setKee("ON_MODULE").setType(randomRuleTypeExceptHotspot()));
-    IssueDto issueOnProject = db.issues().insert(rule, project, project, i -> i.setKee("ON_PROJECT").setType(randomRuleTypeExceptHotspot()));
-
-    addPermissionTo(project);
-    try (CloseableIterator<ServerIssue> result = callStream(project.getKey(), null)) {
-      assertThat(result)
-        .toIterable()
-        .extracting(ServerIssue::getKey)
-        .containsExactlyInAnyOrder(
-          issueOnFile.getKey(),
-          issueOnModule.getKey(),
-          issueOnProject.getKey());
-    }
-  }
-
-  @Test
-  public void does_not_return_issues_from_external_rules() {
-    RuleDto rule = db.rules().insert();
-    ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto file = db.components().insertComponent(newFileDto(module, null));
-    IssueDto issueOnProject = db.issues().insert(rule, project, project, i -> i.setKee("ON_PROJECT").setType(randomRuleTypeExceptHotspot()));
-    IssueDto issueOnModule = db.issues().insert(rule, project, module, i -> i.setKee("ON_MODULE").setType(randomRuleTypeExceptHotspot()));
-    IssueDto issueOnFile = db.issues().insert(rule, project, file, i -> i.setKee("ON_FILE").setType(randomRuleTypeExceptHotspot()));
-
-    RuleDto external = db.rules().insert(ruleDefinitionDto -> ruleDefinitionDto.setIsExternal(true));
-    IssueDto issueFromExteralruleOnFile = db.issues().insert(external, project, file, i -> i.setKee("ON_FILE_FROM_EXTERNAL").setType(randomRuleTypeExceptHotspot()));
-
-    RuleDto migrated = db.rules().insert();
-    db.executeUpdateSql("update rules set is_external=? where rules.uuid = ?", false, migrated.getUuid());
-    IssueDto issueFromMigratedRule = db.issues().insert(migrated, project, file, i -> i.setKee("MIGRATED").setType(randomRuleTypeExceptHotspot()));
-
-    addPermissionTo(project);
-    try (CloseableIterator<ServerIssue> result = callStream(project.getKey(), null)) {
-      assertThat(result)
-        .toIterable()
-        .extracting(ServerIssue::getKey)
-        .containsExactlyInAnyOrder(
-          issueOnFile.getKey(),
-          issueOnModule.getKey(),
-          issueOnProject.getKey(),
-          issueFromMigratedRule.getKey());
-    }
-  }
-
-  @Test
-  public void return_issues_of_file() {
-    RuleDto rule = db.rules().insert();
-    ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto file = db.components().insertComponent(newFileDto(module, null));
-    IssueDto issueOnFile = db.issues().insert(rule, project, file, i -> i.setType(randomRuleTypeExceptHotspot()));
-    IssueDto issueOnModule = db.issues().insert(rule, project, module, i -> i.setType(randomRuleTypeExceptHotspot()));
-    IssueDto issueOnProject = db.issues().insert(rule, project, project, i -> i.setType(randomRuleTypeExceptHotspot()));
-
-    addPermissionTo(project);
-    try (CloseableIterator<ServerIssue> result = callStream(file.getKey(), null)) {
-      assertThat(result)
-        .toIterable()
-        .extracting(ServerIssue::getKey)
-        .containsExactlyInAnyOrder(issueOnFile.getKey());
-    }
-  }
-
-  @Test
-  public void return_issues_by_project_and_branch() {
-    RuleDto rule = db.rules().insert();
-    ComponentDto project = db.components().insertPrivateProject();
-    addPermissionTo(project);
-    ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("my_branch"));
-    ComponentDto file = db.components().insertComponent(newFileDto(branch));
-    IssueDto issueOnFile = db.issues().insert(rule, branch, file, i -> i.setType(randomRuleTypeExceptHotspot()));
-    IssueDto issueOnBranch = db.issues().insert(rule, branch, branch, i -> i.setType(randomRuleTypeExceptHotspot()));
-
-    assertResult(project.getKey(), "my_branch", issueOnFile.getKey(), issueOnBranch.getKey());
-  }
-
-  @Test
-  public void fail_if_requested_component_is_a_directory() throws IOException {
-    ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto directory = db.components().insertComponent(newDirectory(project, "src/main/java"));
-    addPermissionTo(project);
-
-    assertThatThrownBy(() -> call(directory.getKey()))
-      .isInstanceOf(IllegalArgumentException.class)
-      .hasMessage("Component of scope 'DIR' is not allowed");
-  }
-
-  @Test
-  public void fail_if_user_does_not_have_permission_on_project() {
-    ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto file = db.components().insertComponent(newFileDto(project));
-
-    assertThatThrownBy(() -> tester.newRequest().setParam("key", file.getKey()).execute())
-      .isInstanceOf(ForbiddenException.class);
-  }
-
-  @Test
-  public void fail_if_component_does_not_exist() {
-    assertThatThrownBy(() -> tester.newRequest().setParam("key", "does_not_exist").execute())
-      .isInstanceOf(NotFoundException.class)
-      .hasMessage("Component key 'does_not_exist' not found");
-  }
-
-  @Test
-  public void fail_if_branch_does_not_exist() {
-    ComponentDto project = db.components().insertPrivateProject();
-    db.components().insertProjectBranch(project, b -> b.setKey("my_branch"));
-    addPermissionTo(project);
-
-    assertThatThrownBy(() -> {
-      tester.newRequest()
-        .setParam("key", project.getKey())
-        .setParam("branch", "does_not_exist")
-        .execute();
-    })
-      .isInstanceOf(NotFoundException.class)
-      .hasMessage(format("Component '%s' on branch 'does_not_exist' not found", project.getKey()));
-  }
-
-  private void addPermissionTo(ComponentDto project) {
-    userSessionRule.addProjectPermission(UserRole.USER, project);
-  }
-
-  private ServerIssue call(String componentKey) throws IOException {
-    TestResponse response = tester.newRequest().setParam("key", componentKey).execute();
-    return ServerIssue.parseDelimitedFrom(response.getInputStream());
-  }
-
-  private CloseableIterator<ServerIssue> callStream(String componentKey, @Nullable String branch) {
-    TestRequest request = tester.newRequest()
-      .setParam("key", componentKey);
-    if (branch != null) {
-      request.setParam("branch", branch);
-    }
-    return Protobuf.readStream(request.execute().getInputStream(), ServerIssue.parser());
-  }
-
-  private void assertResult(String componentKey, String branch, String... issueKeys) {
-    try (CloseableIterator<ServerIssue> result = callStream(componentKey, branch)) {
-      assertThat(result)
-        .toIterable()
-        .extracting(ServerIssue::getKey)
-        .containsExactlyInAnyOrder(issueKeys);
-    }
-  }
-
-  private RuleType randomRuleTypeExceptHotspot() {
-    return RULE_TYPES_EXCEPT_HOTSPOT[nextInt(RULE_TYPES_EXCEPT_HOTSPOT.length)];
-  }
-}
index fbf5f89e2fd5287a863bff9ddb05053df10e75c4..d68b8866fa103e8aa6672c58412ce945f7c0e553 100644 (file)
@@ -43,11 +43,8 @@ import static com.google.common.collect.ImmutableList.of;
 import static java.lang.String.format;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 import static org.sonar.core.permission.GlobalPermissions.SCAN_EXECUTION;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 
 public class ProjectDataLoaderTest {
   @Rule
@@ -131,35 +128,22 @@ public class ProjectDataLoaderTest {
   }
 
   @Test
-  public void fails_with_BRE_if_component_is_not_a_project() {
-    String[][] allScopesAndQualifierButProjectAndModule = {
-      {Scopes.PROJECT, "fakeModuleUuid"},
-      {Scopes.FILE, null},
-      {Scopes.DIRECTORY, null}
-    };
-
-    for (String[] scopeAndQualifier : allScopesAndQualifierButProjectAndModule) {
-      String scope = scopeAndQualifier[0];
-      String moduleUuid = scopeAndQualifier[1];
-      String key = "theKey_" + scope + "_" + moduleUuid;
-      String uuid = "uuid_" + uuidCounter++;
-      dbClient.componentDao().insert(dbSession, new ComponentDto()
-        .setUuid(uuid)
-        .setUuidPath(uuid + ".")
-        .setRootUuid(uuid)
-        .setBranchUuid(uuid)
-        .setScope(scope)
-        .setModuleUuid(moduleUuid)
-        .setKey(key));
-      dbSession.commit();
-
-      try {
-        underTest.load(ProjectDataQuery.create().setProjectKey(key));
-        fail("A NotFoundException should have been raised because component is not project");
-      } catch (BadRequestException e) {
-        assertThat(e).hasMessage("Key '" + key + "' belongs to a component which is not a Project");
-      }
-    }
+  public void fails_with_BRE_if_component_is_not_root() {
+    String uuid = "uuid";
+    String key = "key";
+    dbClient.componentDao().insert(dbSession, new ComponentDto()
+      .setUuid(uuid)
+      .setUuidPath(uuid + ".")
+      .setRootUuid(uuid)
+      .setBranchUuid("branchUuid")
+      .setScope(Scopes.PROJECT)
+      .setKey("key"));
+    dbSession.commit();
+
+    ProjectDataQuery query = ProjectDataQuery.create().setProjectKey(key);
+    assertThatThrownBy(() -> underTest.load(query))
+      .isInstanceOf(BadRequestException.class)
+      .hasMessage("Key '" + key + "' belongs to a component which is not a Project");
   }
 
   @Test
index fba7369f8d6f3e285a80ec773a2fd7577b59abc3..897975b253693816e6b49088e990c8681983d347 100644 (file)
@@ -68,7 +68,7 @@ import static org.mockito.Mockito.when;
 import static org.sonar.core.permission.GlobalPermissions.SCAN_EXECUTION;
 import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex;
 import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
+import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.permission.GlobalPermission.PROVISION_PROJECTS;
 import static org.sonar.db.permission.GlobalPermission.SCAN;
 
@@ -274,23 +274,23 @@ public class ReportSubmitterTest {
   }
 
   @Test
-  public void fail_if_project_key_already_exists_as_module() {
+  public void fail_if_project_key_already_exists_as_other_component() {
     ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
+    ComponentDto dir = db.components().insertComponent(newDirectory(project, "path"));
     userSession.logIn().addProjectPermission(SCAN_EXECUTION, project);
     mockSuccessfulPrepareSubmitCall();
 
-    String moduleDbKey = module.getKey();
-    String name = module.name();
+    String dirDbKey = dir.getKey();
+    String name = dir.name();
     Map<String, String> emptyMap = emptyMap();
     InputStream inputStream = IOUtils.toInputStream("{binary}", UTF_8);
-    assertThatThrownBy(() -> underTest.submit(moduleDbKey, name, emptyMap, inputStream))
+    assertThatThrownBy(() -> underTest.submit(dirDbKey, name, emptyMap, inputStream))
       .isInstanceOf(BadRequestException.class)
       .extracting(throwable -> ((BadRequestException) throwable).errors())
       .asList()
       .contains(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'.",
-        module.getKey(), project.getKey(), project.getKey(), module.getKey()));
+        dir.getKey(), project.getKey(), project.getKey(), dir.getKey()));
   }
 
   @Test
index 5901c9e6eecb3db12a9af355d95d20f159a581e1..0b6a97a2db4d6adfe0ad802c6a49204f93bae1f6 100644 (file)
@@ -34,7 +34,6 @@ import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 import static org.sonar.db.component.BranchType.PULL_REQUEST;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.server.component.ComponentFinder.ParamNames.ID_AND_KEY;
 
@@ -152,12 +151,10 @@ public class ComponentFinderTest {
   public void get_by_key_and_branch() {
     ComponentDto project = db.components().insertPublicProject();
     ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("my_branch"));
-    ComponentDto module = db.components().insertComponent(newModuleDto(branch));
-    ComponentDto directory = db.components().insertComponent(newDirectory(module, "scr"));
-    ComponentDto file = db.components().insertComponent(newFileDto(module));
+    ComponentDto directory = db.components().insertComponent(newDirectory(branch, "scr"));
+    ComponentDto file = db.components().insertComponent(newFileDto(branch));
 
     assertThat(underTest.getByKeyAndBranch(dbSession, project.getKey(), "my_branch").uuid()).isEqualTo(branch.uuid());
-    assertThat(underTest.getByKeyAndBranch(dbSession, module.getKey(), "my_branch").uuid()).isEqualTo(module.uuid());
     assertThat(underTest.getByKeyAndBranch(dbSession, file.getKey(), "my_branch").uuid()).isEqualTo(file.uuid());
     assertThat(underTest.getByKeyAndBranch(dbSession, directory.getKey(), "my_branch").uuid()).isEqualTo(directory.uuid());
   }
@@ -166,12 +163,10 @@ public class ComponentFinderTest {
   public void get_by_key_and_pull_request() {
     ComponentDto project = db.components().insertPublicProject();
     ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("pr-123").setBranchType(PULL_REQUEST).setMergeBranchUuid(project.uuid()));
-    ComponentDto module = db.components().insertComponent(newModuleDto(branch));
-    ComponentDto directory = db.components().insertComponent(newDirectory(module, "scr"));
-    ComponentDto file = db.components().insertComponent(newFileDto(module));
+    ComponentDto directory = db.components().insertComponent(newDirectory(branch, "scr"));
+    ComponentDto file = db.components().insertComponent(newFileDto(branch));
 
     assertThat(underTest.getByKeyAndOptionalBranchOrPullRequest(dbSession, project.getKey(), null, "pr-123").uuid()).isEqualTo(branch.uuid());
-    assertThat(underTest.getByKeyAndOptionalBranchOrPullRequest(dbSession, module.getKey(), null, "pr-123").uuid()).isEqualTo(module.uuid());
     assertThat(underTest.getByKeyAndOptionalBranchOrPullRequest(dbSession, file.getKey(), null, "pr-123").uuid()).isEqualTo(file.uuid());
     assertThat(underTest.getByKeyAndOptionalBranchOrPullRequest(dbSession, directory.getKey(), null, "pr-123").uuid()).isEqualTo(directory.uuid());
   }
@@ -183,7 +178,6 @@ public class ComponentFinderTest {
     ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("branch"));
     ComponentDto branchFile = db.components().insertComponent(newFileDto(branch));
 
-
     assertThat(underTest.getOptionalByKeyAndOptionalBranchOrPullRequest(dbSession, project.getKey(), null, null)).isPresent();
     assertThat(underTest.getOptionalByKeyAndOptionalBranchOrPullRequest(dbSession, project.getKey(), null, null).get().uuid())
       .isEqualTo(project.uuid());
index 9ad470537f78a2d15e9ea7f226c8b3f18376c41f..1689ca50fc8dfdfe3d231fad2bb6be7633437e3c 100644 (file)
@@ -97,8 +97,6 @@ public class ComponentUpdaterTest {
     assertThat(loaded.scope()).isEqualTo(Scopes.PROJECT);
     assertThat(loaded.uuid()).isNotNull();
     assertThat(loaded.branchUuid()).isEqualTo(loaded.uuid());
-    assertThat(loaded.moduleUuid()).isNull();
-    assertThat(loaded.moduleUuidPath()).isEqualTo("." + loaded.uuid() + ".");
     assertThat(loaded.isPrivate()).isEqualTo(project.isPrivate());
     assertThat(loaded.getCreatedAt()).isNotNull();
     assertThat(db.getDbClient().componentDao().selectByKey(db.getSession(), DEFAULT_PROJECT_KEY)).isPresent();
index 3469ac82e3ef7970a23cc2395d8d77d332dac5ba..f40389b65d79a4e8159bf3626c5cb37609a723fb 100644 (file)
@@ -46,7 +46,6 @@ import static org.sonar.api.web.UserRole.USER;
 import static org.sonar.db.component.BranchType.PULL_REQUEST;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.test.JsonAssert.assertJson;
 
 public class AppActionTest {
@@ -91,9 +90,8 @@ public class AppActionTest {
   @Test
   public void file_on_module() {
     ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto directory = db.components().insertComponent(newDirectory(module, "src"));
-    ComponentDto file = db.components().insertComponent(newFileDto(module, directory));
+    ComponentDto directory = db.components().insertComponent(newDirectory(project, "src"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, directory));
     userSession.logIn("john").addProjectPermission(USER, project);
 
     String result = ws.newRequest()
@@ -256,9 +254,8 @@ public class AppActionTest {
     userSession.logIn("john").addProjectPermission(USER, project);
     String branchName = randomAlphanumeric(248);
     ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey(branchName));
-    ComponentDto module = db.components().insertComponent(newModuleDto(branch));
-    ComponentDto directory = db.components().insertComponent(newDirectory(module, "src"));
-    ComponentDto file = db.components().insertComponent(newFileDto(module, directory));
+    ComponentDto directory = db.components().insertComponent(newDirectory(branch, "src"));
+    ComponentDto file = db.components().insertComponent(newFileDto(branch, directory));
     MetricDto coverage = db.measures().insertMetric(m -> m.setKey(COVERAGE_KEY));
     db.measures().insertLiveMeasure(file, coverage, m -> m.setValue(95.4d));
 
index 4f4a1f31965a4a29c0f2fc4788006ad97ae3589f..cfd68196a6fcc1fd348118064f717ab6c68d115c 100644 (file)
@@ -62,9 +62,8 @@ import static org.sonar.api.server.ws.WebService.Param.PAGE;
 import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE;
 import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
-import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newPortfolio;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.test.JsonAssert.assertJson;
 import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_QUALIFIERS;
 
@@ -165,11 +164,10 @@ public class SearchActionTest {
   @Test
   public void return_project_key() {
     ComponentDto project = ComponentTesting.newPublicProjectDto();
-    ComponentDto module = ComponentTesting.newModuleDto(project);
-    ComponentDto dir1 = newDirectory(module, "dir1").setKey("dir1");
-    ComponentDto dir2 = newDirectory(module, "dir2").setKey("dir2");
+    ComponentDto dir1 = newDirectory(project, "dir1").setKey("dir1");
+    ComponentDto dir2 = newDirectory(project, "dir2").setKey("dir2");
     ComponentDto dir3 = newDirectory(project, "dir3").setKey("dir3");
-    db.components().insertComponents(project, module, dir1, dir2, dir3);
+    db.components().insertComponents(project, dir1, dir2, dir3);
     setBrowsePermissionOnUserAndIndex(project);
 
     SearchWsResponse response = call(new SearchRequest().setQualifiers(asList(PROJECT, APP)));
@@ -210,10 +208,9 @@ public class SearchActionTest {
   public void test_json_example() {
     db.components().insertComponent(newPortfolio());
     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 directory = newDirectory(project, "path/to/directoy").setUuid("directory-uuid").setKey("directory-key").setName("Directory Name");
     ComponentDto view = newPortfolio();
-    db.components().insertComponents(project, module, directory, view);
+    db.components().insertComponents(project, directory, view);
     setBrowsePermissionOnUserAndIndex(project);
 
     String response = underTest.newRequest()
index 0d81ed26f25c2b42d1ee3a3209548aa32d2c962f..f1630f218af29894646d1c1f4734380d57ff3b0f 100644 (file)
@@ -53,7 +53,6 @@ import static org.sonar.db.component.BranchType.BRANCH;
 import static org.sonar.db.component.BranchType.PULL_REQUEST;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 import static org.sonar.test.JsonAssert.assertJson;
@@ -135,21 +134,19 @@ public class ShowActionTest {
   @Test
   public void show_with_ancestors_when_not_project() {
     ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto directory = db.components().insertComponent(newDirectory(module, "dir"));
-    ComponentDto file = db.components().insertComponent(newFileDto(directory));
+    ComponentDto directory = db.components().insertComponent(newDirectory(project, "dir"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, directory));
     userSession.addProjectPermission(USER, project);
 
     ShowWsResponse response = newRequest(file.getKey());
 
     assertThat(response.getComponent().getKey()).isEqualTo(file.getKey());
-    assertThat(response.getAncestorsList()).extracting(Component::getKey).containsOnly(directory.getKey(), module.getKey(), project.getKey());
+    assertThat(response.getAncestorsList()).extracting(Component::getKey).containsOnly(directory.getKey(), project.getKey());
   }
 
   @Test
   public void show_without_ancestors_when_project() {
     ComponentDto project = db.components().insertPrivateProject();
-    db.components().insertComponent(newModuleDto(project));
     userSession.addProjectPermission(USER, project);
 
     ShowWsResponse response = newRequest(project.getKey());
@@ -191,9 +188,8 @@ public class ShowActionTest {
   public void show_with_ancestors_and_analysis_date() {
     ComponentDto project = db.components().insertPrivateProject();
     db.components().insertSnapshot(newAnalysis(project).setCreatedAt(3_000_000_000L).setLast(true));
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto directory = db.components().insertComponent(newDirectory(module, "dir"));
-    ComponentDto file = db.components().insertComponent(newFileDto(directory));
+    ComponentDto directory = db.components().insertComponent(newDirectory(project, "dir"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, directory));
     userSession.addProjectPermission(USER, project);
 
     ShowWsResponse response = newRequest(file.getKey());
@@ -232,22 +228,11 @@ public class ShowActionTest {
     assertThat(result.getComponent().hasVisibility()).isTrue();
   }
 
-  @Test
-  public void should_not_return_visibility_for_module() {
-    ComponentDto privateProject = db.components().insertPrivateProject();
-    userSession.addProjectPermission(USER, privateProject);
-    ComponentDto module = db.components().insertComponent(newModuleDto(privateProject));
-
-    ShowWsResponse result = newRequest(module.getKey());
-    assertThat(result.getComponent().hasVisibility()).isFalse();
-  }
-
   @Test
   public void display_version() {
     ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto directory = db.components().insertComponent(newDirectory(module, "dir"));
-    ComponentDto file = db.components().insertComponent(newFileDto(directory));
+    ComponentDto directory = db.components().insertComponent(newDirectory(project, "dir"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, directory));
     db.components().insertSnapshot(project, s -> s.setProjectVersion("1.1"));
     userSession.addProjectPermission(USER, project);
 
@@ -265,9 +250,8 @@ public class ShowActionTest {
     userSession.addProjectPermission(UserRole.USER, project);
     String branchKey = "my_branch";
     ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey(branchKey));
-    ComponentDto module = db.components().insertComponent(newModuleDto(branch));
-    ComponentDto directory = db.components().insertComponent(newDirectory(module, "dir"));
-    ComponentDto file = db.components().insertComponent(newFileDto(directory));
+    ComponentDto directory = db.components().insertComponent(newDirectory(branch, "dir"));
+    ComponentDto file = db.components().insertComponent(newFileDto(branch, directory));
     db.components().insertSnapshot(branch, s -> s.setProjectVersion("1.1"));
 
     ShowWsResponse response = ws.newRequest()
@@ -281,7 +265,6 @@ public class ShowActionTest {
     assertThat(response.getAncestorsList()).extracting(Component::getKey, Component::getBranch, Component::getVersion)
       .containsExactlyInAnyOrder(
         tuple(directory.getKey(), branchKey, "1.1"),
-        tuple(module.getKey(), branchKey, "1.1"),
         tuple(branch.getKey(), branchKey, "1.1"));
   }
 
@@ -306,9 +289,8 @@ public class ShowActionTest {
     userSession.addProjectPermission(UserRole.USER, project);
     String pullRequest = "pr-1234";
     ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey(pullRequest).setBranchType(PULL_REQUEST));
-    ComponentDto module = db.components().insertComponent(newModuleDto(branch));
-    ComponentDto directory = db.components().insertComponent(newDirectory(module, "dir"));
-    ComponentDto file = db.components().insertComponent(newFileDto(directory));
+    ComponentDto directory = db.components().insertComponent(newDirectory(branch, "dir"));
+    ComponentDto file = db.components().insertComponent(newFileDto(branch, directory));
     db.components().insertSnapshot(branch, s -> s.setProjectVersion("1.1"));
 
     ShowWsResponse response = ws.newRequest()
@@ -322,7 +304,6 @@ public class ShowActionTest {
     assertThat(response.getAncestorsList()).extracting(Component::getKey, Component::getPullRequest, Component::getVersion)
       .containsExactlyInAnyOrder(
         tuple(directory.getKey(), pullRequest, "1.1"),
-        tuple(module.getKey(), pullRequest, "1.1"),
         tuple(branch.getKey(), pullRequest, "1.1"));
   }
 
@@ -336,9 +317,8 @@ public class ShowActionTest {
     ComponentDto project1 = db.components().insertPrivateProject();
     ComponentDto branch1 = db.components().insertProjectBranch(project1, b -> b.setBranchType(PULL_REQUEST).setKey(pullRequestKey1)
       .setNeedIssueSync(true));
-    ComponentDto module = db.components().insertComponent(newModuleDto(branch1));
-    ComponentDto directory = db.components().insertComponent(newDirectory(module, "dir"));
-    ComponentDto file = db.components().insertComponent(newFileDto(directory));
+    ComponentDto directory = db.components().insertComponent(newDirectory(branch1, "dir"));
+    ComponentDto file = db.components().insertComponent(newFileDto(branch1, directory));
 
     ComponentDto project2 = db.components().insertPrivateProject();
     String branchName2 = randomAlphanumeric(248);
@@ -349,9 +329,8 @@ public class ShowActionTest {
     ComponentDto project3 = db.components().insertPrivateProject();
     String pullRequestKey4 = randomAlphanumeric(100);
     ComponentDto branch4 = db.components().insertProjectBranch(project3, b -> b.setBranchType(PULL_REQUEST).setKey(pullRequestKey4).setNeedIssueSync(false));
-    ComponentDto moduleOfBranch4 = db.components().insertComponent(newModuleDto(branch4));
-    ComponentDto directoryOfBranch4 = db.components().insertComponent(newDirectory(moduleOfBranch4, "dir"));
-    ComponentDto fileOfBranch4 = db.components().insertComponent(newFileDto(directoryOfBranch4));
+    ComponentDto directoryOfBranch4 = db.components().insertComponent(newDirectory(branch4, "dir"));
+    ComponentDto fileOfBranch4 = db.components().insertComponent(newFileDto(branch4, directoryOfBranch4));
     String branchName5 = randomAlphanumeric(248);
     ComponentDto branch5 = db.components().insertProjectBranch(project3, b -> b.setBranchType(BRANCH).setNeedIssueSync(false).setKey(branchName5));
 
@@ -366,7 +345,6 @@ public class ShowActionTest {
     // if branch need sync it is propagated to other components
     assertNeedIssueSyncEqual(null, null, project1, true);
     assertNeedIssueSyncEqual(pullRequestKey1, null, branch1, true);
-    assertNeedIssueSyncEqual(pullRequestKey1, null, module, true);
     assertNeedIssueSyncEqual(pullRequestKey1, null, directory, true);
     assertNeedIssueSyncEqual(pullRequestKey1, null, file, true);
 
@@ -377,7 +355,6 @@ public class ShowActionTest {
     // if all branches are synced, need issue sync on project is is set to false
     assertNeedIssueSyncEqual(null, null, project3, false);
     assertNeedIssueSyncEqual(pullRequestKey4, null, branch4, false);
-    assertNeedIssueSyncEqual(pullRequestKey4, null, moduleOfBranch4, false);
     assertNeedIssueSyncEqual(pullRequestKey4, null, directoryOfBranch4, false);
     assertNeedIssueSyncEqual(pullRequestKey4, null, fileOfBranch4, false);
     assertNeedIssueSyncEqual(null, branchName5, branch5, false);
@@ -452,11 +429,11 @@ public class ShowActionTest {
 
   private void insertJsonExampleComponentsAndSnapshots() {
     ComponentDto project = db.components().insertPrivateProject(c -> c.setUuid("AVIF98jgA3Ax6PH2efOW")
-      .setBranchUuid("AVIF98jgA3Ax6PH2efOW")
-      .setKey("com.sonarsource:java-markdown")
-      .setName("Java Markdown")
-      .setDescription("Java Markdown Project")
-      .setQualifier(Qualifiers.PROJECT),
+        .setBranchUuid("AVIF98jgA3Ax6PH2efOW")
+        .setKey("com.sonarsource:java-markdown")
+        .setName("Java Markdown")
+        .setDescription("Java Markdown Project")
+        .setQualifier(Qualifiers.PROJECT),
       p -> p.setTagsString("language, plugin"));
     userSession.addProjectPermission(USER, project);
     db.components().insertSnapshot(project, snapshot -> snapshot
index ae202fee74c6286412ac21fae533e77495045d24..5dd69b3e8265e6c5a32bcd182581b50c6cc9b7b6 100644 (file)
  */
 package org.sonar.server.component.ws;
 
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import javax.annotation.Nullable;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -58,13 +62,12 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.sonar.api.resources.Qualifiers.APP;
 import static org.sonar.api.resources.Qualifiers.FILE;
-import static org.sonar.api.resources.Qualifiers.MODULE;
 import static org.sonar.api.resources.Qualifiers.PROJECT;
 import static org.sonar.api.resources.Qualifiers.SUBVIEW;
 import static org.sonar.api.resources.Qualifiers.UNIT_TEST_FILE;
 import static org.sonar.api.resources.Qualifiers.VIEW;
 import static org.sonar.api.web.UserRole.USER;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
+import static org.sonar.db.component.ComponentTesting.newFileDto;
 import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newPublicProjectDto;
 import static org.sonar.server.component.ws.SuggestionsAction.PARAM_MORE;
@@ -72,10 +75,6 @@ import static org.sonar.server.component.ws.SuggestionsAction.PARAM_QUERY;
 import static org.sonar.server.component.ws.SuggestionsAction.PARAM_RECENTLY_BROWSED;
 import static org.sonar.server.component.ws.SuggestionsAction.SHORT_INPUT_WARNING;
 import static org.sonar.test.JsonAssert.assertJson;
-import javax.annotation.Nullable;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 public class SuggestionsActionTest {
   private static final String[] SUGGESTION_QUALIFIERS = Stream.of(SuggestionCategory.values())
@@ -115,6 +114,7 @@ public class SuggestionsActionTest {
       PARAM_QUERY,
       PARAM_RECENTLY_BROWSED);
     assertThat(action.changelog()).extracting(Change::getVersion, Change::getDescription).containsExactlyInAnyOrder(
+      tuple("10.0", "The use of 'BRC' as value for parameter 'more' is no longer supported"),
       tuple("8.4", "The use of 'DIR', 'FIL','UTS' as values for parameter 'more' is no longer supported"),
       tuple("7.6", "The use of 'BRC' as value for parameter 'more' is deprecated"));
 
@@ -347,7 +347,7 @@ public class SuggestionsActionTest {
 
   @Test
   public void suggestions_should_filter_allowed_qualifiers() {
-    resourceTypes.setAllQualifiers(PROJECT, MODULE, FILE, UNIT_TEST_FILE);
+    resourceTypes.setAllQualifiers(PROJECT, FILE, UNIT_TEST_FILE);
     ComponentDto project = db.components().insertComponent(newPrivateProjectDto());
     componentIndexer.indexOnAnalysis(project.branchUuid());
     userSessionRule.addProjectPermission(USER, project);
@@ -359,7 +359,7 @@ public class SuggestionsActionTest {
 
     assertThat(response.getResultsList())
       .extracting(Category::getQ)
-      .containsExactlyInAnyOrder(PROJECT).doesNotContain(MODULE, FILE, UNIT_TEST_FILE);
+      .containsExactlyInAnyOrder(PROJECT).doesNotContain(FILE, UNIT_TEST_FILE);
   }
 
   @Test
@@ -470,39 +470,18 @@ public class SuggestionsActionTest {
       .containsExactlyInAnyOrder(tuple(project1.getKey(), project1.name()));
   }
 
-  @Test
-  public void should_not_return_modules() {
-    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.branchUuid());
-    authorizationIndexerTester.allowOnlyAnyone(project);
-
-    SuggestionsWsResponse response = ws.newRequest()
-      .setMethod("POST")
-      .setParam(PARAM_QUERY, "Module")
-      .executeProtobuf(SuggestionsWsResponse.class);
-
-    assertThat(response.getResultsList())
-      .flatExtracting(Category::getItemsList)
-      .extracting(Suggestion::getKey)
-      .containsOnly(project.getKey());
-  }
-
   @Test
   public void should_mark_recently_browsed_items() {
-    ComponentDto project = db.components().insertComponent(newPrivateProjectDto().setName("ProjectModule"));
-    ComponentDto module1 = newModuleDto(project).setName("Module1");
-    db.components().insertComponent(module1);
-    ComponentDto module2 = newModuleDto(project).setName("Module2");
-    db.components().insertComponent(module2);
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto().setName("ProjectTest"));
+    ComponentDto file1 = newFileDto(project).setName("File1");
+    ComponentDto file2 = newFileDto(project).setName("File2");
     componentIndexer.indexOnAnalysis(project.branchUuid());
     authorizationIndexerTester.allowOnlyAnyone(project);
 
     SuggestionsWsResponse response = ws.newRequest()
       .setMethod("POST")
-      .setParam(PARAM_QUERY, "Module")
-      .setParam(PARAM_RECENTLY_BROWSED, Stream.of(module1.getKey(), project.getKey()).collect(joining(",")))
+      .setParam(PARAM_QUERY, "Test")
+      .setParam(PARAM_RECENTLY_BROWSED, Stream.of(file1.getKey(), project.getKey()).collect(joining(",")))
       .executeProtobuf(SuggestionsWsResponse.class);
 
     assertThat(response.getResultsList())
@@ -556,9 +535,9 @@ public class SuggestionsActionTest {
     ComponentDto view = db.components().insertPublicPortfolio(v -> v.setName(query));
     ComponentDto subView = db.components().insertComponent(ComponentTesting.newSubPortfolio(view).setName(query));
     ComponentDto project = db.components().insertPrivateProject(p -> p.setName(query));
-    ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project).setName(query));
-    ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(module).setName(query));
-    ComponentDto test = db.components().insertComponent(ComponentTesting.newFileDto(module).setName(query).setQualifier(UNIT_TEST_FILE));
+    ComponentDto dir = db.components().insertComponent(ComponentTesting.newDirectory(project, "path").setName(query));
+    ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project, dir).setName(query));
+    ComponentDto test = db.components().insertComponent(ComponentTesting.newFileDto(project, dir).setName(query).setQualifier(UNIT_TEST_FILE));
     componentIndexer.indexAll();
     authorizationIndexerTester.allowOnlyAnyone(project);
     authorizationIndexerTester.allowOnlyAnyone(view);
index b5af8763ca6cb73b6122cd6e1d02bae1a9f42334..0518969fcd184fde63a1348e808e5dfcceb171fc 100644 (file)
@@ -65,7 +65,6 @@ import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 import static org.sonar.db.component.BranchType.PULL_REQUEST;
 import static org.sonar.db.component.ComponentTesting.newChildComponent;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newProjectBranchCopy;
 import static org.sonar.db.component.ComponentTesting.newProjectCopy;
@@ -132,21 +131,21 @@ public class TreeActionTest {
   public void return_children() {
     ComponentDto project = newPrivateProjectDto("project-uuid");
     db.components().insertProjectAndSnapshot(project);
-    ComponentDto module = newModuleDto("module-uuid-1", project);
-    db.components().insertComponent(module);
+    ComponentDto dir = newDirectory(project, "dir");
+    db.components().insertComponent(dir);
     db.components().insertComponent(newFileDto(project, 1));
     for (int i = 2; i <= 9; i++) {
-      db.components().insertComponent(newFileDto(module, i));
+      db.components().insertComponent(newFileDto(dir, i));
     }
-    ComponentDto directory = newDirectory(module, "directory-path-1");
+    ComponentDto directory = newDirectory(dir, "directory-path-1");
     db.components().insertComponent(directory);
-    db.components().insertComponent(newFileDto(module, directory, 10));
+    db.components().insertComponent(newFileDto(project, directory, 10));
     db.commit();
     logInWithBrowsePermission(project);
 
     TreeWsResponse response = ws.newRequest()
       .setParam(PARAM_STRATEGY, "children")
-      .setParam(PARAM_COMPONENT, module.getKey())
+      .setParam(PARAM_COMPONENT, dir.getKey())
       .setParam(Param.PAGE, "2")
       .setParam(Param.PAGE_SIZE, "3")
       .setParam(Param.TEXT_QUERY, "file-name")
@@ -162,7 +161,7 @@ public class TreeActionTest {
   public void return_descendants() {
     ComponentDto project = newPrivateProjectDto("project-uuid");
     db.components().insertProjectAndSnapshot(project);
-    ComponentDto module = newModuleDto("module-uuid-1", project);
+    ComponentDto module = newDirectory(project, "path");
     db.components().insertComponent(module);
     db.components().insertComponent(newFileDto(project, 10));
     for (int i = 2; i <= 9; i++) {
@@ -194,7 +193,6 @@ public class TreeActionTest {
     db.components().insertProjectAndSnapshot(project);
     db.components().insertComponent(newFileDto(project, 1));
     db.components().insertComponent(newFileDto(project, 2));
-    db.components().insertComponent(newModuleDto("module-uuid-1", project));
     db.commit();
     logInWithBrowsePermission(project);
 
@@ -210,13 +208,11 @@ public class TreeActionTest {
   public void return_leaves() {
     ComponentDto project = newPrivateProjectDto("project-uuid");
     db.components().insertProjectAndSnapshot(project);
-    ComponentDto module = newModuleDto("module-uuid-1", project);
-    db.components().insertComponent(module);
     db.components().insertComponent(newFileDto(project, 1));
-    db.components().insertComponent(newFileDto(module, 2));
+    db.components().insertComponent(newFileDto(project, 2));
     ComponentDto directory = newDirectory(project, "directory-path-1");
     db.components().insertComponent(directory);
-    db.components().insertComponent(newFileDto(module, directory, 3));
+    db.components().insertComponent(newFileDto(project, directory, 3));
     db.commit();
     logInWithBrowsePermission(project);
 
@@ -236,8 +232,6 @@ public class TreeActionTest {
     db.components().insertProjectAndSnapshot(project);
     db.components().insertComponent(newFileDto(project, 1));
     db.components().insertComponent(newFileDto(project, 2));
-    ComponentDto module = newModuleDto("module-uuid-1", project);
-    db.components().insertComponent(module);
     db.components().insertComponent(newDirectory(project, "path/directory/", "directory-uuid-1"));
     db.commit();
     logInWithBrowsePermission(project);
@@ -247,7 +241,7 @@ public class TreeActionTest {
       .setParam(Param.SORT, "qualifier, name")
       .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");
+    assertThat(response.getComponentsList()).extracting("key").containsExactly("KEY_project-uuid:directory-uuid-1", "file-key-1", "file-key-2");
   }
 
   @Test
@@ -360,17 +354,16 @@ public class TreeActionTest {
     userSession.addProjectPermission(UserRole.USER, project);
     String branchKey = "my_branch";
     ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey(branchKey));
-    ComponentDto module = db.components().insertComponent(newModuleDto(branch));
-    ComponentDto directory = db.components().insertComponent(newDirectory(module, "dir"));
+    ComponentDto directory = db.components().insertComponent(newDirectory(branch, "dir"));
     ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(directory));
 
     TreeWsResponse response = ws.newRequest()
-      .setParam(PARAM_COMPONENT, module.getKey())
+      .setParam(PARAM_COMPONENT, branch.getKey())
       .setParam(PARAM_BRANCH, branchKey)
       .executeProtobuf(TreeWsResponse.class);
 
     assertThat(response.getBaseComponent()).extracting(Component::getKey, Component::getBranch)
-      .containsExactlyInAnyOrder(module.getKey(), branchKey);
+      .containsExactlyInAnyOrder(branch.getKey(), branchKey);
     assertThat(response.getComponentsList()).extracting(Component::getKey, Component::getBranch)
       .containsExactlyInAnyOrder(
         tuple(directory.getKey(), branchKey),
@@ -398,20 +391,18 @@ public class TreeActionTest {
     userSession.addProjectPermission(UserRole.USER, project);
     String pullRequestId = "pr-123";
     ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey(pullRequestId).setBranchType(PULL_REQUEST));
-    ComponentDto module = db.components().insertComponent(newModuleDto(branch));
-    ComponentDto directory = db.components().insertComponent(newDirectory(module, "dir"));
+    ComponentDto directory = db.components().insertComponent(newDirectory(branch, "dir"));
     ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(directory));
 
     TreeWsResponse response = ws.newRequest()
-      .setParam(PARAM_COMPONENT, module.getKey())
+      .setParam(PARAM_COMPONENT, directory.getKey())
       .setParam(PARAM_PULL_REQUEST, pullRequestId)
       .executeProtobuf(TreeWsResponse.class);
 
     assertThat(response.getBaseComponent()).extracting(Component::getKey, Component::getPullRequest)
-      .containsExactlyInAnyOrder(module.getKey(), pullRequestId);
+      .containsExactlyInAnyOrder(directory.getKey(), pullRequestId);
     assertThat(response.getComponentsList()).extracting(Component::getKey, Component::getPullRequest)
       .containsExactlyInAnyOrder(
-        tuple(directory.getKey(), pullRequestId),
         tuple(file.getKey(), pullRequestId));
   }
 
@@ -535,10 +526,10 @@ public class TreeActionTest {
 
   private ComponentDto initJsonExampleComponents() throws IOException {
     ComponentDto project = db.components().insertPrivateProject(c -> c.setUuid("MY_PROJECT_ID")
-      .setDescription("MY_PROJECT_DESCRIPTION")
-      .setKey("MY_PROJECT_KEY")
-      .setName("Project Name")
-      .setBranchUuid("MY_PROJECT_ID"),
+        .setDescription("MY_PROJECT_DESCRIPTION")
+        .setKey("MY_PROJECT_KEY")
+        .setName("Project Name")
+        .setBranchUuid("MY_PROJECT_ID"),
       p -> p.setTagsString("abc,def"));
     db.components().insertSnapshot(project);
 
index f8829104c2e2db4bbc4e5b55224af2ef628d670c..59ae4de4511293eb3fc94d72ebcf887112232684 100644 (file)
@@ -34,8 +34,8 @@ import org.sonar.test.JsonAssert;
 import static com.google.common.collect.Lists.newArrayList;
 import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
 import static org.sonar.db.component.BranchType.PULL_REQUEST;
+import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 
 public class ShowResponseBuilderTest {
 
@@ -47,9 +47,9 @@ public class ShowResponseBuilderTest {
   @Test
   public void write_duplications() {
     ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto file1 = db.components().insertComponent(newFileDto(module));
-    ComponentDto file2 = db.components().insertComponent(newFileDto(module));
+    ComponentDto dir = db.components().insertComponent(newDirectory(project, "path"));
+    ComponentDto file1 = db.components().insertComponent(newFileDto(project, dir));
+    ComponentDto file2 = db.components().insertComponent(newFileDto(project, dir));
     List<DuplicationsParser.Block> blocks = newArrayList();
     blocks.add(new DuplicationsParser.Block(newArrayList(
       Duplication.newComponent(file1, 57, 12),
index 06126444c9e393be7807ce2d2e65a0b1086b678e..33fbf99c5914a588e987000c1046629c50d618b6 100644 (file)
@@ -46,8 +46,8 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.sonar.api.rule.RuleStatus.REMOVED;
 import static org.sonar.core.issue.IssueChangeContext.issueChangeContextByUserBuilder;
+import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.issue.IssueTesting.newIssue;
 
 public class WebIssueStorageTest {
@@ -86,8 +86,8 @@ public class WebIssueStorageTest {
   public void insert_new_issues() {
     RuleDto rule = db.rules().insert();
     ComponentDto project = db.components().insertPublicProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto file = db.components().insertComponent(newFileDto(module));
+    ComponentDto dir = db.components().insertComponent(newDirectory(project, "path"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, dir));
 
     String issueKey = "ABCDE";
     DefaultIssueComment comment = DefaultIssueComment.create(issueKey, "user_uuid", "the comment");
@@ -135,8 +135,8 @@ public class WebIssueStorageTest {
   public void update_issues() {
     RuleDto rule = db.rules().insert();
     ComponentDto project = db.components().insertPublicProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto file = db.components().insertComponent(newFileDto(module));
+    ComponentDto dir = db.components().insertComponent(newDirectory(project, "path"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, dir));
 
     Date date = DateUtils.parseDateTime("2013-05-18T12:00:00+0000");
     DefaultIssue issue = new DefaultIssue()
@@ -218,8 +218,8 @@ public class WebIssueStorageTest {
   public void rule_uuid_is_set_on_updated_issue() {
     RuleDto rule = db.rules().insert();
     ComponentDto project = db.components().insertPublicProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto file = db.components().insertComponent(newFileDto(module));
+    ComponentDto dir = db.components().insertComponent(newDirectory(project, "path"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, dir));
     DefaultIssue issue = newIssue(rule, project, file).toDefaultIssue();
 
     Collection<IssueDto> results = underTest.save(db.getSession(), singletonList(issue));
@@ -232,8 +232,8 @@ public class WebIssueStorageTest {
   public void rule_uuid_is_not_set_on_updated_issue_when_rule_is_removed() {
     RuleDto rule = db.rules().insert(r -> r.setStatus(REMOVED));
     ComponentDto project = db.components().insertPublicProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto file = db.components().insertComponent(newFileDto(module));
+    ComponentDto dir = db.components().insertComponent(newDirectory(project, "path"));
+    ComponentDto file = db.components().insertComponent(newFileDto(project, dir));
     DefaultIssue issue = newIssue(rule, project, file).toDefaultIssue();
 
     Collection<IssueDto> results = underTest.save(db.getSession(), singletonList(issue));
index 551210a14aa9f3b2234c7d23b0d81489c4cc5df6..53927524835629b4ea22280dc100e7872c38ec49 100644 (file)
@@ -71,7 +71,6 @@ import static org.sonar.db.component.BranchType.BRANCH;
 import static org.sonar.db.component.BranchType.PULL_REQUEST;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.component.ComponentTesting.newProjectCopy;
 import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_BRANCH;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_KEYS;
@@ -148,25 +147,6 @@ public class SearchActionComponentsTest {
       .containsExactlyInAnyOrder(tuple(project.getKey(), true), tuple(file.getKey(), true), tuple(project2.getKey(), true), tuple(file2.getKey(), true));
   }
 
-  @Test
-  public void search_by_module() {
-    ComponentDto project = db.components().insertPublicProject();
-    ComponentDto module1 = db.components().insertComponent(newModuleDto(project));
-    ComponentDto file1 = db.components().insertComponent(newFileDto(module1));
-    ComponentDto module2 = db.components().insertComponent(newModuleDto(project));
-    ComponentDto file2 = db.components().insertComponent(newFileDto(module2));
-    RuleDto rule = db.rules().insertIssueRule();
-    IssueDto issue1 = db.issues().insertIssue(rule, project, file1);
-    IssueDto issue2 = db.issues().insertIssue(rule, project, file2);
-    allowAnyoneOnProjects(project);
-    indexIssues();
-
-    assertThat(ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, module1.getKey())
-      .executeProtobuf(SearchWsResponse.class).getIssuesList()).extracting(Issue::getKey)
-        .containsExactlyInAnyOrder(issue1.getKey());
-  }
-
   @Test
   public void search_since_leak_period_on_project() {
     ComponentDto project = db.components().insertPublicProject(p -> p.setKey("PK1"));
@@ -189,30 +169,6 @@ public class SearchActionComponentsTest {
       .assertJson(this.getClass(), "search_since_leak_period.json");
   }
 
-  @Test
-  public void search_since_leak_period_on_file_in_module_project() {
-    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").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)
-      .setIssueCreationDate(parseDateTime("2015-09-04T00:00:00+0100"))
-      .setIssueUpdateDate(parseDateTime("2015-10-04T00:00:00+0100")));
-    IssueDto issueBeforeLeak = db.issues().insertIssue(rule, project, file, i -> i.setKee(UUID_EXAMPLE_02)
-      .setIssueCreationDate(parseDateTime("2014-09-04T00:00:00+0100"))
-      .setIssueUpdateDate(parseDateTime("2015-10-04T00:00:00+0100")));
-    allowAnyoneOnProjects(project);
-    indexIssues();
-
-    ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, project.getKey())
-      .setParam(PARAM_FILES, file.path())
-      .setParam(PARAM_SINCE_LEAK_PERIOD, "true")
-      .execute()
-      .assertJson(this.getClass(), "search_since_leak_period.json");
-  }
-
   @Test
   public void search_by_file_uuid() {
     ComponentDto project = db.components().insertPublicProject(p -> p.setKey("PK1"));
index d2048ed8e04cbb1af554e4ec5144ab1d3caa7eab..2993aca6bf5806788d4f25f1d8fcda1e3918e906 100644 (file)
@@ -61,7 +61,6 @@ import static org.assertj.core.groups.Tuple.tuple;
 import static org.sonar.api.server.ws.WebService.Param.FACETS;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.server.tester.UserSessionRule.standalone;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_KEYS;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_FILES;
@@ -94,8 +93,7 @@ public class SearchActionFacetsTest {
   @Test
   public void display_all_facets() {
     ComponentDto project = db.components().insertPublicProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto file = db.components().insertComponent(newFileDto(module));
+    ComponentDto file = db.components().insertComponent(newFileDto(project));
     RuleDto rule = db.rules().insertIssueRule();
     UserDto user = db.users().insertUser();
     db.issues().insertIssue(rule, project, file, i -> i
@@ -262,9 +260,8 @@ public class SearchActionFacetsTest {
     IntStream.rangeClosed(1, 110)
       .forEach(index -> {
         UserDto user = db.users().insertUser();
-        ComponentDto module = db.components().insertComponent(newModuleDto(project));
-        ComponentDto directory = db.components().insertComponent(newDirectory(module, "dir" + index));
-        ComponentDto file = db.components().insertComponent(newFileDto(directory));
+        ComponentDto directory = db.components().insertComponent(newDirectory(project, "dir" + index));
+        ComponentDto file = db.components().insertComponent(newFileDto(project, directory));
 
         RuleDto rule = db.rules().insertIssueRule();
         db.issues().insertIssue(rule, project, file, i -> i.setAssigneeUuid(user.getUuid())
@@ -273,12 +270,11 @@ public class SearchActionFacetsTest {
       });
 
     // insert some hotspots which should be filtered by default
-    IntStream.rangeClosed(1, 30)
+    IntStream.rangeClosed(201, 230)
       .forEach(index -> {
         UserDto user = db.users().insertUser();
-        ComponentDto module = db.components().insertComponent(newModuleDto(project));
-        ComponentDto directory = db.components().insertComponent(newDirectory(module, "dir" + index));
-        ComponentDto file = db.components().insertComponent(newFileDto(directory));
+        ComponentDto directory = db.components().insertComponent(newDirectory(project, "dir" + index));
+        ComponentDto file = db.components().insertComponent(newFileDto(project, directory));
 
         db.issues().insertHotspot(project, file, i -> i.setAssigneeUuid(user.getUuid())
           .setStatus(random.nextBoolean() ? Issue.STATUS_TO_REVIEW : Issue.STATUS_REVIEWED));
@@ -330,11 +326,9 @@ public class SearchActionFacetsTest {
   @Test
   public void display_zero_valued_facets_for_selected_items_having_no_issue() {
     ComponentDto project1 = db.components().insertPublicProject();
-    ComponentDto module1 = db.components().insertComponent(newModuleDto(project1));
-    ComponentDto module2 = db.components().insertComponent(newModuleDto(project1));
     ComponentDto project2 = db.components().insertPublicProject();
-    ComponentDto file1 = db.components().insertComponent(newFileDto(module1));
-    ComponentDto file2 = db.components().insertComponent(newFileDto(module1));
+    ComponentDto file1 = db.components().insertComponent(newFileDto(project1));
+    ComponentDto file2 = db.components().insertComponent(newFileDto(project1));
     RuleDto rule1 = db.rules().insertIssueRule();
     RuleDto rule2 = db.rules().insertIssueRule();
     UserDto user1 = db.users().insertUser();
index a89d1923f11c724875a2d6a1e63e1d2fab152ca5..637df388b5a1dfcb3c4e08b1845410fff69c6afb 100644 (file)
@@ -596,21 +596,6 @@ public class SearchActionTest {
       .assertJson(this.getClass(), "apply_paging_with_one_component.json");
   }
 
-  @Test
-  public void components_contains_sub_projects() {
-    ComponentDto project = db.components().insertPublicProject("PROJECT_ID", c -> c.setKey("PROJECT_KEY").setKey("ProjectHavingModule"));
-    indexPermissions();
-    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();
-    indexIssues();
-
-    ws.newRequest().setParam(PARAM_ADDITIONAL_FIELDS, "_all").execute()
-      .assertJson(this.getClass(), "components_contains_sub_projects.json");
-  }
-
   @Test
   public void filter_by_assigned_to_me() {
     UserDto john = db.users().insertUser(u -> u.setLogin("john").setName("John").setEmail("john@email.com"));
index 081fdd384183bd0ede29aa0271a1666df59ee87a..c2a229ea1e7be31ad1a1e28a8e3e21501be42520 100644 (file)
@@ -52,7 +52,6 @@ import static org.sonar.api.measures.Metric.ValueType.FLOAT;
 import static org.sonar.api.measures.Metric.ValueType.INT;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.component.ComponentTesting.newSubPortfolio;
 import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_KEYS;
 import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_PROJECT_KEYS;
@@ -336,18 +335,6 @@ public class SearchActionTest {
     call(keys, singletonList(metric.getKey()));
   }
 
-  @Test
-  public void fail_if_module() {
-    ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    userSession.addProjectPermission(UserRole.USER, project);
-    MetricDto metric = db.measures().insertMetric();
-
-    assertThatThrownBy(() -> call(singletonList(module.getKey()), singletonList(metric.getKey())))
-      .isInstanceOf(IllegalArgumentException.class)
-      .hasMessage("Only component of qualifiers [TRK, APP, VW, SVW] are allowed");
-  }
-
   @Test
   public void fail_if_directory() {
     ComponentDto project = db.components().insertPrivateProject();
index 6cba227e593396d488bfef8d7422b9c8cdd6be0c..d7fea01e926aad0c16c0f7a9694a175fa06cabb8 100644 (file)
@@ -47,7 +47,6 @@ import static org.sonar.api.web.UserRole.USER;
 import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newSubPortfolio;
 import static org.sonar.db.permission.GlobalPermission.ADMINISTER;
@@ -186,14 +185,6 @@ public class AddGroupActionTest extends BasePermissionWsTest<AddGroupAction> {
       .isInstanceOf(NotFoundException.class);
   }
 
-  @Test
-  public void fail_when_component_is_a_module() {
-    ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-
-    failIfComponentIsNotAProjectOrView(module);
-  }
-
   @Test
   public void fail_when_component_is_a_directory() {
     ComponentDto project = db.components().insertPrivateProject();
index 461e06639f831ab9a431fa1759a529aeb9586e3c..a7af59edeebc8a39b8f9cdec02406cb2d3e5ba9e 100644 (file)
@@ -47,7 +47,6 @@ import static org.sonar.api.web.UserRole.USER;
 import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.component.ComponentTesting.newSubPortfolio;
 import static org.sonar.db.permission.GlobalPermission.ADMINISTER;
 import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION;
@@ -144,14 +143,6 @@ public class AddUserActionTest extends BasePermissionWsTest<AddUserAction> {
       .isInstanceOf(NotFoundException.class);
   }
 
-  @Test
-  public void fail_when_component_is_a_module() {
-    ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-
-    failIfComponentIsNotAProjectOrView(module);
-  }
-
   @Test
   public void fail_when_component_is_a_directory() {
     ComponentDto project = db.components().insertPrivateProject();
index 3b4f803f924aacc0464ca560720d547953e701a2..fc3ac3bafa24b81d33887d3b5c2ee680a5240bbb 100644 (file)
@@ -49,7 +49,6 @@ import static org.sonar.core.permission.GlobalPermissions.PROVISIONING;
 import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.component.ComponentTesting.newSubPortfolio;
 import static org.sonar.db.permission.GlobalPermission.ADMINISTER;
 import static org.sonar.db.permission.GlobalPermission.PROVISION_PROJECTS;
@@ -206,14 +205,6 @@ public class RemoveGroupActionTest extends BasePermissionWsTest<RemoveGroupActio
       .hasMessage("Invalid global permission 'issueadmin'. Valid values are [admin, gateadmin, profileadmin, provisioning, scan]");
   }
 
-  @Test
-  public void fail_when_component_is_a_module() {
-    ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-
-    failIfComponentIsNotAProjectOrView(module);
-  }
-
   @Test
   public void fail_when_component_is_a_directory() {
     ComponentDto project = db.components().insertPrivateProject();
index 66f153b828a9abd36d287e1c4474600c5f594a6e..a4e70827191636dc77604b0514eb8e7c6a45da06 100644 (file)
@@ -47,7 +47,6 @@ import static org.sonar.core.permission.GlobalPermissions.QUALITY_GATE_ADMIN;
 import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.component.ComponentTesting.newSubPortfolio;
 import static org.sonar.db.permission.GlobalPermission.ADMINISTER;
 import static org.sonar.db.permission.GlobalPermission.ADMINISTER_QUALITY_GATES;
@@ -215,14 +214,6 @@ public class RemoveUserActionTest extends BasePermissionWsTest<RemoveUserAction>
       .isInstanceOf(BadRequestException.class);
   }
 
-  @Test
-  public void fail_when_component_is_a_module() {
-    ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-
-    failIfComponentIsNotAProjectOrView(module);
-  }
-
   @Test
   public void fail_when_component_is_a_directory() {
     ComponentDto project = db.components().insertPrivateProject();
index 39af89c713cfdd351bb1131aa4c79f506f60fd45..9c6bcc8f1b76f82443eb855fd145972a2ec03e6f 100644 (file)
@@ -57,9 +57,8 @@ import static org.sonar.api.utils.DateUtils.formatDateTime;
 import static org.sonar.api.utils.DateUtils.parseDateTime;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
-import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newPortfolio;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 import static org.sonar.db.permission.GlobalPermission.ADMINISTER;
 import static org.sonar.db.permission.GlobalPermission.ADMINISTER_QUALITY_PROFILES;
@@ -136,11 +135,10 @@ public class SearchActionTest {
   public void search_projects() {
     userSession.addPermission(ADMINISTER);
     ComponentDto project = ComponentTesting.newPrivateProjectDto().setKey(PROJECT_KEY_1);
-    ComponentDto module = newModuleDto(project);
-    ComponentDto directory = newDirectory(module, "dir");
+    ComponentDto directory = newDirectory(project, "dir");
     ComponentDto file = newFileDto(directory);
     db.components().insertComponents(
-      project, module, directory, file,
+      project, directory, file,
       ComponentTesting.newPrivateProjectDto().setKey(PROJECT_KEY_2),
       newPortfolio());
 
index c19573d6c7369cfdbc9efc29e59636c3d9b7f1e1..9c6d73422c6770721c56a838288bb9d5275d40f8 100644 (file)
@@ -189,10 +189,9 @@ public class UpdateVisibilityActionTest {
   @Test
   public void execute_fails_with_BadRequestException_if_specified_component_is_neither_a_project_a_portfolio_nor_an_application() {
     ComponentDto project = randomPublicOrPrivateProject();
-    ComponentDto module = ComponentTesting.newModuleDto(project);
     ComponentDto dir = ComponentTesting.newDirectory(project, "path");
     ComponentDto file = ComponentTesting.newFileDto(project);
-    dbTester.components().insertComponents(module, dir, file);
+    dbTester.components().insertComponents(dir, file);
     ComponentDto application = dbTester.components().insertPublicApplication();
     ComponentDto portfolio = dbTester.components().insertPrivatePortfolio();
     ComponentDto subView = ComponentTesting.newSubPortfolio(portfolio);
@@ -205,7 +204,7 @@ public class UpdateVisibilityActionTest {
       .setParam(PARAM_VISIBILITY, randomVisibility)
       .execute());
 
-    Stream.of(module, dir, file, subView, projectCopy)
+    Stream.of(dir, file, subView, projectCopy)
       .forEach(nonRootComponent -> {
         request.setParam(PARAM_PROJECT, nonRootComponent.getKey())
           .setParam(PARAM_VISIBILITY, randomVisibility);
@@ -307,11 +306,10 @@ public class UpdateVisibilityActionTest {
     dbClient.branchDao().insert(dbSession, branchDto);
 
     ComponentDto branch = ComponentTesting.newBranchComponent(project, branchDto);
-    ComponentDto module = ComponentTesting.newModuleDto(project);
     ComponentDto dir = ComponentTesting.newDirectory(project, "path");
     ComponentDto file = ComponentTesting.newFileDto(project);
 
-    dbTester.components().insertComponents(branch, module, dir, file);
+    dbTester.components().insertComponents(branch, dir, file);
     userSessionRule.addProjectPermission(UserRole.ADMIN, project);
 
     request.setParam(PARAM_PROJECT, project.getKey())
@@ -320,7 +318,6 @@ public class UpdateVisibilityActionTest {
 
     assertThat(isPrivateInDb(project)).isEqualTo(!initiallyPrivate);
     assertThat(isPrivateInDb(branch)).isEqualTo(!initiallyPrivate);
-    assertThat(isPrivateInDb(module)).isEqualTo(!initiallyPrivate);
     assertThat(isPrivateInDb(dir)).isEqualTo(!initiallyPrivate);
     assertThat(isPrivateInDb(file)).isEqualTo(!initiallyPrivate);
   }
@@ -335,14 +332,12 @@ public class UpdateVisibilityActionTest {
 
     ComponentDto branch = ComponentTesting.newBranchComponent(project, branchDto)
       .setPrivate(initiallyPrivate);
-    ComponentDto module = ComponentTesting.newModuleDto(project)
-      .setPrivate(initiallyPrivate);
     ComponentDto dir = ComponentTesting.newDirectory(project, "path")
       // child is inconsistent with root (should not occur) and won't be fixed
       .setPrivate(!initiallyPrivate);
     ComponentDto file = ComponentTesting.newFileDto(project)
       .setPrivate(initiallyPrivate);
-    dbTester.components().insertComponents(branch, module, dir, file);
+    dbTester.components().insertComponents(branch, dir, file);
     userSessionRule.addProjectPermission(UserRole.ADMIN, project);
 
     request.setParam(PARAM_PROJECT, project.getKey())
@@ -351,7 +346,6 @@ public class UpdateVisibilityActionTest {
 
     assertThat(isPrivateInDb(project)).isEqualTo(initiallyPrivate);
     assertThat(isPrivateInDb(branch)).isEqualTo(initiallyPrivate);
-    assertThat(isPrivateInDb(module)).isEqualTo(initiallyPrivate);
     assertThat(isPrivateInDb(dir)).isEqualTo(!initiallyPrivate);
     assertThat(isPrivateInDb(file)).isEqualTo(initiallyPrivate);
   }
index 61c39ca8513ccfb72764c575c0862a3ff9fee6de..6c5fd36887d8a80c86810c136ee71f10a26ad500 100644 (file)
@@ -183,14 +183,6 @@ public class CreateActionTest {
       .isInstanceOf(ForbiddenException.class);
   }
 
-  @Test
-  public void fail_if_module() {
-    ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project));
-    failIfNotAProjectWithKey(project, module);
-    failIfNotAProjectWithUuid(project, module);
-  }
-
   @Test
   public void fail_if_directory() {
     ComponentDto project = db.components().insertPrivateProject();
index 92f7ff6f37626a2aa3c31cacd850a39d92f97548..a4cd6e2431cd32840d4442a0561c351d4c183a62 100644 (file)
@@ -173,14 +173,6 @@ public class SearchActionTest {
       .isInstanceOf(NotFoundException.class);
   }
 
-  @Test
-  public void fail_if_module() {
-    ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project));
-    failIfNotAProjectWithKey(project, module);
-    failIfNotAProjectWithUuid(project, module);
-  }
-
   @Test
   public void fail_if_directory() {
     ComponentDto project = db.components().insertPrivateProject();
index dc74d8b5c3200a3f42c27288ba9f192df7ffd6b1..669bc592438694ba723601a447c266b051e8ac65 100644 (file)
@@ -41,7 +41,6 @@ import org.sonar.server.ws.TestRequest;
 import org.sonar.server.ws.TestResponse;
 import org.sonar.server.ws.WsActionTester;
 
-import static java.lang.String.format;
 import static java.net.HttpURLConnection.HTTP_NO_CONTENT;
 import static java.util.Optional.ofNullable;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -49,7 +48,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.sonar.api.web.UserRole.ADMIN;
 import static org.sonar.api.web.UserRole.USER;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 
 public class SetActionTest {
   @Rule
@@ -161,17 +159,6 @@ public class SetActionTest {
       .hasMessage("Project 'VIEW_KEY' not found");
   }
 
-  @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).setKey("MODULE_KEY"));
-
-    String moduleKey = module.getKey();
-    assertThatThrownBy(() -> call(moduleKey, "modz"))
-      .isInstanceOf(NotFoundException.class)
-      .hasMessage("Project 'MODULE_KEY' not found");
-  }
-
   @Test
   public void fail_if_component_is_a_file() {
     ComponentDto projectComponent = dbClient.componentDao().selectByUuid(dbSession, project.getUuid()).get();
index 8953ea817e984f1ae36516e3e785df1f06121789..2b15554847394681a60e2e19bc3e005a92896da6 100644 (file)
@@ -29,7 +29,6 @@ import org.sonar.api.config.PropertyDefinitions;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.api.server.ws.WebService.Param;
 import org.sonar.api.utils.System2;
-import org.sonar.api.web.UserRole;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
@@ -326,13 +325,6 @@ public class ResetActionTest {
     succeedForPropertyWithoutDefinitionAndValidComponent(project, project);
   }
 
-  @Test
-  public void succeed_for_property_without_definition_when_set_on_module_component() {
-    ComponentDto project = randomPublicOrPrivateProject();
-    ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project));
-    succeedForPropertyWithoutDefinitionAndValidComponent(project, module);
-  }
-
   @Test
   public void fail_for_property_without_definition_when_set_on_directory_component() {
     ComponentDto project = randomPublicOrPrivateProject();
index 64e7145a104c5cfce40d5ccbf2e85ad5d944ecee..93ac8612d618970627ec308e3f39c340ff2ce43a 100644 (file)
@@ -315,8 +315,8 @@ public class SetActionTest {
     logInAsProjectAdministrator(project);
 
     callForComponentPropertySet("my.key", newArrayList(
-      GSON.toJson(ImmutableMap.of("firstField", "firstValue", "secondField", "secondValue")),
-      GSON.toJson(ImmutableMap.of("firstField", "anotherFirstValue", "secondField", "anotherSecondValue"))),
+        GSON.toJson(ImmutableMap.of("firstField", "firstValue", "secondField", "secondValue")),
+        GSON.toJson(ImmutableMap.of("firstField", "anotherFirstValue", "secondField", "anotherSecondValue"))),
       project.getKey());
 
     assertThat(dbClient.propertiesDao().selectGlobalProperties(dbSession)).hasSize(3);
@@ -839,13 +839,6 @@ public class SetActionTest {
     succeedForPropertyWithoutDefinitionAndValidComponent(project, project);
   }
 
-  @Test
-  public void succeed_for_property_without_definition_when_set_on_module_component() {
-    ComponentDto project = randomPublicOrPrivateProject();
-    ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project));
-    succeedForPropertyWithoutDefinitionAndValidComponent(project, module);
-  }
-
   @Test
   public void fail_for_property_without_definition_when_set_on_directory_component() {
     ComponentDto project = randomPublicOrPrivateProject();
index fbc821a7bdcd4d888b56842fabfa1902a65f2d21..7bdd2227d21b9a7fdd371f7e7dd29c18c841f782 100644 (file)
@@ -38,7 +38,6 @@ import org.sonar.api.web.UserRole;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
-import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.permission.GlobalPermission;
 import org.sonar.process.ProcessProperties;
 import org.sonar.server.component.TestComponentFinder;
@@ -57,13 +56,13 @@ import static java.util.Comparator.comparing;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.assertj.core.groups.Tuple.tuple;
-import static org.sonar.api.resources.Qualifiers.MODULE;
+import static org.sonar.api.resources.Qualifiers.FILE;
 import static org.sonar.api.resources.Qualifiers.PROJECT;
 import static org.sonar.api.web.UserRole.ADMIN;
 import static org.sonar.api.web.UserRole.CODEVIEWER;
 import static org.sonar.api.web.UserRole.USER;
 import static org.sonar.core.permission.GlobalPermissions.SCAN_EXECUTION;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
+import static org.sonar.db.component.ComponentTesting.newFileDto;
 import static org.sonar.db.permission.GlobalPermission.SCAN;
 import static org.sonar.db.property.PropertyTesting.newComponentPropertyDto;
 import static org.sonar.db.property.PropertyTesting.newGlobalPropertyDto;
@@ -337,40 +336,23 @@ public class ValuesActionTest {
     assertThat(result.getSettingsList()).isEmpty();
   }
 
-  @Test
-  public void return_module_values() {
-    logInAsProjectUser();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    definitions.addComponent(PropertyDefinition.builder("property").defaultValue("default").onQualifiers(PROJECT, MODULE).build());
-    db.properties().insertProperties(null, null, null, null,
-      newGlobalPropertyDto().setKey("property").setValue("one"));
-    db.properties().insertProperties(null, module.getKey(), module.name(), module.qualifier(),
-      // The property is overriding global value
-      newComponentPropertyDto(module).setKey("property").setValue("two"));
-
-    ValuesWsResponse result = executeRequestForComponentProperties(module, "property");
-
-    assertThat(result.getSettingsList()).hasSize(1);
-    assertSetting(result.getSettings(0), "property", "two", false);
-  }
-
   @Test
   public void return_inherited_values_on_module() {
     logInAsProjectUser();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
+    ComponentDto file = db.components().insertComponent(newFileDto(project));
     definitions.addComponents(asList(
-      PropertyDefinition.builder("defaultProperty").defaultValue("default").onQualifiers(PROJECT, MODULE).build(),
-      PropertyDefinition.builder("globalProperty").onQualifiers(PROJECT, MODULE).build(),
-      PropertyDefinition.builder("projectProperty").onQualifiers(PROJECT, MODULE).build(),
-      PropertyDefinition.builder("moduleProperty").onQualifiers(PROJECT, MODULE).build()));
+      PropertyDefinition.builder("defaultProperty").defaultValue("default").onQualifiers(PROJECT).build(),
+      PropertyDefinition.builder("globalProperty").onQualifiers(PROJECT).build(),
+      PropertyDefinition.builder("projectProperty").onQualifiers(PROJECT).build(),
+      PropertyDefinition.builder("moduleProperty").onQualifiers(PROJECT).build()));
     db.properties().insertProperties(null, null, null, null,
       newGlobalPropertyDto().setKey("globalProperty").setValue("global"));
     db.properties().insertProperties(null, project.getKey(), project.name(), project.qualifier(),
       newComponentPropertyDto(project).setKey("projectProperty").setValue("project"));
-    db.properties().insertProperties(null, module.getKey(), module.name(), module.qualifier(),
-      newComponentPropertyDto(module).setKey("moduleProperty").setValue("module"));
+    db.properties().insertProperties(null, file.getKey(), file.name(), file.qualifier(),
+      newComponentPropertyDto(file).setKey("moduleProperty").setValue("module"));
 
-    ValuesWsResponse result = executeRequestForComponentProperties(module, "defaultProperty", "globalProperty", "projectProperty", "moduleProperty");
+    ValuesWsResponse result = executeRequestForComponentProperties(file, "defaultProperty", "globalProperty", "projectProperty", "moduleProperty");
 
     assertThat(result.getSettingsList()).hasSize(4);
     assertSetting(result.getSettings(0), "defaultProperty", "default", true);
@@ -398,51 +380,28 @@ public class ValuesActionTest {
   @Test
   public void return_parent_value() {
     logInAsProjectUser();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto subModule = db.components().insertComponent(newModuleDto(module));
+    ComponentDto file = db.components().insertComponent(newFileDto(project));
     definitions.addComponents(asList(
-      PropertyDefinition.builder("foo").defaultValue("default").onQualifiers(PROJECT, MODULE).build()));
+      PropertyDefinition.builder("foo").defaultValue("default").onQualifiers(PROJECT).build()));
     db.properties().insertProperties(null, null, null, null,
       newGlobalPropertyDto().setKey("foo").setValue("global"));
     db.properties().insertProperties(null, project.getKey(), project.name(), project.qualifier(),
       newComponentPropertyDto(project).setKey("foo").setValue("project"));
-    db.properties().insertProperties(null, module.getKey(), module.name(), module.qualifier(),
-      newComponentPropertyDto(module).setKey("foo").setValue("module"));
+    db.properties().insertProperties(null, file.getKey(), file.name(), file.qualifier(),
+      newComponentPropertyDto(file).setKey("foo").setValue("file"));
 
-    assertParentValue(executeRequestForComponentProperties(subModule, "foo").getSettings(0), "module");
-    assertParentValue(executeRequestForComponentProperties(module, "foo").getSettings(0), "project");
+    assertParentValue(executeRequestForComponentProperties(file, "foo").getSettings(0), "project");
     assertParentValue(executeRequestForComponentProperties(project, "foo").getSettings(0), "global");
     assertParentValue(executeRequestForGlobalProperties("foo").getSettings(0), "default");
   }
 
-  @Test
-  public void return_parent_values() {
-    logInAsProjectUser();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto subModule = db.components().insertComponent(newModuleDto(module));
-    definitions.addComponents(asList(
-      PropertyDefinition.builder("foo").defaultValue("default1,default2").multiValues(true).onQualifiers(PROJECT, MODULE).build()));
-    db.properties().insertProperties(null, null, null, null,
-      newGlobalPropertyDto().setKey("foo").setValue("global1,global2"));
-    db.properties().insertProperties(null, project.getKey(), project.name(), project.qualifier(),
-      newComponentPropertyDto(project).setKey("foo").setValue("project1,project2"));
-    db.properties().insertProperties(null, module.getKey(), module.name(), module.qualifier(),
-      newComponentPropertyDto(module).setKey("foo").setValue("module1,module2"));
-
-    assertParentValues(executeRequestForComponentProperties(subModule, "foo").getSettings(0), "module1", "module2");
-    assertParentValues(executeRequestForComponentProperties(module, "foo").getSettings(0), "project1", "project2");
-    assertParentValues(executeRequestForComponentProperties(project, "foo").getSettings(0), "global1", "global2");
-    assertParentValues(executeRequestForGlobalProperties("foo").getSettings(0), "default1", "default2");
-  }
-
   @Test
   public void return_parent_field_values() {
     logInAsProjectUser();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto subModule = db.components().insertComponent(newModuleDto(module));
+    ComponentDto file = db.components().insertComponent(newFileDto(project));
     definitions.addComponent(PropertyDefinition
       .builder("foo")
-      .onQualifiers(PROJECT, MODULE)
+      .onQualifiers(PROJECT)
       .type(PropertyType.PROPERTY_SET)
       .fields(asList(
         PropertyFieldDefinition.build("key").name("Key").build(),
@@ -450,10 +409,9 @@ public class ValuesActionTest {
       .build());
     db.properties().insertPropertySet("foo", null, ImmutableMap.of("key", "keyG1", "size", "sizeG1"));
     db.properties().insertPropertySet("foo", project, ImmutableMap.of("key", "keyP1", "size", "sizeP1"));
-    db.properties().insertPropertySet("foo", module, ImmutableMap.of("key", "keyM1", "size", "sizeM1"));
+    db.properties().insertPropertySet("foo", file, ImmutableMap.of("key", "keyM1", "size", "sizeM1"));
 
-    assertParentFieldValues(executeRequestForComponentProperties(subModule, "foo").getSettings(0), ImmutableMap.of("key", "keyM1", "size", "sizeM1"));
-    assertParentFieldValues(executeRequestForComponentProperties(module, "foo").getSettings(0), ImmutableMap.of("key", "keyP1", "size", "sizeP1"));
+    assertParentFieldValues(executeRequestForComponentProperties(file, "foo").getSettings(0), ImmutableMap.of("key", "keyP1", "size", "sizeP1"));
     assertParentFieldValues(executeRequestForComponentProperties(project, "foo").getSettings(0), ImmutableMap.of("key", "keyG1", "size", "sizeG1"));
     assertParentFieldValues(executeRequestForGlobalProperties("foo").getSettings(0));
   }
@@ -461,38 +419,37 @@ public class ValuesActionTest {
   @Test
   public void return_no_parent_value() {
     logInAsProjectUser();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
-    ComponentDto subModule = db.components().insertComponent(newModuleDto(module));
+    ComponentDto file = db.components().insertComponent(newFileDto(project));
     definitions.addComponents(asList(
-      PropertyDefinition.builder("simple").onQualifiers(PROJECT, MODULE).build(),
-      PropertyDefinition.builder("multi").multiValues(true).onQualifiers(PROJECT, MODULE).build(),
+      PropertyDefinition.builder("simple").onQualifiers(PROJECT).build(),
+      PropertyDefinition.builder("multi").multiValues(true).onQualifiers(PROJECT).build(),
       PropertyDefinition.builder("set")
         .type(PropertyType.PROPERTY_SET)
-        .onQualifiers(PROJECT, MODULE)
+        .onQualifiers(PROJECT)
         .fields(asList(
           PropertyFieldDefinition.build("key").name("Key").build(),
           PropertyFieldDefinition.build("size").name("Size").build()))
         .build()));
-    db.properties().insertProperties(null, module.getKey(), module.name(), module.qualifier(),
-      newComponentPropertyDto(module).setKey("simple").setValue("module"),
-      newComponentPropertyDto(module).setKey("multi").setValue("module1,module2"));
-    db.properties().insertPropertySet("set", module, ImmutableMap.of("key", "keyM1", "size", "sizeM1"));
+    db.properties().insertProperties(null, project.getKey(), project.name(), project.qualifier(),
+      newComponentPropertyDto(project).setKey("simple").setValue("module"),
+      newComponentPropertyDto(project).setKey("multi").setValue("module1,module2"));
+    db.properties().insertPropertySet("set", project, ImmutableMap.of("key", "keyM1", "size", "sizeM1"));
 
-    assertParentValue(executeRequestForComponentProperties(subModule, "simple").getSettings(0), null);
-    assertParentValues(executeRequestForComponentProperties(subModule, "multi").getSettings(0));
-    assertParentFieldValues(executeRequestForComponentProperties(subModule, "set").getSettings(0));
+    assertParentValue(executeRequestForComponentProperties(file, "simple").getSettings(0), null);
+    assertParentValues(executeRequestForComponentProperties(file, "multi").getSettings(0));
+    assertParentFieldValues(executeRequestForComponentProperties(file, "set").getSettings(0));
   }
 
   @Test
   public void return_parent_value_when_no_definition() {
     logInAsProjectUser();
-    ComponentDto module = db.components().insertComponent(newModuleDto(project));
+    ComponentDto file = db.components().insertComponent(newFileDto(project));
     db.properties().insertProperties(null, null, null, null,
       newGlobalPropertyDto().setKey("foo").setValue("global"));
     db.properties().insertProperties(null, project.getKey(), project.name(), project.qualifier(),
       newComponentPropertyDto(project).setKey("foo").setValue("project"));
 
-    assertParentValue(executeRequestForComponentProperties(module, "foo").getSettings(0), "project");
+    assertParentValue(executeRequestForComponentProperties(file, "foo").getSettings(0), "project");
     assertParentValue(executeRequestForComponentProperties(project, "foo").getSettings(0), "global");
     assertParentValue(executeRequestForGlobalProperties("foo").getSettings(0), null);
   }
index 0d12cc1162b0180c730c4cbabd9f4258282e8647..9e2184ded528cd215ad26a3f99f595642647b4e9 100644 (file)
@@ -84,7 +84,6 @@ import static org.sonar.api.web.page.Page.Scope.COMPONENT;
 import static org.sonar.db.component.ComponentDbTester.toProjectDto;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newSubPortfolio;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
@@ -602,10 +601,9 @@ public class ComponentActionTest {
   @Test
   public void return_bread_crumbs_on_several_levels() {
     ComponentDto project = insertProject();
-    ComponentDto module = componentDbTester.insertComponent(newModuleDto("bcde", project).setKey("palap").setName("Palap"));
-    ComponentDto directory = componentDbTester.insertComponent(newDirectory(module, "src/main/xoo"));
+    ComponentDto directory = componentDbTester.insertComponent(newDirectory(project, "src/main/xoo"));
     ComponentDto file = componentDbTester.insertComponent(newFileDto(directory, directory, "cdef").setName("Source.xoo")
-      .setKey("palap:src/main/xoo/Source.xoo")
+      .setKey("polop:src/main/xoo/Source.xoo")
       .setPath(directory.path()));
     userSession.addProjectPermission(UserRole.USER, project);
     init();
@@ -755,21 +753,10 @@ public class ComponentActionTest {
     assertThat(componentId.exampleValue()).isNotNull();
   }
 
-  @Test
-  public void fail_on_module_key_as_param() {
-    ComponentDto project = insertProject();
-    ComponentDto module = componentDbTester.insertComponent(newModuleDto("bcde", project).setKey("palap").setName("Palap"));
-    init();
-
-    assertThatThrownBy(() -> execute(module.getKey()))
-      .isInstanceOf(BadRequestException.class);
-  }
-
   @Test
   public void fail_on_directory_key_as_param() {
     ComponentDto project = insertProject();
-    ComponentDto module = componentDbTester.insertComponent(newModuleDto("bcde", project).setKey("palap").setName("Palap"));
-    ComponentDto directory = componentDbTester.insertComponent(newDirectory(module, "src/main/xoo"));
+    ComponentDto directory = componentDbTester.insertComponent(newDirectory(project, "src/main/xoo"));
     userSession.addProjectPermission(UserRole.USER, project);
     init();
     String dirKey = directory.getKey();
diff --git a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/components_contains_sub_projects.json b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/components_contains_sub_projects.json
deleted file mode 100644 (file)
index 5ff9016..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-{
-  "components": [
-    {
-      "key": "FileLinkedToModule"
-    },
-    {
-      "key": "ModuleHavingFile"
-    },
-    {
-      "key": "ProjectHavingModule"
-    }
-  ]
-}
index fe5e86638338bf7088090d76e91c23e6436e3204..ae845b53b1767f7b09e1e2543f1cba0e0182f3b8 100644 (file)
@@ -1,5 +1,5 @@
 {
-  "key": "palap:src/main/xoo/Source.xoo",
+  "key": "polop:src/main/xoo/Source.xoo",
   "id": "cdef",
   "name": "Source.xoo",
   "isFavorite": false,
       "qualifier": "TRK"
     },
     {
-      "key": "palap",
-      "name": "Palap",
-      "qualifier": "BRC"
-    },
-    {
-      "key": "palap:src/main/xoo",
+      "key": "polop:src/main/xoo",
       "name": "src/main/xoo",
       "qualifier": "DIR"
     },
     {
-      "key": "palap:src/main/xoo/Source.xoo",
+      "key": "polop:src/main/xoo/Source.xoo",
       "name": "Source.xoo",
       "qualifier": "FIL"
     }
index 2159b8bb5737e864e7866c69b9e2730478db0142..931746fa44f6ca7c847f5e0b73702cbc9ad81eb7 100644 (file)
@@ -57,8 +57,6 @@ public class DefaultIssue implements Issue, Trackable, org.sonar.api.ce.measure.
   private String componentUuid = null;
   private String componentKey = null;
 
-  private String moduleUuidPath = null;
-
   private String projectUuid = null;
   private String projectKey = null;
 
@@ -175,16 +173,6 @@ public class DefaultIssue implements Issue, Trackable, org.sonar.api.ce.measure.
     return this;
   }
 
-  @CheckForNull
-  public String moduleUuidPath() {
-    return moduleUuidPath;
-  }
-
-  public DefaultIssue setModuleUuidPath(@Nullable String moduleUuidPath) {
-    this.moduleUuidPath = moduleUuidPath;
-    return this;
-  }
-
   @Override
   public String projectUuid() {
     return projectUuid;