CREATE TABLE "PROJECT_BRANCHES" (
"UUID" VARCHAR(50) NOT NULL PRIMARY KEY,
"PROJECT_UUID" VARCHAR(50) NOT NULL,
- "KEE_TYPE" VARCHAR(6) NOT NULL,
"KEE" VARCHAR(255) NOT NULL,
"BRANCH_TYPE" VARCHAR(5),
"MERGE_BRANCH_UUID" VARCHAR(50),
- "PULL_REQUEST_TITLE" VARCHAR(4000),
"CREATED_AT" BIGINT NOT NULL,
"UPDATED_AT" BIGINT NOT NULL
);
CREATE UNIQUE INDEX "PK_PROJECT_BRANCHES" ON "PROJECT_BRANCHES" ("UUID");
-CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE_TYPE", "KEE");
+CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE");
import java.util.Collection;
import java.util.List;
import java.util.Optional;
-import javax.annotation.Nullable;
import org.sonar.api.utils.System2;
import org.sonar.db.Dao;
import org.sonar.db.DbSession;
return mapper(dbSession).updateMainBranchName(projectUuid, newBranchKey, now);
}
- public Optional<BranchDto> selectByKey(DbSession dbSession, String projectUuid, BranchKeyType keyType, @Nullable String key) {
- return Optional.ofNullable(mapper(dbSession).selectByKey(projectUuid, keyType, key));
+ public Optional<BranchDto> selectByKey(DbSession dbSession, String projectUuid, String key) {
+ return Optional.ofNullable(mapper(dbSession).selectByKey(projectUuid, key));
}
public Collection<BranchDto> selectByComponent(DbSession dbSession, ComponentDto component) {
private String projectUuid;
/**
- * Not null.
- */
- private BranchKeyType keeType;
-
- /**
- * If {@link #keeType} is {@link BranchKeyType#BRANCH}, then name of branch, for example
- * "feature/foo".
- *
- * If {@link #keeType} is {@link BranchKeyType#PR}, then id of the pull request, for
- * example "1204".
+ * Name of branch, for example "feature/foo".
*/
private String kee;
/**
- * Value is mandatory when {@link #keeType} is {@link BranchKeyType#BRANCH}.
- * Otherwise it is null.
+ * Branch type, as provided by {@link BranchType}.
+ * Not null.
*/
- @Nullable
private BranchType branchType;
/**
@Nullable
private String mergeBranchUuid;
- /**
- * Optional title of pull requests
- */
- @Nullable
- private String pullRequestTitle;
-
public String getUuid() {
return uuid;
}
return projectUuid.equals(uuid);
}
- public BranchKeyType getKeeType() {
- return keeType;
- }
-
- public BranchDto setKeeType(BranchKeyType t) {
- this.keeType = t;
- return this;
- }
-
/**
* This is the getter used by MyBatis mapper.
*/
return this;
}
- @Nullable
public BranchType getBranchType() {
return branchType;
}
return this;
}
- @Nullable
- public String getPullRequestTitle() {
- return pullRequestTitle;
- }
-
- public BranchDto setPullRequestTitle(@Nullable String s) {
- checkArgument(s == null || s.length() <= 4000, "Maximum length of pull request title is 4000: %s", s);
- this.pullRequestTitle = s;
- return this;
- }
-
@Override
public String toString() {
StringBuilder sb = new StringBuilder("BranchDto{");
sb.append("uuid='").append(uuid).append('\'');
sb.append(", projectUuid='").append(projectUuid).append('\'');
- sb.append(", keeType=").append(keeType);
sb.append(", kee='").append(kee).append('\'');
sb.append(", branchType=").append(branchType);
sb.append(", mergeBranchUuid='").append(mergeBranchUuid).append('\'');
- sb.append(", pullRequestTitle='").append(pullRequestTitle).append('\'');
sb.append('}');
return sb.toString();
}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 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;
-
-/**
- * Supported values in column project_branches.kee_type
- */
-public enum BranchKeyType {
- /**
- * Branch, whatever long or short, main or not.
- */
- BRANCH,
-
- /**
- * Pull request
- */
- PR
-}
int updateMainBranchName(@Param("projectUuid") String projectUuid, @Param("newBranchName") String newBranchName, @Param("now") long now);
- BranchDto selectByKey(@Param("projectUuid") String projectUuid,
- @Param("keyType") BranchKeyType keyType, @Param("key") String key);
+ BranchDto selectByKey(@Param("projectUuid") String projectUuid, @Param("key") String key);
BranchDto selectByUuid(@Param("uuid") String uuid);
<sql id="columns">
pb.uuid as uuid,
pb.project_uuid as projectUuid,
- pb.kee_type as keeType,
pb.kee as kee,
pb.branch_type as branchType,
- pb.merge_branch_uuid as mergeBranchUuid,
- pb.pull_request_title as pullRequestTitle
+ pb.merge_branch_uuid as mergeBranchUuid
</sql>
<insert id="insert" parameterType="map" useGeneratedKeys="false">
insert into project_branches (
uuid,
project_uuid,
- kee_type,
kee,
branch_type,
merge_branch_uuid,
- pull_request_title,
created_at,
updated_at
) values (
#{dto.uuid, jdbcType=VARCHAR},
#{dto.projectUuid, jdbcType=VARCHAR},
- #{dto.keeType, jdbcType=VARCHAR},
#{dto.kee, jdbcType=VARCHAR},
#{dto.branchType, jdbcType=VARCHAR},
#{dto.mergeBranchUuid, jdbcType=VARCHAR},
- #{dto.pullRequestTitle, jdbcType=VARCHAR},
#{now, jdbcType=BIGINT},
#{now, jdbcType=BIGINT}
)
update project_branches
set
merge_branch_uuid = #{dto.mergeBranchUuid, jdbcType=VARCHAR},
- pull_request_title = #{dto.pullRequestTitle, jdbcType=VARCHAR},
updated_at = #{now, jdbcType=BIGINT}
where
uuid = #{dto.uuid, jdbcType=VARCHAR}
from project_branches pb
where
pb.project_uuid = #{projectUuid, jdbcType=VARCHAR} and
- pb.kee_type = #{keyType, jdbcType=VARCHAR} and
pb.kee = #{key, jdbcType=VARCHAR}
</select>
public class BranchDaoTest {
private static final long NOW = 1_000L;
- private static final String SELECT_FROM = "select project_uuid as \"projectUuid\", uuid as \"uuid\", branch_type as \"branchType\", kee_type as \"keeType\", " +
- "kee as \"kee\", merge_branch_uuid as \"mergeBranchUuid\", pull_request_title as \"pullRequestTitle\", created_at as \"createdAt\", updated_at as \"updatedAt\" " +
+ private static final String SELECT_FROM = "select project_uuid as \"projectUuid\", uuid as \"uuid\", branch_type as \"branchType\", " +
+ "kee as \"kee\", merge_branch_uuid as \"mergeBranchUuid\", created_at as \"createdAt\", updated_at as \"updatedAt\" " +
"from project_branches ";
private System2 system2 = new TestSystem2().setNow(NOW);
dto.setProjectUuid("U1");
dto.setUuid("U2");
dto.setBranchType(BranchType.SHORT);
- dto.setKeeType(BranchKeyType.BRANCH);
dto.setKey("feature/foo");
underTest.insert(dbSession, dto);
entry("projectUuid", "U1"),
entry("uuid", "U2"),
entry("branchType", "SHORT"),
- entry("keeType", "BRANCH"),
entry("kee", "feature/foo"),
entry("mergeBranchUuid", null),
- entry("pullRequestTitle", null),
entry("createdAt", 1_000L),
entry("updatedAt", 1_000L));
}
dto.setProjectUuid("U1");
dto.setUuid("U1");
dto.setBranchType(BranchType.LONG);
- dto.setKeeType(BranchKeyType.BRANCH);
dto.setKey("feature");
underTest.insert(dbSession, dto);
dto2.setProjectUuid("U2");
dto2.setUuid("U2");
dto2.setBranchType(BranchType.LONG);
- dto2.setKeeType(BranchKeyType.BRANCH);
dto2.setKey("branch");
underTest.insert(dbSession, dto2);
underTest.updateMainBranchName(dbSession, "U1", "master");
- BranchDto loaded = underTest.selectByKey(dbSession, "U1", BranchKeyType.BRANCH, "master").get();
+ BranchDto loaded = underTest.selectByKey(dbSession, "U1", "master").get();
assertThat(loaded.getMergeBranchUuid()).isNull();
- assertThat(loaded.getPullRequestTitle()).isNull();
assertThat(loaded.getProjectUuid()).isEqualTo("U1");
assertThat(loaded.getBranchType()).isEqualTo(BranchType.LONG);
- assertThat(loaded.getKeeType()).isEqualTo(BranchKeyType.BRANCH);
}
@Test
dto.setProjectUuid(repeat("a", 50));
dto.setUuid(repeat("b", 50));
dto.setBranchType(BranchType.SHORT);
- dto.setKeeType(BranchKeyType.BRANCH);
dto.setKey(repeat("c", 255));
dto.setMergeBranchUuid(repeat("d", 50));
- dto.setPullRequestTitle(repeat("e", 4_000));
underTest.insert(dbSession, dto);
assertThat((String) map.get("uuid")).contains("b").isEqualTo(dto.getUuid());
assertThat((String) map.get("kee")).contains("c").isEqualTo(dto.getKey());
assertThat((String) map.get("mergeBranchUuid")).contains("d").isEqualTo(dto.getMergeBranchUuid());
- assertThat((String) map.get("pullRequestTitle")).contains("e").isEqualTo(dto.getPullRequestTitle());
}
@Test
dto.setProjectUuid("U1");
dto.setUuid("U2");
dto.setBranchType(BranchType.LONG);
- dto.setKeeType(BranchKeyType.BRANCH);
dto.setKey("foo");
underTest.insert(dbSession, dto);
// the fields that can be updated
dto.setMergeBranchUuid("U3");
- dto.setPullRequestTitle("theTitle");
// the fields that can't be updated. New values are ignored.
dto.setProjectUuid("ignored");
dto.setBranchType(BranchType.SHORT);
- dto.setKeeType(BranchKeyType.PR);
underTest.upsert(dbSession, dto);
- BranchDto loaded = underTest.selectByKey(dbSession, "U1", BranchKeyType.BRANCH, "foo").get();
+ BranchDto loaded = underTest.selectByKey(dbSession, "U1", "foo").get();
assertThat(loaded.getMergeBranchUuid()).isEqualTo("U3");
- assertThat(loaded.getPullRequestTitle()).isEqualTo("theTitle");
assertThat(loaded.getProjectUuid()).isEqualTo("U1");
assertThat(loaded.getBranchType()).isEqualTo(BranchType.LONG);
- assertThat(loaded.getKeeType()).isEqualTo(BranchKeyType.BRANCH);
}
@Test
mainBranch.setProjectUuid("U1");
mainBranch.setUuid("U1");
mainBranch.setBranchType(BranchType.LONG);
- mainBranch.setKeeType(BranchKeyType.BRANCH);
mainBranch.setKey("master");
underTest.insert(dbSession, mainBranch);
featureBranch.setProjectUuid("U1");
featureBranch.setUuid("U2");
featureBranch.setBranchType(BranchType.SHORT);
- featureBranch.setKeeType(BranchKeyType.BRANCH);
featureBranch.setKey("feature/foo");
featureBranch.setMergeBranchUuid("U3");
underTest.insert(dbSession, featureBranch);
// select the feature branch
- BranchDto loaded = underTest.selectByKey(dbSession, "U1", BranchKeyType.BRANCH, "feature/foo").get();
+ BranchDto loaded = underTest.selectByKey(dbSession, "U1", "feature/foo").get();
assertThat(loaded.getUuid()).isEqualTo(featureBranch.getUuid());
assertThat(loaded.getKey()).isEqualTo(featureBranch.getKey());
assertThat(loaded.getProjectUuid()).isEqualTo(featureBranch.getProjectUuid());
assertThat(loaded.getBranchType()).isEqualTo(featureBranch.getBranchType());
- assertThat(loaded.getKeeType()).isEqualTo(featureBranch.getKeeType());
assertThat(loaded.getMergeBranchUuid()).isEqualTo(featureBranch.getMergeBranchUuid());
- assertThat(loaded.getPullRequestTitle()).isEqualTo(featureBranch.getPullRequestTitle());
-
- // select a pull request with same key than the feature branch
- assertThat(underTest.selectByKey(dbSession, "U1", BranchKeyType.PR, "feature/foo")).isEmpty();
// select a branch on another project with same branch name
- assertThat(underTest.selectByKey(dbSession, "U3", BranchKeyType.BRANCH, "feature/foo")).isEmpty();
+ assertThat(underTest.selectByKey(dbSession, "U3", "feature/foo")).isEmpty();
}
@Test
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
-import static org.sonar.db.component.BranchKeyType.BRANCH;
import static org.sonar.db.component.ComponentDto.UUID_PATH_SEPARATOR;
public class ComponentTesting {
.setUuid(Uuids.createFast())
// MainBranchProjectUuid will be null if it's a main branch
.setProjectUuid(projectUuid)
- .setKeeType(BRANCH)
.setBranchType(branchType);
}
.setKey(key)
.setUuid(branchComponent.uuid())
.setProjectUuid(projectUuid)
- .setKeeType(BRANCH)
.setBranchType(branchType);
}
.setIsNullable(false)
.setLimit(50)
.build())
- .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder()
- .setColumnName("kee_type")
- .setIsNullable(false)
- .setLimit(6)
- .build())
.addColumn(VarcharColumnDef.newVarcharColumnDefBuilder()
.setColumnName("kee")
.setIsNullable(false)
.setIsNullable(false)
.setLimit(50)
.build())
- .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder()
- .setColumnName("kee_type")
- .setIsNullable(false)
- .setLimit(6)
- .build())
.addColumn(VarcharColumnDef.newVarcharColumnDefBuilder()
.setColumnName("kee")
.setIsNullable(false)
.setIsNullable(true)
.setLimit(50)
.build())
- .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder()
- .setColumnName("pull_request_title")
- .setIsNullable(true)
- .setLimit(4000)
- .build())
.addColumn(BigIntegerColumnDef.newBigIntegerColumnDefBuilder()
.setColumnName("created_at")
.setIsNullable(false)
massUpdate.select("SELECT uuid FROM projects p "
+ "WHERE p.scope='PRJ' AND p.qualifier='TRK' AND p.main_branch_project_uuid IS NULL "
+ "AND NOT EXISTS (SELECT uuid FROM project_branches b WHERE b.uuid = p.uuid)");
- massUpdate.update("INSERT INTO project_branches (uuid, project_uuid, kee_type, kee, branch_type, "
- + "merge_branch_uuid, pull_request_title, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ massUpdate.update("INSERT INTO project_branches (uuid, project_uuid, kee, branch_type, "
+ + "merge_branch_uuid, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?)");
massUpdate.rowPluralName("projects");
massUpdate.execute((row, update) -> {
String uuid = row.getString(1);
update.setString(1, uuid);
update.setString(2, uuid);
- update.setString(3, "BRANCH");
- update.setString(4, MAIN_BRANCH_NAME);
- update.setString(5, "LONG");
- update.setString(6, null);
- update.setString(7, null);
- update.setLong(8, now);
- update.setLong(9, now);
+ update.setString(3, MAIN_BRANCH_NAME);
+ update.setString(4, "LONG");
+ update.setString(5, null);
+ update.setLong(6, now);
+ update.setLong(7, now);
return true;
});
}
db.assertColumnDefinition(TABLE, "uuid", Types.VARCHAR, 50, false);
db.assertColumnDefinition(TABLE, "project_uuid", Types.VARCHAR, 50, false);
- db.assertColumnDefinition(TABLE, "kee_type", Types.VARCHAR, 6, false);
db.assertColumnDefinition(TABLE, "kee", Types.VARCHAR, 255, false);
db.assertColumnDefinition(TABLE, "branch_type", Types.VARCHAR, 5, true);
db.assertColumnDefinition(TABLE, "merge_branch_uuid", Types.VARCHAR, 50, true);
- db.assertColumnDefinition(TABLE, "pull_request_title", Types.VARCHAR, 4000, true);
db.assertColumnDefinition(TABLE, "created_at", Types.BIGINT, null, false);
db.assertColumnDefinition(TABLE, "updated_at", Types.BIGINT, null, false);
db.assertPrimaryKey(TABLE, "pk_" + TABLE, "uuid");
underTest.execute();
- assertProjectBranches(tuple("master", project, project, "BRANCH", "LONG", NOW, NOW));
+ assertProjectBranches(tuple("master", project, project, "LONG", NOW, NOW));
}
@Test
underTest.execute();
- assertProjectBranches(tuple("master", project, project, "BRANCH", "LONG", PAST, PAST));
+ assertProjectBranches(tuple("master", project, project, "LONG", PAST, PAST));
}
private void assertProjectBranches(Tuple... expectedTuples) {
- assertThat(db.select("SELECT KEE, UUID, PROJECT_UUID, KEE_TYPE, BRANCH_TYPE, CREATED_AT, UPDATED_AT FROM PROJECT_BRANCHES")
+ assertThat(db.select("SELECT KEE, UUID, PROJECT_UUID, BRANCH_TYPE, CREATED_AT, UPDATED_AT FROM PROJECT_BRANCHES")
.stream()
- .map(map -> new Tuple(map.get("KEE"), map.get("UUID"), map.get("PROJECT_UUID"), map.get("KEE_TYPE"), map.get("BRANCH_TYPE"), map.get("CREATED_AT"), map.get("UPDATED_AT")))
+ .map(map -> new Tuple(map.get("KEE"), map.get("UUID"), map.get("PROJECT_UUID"), map.get("BRANCH_TYPE"), map.get("CREATED_AT"), map.get("UPDATED_AT")))
.collect(Collectors.toList()))
.containsExactlyInAnyOrder(expectedTuples);
}
db.executeInsert("PROJECT_BRANCHES",
"uuid", uuid,
"project_uuid", uuid,
- "kee_type", "BRANCH",
"kee", "master",
"branch_type", "LONG",
"created_at", PAST,
CREATE TABLE "PROJECT_BRANCHES" (
"UUID" VARCHAR(50) NOT NULL PRIMARY KEY,
"PROJECT_UUID" VARCHAR(50) NOT NULL,
- "KEE_TYPE" VARCHAR(6) NOT NULL,
"KEE" VARCHAR(255) NOT NULL,
"BRANCH_TYPE" VARCHAR(5),
"MERGE_BRANCH_UUID" VARCHAR(50),
- "PULL_REQUEST_TITLE" VARCHAR(4000),
"CREATED_AT" BIGINT NOT NULL,
"UPDATED_AT" BIGINT NOT NULL
);
CREATE UNIQUE INDEX "PK_PROJECT_BRANCHES" ON "PROJECT_BRANCHES" ("UUID");
-CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE_TYPE", "KEE");
+CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE");
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.BranchDto;
-import org.sonar.db.component.BranchKeyType;
import org.sonar.db.component.BranchType;
import org.sonar.db.component.ComponentDto;
import org.sonar.server.es.ProjectIndexer.Cause;
private BranchDto createBranch(DbSession session, String componentUuid) {
BranchDto branch = new BranchDto()
.setBranchType(BranchType.LONG)
- .setKeeType(BranchKeyType.BRANCH)
.setUuid(componentUuid)
.setKey(BranchDto.DEFAULT_MAIN_BRANCH_NAME)
.setMergeBranchUuid(null)
- .setPullRequestTitle(null)
.setProjectUuid(componentUuid);
dbClient.branchDao().upsert(session, branch);
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.BranchDto;
-import org.sonar.db.component.BranchKeyType;
import org.sonar.db.component.ComponentDto;
import org.sonar.server.computation.task.projectanalysis.analysis.AnalysisMetadataHolder;
import org.sonar.server.computation.task.projectanalysis.analysis.Branch;
dto.setUuid(componentDto.uuid());
// MainBranchProjectUuid will be null if it's a main branch
dto.setProjectUuid(firstNonNull(componentDto.getMainBranchProjectUuid(), componentDto.projectUuid()));
- dto.setKeeType(BranchKeyType.BRANCH);
dto.setKey(branch.getName());
dto.setBranchType(branch.getType());
// merge branch is only present if it's a short living branch
dto.setMergeBranchUuid(branch.getMergeBranchUuid().orElse(null));
- dto.setPullRequestTitle(null);
return dto;
}
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.BranchDto;
-import org.sonar.db.component.BranchKeyType;
import org.sonar.db.component.ComponentDto;
import org.sonar.server.component.ComponentCleanerService;
import org.sonar.server.component.ComponentFinder;
checkPermission(project);
BranchDto branch = checkFoundWithOptional(
- dbClient.branchDao().selectByKey(dbSession, project.uuid(), BranchKeyType.BRANCH, branchKey),
+ dbClient.branchDao().selectByKey(dbSession, project.uuid(), branchKey),
"Branch '%s' not found for project '%s'", branchKey, projectKey);
if (branch.isMain()) {
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.BranchDto;
-import org.sonar.db.component.BranchKeyType;
import org.sonar.db.component.BranchType;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.SnapshotDto;
WsBranches.ListWsResponse.Builder protobufResponse = WsBranches.ListWsResponse.newBuilder();
branches.stream()
- .filter(b -> b.getKeeType().equals(BranchKeyType.BRANCH))
.forEach(b -> addBranch(protobufResponse, b, mergeBranchesByUuid, qualityGateMeasuresByComponentUuids.get(b.getUuid()), branchStatisticsByBranchUuid.get(b.getUuid()),
analysisDateByBranchUuid.get(b.getUuid())));
WsUtils.writeProtobuf(protobufResponse.build(), request, response);
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.BranchDto;
-import org.sonar.db.component.BranchKeyType;
import org.sonar.db.component.ComponentDto;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.user.UserSession;
ComponentDto project = componentFinder.getRootComponentByUuidOrKey(dbSession, null, projectKey);
checkPermission(project);
- Optional<BranchDto> branch = dbClient.branchDao().selectByKey(dbSession, project.uuid(), BranchKeyType.BRANCH, branchKey);
+ Optional<BranchDto> branch = dbClient.branchDao().selectByKey(dbSession, project.uuid(), branchKey);
if (branch.isPresent() && !branch.get().isMain()) {
throw new IllegalArgumentException("Impossible to update branch name: a branch with name \"" + branchKey + "\" already exists in the project.");
}
import org.sonar.api.utils.System2;
import org.sonar.db.DbTester;
import org.sonar.db.component.BranchDto;
-import org.sonar.db.component.BranchKeyType;
import org.sonar.db.component.BranchType;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.organization.OrganizationDto;
Optional<BranchDto> branch = db.getDbClient().branchDao().selectByUuid(db.getSession(), returned.uuid());
assertThat(branch).isPresent();
- assertThat(branch.get().getKeeType()).isEqualTo(BranchKeyType.BRANCH);
assertThat(branch.get().getKey()).isEqualTo(BranchDto.DEFAULT_MAIN_BRANCH_NAME);
assertThat(branch.get().getMergeBranchUuid()).isNull();
- assertThat(branch.get().getPullRequestTitle()).isNull();
assertThat(branch.get().getBranchType()).isEqualTo(BranchType.LONG);
assertThat(branch.get().getUuid()).isEqualTo(returned.uuid());
assertThat(branch.get().getProjectUuid()).isEqualTo(returned.uuid());