diff options
3 files changed, 13 insertions, 25 deletions
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/SearchActionIT.java index ab7887753b7..a6af513679b 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/SearchActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/SearchActionIT.java @@ -19,13 +19,11 @@ */ package org.sonar.server.qualitygate.ws; -import java.util.stream.Stream; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.ValueSource; import org.sonar.api.server.ws.WebService; import org.sonar.db.DbClient; import org.sonar.db.DbTester; @@ -300,13 +298,12 @@ class SearchActionIT { } @ParameterizedTest - @MethodSource("aiCodeAssuranceParams") - void return_ai_code_assurance(boolean containsAiCode, boolean aiCodeSupportedByQg, AiCodeAssurance expected) { - QualityGateDto qualityGate = db.qualityGates().insertQualityGate(qg -> qg.setAiCodeSupported(aiCodeSupportedByQg)); + @ValueSource(booleans = {true, false}) + void return_ai_code_assurance(boolean containsAiCode) { + QualityGateDto qualityGate = db.qualityGates().insertQualityGate(); ProjectDto project = db.components().insertPublicProject(componentDto -> componentDto.setName("proj1"), projectDto -> projectDto.setContainsAiCode(containsAiCode)).getProjectDto(); db.qualityGates().associateProjectToQualityGate(project, qualityGate); - when(aiCodeAssuranceVerifier.getAiCodeAssurance(project.getContainsAiCode(), qualityGate.isAiCodeSupported())).thenReturn(expected); SearchResponse response = ws.newRequest() .setParam(PARAM_GATE_NAME, valueOf(qualityGate.getName())) @@ -314,18 +311,9 @@ class SearchActionIT { .executeProtobuf(SearchResponse.class); assertThat(response.getResultsList()) - .extracting(Result::getName, Result::getKey, result -> result.getAiCodeAssurance().name()) + .extracting(Result::getName, Result::getKey, Result::getContainsAiCode) .containsExactlyInAnyOrder( - tuple(project.getName(), project.getKey(), expected.name())); - } - - private static Stream<Arguments> aiCodeAssuranceParams() { - return Stream.of( - Arguments.of(false, false, AiCodeAssurance.NONE), - Arguments.of(false, true, AiCodeAssurance.NONE), - Arguments.of(true, false, AiCodeAssurance.CONTAINS_AI_CODE), - Arguments.of(true, true, AiCodeAssurance.AI_CODE_ASSURED) - ); + tuple(project.getName(), project.getKey(), containsAiCode)); } @Test diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/SearchAction.java index ec000ac70f5..eae38d6b605 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/SearchAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/SearchAction.java @@ -36,7 +36,6 @@ import org.sonar.db.qualitygate.QualityGateDto; import org.sonar.server.ai.code.assurance.AiCodeAssuranceVerifier; import org.sonar.server.user.UserSession; import org.sonarqube.ws.Qualitygates; -import org.sonarqube.ws.Qualitygates.SearchResponse.AiCodeAssurance; import static org.sonar.api.server.ws.WebService.Param.SELECTED; import static org.sonar.api.utils.Paging.forPageIndex; @@ -70,6 +69,9 @@ public class SearchAction implements QualityGatesWsAction { .setSince("4.3") .setResponseExample(Resources.getResource(this.getClass(), "search-example.json")) .setChangelog( + new Change("2025.1", "Field 'containsAiCode' response field has added."), + new Change("2025.1", "Field 'isAiCodeAssured' response field has been removed."), + new Change("2025.1", "Field 'aiCodeAssurance' response field has been removed."), new Change("10.8", "Field 'isAiCodeAssured' response field has been deprecated. Use 'aiCodeAssurance' instead."), new Change("10.8", "New field 'aiCodeAssurance' in the response."), new Change("10.0", "deprecated 'more' response field has been removed"), @@ -137,14 +139,11 @@ public class SearchAction implements QualityGatesWsAction { .build(); for (ProjectQgateAssociationDto project : paginatedProjects) { - AiCodeAssurance aiCodeAssurance = AiCodeAssurance.valueOf(aiCodeAssuranceVerifier.getAiCodeAssurance(project.getContainsAiCode(), - project.isAiCodeSupportedByQg()).name()); createResponse.addResultsBuilder() .setName(project.getName()) .setKey(project.getKey()) .setSelected(project.getGateUuid() != null) - .setIsAiCodeAssured(AiCodeAssurance.AI_CODE_ASSURED.equals(aiCodeAssurance)) - .setAiCodeAssurance(aiCodeAssurance); + .setContainsAiCode(project.getContainsAiCode()); } writeProtobuf(createResponse.build(), request, response); diff --git a/sonar-ws/src/main/protobuf/ws-qualitygates.proto b/sonar-ws/src/main/protobuf/ws-qualitygates.proto index 161d7781569..b816b2e29ff 100644 --- a/sonar-ws/src/main/protobuf/ws-qualitygates.proto +++ b/sonar-ws/src/main/protobuf/ws-qualitygates.proto @@ -149,8 +149,9 @@ message SearchResponse { optional string name = 2; optional bool selected = 3; optional string key = 4; - optional bool isAiCodeAssured = 5; - optional AiCodeAssurance aiCodeAssurance = 6; + reserved 5; + reserved 6; + optional bool containsAiCode = 7; } enum AiCodeAssurance { |