Search in sources :

Example 21 with ProjectLinkDto

use of org.sonar.db.component.ProjectLinkDto in project sonarqube by SonarSource.

the class SearchActionTest method request_by_project_key.

@Test
public void request_by_project_key() {
    ComponentDto project = db.components().insertPrivateProject();
    ProjectLinkDto link = db.componentLinks().insertCustomLink(project);
    logInAsProjectAdministrator(project);
    SearchWsResponse response = callByKey(project.getKey());
    assertThat(response.getLinksList()).extracting(Link::getId, Link::getName).containsExactlyInAnyOrder(tuple(link.getUuid(), link.getName()));
}
Also used : ProjectLinkDto(org.sonar.db.component.ProjectLinkDto) ComponentDto(org.sonar.db.component.ComponentDto) SearchWsResponse(org.sonarqube.ws.ProjectLinks.SearchWsResponse) Test(org.junit.Test)

Example 22 with ProjectLinkDto

use of org.sonar.db.component.ProjectLinkDto in project sonarqube by SonarSource.

the class SearchAction method doHandle.

private SearchWsResponse doHandle(SearchRequest searchWsRequest) {
    try (DbSession dbSession = dbClient.openSession(false)) {
        ProjectDto project = getProjectByUuidOrKey(dbSession, searchWsRequest);
        List<ProjectLinkDto> links = dbClient.projectLinkDao().selectByProjectUuid(dbSession, project.getUuid());
        return buildResponse(links);
    }
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) DbSession(org.sonar.db.DbSession) ProjectLinkDto(org.sonar.db.component.ProjectLinkDto)

Aggregations

ProjectLinkDto (org.sonar.db.component.ProjectLinkDto)22 Test (org.junit.Test)15 ComponentDto (org.sonar.db.component.ComponentDto)13 SearchWsResponse (org.sonarqube.ws.ProjectLinks.SearchWsResponse)7 DbSession (org.sonar.db.DbSession)6 Component (org.sonar.ce.task.projectanalysis.component.Component)2 TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)2 ProjectDto (org.sonar.db.project.ProjectDto)2 ScannerReport (org.sonar.scanner.protocol.output.ScannerReport)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Link (com.sonarsource.governance.projectdump.protobuf.ProjectDump.Link)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 AnalysisMetadataHolder (org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolder)1 BatchReportReader (org.sonar.ce.task.projectanalysis.batch.BatchReportReader)1 TreeRootHolder (org.sonar.ce.task.projectanalysis.component.TreeRootHolder)1 ComputationStep (org.sonar.ce.task.step.ComputationStep)1