Search in sources :

Example 16 with ProjectLinkDto

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

the class DeleteActionTest method fail_if_not_project_admin.

@Test
public void fail_if_not_project_admin() {
    ComponentDto project = db.components().insertPrivateProject();
    ProjectLinkDto link = db.componentLinks().insertCustomLink(project);
    userSession.logIn();
    assertThatThrownBy(() -> deleteLink(link)).isInstanceOf(ForbiddenException.class);
}
Also used : ProjectLinkDto(org.sonar.db.component.ProjectLinkDto) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 17 with ProjectLinkDto

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

the class SearchActionTest method request_does_not_fail_when_link_has_no_name.

@Test
public void request_does_not_fail_when_link_has_no_name() {
    ComponentDto project = db.components().insertPrivateProject();
    ProjectLinkDto link = db.componentLinks().insertProvidedLink(project);
    logInAsProjectAdministrator(project);
    SearchWsResponse response = callByKey(project.getKey());
    assertThat(response.getLinksList()).extracting(Link::getId, Link::hasName).containsExactlyInAnyOrder(tuple(link.getUuid(), false));
}
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 18 with ProjectLinkDto

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

the class SearchActionTest method request_by_project_id.

@Test
public void request_by_project_id() {
    ComponentDto project = db.components().insertPrivateProject();
    ProjectLinkDto link = db.componentLinks().insertCustomLink(project);
    logInAsProjectAdministrator(project);
    SearchWsResponse response = callByUuid(project.uuid());
    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 19 with ProjectLinkDto

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

the class CreateActionTest method createAndTest.

private void createAndTest(ComponentDto project, String name, String url, String type) {
    ProjectLinks.CreateWsResponse response = ws.newRequest().setMethod("POST").setParam(PARAM_PROJECT_KEY, project.getDbKey()).setParam(PARAM_NAME, name).setParam(PARAM_URL, url).executeProtobuf(ProjectLinks.CreateWsResponse.class);
    String newId = response.getLink().getId();
    ProjectLinkDto link = dbClient.projectLinkDao().selectByUuid(dbSession, newId);
    assertThat(link.getName()).isEqualTo(name);
    assertThat(link.getHref()).isEqualTo(url);
    assertThat(link.getType()).isEqualTo(type);
}
Also used : ProjectLinkDto(org.sonar.db.component.ProjectLinkDto) ProjectLinks(org.sonarqube.ws.ProjectLinks)

Example 20 with ProjectLinkDto

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

the class SearchActionTest method project_administrator_can_search_for_links.

@Test
public void project_administrator_can_search_for_links() {
    ComponentDto project = db.components().insertPrivateProject();
    ProjectLinkDto link = db.componentLinks().insertCustomLink(project);
    userSession.logIn().addProjectPermission(UserRole.ADMIN, 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)

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