import org.junit.Test;
import org.junit.runner.RunWith;
import org.sonar.api.measures.Metric;
-import org.sonar.db.component.ComponentQualifiers;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.server.ws.WebService.Param;
import org.sonar.api.utils.System2;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentQualifiers;
import org.sonar.db.component.ProjectData;
import org.sonar.db.entity.EntityDto;
import org.sonar.db.measure.MeasureDto;
tuple(project.getKey(), aiCodeAssured));
}
+ @Test
+ @DataProvider({"true", "false"})
+ public void return_ai_codefix_enabled(Boolean isEnabled) {
+ userSession.logIn();
+ ProjectDto project = db.components().insertPublicProject(componentDto -> componentDto.setName("proj_A"),
+ projectDto -> {
+ projectDto.setAiCodeFixEnabled(isEnabled);
+ }).getProjectDto();
+ authorizationIndexerTester.allowOnlyAnyone(project);
+ index();
+
+ SearchProjectsWsResponse result = call(request);
+
+ assertThat(result.getComponentsList()).extracting(Component::getKey, Component::getIsAiCodeFixEnabled)
+ .containsExactly(
+ tuple(project.getKey(), isEnabled));
+ }
+
@Test
public void does_not_return_branches() {
ProjectDto project = db.components().insertPublicProject().getProjectDto();
import java.util.stream.Stream;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-import org.sonar.db.component.ComponentQualifiers;
import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.BranchDto;
+import org.sonar.db.component.ComponentQualifiers;
import org.sonar.db.component.SnapshotDto;
import org.sonar.db.project.ProjectDto;
import org.sonar.db.property.PropertyDto;
import org.sonar.db.property.PropertyQuery;
-import org.sonar.server.ai.code.assurance.AiCodeAssuranceVerifier;
import org.sonar.db.user.TokenType;
+import org.sonar.server.ai.code.assurance.AiCodeAssuranceVerifier;
import org.sonar.server.component.ws.FilterParser.Criterion;
import org.sonar.server.component.ws.SearchProjectsAction.SearchResults.SearchResultsBuilder;
import org.sonar.server.es.Facets;
.setName(dbProject.getName())
.setQualifier(dbProject.getQualifier())
.setVisibility(Visibility.getLabel(dbProject.isPrivate()))
- .setIsAiCodeAssured(aiCodeAssuranceVerifier.isAiCodeAssured(dbProject));
+ .setIsAiCodeAssured(aiCodeAssuranceVerifier.isAiCodeAssured(dbProject))
+ .setIsAiCodeFixEnabled(dbProject.getAiCodeFixEnabled());
wsComponent.getTagsBuilder().addAllTags(dbProject.getTags());
SnapshotDto snapshotDto = analysisByProjectUuid.get(dbProject.getUuid());
return wsComponent.build();
}
-
}
public static class SearchResults {
private final ProjectMeasuresQuery query;
private final int total;
- private SearchResults(List<ProjectDto> projects, Set<String> favoriteProjectUuids, SearchIdResult<String> searchResults, Map<String,
- SnapshotDto> analysisByProjectUuid,
+ private SearchResults(List<ProjectDto> projects, Set<String> favoriteProjectUuids, SearchIdResult<String> searchResults, Map<String, SnapshotDto> analysisByProjectUuid,
Map<String, Long> applicationsLeakPeriods, ProjectMeasuresQuery query) {
this.projects = projects;
this.favoriteProjectUuids = favoriteProjectUuids;
"java"
],
"visibility": "public",
- "isAiCodeAssured": false
+ "isAiCodeAssured": false,
+ "isAiCodeFixEnabled": false
},
{
"key": "another_project",
"isFavorite": false,
"tags": [],
"visibility": "public",
- "isAiCodeAssured": false
+ "isAiCodeAssured": false,
+ "isAiCodeFixEnabled": false
},
{
"key": "third_project",
"java"
],
"visibility": "public",
- "isAiCodeAssured": false
+ "isAiCodeAssured": false,
+ "isAiCodeFixEnabled": false
}
],
"facets": [