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;
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;
.containsEntry("projectName_p2", false);
}
+ @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");
private String tags;
private CreationMethod creationMethod;
private boolean aiCodeAssurance;
+ private boolean aiCodeFixEnabled = false;
private long createdAt;
private long updatedAt;
this.aiCodeAssurance = aiCodeAssurance;
return this;
}
+
+ public boolean getAiCodeFixEnabled() {
+ return aiCodeFixEnabled;
+ }
+
+ public ProjectDto setAiCodeFixEnabled(boolean aiCodeFixEnabled) {
+ this.aiCodeFixEnabled = aiCodeFixEnabled;
+ return this;
+ }
}
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>
tags,
creation_method,
ai_code_assurance,
+ ai_code_fix_enabled,
created_at,
updated_at
)
#{tagsString, jdbcType=VARCHAR},
#{creationMethod, jdbcType=VARCHAR},
#{aiCodeAssurance, jdbcType=BOOLEAN},
+ #{aiCodeFixEnabled, jdbcType=BOOLEAN},
#{createdAt,jdbcType=BIGINT},
#{updatedAt,jdbcType=BIGINT}
)
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.db.component.ComponentQualifiers;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.System2;
import org.sonar.api.web.UserRole;
import org.sonar.db.DbTester;
+import org.sonar.db.component.ComponentDbTester;
import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentQualifiers;
import org.sonar.db.component.ProjectData;
import org.sonar.server.component.TestComponentFinder;
import org.sonar.server.exceptions.ForbiddenException;
.hasMessage(String.format("Component '%s' on branch '%s' not found", file.getKey(), "another_branch"));
}
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void return_isAiCodeFixEnabled(boolean isAiCodeFixEnabled) {
+ var projectData = db.components().insertPrivateProject(ComponentDbTester.defaults(),
+ p -> p.setAiCodeFixEnabled(isAiCodeFixEnabled));
+ userSession.addProjectPermission(USER, projectData.getProjectDto())
+ .registerBranches(projectData.getMainBranchDto());
+
+ var response = newRequest(projectData.projectKey());
+
+ assertThat(response.getComponent().getIsAiCodeFixEnabled()).isEqualTo(isAiCodeFixEnabled);
+ }
+
private ShowWsResponse newRequest(@Nullable String key) {
TestRequest request = ws.newRequest();
if (key != null) {
Components.Component.Builder wsComponent = Components.Component.newBuilder()
.setKey(project.getKey())
.setName(project.getName())
- .setQualifier(project.getQualifier());
+ .setQualifier(project.getQualifier())
+ .setIsAiCodeFixEnabled(project.getAiCodeFixEnabled());
ofNullable(emptyToNull(project.getDescription())).ifPresent(wsComponent::setDescription);
ofNullable(lastAnalysis).ifPresent(
optional string pullRequest = 20;
optional bool needIssueSync = 21;
optional bool isAiCodeAssured = 22;
+ optional bool isAiCodeFixEnabled = 23;
message Tags {
repeated string tags = 1;