aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao
diff options
context:
space:
mode:
authorSerhat Yenican <104850907+serhat-yenican-sonarsource@users.noreply.github.com>2024-11-07 09:38:00 +0100
committersonartech <sonartech@sonarsource.com>2024-11-19 20:02:53 +0000
commit961be4c047ef16ad9c3c7a42d83176c50dd35692 (patch)
tree4eed1c9a004b8b363f6626c3f87e511d879e239b /server/sonar-db-dao
parentf5d3bf0075612ffcde324c35cf23959cbb7e14c3 (diff)
downloadsonarqube-961be4c047ef16ad9c3c7a42d83176c50dd35692.tar.gz
sonarqube-961be4c047ef16ad9c3c7a42d83176c50dd35692.zip
CODEFIX-187 Add `isAiCodeFixEnabled` property to the Component Response (#12212)
Diffstat (limited to 'server/sonar-db-dao')
-rw-r--r--server/sonar-db-dao/src/it/java/org/sonar/db/project/ProjectDaoIT.java19
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDto.java10
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml3
3 files changed, 31 insertions, 1 deletions
diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/project/ProjectDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/project/ProjectDaoIT.java
index 2ebe14fa96c..0157ec89288 100644
--- a/server/sonar-db-dao/src/it/java/org/sonar/db/project/ProjectDaoIT.java
+++ b/server/sonar-db-dao/src/it/java/org/sonar/db/project/ProjectDaoIT.java
@@ -35,7 +35,6 @@ import org.assertj.core.groups.Tuple;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.api.impl.utils.AlwaysIncreasingSystem2;
-import org.sonar.db.component.ComponentQualifiers;
import org.sonar.api.utils.System2;
import org.sonar.db.DbTester;
import org.sonar.db.Pagination;
@@ -44,6 +43,7 @@ import org.sonar.db.audit.NoOpAuditPersister;
import org.sonar.db.component.BranchDto;
import org.sonar.db.component.BranchType;
import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentQualifiers;
import org.sonar.db.entity.EntityDto;
import static java.util.Collections.emptySet;
@@ -150,6 +150,23 @@ class ProjectDaoIT {
}
@Test
+ void selectProjects_returnsAiCodeFixEnabled() {
+ var dbSession = db.getSession();
+
+ var dto1 = createProject("o1", "p1").setAiCodeFixEnabled(true);
+ var dto2 = createProject("o1", "p2");
+
+ projectDao.insert(dbSession, dto1);
+ projectDao.insert(dbSession, dto2);
+
+ assertThat(projectDao.selectProjects(dbSession))
+ .extracting(EntityDto::getName, ProjectDto::getAiCodeFixEnabled)
+ .containsExactlyInAnyOrder(
+ tuple("projectName_p1", true),
+ tuple("projectName_p2", false));
+ }
+
+ @Test
void select_all() {
ProjectDto dto1 = createProject("o1", "p1");
ProjectDto dto2 = createProject("o1", "p2");
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDto.java
index e7abfb11ece..06414302257 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDto.java
@@ -33,6 +33,7 @@ public class ProjectDto extends EntityDto {
private String tags;
private CreationMethod creationMethod;
private boolean aiCodeAssurance;
+ private boolean aiCodeFixEnabled = false;
private long createdAt;
private long updatedAt;
@@ -133,4 +134,13 @@ public class ProjectDto extends EntityDto {
this.aiCodeAssurance = aiCodeAssurance;
return this;
}
+
+ public boolean getAiCodeFixEnabled() {
+ return aiCodeFixEnabled;
+ }
+
+ public ProjectDto setAiCodeFixEnabled(boolean aiCodeFixEnabled) {
+ this.aiCodeFixEnabled = aiCodeFixEnabled;
+ return this;
+ }
}
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml
index c54aa32323f..9f332354d87 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml
@@ -12,6 +12,7 @@
p.private as isPrivate,
p.creation_method as creationMethod,
p.ai_code_assurance as aiCodeAssurance,
+ p.ai_code_fix_enabled as aiCodeFixEnabled,
p.created_at as createdAt,
p.updated_at as updatedAt
</sql>
@@ -138,6 +139,7 @@
tags,
creation_method,
ai_code_assurance,
+ ai_code_fix_enabled,
created_at,
updated_at
)
@@ -151,6 +153,7 @@
#{tagsString, jdbcType=VARCHAR},
#{creationMethod, jdbcType=VARCHAR},
#{aiCodeAssurance, jdbcType=BOOLEAN},
+ #{aiCodeFixEnabled, jdbcType=BOOLEAN},
#{createdAt,jdbcType=BIGINT},
#{updatedAt,jdbcType=BIGINT}
)