Map<String, ComponentDto> existingDtosByUuids = indexExistingDtosByUuids(dbSession);
boolean isRootPrivate = isRootPrivate(treeRootHolder.getRoot(), existingDtosByUuids);
- String mainBranchProjectUuid = loadProjectUuidOfMainBranch();
// Insert or update the components in database. They are removed from existingDtosByUuids
// at the same time.
- new PathAwareCrawler<>(new PersistComponentStepsVisitor(existingDtosByUuids, dbSession, mainBranchProjectUuid))
+ new PathAwareCrawler<>(new PersistComponentStepsVisitor(existingDtosByUuids, dbSession))
.visit(treeRootHolder.getRoot());
disableRemainingComponents(dbSession, existingDtosByUuids.values());
}
}
- @CheckForNull
- private String loadProjectUuidOfMainBranch() {
- if (!analysisMetadataHolder.getBranch().isMain()) {
- return analysisMetadataHolder.getProject().getUuid();
- }
- return null;
- }
-
private void disableRemainingComponents(DbSession dbSession, Collection<ComponentDto> dtos) {
Set<String> uuids = dtos.stream()
.filter(ComponentDto::isEnabled)
private final Map<String, ComponentDto> existingComponentDtosByUuids;
private final DbSession dbSession;
- @Nullable
- private final String mainBranchProjectUuid;
- PersistComponentStepsVisitor(Map<String, ComponentDto> existingComponentDtosByUuids, DbSession dbSession, @Nullable String mainBranchProjectUuid) {
+ PersistComponentStepsVisitor(Map<String, ComponentDto> existingComponentDtosByUuids, DbSession dbSession) {
super(
CrawlerDepthLimit.LEAVES,
PRE_ORDER,
});
this.existingComponentDtosByUuids = existingComponentDtosByUuids;
this.dbSession = dbSession;
- this.mainBranchProjectUuid = mainBranchProjectUuid;
}
@Override
ComponentDto componentDto = new ComponentDto();
componentDto.setUuid(componentUuid);
componentDto.setKey(componentKey);
- componentDto.setMainBranchProjectUuid(mainBranchProjectUuid);
componentDto.setEnabled(true);
componentDto.setCreatedAt(new Date(system2.now()));
reserved 14; // module_uuid_path
string deprecated_key = 15;
string project_uuid = 16;
- reserved 17;
+ reserved 17; // main_branch_project_uuid
}
message Branch {
dbTester.components().insertComponent(newFileDto(directory1));
dbTester.components().insertComponent(newFileDto(directory2));
- directory1 = dbTester.components().insertComponent(ComponentTesting.newDirectory(branch, "a")
- .setMainBranchProjectUuid(project.uuid()));
- directory2 = dbTester.components().insertComponent(ComponentTesting.newDirectory(branch, "b")
- .setMainBranchProjectUuid(project.uuid()));
- dbTester.components().insertComponent(newFileDto(branch, project.uuid()).setMainBranchProjectUuid(project.uuid()));
- dbTester.components().insertComponent(newFileDto(directory1).setMainBranchProjectUuid(project.uuid()));
- dbTester.components().insertComponent(newFileDto(directory2).setMainBranchProjectUuid(project.uuid()));
+ directory1 = dbTester.components().insertComponent(ComponentTesting.newDirectory(branch, "a"));
+ directory2 = dbTester.components().insertComponent(ComponentTesting.newDirectory(branch, "b"));
+ dbTester.components().insertComponent(newFileDto(branch, project.uuid()));
+ dbTester.components().insertComponent(newFileDto(directory1));
+ dbTester.components().insertComponent(newFileDto(directory2));
underTest.deleteNonMainBranchComponentsByProjectUuid(project.uuid());
* - on sub-view: UUID="6" PROJECT_UUID="5"
*/
private String branchUuid;
-
- /**
- * 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
- * - branch B of project P : kee=P, uuid=U3, qualifier=TRK, project_uuid=U3, main_branch_project_uuid=U1
- * - file F in branch B of project P : kee=P:F, uuid=U4, qualifier=FIL, project_uuid=U3, main_branch_project_uuid=U1
- */
- @Nullable
- private String mainBranchProjectUuid;
-
private String copyComponentUuid;
private String scope;
private String qualifier;
return this;
}
- @Nullable
- public String getMainBranchProjectUuid() {
- return mainBranchProjectUuid;
- }
-
- public ComponentDto setMainBranchProjectUuid(@Nullable String s) {
- this.mainBranchProjectUuid = s;
- return this;
- }
-
public boolean isEnabled() {
return enabled;
}
.append("scope", scope)
.append("qualifier", qualifier)
.append("branchUuid", branchUuid)
- .append("mainBranchProjectUuid", mainBranchProjectUuid)
.append("copyComponentUuid", copyComponentUuid)
.append("path", path)
.append("name", name)
copy.uuid = uuid;
copy.uuidPath = uuidPath;
copy.branchUuid = branchUuid;
- copy.mainBranchProjectUuid = mainBranchProjectUuid;
copy.copyComponentUuid = copyComponentUuid;
copy.scope = scope;
copy.qualifier = qualifier;
p.uuid as uuid,
p.uuid_path as uuidPath,
p.branch_uuid as branchUuid,
- p.main_branch_project_uuid as mainBranchProjectUuid,
p.kee as kee,
p.name as name,
p.long_name as longName,
p.uuid as uuid,
p.uuid_path as uuidPath,
p.branch_uuid as branchUuid,
- p.main_branch_project_uuid as mainBranchProjectUuid,
p.kee as kee,
case
when pr.name is not null and p.scope = 'PRJ'
uuid,
uuid_path,
branch_uuid,
- main_branch_project_uuid,
name,
long_name,
qualifier,
#{uuid,jdbcType=VARCHAR},
#{uuidPath,jdbcType=VARCHAR},
#{branchUuid,jdbcType=VARCHAR},
- #{mainBranchProjectUuid, jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR},
#{longName,jdbcType=VARCHAR},
#{qualifier,jdbcType=VARCHAR},
"PATH" CHARACTER VARYING(2000),
"UUID_PATH" CHARACTER VARYING(1500) NOT NULL,
"BRANCH_UUID" CHARACTER VARYING(50) NOT NULL,
- "MAIN_BRANCH_PROJECT_UUID" CHARACTER VARYING(50),
"B_CHANGED" BOOLEAN,
"B_NAME" CHARACTER VARYING(500),
"B_LONG_NAME" CHARACTER VARYING(500),
"CREATED_AT" TIMESTAMP
);
CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER" 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);
.setLongName(path)
.setScope(Scopes.FILE)
.setBranchUuid(branch.branchUuid())
- .setMainBranchProjectUuid(mainBranchUuid)
.setQualifier(Qualifiers.FILE)
.setPath(path)
.setCreatedAt(new Date())
.setName(path)
.setLongName(path)
.setBranchUuid(project.branchUuid())
- .setMainBranchProjectUuid(mainBranchUuid)
.setPath(path)
.setScope(Scopes.DIRECTORY)
.setQualifier(Qualifiers.DIRECTORY);
.setUuidPath(UUID_PATH_OF_ROOT)
.setBranchUuid(uuid)
.setKey(project.getKey())
- .setMainBranchProjectUuid(project.getUuid())
.setName(project.getName())
.setLongName(project.getName())
.setDescription(project.getDescription())
.setUuidPath(UUID_PATH_OF_ROOT)
.setBranchUuid(uuid)
.setKey(project.getKey())
- .setMainBranchProjectUuid(project.uuid())
.setName(project.name())
.setLongName(project.longName())
.setDescription(project.description())
.add(10_2_011, "Create index 'ce_queue_entity_uuid' in 'ce_queue' table", CreateIndexEntityUuidInCeQueue.class)
.add(10_2_012, "Drop 'project_mappings' table", DropTableProjectMappings.class)
+
+ .add(10_2_013, "Drop index on 'components.main_branch_project_uuid", DropIndexOnMainBranchProjectUuid.class)
+ .add(10_2_014, "Drop column 'main_branch_project_uuid' in the components table", DropMainBranchProjectUuidInComponents.class)
;
}
-
}
--- /dev/null
+/*
+ * 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.v102;
+
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DropIndexChange;
+
+public class DropIndexOnMainBranchProjectUuid extends DropIndexChange {
+ private static final String INDEX_NAME = "idx_main_branch_prj_uuid";
+ private static final String TABLE_NAME = "components";
+
+ public DropIndexOnMainBranchProjectUuid(Database db) {
+ super(db, INDEX_NAME, TABLE_NAME);
+ }
+}
--- /dev/null
+/*
+ * 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.v102;
+
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DropColumnChange;
+
+class DropMainBranchProjectUuidInComponents extends DropColumnChange {
+ static final String TABLE_NAME = "components";
+ static final String COLUMN_NAME = "main_branch_project_uuid";
+
+ public DropMainBranchProjectUuidInComponents(Database db) {
+ super(db, TABLE_NAME, COLUMN_NAME);
+ }
+}
--- /dev/null
+/*
+ * 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.v102;
+
+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 DropIndexOnMainBranchProjectUuidTest {
+ private static final String TABLE_NAME = "components";
+ private static final String COLUMN_NAME = "main_branch_project_uuid";
+ private static final String INDEX_NAME = "idx_main_branch_prj_uuid";
+
+ @Rule
+ public final CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnMainBranchProjectUuidTest.class, "schema.sql");
+ private final DdlChange underTest = new DropIndexOnMainBranchProjectUuid(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);
+ }
+}
--- /dev/null
+/*
+ * 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.v102;
+
+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;
+
+import static org.sonar.server.platform.db.migration.version.v102.DropMainBranchProjectUuidInComponents.COLUMN_NAME;
+import static org.sonar.server.platform.db.migration.version.v102.DropMainBranchProjectUuidInComponents.TABLE_NAME;
+
+public class DropMainBranchProjectUuidInComponentsTest {
+
+ @Rule
+ public final CoreDbTester db = CoreDbTester.createForSchema(DropMainBranchProjectUuidInComponentsTest.class, "schema.sql");
+ private final DdlChange underTest = new DropMainBranchProjectUuidInComponents(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);
+ }
+}
--- /dev/null
+
+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,
+ "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,
+ "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),
+ "CREATED_AT" TIMESTAMP
+);
+CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER" 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);
--- /dev/null
+
+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,
+ "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,
+ "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),
+ "CREATED_AT" TIMESTAMP
+);
+CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER" 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);
ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("feature/foo"));
BranchDto branchDto = db.getDbClient().branchDao().selectByUuid(db.getSession(), branch.uuid()).orElseThrow();
ComponentDto dir = db.components().insertComponent(ComponentTesting.newDirectory(branch, "src/main/java/foo"));
- ComponentDto file = db.components().insertComponent(newFileDto(branch, dir, "F1").setMainBranchProjectUuid(project.uuid()));
+ ComponentDto file = db.components().insertComponent(newFileDto(branch, dir, "F1"));
IssueDto issue = db.issues().insert(rule, branch, file);
underTest.indexAllIssues();
.setGroups(group);
threadLocalUserSession.set(expected);
- ComponentDto componentDto = new ComponentDto().setQualifier(Qualifiers.APP).setMainBranchProjectUuid("component-uuid");
+ ComponentDto componentDto = new ComponentDto().setQualifier(Qualifiers.APP);
ProjectDto projectDto = new ProjectDto().setQualifier(Qualifiers.APP).setUuid("project-uuid");
assertThatThrownBy(() -> threadLocalUserSession.checkChildProjectsPermission(USER, componentDto))
.isInstanceOf(ForbiddenException.class);
ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent();
ComponentDto projectFile = db.components().insertComponent(newFileDto(project));
ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("my_branch"));
- ComponentDto branchFile = db.components().insertComponent(newFileDto(branch, project.uuid())).setMainBranchProjectUuid(project.uuid());
+ ComponentDto branchFile = db.components().insertComponent(newFileDto(branch, project.uuid()));
indexIssues(
newDocForProject("I1", project),
ComponentDto applicationBranch2 = db.components().insertProjectBranch(application, a -> a.setKey("app-branch2"));
ComponentDto project1 = db.components().insertPrivateProject(p -> p.setKey("prj1")).getMainBranchComponent();
ComponentDto project1Branch1 = db.components().insertProjectBranch(project1);
- ComponentDto fileOnProject1Branch1 = db.components().insertComponent(newFileDto(project1Branch1)).setMainBranchProjectUuid(project1.uuid());
+ ComponentDto fileOnProject1Branch1 = db.components().insertComponent(newFileDto(project1Branch1));
ComponentDto project1Branch2 = db.components().insertProjectBranch(project1);
ComponentDto project2 = db.components().insertPrivateProject(p -> p.setKey("prj2")).getMainBranchComponent();
indexView(applicationBranch1.uuid(), asList(project1Branch1.uuid(), project2.uuid()));
ComponentDto project = db.components().insertPrivateProject(p -> p.setKey("project-key")).getMainBranchComponent();
ComponentDto projectBranch = db.components().insertProjectBranch(project, b -> b.setKey(projectBranchName));
ComponentDto techProjectBranch = db.components().insertComponent(newProjectCopy(projectBranch, applicationBranch)
- .setKey(applicationBranch.getKey() + project.getKey()).setMainBranchProjectUuid(application.getUuid()));
+ .setKey(applicationBranch.getKey() + project.getKey()));
logInWithBrowsePermission(applicationData);
userSession.addProjectBranchMapping(application.getUuid(), applicationBranch);
String branchName = randomAlphanumeric(248);
ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey(branchName));
userSessionRule.addProjectBranchMapping(project.uuid(), branch);
- ComponentDto file = db.components().insertComponent(newFileDto(branch, project.uuid()).setMainBranchProjectUuid(project.uuid()));
+ ComponentDto file = db.components().insertComponent(newFileDto(branch, project.uuid()));
db.measures().insertLiveMeasure(file, dataMetric, m -> m.setData(format("<duplications>\n" +
" <g>\n" +
" <b s=\"31\" l=\"5\" r=\"%s\"/>\n" +
UserDto assignee = insertUser(randomAlphanumeric(15));
when(branchDto.getBranchType()).thenReturn(BranchType.BRANCH);
+ String projectUuid = "projectUuid";
+ when(branchDto.getProjectUuid()).thenReturn(projectUuid);
when(issueFieldsSetter.assign(eq(hotspot.toDefaultIssue()), userMatcher(assignee), any(IssueChangeContext.class))).thenReturn(true);
executeRequest(hotspot, assignee.getLogin(), null);
- verify(hotspotChangeEventService).distributeHotspotChangedEvent(eq(project.getMainBranchProjectUuid()), any(HotspotChangedEvent.class));
+ verify(hotspotChangeEventService).distributeHotspotChangedEvent(eq(projectUuid), any(HotspotChangedEvent.class));
}
@Test
.addProjectPermission(UserRole.SECURITYHOTSPOT_ADMIN, projectData.getProjectDto());
ComponentDto file = dbTester.components().insertComponent(newFileDto(project));
when(branchDto.getBranchType()).thenReturn(BranchType.BRANCH);
+ String projectUuid = "projectUuid";
+ when(branchDto.getProjectUuid()).thenReturn(projectUuid);
IssueDto hotspot = dbTester.issues().insertHotspot(project, file);
when(transitionService.doTransition(any(), any(), any())).thenReturn(true);
newRequest(hotspot, STATUS_REVIEWED, RESOLUTION_FIXED, NO_COMMENT).execute();
- verify(hotspotChangeEventService).distributeHotspotChangedEvent(eq(project.getMainBranchProjectUuid()), any(HotspotChangedEvent.class));
+ verify(hotspotChangeEventService).distributeHotspotChangedEvent(eq(projectUuid), any(HotspotChangedEvent.class));
}
@Test
ComponentDto branch = db.components().insertProjectBranch(mainBranch, b -> b.setKey("pr-123").setBranchType(PULL_REQUEST));
userSession.addProjectBranchMapping(projectData.projectUuid(), branch);
SnapshotDto analysis = db.components().insertSnapshot(branch);
- ComponentDto file = db.components().insertComponent(newFileDto(branch, mainBranch.uuid()).setMainBranchProjectUuid(mainBranch.uuid()));
+ ComponentDto file = db.components().insertComponent(newFileDto(branch, mainBranch.uuid()));
MetricDto complexity = db.measures().insertMetric(m -> m.setValueType(INT.name()));
LiveMeasureDto measure = db.measures().insertLiveMeasure(file, complexity, m -> m.setValue(12.0d));